Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow strict-local
  9. * @emails oncall+draft_js
  10. */
  11. 'use strict';
  12. import type DraftEditor from "./DraftEditor.react";
  13. const getFragmentFromSelection = require("./getFragmentFromSelection");
  14. /**
  15. * If we have a selection, create a ContentState fragment and store
  16. * it in our internal clipboard. Subsequent paste events will use this
  17. * fragment if no external clipboard data is supplied.
  18. */
  19. function editOnCopy(editor: DraftEditor, e: SyntheticClipboardEvent<>): void {
  20. const editorState = editor._latestEditorState;
  21. const selection = editorState.getSelection(); // No selection, so there's nothing to copy.
  22. if (selection.isCollapsed()) {
  23. e.preventDefault();
  24. return;
  25. }
  26. editor.setClipboard(getFragmentFromSelection(editor._latestEditorState));
  27. }
  28. module.exports = editOnCopy;