Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/draft-js/lib/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
* @emails oncall+draft_js
*/
'use strict';
var DraftOffsetKey = require("./DraftOffsetKey");
var nullthrows = require("fbjs/lib/nullthrows");
function getUpdatedSelectionState(editorState, anchorKey, anchorOffset, focusKey, focusOffset) {
var selection = nullthrows(editorState.getSelection());
if (!anchorKey || !focusKey) {
// If we cannot make sense of the updated selection state, stick to the current one.
if (process.env.NODE_ENV !== "production") {
/* eslint-disable-next-line */
console.warn('Invalid selection state.', arguments, editorState.toJS());
}
return selection;
}
var anchorPath = DraftOffsetKey.decode(anchorKey);
var anchorBlockKey = anchorPath.blockKey;
var anchorLeafBlockTree = editorState.getBlockTree(anchorBlockKey);
var anchorLeaf = anchorLeafBlockTree && anchorLeafBlockTree.getIn([anchorPath.decoratorKey, 'leaves', anchorPath.leafKey]);
var focusPath = DraftOffsetKey.decode(focusKey);
var focusBlockKey = focusPath.blockKey;
var focusLeafBlockTree = editorState.getBlockTree(focusBlockKey);
var focusLeaf = focusLeafBlockTree && focusLeafBlockTree.getIn([focusPath.decoratorKey, 'leaves', focusPath.leafKey]);
if (!anchorLeaf || !focusLeaf) {
// If we cannot make sense of the updated selection state, stick to the current one.
if (process.env.NODE_ENV !== "production") {
/* eslint-disable-next-line */
console.warn('Invalid selection state.', arguments, editorState.toJS());
}
return selection;
}
var anchorLeafStart = anchorLeaf.get('start');
var focusLeafStart = focusLeaf.get('start');
var anchorBlockOffset = anchorLeaf ? anchorLeafStart + anchorOffset : null;
var focusBlockOffset = focusLeaf ? focusLeafStart + focusOffset : null;
var areEqual = selection.getAnchorKey() === anchorBlockKey && selection.getAnchorOffset() === anchorBlockOffset && selection.getFocusKey() === focusBlockKey && selection.getFocusOffset() === focusBlockOffset;
if (areEqual) {
return selection;
}
var isBackward = false;
if (anchorBlockKey === focusBlockKey) {
var anchorLeafEnd = anchorLeaf.get('end');
var focusLeafEnd = focusLeaf.get('end');
if (focusLeafStart === anchorLeafStart && focusLeafEnd === anchorLeafEnd) {
isBackward = focusOffset < anchorOffset;
} else {
isBackward = focusLeafStart < anchorLeafStart;
}
} else {
var startKey = editorState.getCurrentContent().getBlockMap().keySeq().skipUntil(function (v) {
return v === anchorBlockKey || v === focusBlockKey;
}).first();
isBackward = startKey === focusBlockKey;
}
return selection.merge({
anchorKey: anchorBlockKey,
anchorOffset: anchorBlockOffset,
focusKey: focusBlockKey,
focusOffset: focusBlockOffset,
isBackward: isBackward
});
}
module.exports = getUpdatedSelectionState; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0048 ]-- |