UNPKG

913 BJavaScriptView Raw
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
13var EditorState = require("./EditorState");
14/**
15 * See comment for `moveSelectionToStartOfBlock`.
16 */
17
18
19function keyCommandMoveSelectionToEndOfBlock(editorState) {
20 var selection = editorState.getSelection();
21 var endKey = selection.getEndKey();
22 var content = editorState.getCurrentContent();
23 var textLength = content.getBlockForKey(endKey).getLength();
24 return EditorState.set(editorState, {
25 selection: selection.merge({
26 anchorKey: endKey,
27 anchorOffset: textLength,
28 focusKey: endKey,
29 focusOffset: textLength,
30 isBackward: false
31 }),
32 forceSelection: true
33 });
34}
35
36module.exports = keyCommandMoveSelectionToEndOfBlock;
\No newline at end of file