Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

35 linhas
999 B

  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;