@fluentui-copilot/chat-input-plugins 0.4.2-hotfix.2 → 0.4.2-hotfix.3

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.
Files changed (48) hide show
  1. package/CHANGELOG.json +4 -4
  2. package/CHANGELOG.md +5 -5
  3. package/lib/BasicFunctionality/BasicFunctionality.base.js +92 -92
  4. package/lib/BasicFunctionality/SentinelNode.js +30 -29
  5. package/lib/BasicFunctionality/SentinelNodeHandlers.js +78 -73
  6. package/lib/BasicFunctionality/index.js +1 -0
  7. package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js +114 -109
  8. package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js +2 -1
  9. package/lib/ChatInputEntity/index.js +1 -0
  10. package/lib/GhostText/GhostText.base.js +145 -142
  11. package/lib/GhostText/index.js +1 -0
  12. package/lib/ImperativeControl/ImperativeControl.base.js +83 -82
  13. package/lib/ImperativeControl/index.js +1 -0
  14. package/lib/ManualGhostText/ManualGhostText.base.js +67 -68
  15. package/lib/ManualGhostText/index.js +1 -0
  16. package/lib/PasteUnfurling/PasteUnfurling.base.js +57 -52
  17. package/lib/PasteUnfurling/PasteUnfurling.types.js +2 -1
  18. package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js +139 -138
  19. package/lib/PasteUnfurling/index.js +1 -0
  20. package/lib/index.js +1 -0
  21. package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js +3 -2
  22. package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js.map +1 -1
  23. package/lib-commonjs/BasicFunctionality/SentinelNode.js +1 -1
  24. package/lib-commonjs/BasicFunctionality/SentinelNode.js.map +1 -1
  25. package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js +5 -3
  26. package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js.map +1 -1
  27. package/lib-commonjs/BasicFunctionality/index.js +1 -0
  28. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js +5 -3
  29. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js.map +1 -1
  30. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js +1 -0
  31. package/lib-commonjs/ChatInputEntity/index.js +1 -0
  32. package/lib-commonjs/GhostText/GhostText.base.js +3 -2
  33. package/lib-commonjs/GhostText/GhostText.base.js.map +1 -1
  34. package/lib-commonjs/GhostText/index.js +1 -0
  35. package/lib-commonjs/ImperativeControl/ImperativeControl.base.js +1 -1
  36. package/lib-commonjs/ImperativeControl/ImperativeControl.base.js.map +1 -1
  37. package/lib-commonjs/ImperativeControl/index.js +1 -0
  38. package/lib-commonjs/ManualGhostText/ManualGhostText.base.js +1 -1
  39. package/lib-commonjs/ManualGhostText/ManualGhostText.base.js.map +1 -1
  40. package/lib-commonjs/ManualGhostText/index.js +1 -0
  41. package/lib-commonjs/PasteUnfurling/PasteUnfurling.base.js +1 -1
  42. package/lib-commonjs/PasteUnfurling/PasteUnfurling.base.js.map +1 -1
  43. package/lib-commonjs/PasteUnfurling/PasteUnfurling.types.js +1 -0
  44. package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js +1 -1
  45. package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js.map +1 -1
  46. package/lib-commonjs/PasteUnfurling/index.js +1 -0
  47. package/lib-commonjs/index.js +1 -0
  48. package/package.json +2 -2
package/CHANGELOG.json CHANGED
@@ -2,16 +2,16 @@
2
2
  "name": "@fluentui-copilot/chat-input-plugins",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 12 Aug 2025 16:09:21 GMT",
6
- "tag": "@fluentui-copilot/chat-input-plugins_v0.4.2-hotfix.2",
7
- "version": "0.4.2-hotfix.2",
5
+ "date": "Fri, 19 Sep 2025 15:10:19 GMT",
6
+ "tag": "@fluentui-copilot/chat-input-plugins_v0.4.2-hotfix.3",
7
+ "version": "0.4.2-hotfix.3",
8
8
  "comments": {
9
9
  "prerelease": [
10
10
  {
11
11
  "author": "hochelmartin@gmail.com",
12
12
  "package": "@fluentui-copilot/chat-input-plugins",
13
13
  "commit": "3e4ebe676646c4c4346dbbab83511f963ffefd85",
14
- "comment": "release: prepare hotfix 0.26.2-hotfix.1"
14
+ "comment": "release: prepare hotfix 0.26.2-hotfix.2"
15
15
  }
16
16
  ]
17
17
  }
package/CHANGELOG.md CHANGED
@@ -1,17 +1,17 @@
1
1
  # Change Log - @fluentui-copilot/chat-input-plugins
2
2
 
