Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

keyCommandMoveSelectionToStartOfBlock.js.flow 1.0 KiB

před 3 roky
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. * Collapse selection at the start of the first selected block. This is used
  15. * for Firefox versions that attempt to navigate forward/backward instead of
  16. * moving the cursor. Other browsers are able to move the cursor natively.
  17. */
  18. function keyCommandMoveSelectionToStartOfBlock(editorState: EditorState): EditorState {
  19. const selection = editorState.getSelection();
  20. const startKey = selection.getStartKey();
  21. return EditorState.set(editorState, {
  22. selection: selection.merge({
  23. anchorKey: startKey,
  24. anchorOffset: 0,
  25. focusKey: startKey,
  26. focusOffset: 0,
  27. isBackward: false
  28. }),
  29. forceSelection: true
  30. });
  31. }
  32. module.exports = keyCommandMoveSelectionToStartOfBlock;