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

keyCommandMoveSelectionToEndOfBlock.js.flow 967 B

3 лет назад
123456789101112131415161718192021222324252627282930313233343536
  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. const EditorState = require("./EditorState");
  13. /**
  14. * See comment for `moveSelectionToStartOfBlock`.
  15. */
  16. function keyCommandMoveSelectionToEndOfBlock(editorState: EditorState): EditorState {
  17. const selection = editorState.getSelection();
  18. const endKey = selection.getEndKey();
  19. const content = editorState.getCurrentContent();
  20. const textLength = content.getBlockForKey(endKey).getLength();
  21. return EditorState.set(editorState, {
  22. selection: selection.merge({
  23. anchorKey: endKey,
  24. anchorOffset: textLength,
  25. focusKey: endKey,
  26. focusOffset: textLength,
  27. isBackward: false
  28. }),
  29. forceSelection: true
  30. });
  31. }
  32. module.exports = keyCommandMoveSelectionToEndOfBlock;