3
- This log was last generated on Tue, 12 Aug 2025 16:09:21 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 19 Sep 2025 15:10:19 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.4.2-hotfix.2](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.4.2-hotfix.2)
7
+ ## [0.4.2-hotfix.3](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.4.2-hotfix.3)
8
8
 
9
- Tue, 12 Aug 2025 16:09:21 GMT
10
- [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.4.2..@fluentui-copilot/chat-input-plugins_v0.4.2-hotfix.2)
9
+ Fri, 19 Sep 2025 15:10:19 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.4.2..@fluentui-copilot/chat-input-plugins_v0.4.2-hotfix.3)
11
11
 
12
12
  ### Changes
13
13
 
14
- - release: prepare hotfix 0.26.2-hotfix.1 ([PR #3284](https://github.com/microsoft/fluentai/pull/3284) by hochelmartin@gmail.com)
14
+ - release: prepare hotfix 0.26.2-hotfix.2 ([PR #3284](https://github.com/microsoft/fluentai/pull/3284) by hochelmartin@gmail.com)
15
15
 
16
16
  ## [0.4.2](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.4.2)
17
17
 
@@ -4,105 +4,105 @@ import { $createTextNode, $getRoot, $getSelection, $insertNodes, $isRangeSelecti
4
4
  import { SENTINEL_VALUE } from './SentinelNode';
5
5
  import { registerSentinelNodeHandlers } from './SentinelNodeHandlers';
6
6
  function isClipboardEvent(event) {
7
- return event.type === 'paste';
7
+ return event.type === 'paste';
8
8
  }
9
9
  export class BasicFunctionalityBase {
10
- __enterHandler(event) {
11
- const selection = $getSelection();
12
- if (!$isRangeSelection(selection)) {
13
- return false;
14
- }
15
- if (event === null) {
16
- return false;
17
- }
18
- event.preventDefault();
19
- if (event.shiftKey) {
20
- return this.__editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, undefined);
21
- }
22
- // Mark event handled to override default behavior
23
- return true;
24
- }
25
- insertDefaultValue(defaultValue) {
26
- if (defaultValue) {
27
- this.__editor.update(()=>{
28
- $insertNodes([
29
- $createTextNode(defaultValue)
30
- ]);
31
- });
32
- }
10
+ __enterHandler(event) {
11
+ const selection = $getSelection();
12
+ if (!$isRangeSelection(selection)) {
13
+ return false;
33
14
  }
34
- activateContentCallbacks(onContentChange, onCountChanged) {
35
- this.deactivateContentCallbacks();
36
- this.__contentChangeCleanup = this.__editor.registerTextContentListener((text)=>{
37
- // Remove the sentinel node
38
- const processed = text.replace(SENTINEL_VALUE, '');
39
- onContentChange === null || onContentChange === void 0 ? void 0 : onContentChange(processed);
40
- onCountChanged === null || onCountChanged === void 0 ? void 0 : onCountChanged(processed.length);
41
- });
15
+ if (event === null) {
16
+ return false;
42
17
  }
43
- deactivateContentCallbacks() {
44
- var _this___contentChangeCleanup, _this;
45
- (_this___contentChangeCleanup = (_this = this).__contentChangeCleanup) === null || _this___contentChangeCleanup === void 0 ? void 0 : _this___contentChangeCleanup.call(_this);
46
- this.__contentChangeCleanup = undefined;
18
+ event.preventDefault();
19
+ if (event.shiftKey) {
20
+ return this.__editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, undefined);
47
21
  }
48
- activatePasteCallback(onPaste) {
49
- this.__pasteHandlerCleanup = this.__editor.registerCommand(PASTE_COMMAND, (event)=>{
50
- if (!isClipboardEvent(event)) {
51
- return false;
52
- }
53
- onPaste(event);
54
- if (event.defaultPrevented) {
55
- return true;
56
- }
57
- return false;
58
- }, COMMAND_PRIORITY_HIGH);
22
+ // Mark event handled to override default behavior
23
+ return true;
24
+ }
25
+ insertDefaultValue(defaultValue) {
26
+ if (defaultValue) {
27
+ this.__editor.update(() => {
28
+ $insertNodes([$createTextNode(defaultValue)]);
29
+ });
59
30
  }
60
- deactivatePasteCallback() {
61
- var _this___pasteHandlerCleanup, _this;
62
- (_this___pasteHandlerCleanup = (_this = this).__pasteHandlerCleanup) === null || _this___pasteHandlerCleanup === void 0 ? void 0 : _this___pasteHandlerCleanup.call(_this);
63
- this.__pasteHandlerCleanup = undefined;
64
- }
65
- activateTrimWhitespace() {
66
- this.deactivateTrimWhitespace();
67
- this.__trimWhitespaceCleanup = this.__editor.registerTextContentListener((text)=>{
68
- if (text.trim() === '') {
69
- this.__editor.update(()=>{
70
- $getRoot().getAllTextNodes().forEach((node)=>{
71
- node.remove();
72
- });
73
- }, // Don't allow undoing this action
74
- {
75
- tag: 'historic'
76
- });
77
- }
31
+ }
32
+ activateContentCallbacks(onContentChange, onCountChanged) {
33
+ this.deactivateContentCallbacks();
34
+ this.__contentChangeCleanup = this.__editor.registerTextContentListener(text => {
35
+ // Remove the sentinel node
36
+ const processed = text.replace(SENTINEL_VALUE, '');
37
+ onContentChange === null || onContentChange === void 0 ? void 0 : onContentChange(processed);
38
+ onCountChanged === null || onCountChanged === void 0 ? void 0 : onCountChanged(processed.length);
39
+ });
40
+ }
41
+ deactivateContentCallbacks() {
42
+ var _this___contentChangeCleanup, _this;
43
+ (_this___contentChangeCleanup = (_this = this).__contentChangeCleanup) === null || _this___contentChangeCleanup === void 0 ? void 0 : _this___contentChangeCleanup.call(_this);
44
+ this.__contentChangeCleanup = undefined;
45
+ }
46
+ activatePasteCallback(onPaste) {
47
+ this.__pasteHandlerCleanup = this.__editor.registerCommand(PASTE_COMMAND, event => {
48
+ if (!isClipboardEvent(event)) {
49
+ return false;
50
+ }
51
+ onPaste(event);
52
+ if (event.defaultPrevented) {
53
+ return true;
54
+ }
55
+ return false;
56
+ }, COMMAND_PRIORITY_HIGH);
57
+ }
58
+ deactivatePasteCallback() {
59
+ var _this___pasteHandlerCleanup, _this;
60
+ (_this___pasteHandlerCleanup = (_this = this).__pasteHandlerCleanup) === null || _this___pasteHandlerCleanup === void 0 ? void 0 : _this___pasteHandlerCleanup.call(_this);
61
+ this.__pasteHandlerCleanup = undefined;
62
+ }
63
+ activateTrimWhitespace() {
64
+ this.deactivateTrimWhitespace();
65
+ this.__trimWhitespaceCleanup = this.__editor.registerTextContentListener(text => {
66
+ if (text.trim() === '') {
67
+ this.__editor.update(() => {
68
+ $getRoot().getAllTextNodes().forEach(node => {
69
+ node.remove();
70
+ });
71
+ },
72
+ // Don't allow undoing this action
73
+ {
74
+ tag: 'historic'
78
75
  });
79
- }
80
- deactivateTrimWhitespace() {
81
- var _this___trimWhitespaceCleanup, _this;
82
- (_this___trimWhitespaceCleanup = (_this = this).__trimWhitespaceCleanup) === null || _this___trimWhitespaceCleanup === void 0 ? void 0 : _this___trimWhitespaceCleanup.call(_this);
83
- this.__trimWhitespaceCleanup = undefined;
84
- }
85
- setIsDisabled(isDisabled) {
86
- this.__editor.setEditable(!isDisabled);
87
- }
88
- cleanup() {
89
- var _this___baseHandlersCleanup, _this;
90
- this.deactivateContentCallbacks();
91
- this.deactivateTrimWhitespace();
92
- this.deactivatePasteCallback();
93
- (_this___baseHandlersCleanup = (_this = this).__baseHandlersCleanup) === null || _this___baseHandlersCleanup === void 0 ? void 0 : _this___baseHandlersCleanup.call(_this);
94
- this.__baseHandlersCleanup = undefined;
95
- }
96
- constructor(editor, isSentinelNodeEnabled = true){
97
- _define_property(this, "__editor", void 0);
98
- _define_property(this, "__contentChangeCleanup", void 0);
99
- _define_property(this, "__trimWhitespaceCleanup", void 0);
100
- _define_property(this, "__baseHandlersCleanup", void 0);
101
- _define_property(this, "__pasteHandlerCleanup", void 0);
102
- this.__editor = editor;
103
- this.__baseHandlersCleanup = mergeRegister(this.__editor.registerCommand(KEY_ENTER_COMMAND, this.__enterHandler.bind(this), COMMAND_PRIORITY_HIGH), isSentinelNodeEnabled ? registerSentinelNodeHandlers(editor) : noop);
104
- }
76
+ }
77
+ });
78
+ }
79
+ deactivateTrimWhitespace() {
80
+ var _this___trimWhitespaceCleanup, _this;
81
+ (_this___trimWhitespaceCleanup = (_this = this).__trimWhitespaceCleanup) === null || _this___trimWhitespaceCleanup === void 0 ? void 0 : _this___trimWhitespaceCleanup.call(_this);
82
+ this.__trimWhitespaceCleanup = undefined;
83
+ }
84
+ setIsDisabled(isDisabled) {
85
+ this.__editor.setEditable(!isDisabled);
86
+ }
87
+ cleanup() {
88
+ var _this___baseHandlersCleanup, _this;
89
+ this.deactivateContentCallbacks();
90
+ this.deactivateTrimWhitespace();
91
+ this.deactivatePasteCallback();
92
+ (_this___baseHandlersCleanup = (_this = this).__baseHandlersCleanup) === null || _this___baseHandlersCleanup === void 0 ? void 0 : _this___baseHandlersCleanup.call(_this);
93
+ this.__baseHandlersCleanup = undefined;
94
+ }
95
+ constructor(editor, isSentinelNodeEnabled = true) {
96
+ _define_property(this, "__editor", void 0);
97
+ _define_property(this, "__contentChangeCleanup", void 0);
98
+ _define_property(this, "__trimWhitespaceCleanup", void 0);
99
+ _define_property(this, "__baseHandlersCleanup", void 0);
100
+ _define_property(this, "__pasteHandlerCleanup", void 0);
101
+ this.__editor = editor;
102
+ this.__baseHandlersCleanup = mergeRegister(this.__editor.registerCommand(KEY_ENTER_COMMAND, this.__enterHandler.bind(this), COMMAND_PRIORITY_HIGH), isSentinelNodeEnabled ? registerSentinelNodeHandlers(editor) : noop);
103
+ }
105
104
  }
106
105
  function noop() {
107
- return;
106
+ return;
108
107
  }
108
+ //# 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
- 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
- }
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
- return new SentinelNode(key);
37
+ return new SentinelNode(key);
38
38
  }
39
39
  export function $isSentinelNode(node) {
40
- return node instanceof SentinelNode;
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
- // 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 = ({ editorState })=>{
12
- editorState.read(()=>{
13
- const leaves = $getLeafNodes($getRoot());
14
- if (leaves.length === 0) {
15
- return;
16
- }
17
- const lastNode = leaves[leaves.length - 1];
18
- const lastNodeKey = lastNode.getKey();
19
- // If the last node isn't a sentinel, add one
20
- if (!$isSentinelNode(lastNode)) {
21
- editor.update(()=>{
22
- var // We find the node by its key again in case the node was removed before this update runs
23
- _$getNodeByKey;
24
- (_$getNodeByKey = $getNodeByKey(lastNodeKey)) === null || _$getNodeByKey === void 0 ? void 0 : _$getNodeByKey.insertAfter($createSentinelNode());
25
- }, // historic tag prevents every sentinel node addition from being added to LexicalHistoryPlugin undo stack
26
- {
27
- discrete: true,
28
- tag: 'historic'
29
- });
30
- return;
31
- }
32
- // If the sentinel node is not selected, we're done
33
- const previous = lastNode.getPreviousSibling();
34
- if (!previous || !lastNode.isSelected()) {
35
- return;
36
- }
37
- const selection = $getSelection();
38
- if (!$isRangeSelection(selection)) {
39
- return;
40
- }
41
- // If the cursor is inside the sentinel node, move it out (next to the beginning)
42
- // We allow selection on the boundary of the sentinel in case the adjacent node is a decorator node
43
- // where selection is ill-defined.
44
- if (selection.isCollapsed() && selection.anchor.offset > 0) {
45
- editor.update(()=>{
46
- var _$getNodeByKey;
47
- (_$getNodeByKey = $getNodeByKey(lastNodeKey)) === null || _$getNodeByKey === void 0 ? void 0 : _$getNodeByKey.selectStart();
48
- });
49
- return;
50
- }
51
- // If the selection is a range which includes the sentinel, modify the range to exclude it
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
- return mergeRegister(editor.registerUpdateListener(sentinelNodeUpdateHandler), editor.registerNodeTransform(SentinelNode, (node)=>{
74
- if (!node.getPreviousSibling() || node.getNextSibling()) {
75
- node.remove();
76
- return;
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
@@ -1,2 +1,3 @@
1
1
  export { BasicFunctionalityBase } from './BasicFunctionality.base';
2
2
  export { $createSentinelNode, $isSentinelNode, SENTINEL_VALUE, SentinelNode } from './SentinelNode';
3
+ //# sourceMappingURL=index.js.map