d2-ui
Version:
37 lines (33 loc) • 1.05 kB
JavaScript
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule keyCommandMoveSelectionToEndOfBlock
*
*/
;
var EditorState = require('./EditorState');
/**
* See comment for `moveSelectionToStartOfBlock`.
*/
function keyCommandMoveSelectionToEndOfBlock(editorState) {
var selection = editorState.getSelection();
var endKey = selection.getEndKey();
var content = editorState.getCurrentContent();
var textLength = content.getBlockForKey(endKey).getLength();
return EditorState.set(editorState, {
selection: selection.merge({
anchorKey: endKey,
anchorOffset: textLength,
focusKey: endKey,
focusOffset: textLength,
isBackward: false
}),
forceSelection: true
});
}
module.exports = keyCommandMoveSelectionToEndOfBlock;