forgeplus-react/node_modules/draft-js/lib/keyCommandMoveSelectionToEn...

38 lines
1.1 KiB
Plaintext
Raw Normal View History

2023-07-29 21:19:10 +08:00
/**
* 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
* @format
* @flow
*/
'use strict';
var EditorState = require('./EditorState');
/**
* See comment for `moveSelectionToStartOfBlock`.
*/
function keyCommandMoveSelectionToEndOfBlock(editorState: EditorState): 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;