@fluentui-copilot/chat-input-plugins 0.0.0-nightly-20250708-1433-52f2b6b1.1 → 0.0.0-nightly-20250709-0404-150e065c.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +3 -3
- package/CHANGELOG.md +4 -4
- package/lib/BasicFunctionality/BasicFunctionality.base.js +96 -90
- package/lib/BasicFunctionality/SentinelNode.js +30 -29
- package/lib/BasicFunctionality/SentinelNodeHandlers.js +78 -73
- package/lib/BasicFunctionality/index.js +1 -0
- package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js +114 -109
- package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js +2 -1
- package/lib/ChatInputEntity/index.js +1 -0
- package/lib/GhostText/GhostText.base.js +145 -142
- package/lib/GhostText/index.js +1 -0
- package/lib/ImperativeControl/ImperativeControl.base.js +83 -82
- package/lib/ImperativeControl/index.js +1 -0
- package/lib/ManualGhostText/ManualGhostText.base.js +67 -68
- package/lib/ManualGhostText/index.js +1 -0
- package/lib/PasteUnfurling/PasteUnfurling.base.js +57 -52
- package/lib/PasteUnfurling/PasteUnfurling.types.js +2 -1
- package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js +139 -138
- package/lib/PasteUnfurling/index.js +1 -0
- package/lib/index.js +1 -0
- package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js +3 -2
- package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js.map +1 -1
- package/lib-commonjs/BasicFunctionality/SentinelNode.js +1 -1
- package/lib-commonjs/BasicFunctionality/SentinelNode.js.map +1 -1
- package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js +5 -3
- package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js.map +1 -1
- package/lib-commonjs/BasicFunctionality/index.js +1 -0
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js +5 -3
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js.map +1 -1
- package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js +1 -0
- package/lib-commonjs/ChatInputEntity/index.js +1 -0
- package/lib-commonjs/GhostText/GhostText.base.js +3 -2
- package/lib-commonjs/GhostText/GhostText.base.js.map +1 -1
- package/lib-commonjs/GhostText/index.js +1 -0
- package/lib-commonjs/ImperativeControl/ImperativeControl.base.js +1 -1
- package/lib-commonjs/ImperativeControl/ImperativeControl.base.js.map +1 -1
- package/lib-commonjs/ImperativeControl/index.js +1 -0
- package/lib-commonjs/ManualGhostText/ManualGhostText.base.js +1 -1
- package/lib-commonjs/ManualGhostText/ManualGhostText.base.js.map +1 -1
- package/lib-commonjs/ManualGhostText/index.js +1 -0
- package/lib-commonjs/PasteUnfurling/PasteUnfurling.base.js +1 -1
- package/lib-commonjs/PasteUnfurling/PasteUnfurling.base.js.map +1 -1
- package/lib-commonjs/PasteUnfurling/PasteUnfurling.types.js +1 -0
- package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js +1 -1
- package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js.map +1 -1
- package/lib-commonjs/PasteUnfurling/index.js +1 -0
- package/lib-commonjs/index.js +1 -0
- package/package.json +2 -2
package/CHANGELOG.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"name": "@fluentui-copilot/chat-input-plugins",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
6
|
-
"tag": "@fluentui-copilot/chat-input-plugins_v0.0.0-nightly-
|
|
7
|
-
"version": "0.0.0-nightly-
|
|
5
|
+
"date": "Wed, 09 Jul 2025 04:12:05 GMT",
|
|
6
|
+
"tag": "@fluentui-copilot/chat-input-plugins_v0.0.0-nightly-20250709-0404-150e065c.1",
|
|
7
|
+
"version": "0.0.0-nightly-20250709-0404-150e065c.1",
|
|
8
8
|
"comments": {
|
|
9
9
|
"prerelease": [
|
|
10
10
|
{
|
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Change Log - @fluentui-copilot/chat-input-plugins
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 09 Jul 2025 04:12:05 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## [0.0.0-nightly-
|
|
7
|
+
## [0.0.0-nightly-20250709-0404-150e065c.1](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.0.0-nightly-20250709-0404-150e065c.1)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.5.0..@fluentui-copilot/chat-input-plugins_v0.0.0-nightly-
|
|
9
|
+
Wed, 09 Jul 2025 04:12:05 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.5.0..@fluentui-copilot/chat-input-plugins_v0.0.0-nightly-20250709-0404-150e065c.1)
|
|
11
11
|
|
|
12
12
|
### Changes
|
|
13
13
|
|
|
@@ -4,104 +4,110 @@ import { $getRoot, $getSelection, $isRangeSelection, INSERT_PARAGRAPH_COMMAND, K
|
|
|
4
4
|
import { SENTINEL_VALUE } from './SentinelNode';
|
|
5
5
|
import { registerSentinelNodeHandlers } from './SentinelNodeHandlers';
|
|
6
6
|
function isClipboardEvent(event) {
|
|
7
|
-
|
|
7
|
+
return event.type === 'paste';
|
|
8
8
|
}
|
|
9
9
|
function getTextFromEditorState(state) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// Remove the sentinel node whenever getting the text
|
|
11
|
+
return state.read(() => $getRoot().getTextContent()).replace(SENTINEL_VALUE, '');
|
|
12
12
|
}
|
|
13
13
|
export class BasicFunctionalityBase {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
if (event === null) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
event.preventDefault();
|
|
23
|
-
if (event.shiftKey) {
|
|
24
|
-
return this.__editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, undefined);
|
|
25
|
-
}
|
|
26
|
-
// Mark event handled to override default behavior
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
activateContentCallbacks(onContentChange, onCountChanged) {
|
|
30
|
-
this.deactivateContentCallbacks();
|
|
31
|
-
this.__contentChangeCleanup = this.__editor.registerUpdateListener(({ editorState, prevEditorState, tags })=>{
|
|
32
|
-
const prevText = getTextFromEditorState(prevEditorState);
|
|
33
|
-
const newText = getTextFromEditorState(editorState);
|
|
34
|
-
// If the text has not changed, don't trigger callbacks
|
|
35
|
-
if (prevText === newText) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
onContentChange === null || onContentChange === void 0 ? void 0 : onContentChange(newText);
|
|
39
|
-
onCountChanged === null || onCountChanged === void 0 ? void 0 : onCountChanged(newText.length);
|
|
40
|
-
});
|
|
14
|
+
__enterHandler(event) {
|
|
15
|
+
const selection = $getSelection();
|
|
16
|
+
if (!$isRangeSelection(selection)) {
|
|
17
|
+
return false;
|
|
41
18
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(_this___contentChangeCleanup = (_this = this).__contentChangeCleanup) === null || _this___contentChangeCleanup === void 0 ? void 0 : _this___contentChangeCleanup.call(_this);
|
|
45
|
-
this.__contentChangeCleanup = undefined;
|
|
19
|
+
if (event === null) {
|
|
20
|
+
return false;
|
|
46
21
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
onPaste(event);
|
|
53
|
-
if (event.defaultPrevented) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
}, COMMAND_PRIORITY_HIGH);
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
if (event.shiftKey) {
|
|
24
|
+
return this.__editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, undefined);
|
|
58
25
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
26
|
+
// Mark event handled to override default behavior
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
activateContentCallbacks(onContentChange, onCountChanged) {
|
|
30
|
+
this.deactivateContentCallbacks();
|
|
31
|
+
this.__contentChangeCleanup = this.__editor.registerUpdateListener(({
|
|
32
|
+
editorState,
|
|
33
|
+
prevEditorState,
|
|
34
|
+
tags
|
|
35
|
+
}) => {
|
|
36
|
+
const prevText = getTextFromEditorState(prevEditorState);
|
|
37
|
+
const newText = getTextFromEditorState(editorState);
|
|
38
|
+
// If the text has not changed, don't trigger callbacks
|
|
39
|
+
if (prevText === newText) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
onContentChange === null || onContentChange === void 0 ? void 0 : onContentChange(newText);
|
|
43
|
+
onCountChanged === null || onCountChanged === void 0 ? void 0 : onCountChanged(newText.length);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
deactivateContentCallbacks() {
|
|
47
|
+
var _this___contentChangeCleanup, _this;
|
|
48
|
+
(_this___contentChangeCleanup = (_this = this).__contentChangeCleanup) === null || _this___contentChangeCleanup === void 0 ? void 0 : _this___contentChangeCleanup.call(_this);
|
|
49
|
+
this.__contentChangeCleanup = undefined;
|
|
50
|
+
}
|
|
51
|
+
activatePasteCallback(onPaste) {
|
|
52
|
+
this.__pasteHandlerCleanup = this.__editor.registerCommand(PASTE_COMMAND, event => {
|
|
53
|
+
if (!isClipboardEvent(event)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
onPaste(event);
|
|
57
|
+
if (event.defaultPrevented) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}, COMMAND_PRIORITY_HIGH);
|
|
62
|
+
}
|
|
63
|
+
deactivatePasteCallback() {
|
|
64
|
+
var _this___pasteHandlerCleanup, _this;
|
|
65
|
+
(_this___pasteHandlerCleanup = (_this = this).__pasteHandlerCleanup) === null || _this___pasteHandlerCleanup === void 0 ? void 0 : _this___pasteHandlerCleanup.call(_this);
|
|
66
|
+
this.__pasteHandlerCleanup = undefined;
|
|
67
|
+
}
|
|
68
|
+
activateTrimWhitespace() {
|
|
69
|
+
this.deactivateTrimWhitespace();
|
|
70
|
+
this.__trimWhitespaceCleanup = this.__editor.registerTextContentListener(text => {
|
|
71
|
+
if (text.trim() === '') {
|
|
72
|
+
this.__editor.update(() => {
|
|
73
|
+
$getRoot().getAllTextNodes().forEach(node => {
|
|
74
|
+
node.remove();
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
// Don't allow undoing this action
|
|
78
|
+
{
|
|
79
|
+
tag: 'historic'
|
|
77
80
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
deactivateTrimWhitespace() {
|
|
85
|
+
var _this___trimWhitespaceCleanup, _this;
|
|
86
|
+
(_this___trimWhitespaceCleanup = (_this = this).__trimWhitespaceCleanup) === null || _this___trimWhitespaceCleanup === void 0 ? void 0 : _this___trimWhitespaceCleanup.call(_this);
|
|
87
|
+
this.__trimWhitespaceCleanup = undefined;
|
|
88
|
+
}
|
|
89
|
+
setIsDisabled(isDisabled) {
|
|
90
|
+
this.__editor.setEditable(!isDisabled);
|
|
91
|
+
}
|
|
92
|
+
cleanup() {
|
|
93
|
+
var _this___baseHandlersCleanup, _this;
|
|
94
|
+
this.deactivateContentCallbacks();
|
|
95
|
+
this.deactivateTrimWhitespace();
|
|
96
|
+
this.deactivatePasteCallback();
|
|
97
|
+
(_this___baseHandlersCleanup = (_this = this).__baseHandlersCleanup) === null || _this___baseHandlersCleanup === void 0 ? void 0 : _this___baseHandlersCleanup.call(_this);
|
|
98
|
+
this.__baseHandlersCleanup = undefined;
|
|
99
|
+
}
|
|
100
|
+
constructor(editor, isSentinelNodeEnabled = true) {
|
|
101
|
+
_define_property(this, "__editor", void 0);
|
|
102
|
+
_define_property(this, "__contentChangeCleanup", void 0);
|
|
103
|
+
_define_property(this, "__trimWhitespaceCleanup", void 0);
|
|
104
|
+
_define_property(this, "__baseHandlersCleanup", void 0);
|
|
105
|
+
_define_property(this, "__pasteHandlerCleanup", void 0);
|
|
106
|
+
this.__editor = editor;
|
|
107
|
+
this.__baseHandlersCleanup = mergeRegister(this.__editor.registerCommand(KEY_ENTER_COMMAND, this.__enterHandler.bind(this), COMMAND_PRIORITY_HIGH), isSentinelNodeEnabled ? registerSentinelNodeHandlers(editor) : noop);
|
|
108
|
+
}
|
|
104
109
|
}
|
|
105
110
|
function noop() {
|
|
106
|
-
|
|
111
|
+
return;
|
|
107
112
|
}
|
|
113
|
+
//# sourceMappingURL=BasicFunctionality.base.js.map
|
|
@@ -5,37 +5,38 @@ import { TextNode } from '@fluentui-copilot/text-editor';
|
|
|
5
5
|
// These two characters together are a no-op and should not be present together in any legitimate user input.
|
|
6
6
|
export const SENTINEL_VALUE = '\u200b\u200c';
|
|
7
7
|
export class SentinelNode extends TextNode {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
8
|
+
static getType() {
|
|
9
|
+
return 'sentinel';
|
|
10
|
+
}
|
|
11
|
+
static clone(node) {
|
|
12
|
+
return new SentinelNode(node.__key);
|
|
13
|
+
}
|
|
14
|
+
createDOM(config) {
|
|
15
|
+
const element = super.createDOM(config);
|
|
16
|
+
element.ariaHidden = 'true';
|
|
17
|
+
return element;
|
|
18
|
+
}
|
|
19
|
+
isToken() {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
exportJSON() {
|
|
23
|
+
return {
|
|
24
|
+
...super.exportJSON(),
|
|
25
|
+
type: 'sentinel',
|
|
26
|
+
version: 1
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
static importJSON(serializedNode) {
|
|
30
|
+
return $createSentinelNode();
|
|
31
|
+
}
|
|
32
|
+
constructor(key) {
|
|
33
|
+
super(SENTINEL_VALUE, key);
|
|
34
|
+
}
|
|
35
35
|
}
|
|
36
36
|
export function $createSentinelNode(key) {
|
|
37
|
-
|
|
37
|
+
return new SentinelNode(key);
|
|
38
38
|
}
|
|
39
39
|
export function $isSentinelNode(node) {
|
|
40
|
-
|
|
40
|
+
return node instanceof SentinelNode;
|
|
41
41
|
}
|
|
42
|
+
//# sourceMappingURL=SentinelNode.js.map
|
|
@@ -1,79 +1,84 @@
|
|
|
1
1
|
import { $getLeafNodes, $getNodeByKey, $getRoot, $getSelection, $isRangeSelection, $normalizeSelection__EXPERIMENTAL, $setSelection, mergeRegister } from '@fluentui-copilot/text-editor';
|
|
2
2
|
import { $isSentinelNode, $createSentinelNode, SentinelNode } from './SentinelNode';
|
|
3
3
|
export function registerSentinelNodeHandlers(editor) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!selection.isCollapsed()) {
|
|
53
|
-
let selectionChanged = false;
|
|
54
|
-
const newSelection = selection.clone();
|
|
55
|
-
if (newSelection.anchor.getNode() === lastNode && newSelection.anchor.offset > 0) {
|
|
56
|
-
newSelection.anchor.set(lastNodeKey, 0, 'text');
|
|
57
|
-
selectionChanged = true;
|
|
58
|
-
}
|
|
59
|
-
if (newSelection.focus.getNode() === lastNode && newSelection.focus.offset > 0) {
|
|
60
|
-
newSelection.focus.set(lastNodeKey, 0, 'text');
|
|
61
|
-
selectionChanged = true;
|
|
62
|
-
}
|
|
63
|
-
if (selectionChanged) {
|
|
64
|
-
editor.update(()=>{
|
|
65
|
-
if ($getNodeByKey(lastNodeKey) !== null) {
|
|
66
|
-
$setSelection($normalizeSelection__EXPERIMENTAL(newSelection));
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
4
|
+
// Add a sentinel node at the end of the input when there is content.
|
|
5
|
+
// This sentinel node fixes a number of issues.
|
|
6
|
+
// In Safari, Lexical's behaviour of adding <br /> tags to the end of the input when it ends
|
|
7
|
+
// in a decorator node causes cursor location issues: https://github.com/facebook/lexical/issues/4487
|
|
8
|
+
// Otherwise, when a decorator node is the last node in the input, the cursor can't move past it.
|
|
9
|
+
// Adding an invisible text node that doesn't contribute to the content and can't be selected to the end of the input
|
|
10
|
+
// mitigates these issues.
|
|
11
|
+
const sentinelNodeUpdateHandler = ({
|
|
12
|
+
editorState
|
|
13
|
+
}) => {
|
|
14
|
+
editorState.read(() => {
|
|
15
|
+
const leaves = $getLeafNodes($getRoot());
|
|
16
|
+
if (leaves.length === 0) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const lastNode = leaves[leaves.length - 1];
|
|
20
|
+
const lastNodeKey = lastNode.getKey();
|
|
21
|
+
// If the last node isn't a sentinel, add one
|
|
22
|
+
if (!$isSentinelNode(lastNode)) {
|
|
23
|
+
editor.update(() => {
|
|
24
|
+
var
|
|
25
|
+
// We find the node by its key again in case the node was removed before this update runs
|
|
26
|
+
_$getNodeByKey;
|
|
27
|
+
(_$getNodeByKey = $getNodeByKey(lastNodeKey)) === null || _$getNodeByKey === void 0 ? void 0 : _$getNodeByKey.insertAfter($createSentinelNode());
|
|
28
|
+
},
|
|
29
|
+
// historic tag prevents every sentinel node addition from being added to LexicalHistoryPlugin undo stack
|
|
30
|
+
{
|
|
31
|
+
discrete: true,
|
|
32
|
+
tag: 'historic'
|
|
33
|
+
});
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
// If the sentinel node is not selected, we're done
|
|
37
|
+
const previous = lastNode.getPreviousSibling();
|
|
38
|
+
if (!previous || !lastNode.isSelected()) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const selection = $getSelection();
|
|
42
|
+
if (!$isRangeSelection(selection)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
// If the cursor is inside the sentinel node, move it out (next to the beginning)
|
|
46
|
+
// We allow selection on the boundary of the sentinel in case the adjacent node is a decorator node
|
|
47
|
+
// where selection is ill-defined.
|
|
48
|
+
if (selection.isCollapsed() && selection.anchor.offset > 0) {
|
|
49
|
+
editor.update(() => {
|
|
50
|
+
var _$getNodeByKey;
|
|
51
|
+
(_$getNodeByKey = $getNodeByKey(lastNodeKey)) === null || _$getNodeByKey === void 0 ? void 0 : _$getNodeByKey.selectStart();
|
|
71
52
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// If the selection is a range which includes the sentinel, modify the range to exclude it
|
|
56
|
+
if (!selection.isCollapsed()) {
|
|
57
|
+
let selectionChanged = false;
|
|
58
|
+
const newSelection = selection.clone();
|
|
59
|
+
if (newSelection.anchor.getNode() === lastNode && newSelection.anchor.offset > 0) {
|
|
60
|
+
newSelection.anchor.set(lastNodeKey, 0, 'text');
|
|
61
|
+
selectionChanged = true;
|
|
62
|
+
}
|
|
63
|
+
if (newSelection.focus.getNode() === lastNode && newSelection.focus.offset > 0) {
|
|
64
|
+
newSelection.focus.set(lastNodeKey, 0, 'text');
|
|
65
|
+
selectionChanged = true;
|
|
66
|
+
}
|
|
67
|
+
if (selectionChanged) {
|
|
68
|
+
editor.update(() => {
|
|
69
|
+
if ($getNodeByKey(lastNodeKey) !== null) {
|
|
70
|
+
$setSelection($normalizeSelection__EXPERIMENTAL(newSelection));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
77
73
|
}
|
|
78
|
-
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
return mergeRegister(editor.registerUpdateListener(sentinelNodeUpdateHandler), editor.registerNodeTransform(SentinelNode, node => {
|
|
78
|
+
if (!node.getPreviousSibling() || node.getNextSibling()) {
|
|
79
|
+
node.remove();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
79
83
|
}
|
|
84
|
+
//# sourceMappingURL=SentinelNodeHandlers.js.map
|