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

56 строки
1.6 KiB

  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. *
  9. * @emails oncall+draft_js
  10. */
  11. 'use strict';
  12. var DraftJsDebugLogging = require("./DraftJsDebugLogging");
  13. var EditorState = require("./EditorState");
  14. var getContentEditableContainer = require("./getContentEditableContainer");
  15. var getDraftEditorSelection = require("./getDraftEditorSelection");
  16. function editOnSelect(editor) {
  17. if (editor._blockSelectEvents || editor._latestEditorState !== editor.props.editorState) {
  18. if (editor._blockSelectEvents) {
  19. var _editorState = editor.props.editorState;
  20. var selectionState = _editorState.getSelection();
  21. DraftJsDebugLogging.logBlockedSelectionEvent({
  22. // For now I don't think we need any other info
  23. anonymizedDom: 'N/A',
  24. extraParams: JSON.stringify({
  25. stacktrace: new Error().stack
  26. }),
  27. selectionState: JSON.stringify(selectionState.toJS())
  28. });
  29. }
  30. return;
  31. }
  32. var editorState = editor.props.editorState;
  33. var documentSelection = getDraftEditorSelection(editorState, getContentEditableContainer(editor));
  34. var updatedSelectionState = documentSelection.selectionState;
  35. if (updatedSelectionState !== editorState.getSelection()) {
  36. if (documentSelection.needsRecovery) {
  37. editorState = EditorState.forceSelection(editorState, updatedSelectionState);
  38. } else {
  39. editorState = EditorState.acceptSelection(editorState, updatedSelectionState);
  40. }
  41. editor.update(editorState);
  42. }
  43. }
  44. module.exports = editOnSelect;