@fluentui-copilot/chat-input-plugins 0.0.3 → 0.0.5

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 (42) hide show
  1. package/CHANGELOG.json +55 -1
  2. package/CHANGELOG.md +24 -2
  3. package/dist/index.d.ts +20 -1
  4. package/lib/BasicFunctionality/BasicFunctionality.base.js +106 -8
  5. package/lib/BasicFunctionality/BasicFunctionality.base.js.map +1 -1
  6. package/lib/BasicFunctionality/SentinelNode.js +25 -0
  7. package/lib/BasicFunctionality/SentinelNode.js.map +1 -0
  8. package/lib/BasicFunctionality/index.js +1 -0
  9. package/lib/BasicFunctionality/index.js.map +1 -1
  10. package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js.map +1 -1
  11. package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js.map +1 -1
  12. package/lib/ChatInputEntity/index.js.map +1 -1
  13. package/lib/GhostText/GhostText.base.js +46 -4
  14. package/lib/GhostText/GhostText.base.js.map +1 -1
  15. package/lib/GhostText/index.js.map +1 -1
  16. package/lib/ImperativeControl/ImperativeControl.base.js +4 -2
  17. package/lib/ImperativeControl/ImperativeControl.base.js.map +1 -1
  18. package/lib/ImperativeControl/index.js.map +1 -1
  19. package/lib/ManualGhostText/ManualGhostText.base.js.map +1 -1
  20. package/lib/ManualGhostText/index.js.map +1 -1
  21. package/lib/index.js +1 -1
  22. package/lib/index.js.map +1 -1
  23. package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js +101 -7
  24. package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js.map +1 -1
  25. package/lib-commonjs/BasicFunctionality/SentinelNode.js +48 -0
  26. package/lib-commonjs/BasicFunctionality/SentinelNode.js.map +1 -0
  27. package/lib-commonjs/BasicFunctionality/index.js +1 -0
  28. package/lib-commonjs/BasicFunctionality/index.js.map +1 -1
  29. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js.map +1 -1
  30. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js.map +1 -1
  31. package/lib-commonjs/ChatInputEntity/index.js.map +1 -1
  32. package/lib-commonjs/GhostText/GhostText.base.js +45 -3
  33. package/lib-commonjs/GhostText/GhostText.base.js.map +1 -1
  34. package/lib-commonjs/GhostText/index.js.map +1 -1
  35. package/lib-commonjs/ImperativeControl/ImperativeControl.base.js +4 -2
  36. package/lib-commonjs/ImperativeControl/ImperativeControl.base.js.map +1 -1
  37. package/lib-commonjs/ImperativeControl/index.js.map +1 -1
  38. package/lib-commonjs/ManualGhostText/ManualGhostText.base.js.map +1 -1
  39. package/lib-commonjs/ManualGhostText/index.js.map +1 -1
  40. package/lib-commonjs/index.js +12 -0
  41. package/lib-commonjs/index.js.map +1 -1
  42. package/package.json +2 -2
package/CHANGELOG.json CHANGED
@@ -2,7 +2,61 @@
2
2
  "name": "@fluentui-copilot/chat-input-plugins",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 18 Apr 2024 00:27:52 GMT",
5
+ "date": "Wed, 08 May 2024 22:09:00 GMT",
6
+ "tag": "@fluentui-copilot/chat-input-plugins_v0.0.5",
7
+ "version": "0.0.5",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "owcampbe@microsoft.com",
12
+ "package": "@fluentui-copilot/chat-input-plugins",
13
+ "commit": "2bcbb68c4751536bb0ee7b4b19ded4f21be9f956",
14
+ "comment": "fix: Strip out sentinel node characters from ImperativeControlPlugin."
15
+ },
16
+ {
17
+ "author": "owcampbe@microsoft.com",
18
+ "package": "@fluentui-copilot/chat-input-plugins",
19
+ "commit": "da7a5eaa6af7c4eacef58d70f51acfb30977a38c",
20
+ "comment": "fix: insertTextAtCursor should append if no selection exists."
21
+ },
22
+ {
23
+ "author": "owcampbe@microsoft.com",
24
+ "package": "@fluentui-copilot/chat-input-plugins",
25
+ "commit": "8b3fa1f2bc2732776130769a904a98c314207fef",
26
+ "comment": "fix: Improve navigation around GhostText."
27
+ },
28
+ {
29
+ "author": "owcampbe@microsoft.com",
30
+ "package": "@fluentui-copilot/chat-input-plugins",
31
+ "commit": "8758b361c9586e347ec3c8c16038532598c31e77",
32
+ "comment": "fix: Get fresh reference to lexical node for update closure."
33
+ }
34
+ ]
35
+ }
36
+ },
37
+ {
38
+ "date": "Tue, 30 Apr 2024 20:55:42 GMT",
39
+ "tag": "@fluentui-copilot/chat-input-plugins_v0.0.4",
40
+ "version": "0.0.4",
41
+ "comments": {
42
+ "patch": [
43
+ {
44
+ "author": "owcampbe@microsoft.com",
45
+ "package": "@fluentui-copilot/chat-input-plugins",
46
+ "commit": "f2067016fa67e0718cb2c309338ab4376d256cd4",
47
+ "comment": "feat: Add onPaste to BasicFunctionalityPlugin."
48
+ },
49
+ {
50
+ "author": "owcampbe@microsoft.com",
51
+ "package": "@fluentui-copilot/chat-input-plugins",
52
+ "commit": "3483acc61611eefb8dc8a66e21c4d71e74e73674",
53
+ "comment": "fix: Add invisible sentinel node to ChatInput to fix cursor issues."
54
+ }
55
+ ]
56
+ }
57
+ },
58
+ {
59
+ "date": "Thu, 18 Apr 2024 00:28:05 GMT",
6
60
  "tag": "@fluentui-copilot/chat-input-plugins_v0.0.3",
7
61
  "version": "0.0.3",
8
62
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,34 @@
1
1
  # Change Log - @fluentui-copilot/chat-input-plugins
2
2
 
3
- This log was last generated on Thu, 18 Apr 2024 00:27:52 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 08 May 2024 22:09:00 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [0.0.5](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.0.5)
8
+
9
+ Wed, 08 May 2024 22:09:00 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.0.4..@fluentui-copilot/chat-input-plugins_v0.0.5)
11
+
12
+ ### Patches
13
+
14
+ - fix: Strip out sentinel node characters from ImperativeControlPlugin. ([PR #1612](https://github.com/microsoft/fluentai/pull/1612) by owcampbe@microsoft.com)
15
+ - fix: insertTextAtCursor should append if no selection exists. ([PR #1590](https://github.com/microsoft/fluentai/pull/1590) by owcampbe@microsoft.com)
16
+ - fix: Improve navigation around GhostText. ([PR #1611](https://github.com/microsoft/fluentai/pull/1611) by owcampbe@microsoft.com)
17
+ - fix: Get fresh reference to lexical node for update closure. ([PR #1613](https://github.com/microsoft/fluentai/pull/1613) by owcampbe@microsoft.com)
18
+
19
+ ## [0.0.4](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.0.4)
20
+
21
+ Tue, 30 Apr 2024 20:55:42 GMT
22
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.0.3..@fluentui-copilot/chat-input-plugins_v0.0.4)
23
+
24
+ ### Patches
25
+
26
+ - feat: Add onPaste to BasicFunctionalityPlugin. ([PR #1556](https://github.com/microsoft/fluentai/pull/1556) by owcampbe@microsoft.com)
27
+ - fix: Add invisible sentinel node to ChatInput to fix cursor issues. ([PR #1599](https://github.com/microsoft/fluentai/pull/1599) by owcampbe@microsoft.com)
28
+
7
29
  ## [0.0.3](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.0.3)
8
30
 
9
- Thu, 18 Apr 2024 00:27:52 GMT
31
+ Thu, 18 Apr 2024 00:28:05 GMT
10
32
  [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.0.2..@fluentui-copilot/chat-input-plugins_v0.0.3)
11
33
 
12
34
  ### Patches
package/dist/index.d.ts CHANGED
@@ -3,17 +3,25 @@ import { Klass } from 'lexical';
3
3
  import { LexicalEditor } from 'lexical';
4
4
  import { LexicalNode } from 'lexical';
5
5
  import { NodeKey } from 'lexical';
6
+ import { TextNode } from 'lexical';
7
+
8
+ export declare function $createSentinelNode(key?: NodeKey): SentinelNode;
9
+
10
+ export declare function $isSentinelNode(node: LexicalNode | null): node is SentinelNode;
6
11
 
7
12
  export declare class BasicFunctionalityBase implements IBasicFunctionalityBase {
8
13
  private __editor;
9
14
  private __contentChangeCleanup?;
10
15
  private __trimWhitespaceCleanup?;
11
- private __enterHandlerCleanup?;
16
+ private __baseHandlersCleanup?;
17
+ private __pasteHandlerCleanup?;
12
18
  private __enterHandler;
13
19
  constructor(editor: LexicalEditor);
14
20
  insertDefaultValue(defaultValue: string): void;
15
21
  activateContentCallbacks(onContentChange?: ((value: string) => void) | undefined, onCountChanged?: ((count: number) => void) | undefined): void;
16
22
  deactivateContentCallbacks(): void;
23
+ activatePasteCallback(onPaste: (event: ClipboardEvent) => void): void;
24
+ deactivatePasteCallback(): void;
17
25
  activateTrimWhitespace(): void;
18
26
  deactivateTrimWhitespace(): void;
19
27
  setIsDisabled(isDisabled: boolean): void;
@@ -71,6 +79,8 @@ export declare interface IBasicFunctionalityBase {
71
79
  deactivateContentCallbacks(): void;
72
80
  activateTrimWhitespace(): void;
73
81
  deactivateTrimWhitespace(): void;
82
+ activatePasteCallback(onPaste: (event: ClipboardEvent) => void): void;
83
+ deactivatePasteCallback(): void;
74
84
  cleanup(): void;
75
85
  }
76
86
 
@@ -140,4 +150,13 @@ export declare class ManualGhostTextBase<ComponentPropsType> {
140
150
  cancelGhostText(): void;
141
151
  }
142
152
 
153
+ export declare const SENTINEL_VALUE = "\u200B\u200C";
154
+
155
+ export declare class SentinelNode extends TextNode {
156
+ constructor(key?: NodeKey);
157
+ static getType(): string;
158
+ static clone(node: SentinelNode): SentinelNode;
159
+ isToken(): boolean;
160
+ }
161
+
143
162
  export { }
@@ -1,5 +1,6 @@
1
1
  import { _ as _define_property } from "@swc/helpers/_/_define_property";
2
- import { $createTextNode, $getRoot, $getSelection, $insertNodes, $isRangeSelection, COMMAND_PRIORITY_CRITICAL, INSERT_PARAGRAPH_COMMAND, KEY_ENTER_COMMAND } from '@fluentui-copilot/text-editor';
2
+ import { $createTextNode, $getLeafNodes, $getNodeByKey, $getRoot, $getSelection, $insertNodes, $isRangeSelection, $normalizeSelection__EXPERIMENTAL, $setSelection, COMMAND_PRIORITY_CRITICAL, INSERT_PARAGRAPH_COMMAND, KEY_ENTER_COMMAND, PASTE_COMMAND, mergeRegister } from '@fluentui-copilot/text-editor';
3
+ import { $createSentinelNode, $isSentinelNode, SENTINEL_VALUE, SentinelNode } from './SentinelNode';
3
4
  export class BasicFunctionalityBase {
4
5
  __enterHandler(event) {
5
6
  const selection = $getSelection();
@@ -26,8 +27,10 @@ export class BasicFunctionalityBase {
26
27
  activateContentCallbacks(onContentChange, onCountChanged) {
27
28
  this.deactivateContentCallbacks();
28
29
  this.__contentChangeCleanup = this.__editor.registerTextContentListener(text => {
29
- onContentChange === null || onContentChange === void 0 ? void 0 : onContentChange(text);
30
- onCountChanged === null || onCountChanged === void 0 ? void 0 : onCountChanged(text.length);
30
+ // Remove the sentinel node
31
+ const processed = text.replace(SENTINEL_VALUE, '');
32
+ onContentChange === null || onContentChange === void 0 ? void 0 : onContentChange(processed);
33
+ onCountChanged === null || onCountChanged === void 0 ? void 0 : onCountChanged(processed.length);
31
34
  });
32
35
  }
33
36
  deactivateContentCallbacks() {
@@ -35,6 +38,20 @@ export class BasicFunctionalityBase {
35
38
  (_this___contentChangeCleanup = (_this = this).__contentChangeCleanup) === null || _this___contentChangeCleanup === void 0 ? void 0 : _this___contentChangeCleanup.call(_this);
36
39
  this.__contentChangeCleanup = undefined;
37
40
  }
41
+ activatePasteCallback(onPaste) {
42
+ this.__pasteHandlerCleanup = this.__editor.registerCommand(PASTE_COMMAND, event => {
43
+ onPaste(event);
44
+ if (event.defaultPrevented) {
45
+ return true;
46
+ }
47
+ return false;
48
+ }, COMMAND_PRIORITY_CRITICAL);
49
+ }
50
+ deactivatePasteCallback() {
51
+ var _this___pasteHandlerCleanup, _this;
52
+ (_this___pasteHandlerCleanup = (_this = this).__pasteHandlerCleanup) === null || _this___pasteHandlerCleanup === void 0 ? void 0 : _this___pasteHandlerCleanup.call(_this);
53
+ this.__pasteHandlerCleanup = undefined;
54
+ }
38
55
  activateTrimWhitespace() {
39
56
  this.deactivateTrimWhitespace();
40
57
  this.__trimWhitespaceCleanup = this.__editor.registerTextContentListener(text => {
@@ -60,19 +77,100 @@ export class BasicFunctionalityBase {
60
77
  this.__editor.setEditable(!isDisabled);
61
78
  }
62
79
  cleanup() {
63
- var _this___enterHandlerCleanup, _this;
80
+ var _this___baseHandlersCleanup, _this;
64
81
  this.deactivateContentCallbacks();
65
82
  this.deactivateTrimWhitespace();
66
- (_this___enterHandlerCleanup = (_this = this).__enterHandlerCleanup) === null || _this___enterHandlerCleanup === void 0 ? void 0 : _this___enterHandlerCleanup.call(_this);
67
- this.__enterHandlerCleanup = undefined;
83
+ this.deactivatePasteCallback();
84
+ (_this___baseHandlersCleanup = (_this = this).__baseHandlersCleanup) === null || _this___baseHandlersCleanup === void 0 ? void 0 : _this___baseHandlersCleanup.call(_this);
85
+ this.__baseHandlersCleanup = undefined;
68
86
  }
69
87
  constructor(editor) {
70
88
  _define_property(this, "__editor", void 0);
71
89
  _define_property(this, "__contentChangeCleanup", void 0);
72
90
  _define_property(this, "__trimWhitespaceCleanup", void 0);
73
- _define_property(this, "__enterHandlerCleanup", void 0);
91
+ _define_property(this, "__baseHandlersCleanup", void 0);
92
+ _define_property(this, "__pasteHandlerCleanup", void 0);
74
93
  this.__editor = editor;
75
- this.__enterHandlerCleanup = this.__editor.registerCommand(KEY_ENTER_COMMAND, this.__enterHandler.bind(this), COMMAND_PRIORITY_CRITICAL);
94
+ this.__baseHandlersCleanup = mergeRegister(this.__editor.registerCommand(KEY_ENTER_COMMAND, this.__enterHandler.bind(this), COMMAND_PRIORITY_CRITICAL),
95
+ // Add a sentinel node at the end of the input when there is content.
96
+ // This sentinel node fixes a number of issues.
97
+ // In Safari, Lexical's behaviour of adding <br /> tags to the end of the input when it ends
98
+ // in a decorator node causes cursor location issues: https://github.com/facebook/lexical/issues/4487
99
+ // Otherwise, when a decorator node is the last node in the input, the cursor can't move past it.
100
+ // Adding an invisible text node that doesn't contribute to the content and can't be selected to the end of the input
101
+ // mitigates these issues.
102
+ this.__editor.registerUpdateListener(({
103
+ editorState
104
+ }) => {
105
+ editorState.read(() => {
106
+ const leaves = $getLeafNodes($getRoot());
107
+ if (leaves.length === 0) {
108
+ return;
109
+ }
110
+ const lastNode = leaves[leaves.length - 1];
111
+ const lastNodeKey = lastNode.getKey();
112
+ // If the last node isn't a sentinel, add one
113
+ if (!$isSentinelNode(lastNode)) {
114
+ this.__editor.update(() => {
115
+ var
116
+ // We find the node by its key again in case the node was removed before this update runs
117
+ _$getNodeByKey;
118
+ (_$getNodeByKey = $getNodeByKey(lastNodeKey)) === null || _$getNodeByKey === void 0 ? void 0 : _$getNodeByKey.insertAfter($createSentinelNode());
119
+ }, {
120
+ discrete: true
121
+ });
122
+ return;
123
+ }
124
+ // If the sentinel node is not selected, we're done
125
+ const previous = lastNode.getPreviousSibling();
126
+ if (!previous || !lastNode.isSelected()) {
127
+ return;
128
+ }
129
+ const selection = $getSelection();
130
+ if (!$isRangeSelection(selection)) {
131
+ return;
132
+ }
133
+ // If the cursor is inside the sentinel node, move it out (next to the beginning)
134
+ // We allow selection on the boundary of the sentinel in case the adjacent node is a decorator node
135
+ // where selection is ill-defined.
136
+ if (selection.isCollapsed() && selection.anchor.offset > 0) {
137
+ this.__editor.update(() => {
138
+ var _$getNodeByKey;
139
+ (_$getNodeByKey = $getNodeByKey(lastNodeKey)) === null || _$getNodeByKey === void 0 ? void 0 : _$getNodeByKey.selectStart();
140
+ }, {
141
+ discrete: true
142
+ });
143
+ return;
144
+ }
145
+ // If the selection is a range which includes the sentinel, modify the range to exclude it
146
+ if (!selection.isCollapsed()) {
147
+ let selectionChanged = false;
148
+ const newSelection = selection.clone();
149
+ if (newSelection.anchor.getNode() === lastNode && newSelection.anchor.offset > 0) {
150
+ newSelection.anchor.set(lastNodeKey, 0, 'text');
151
+ selectionChanged = true;
152
+ }
153
+ if (newSelection.focus.getNode() === lastNode && newSelection.focus.offset > 0) {
154
+ newSelection.focus.set(lastNodeKey, 0, 'text');
155
+ selectionChanged = true;
156
+ }
157
+ if (selectionChanged) {
158
+ this.__editor.update(() => {
159
+ if ($getNodeByKey(lastNodeKey) !== null) {
160
+ $setSelection($normalizeSelection__EXPERIMENTAL(newSelection));
161
+ }
162
+ }, {
163
+ discrete: true
164
+ });
165
+ }
166
+ }
167
+ });
168
+ }), this.__editor.registerNodeTransform(SentinelNode, node => {
169
+ if (!node.getPreviousSibling() || node.getNextSibling()) {
170
+ node.remove();
171
+ return;
172
+ }
173
+ }));
76
174
  }
77
175
  }
78
176
  //# sourceMappingURL=BasicFunctionality.base.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["BasicFunctionality.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport {\n $createTextNode,\n $getRoot,\n $getSelection,\n $insertNodes,\n $isRangeSelection,\n COMMAND_PRIORITY_CRITICAL,\n INSERT_PARAGRAPH_COMMAND,\n KEY_ENTER_COMMAND,\n} from '@fluentui-copilot/text-editor';\n\nexport interface IBasicFunctionalityBase {\n insertDefaultValue: (defaultValue: string) => void;\n setIsDisabled: (isDisabled: boolean) => void;\n activateContentCallbacks(onContentChange?: (value: string) => void, onCountChanged?: (count: number) => void): void;\n deactivateContentCallbacks(): void;\n activateTrimWhitespace(): void;\n deactivateTrimWhitespace(): void;\n cleanup(): void;\n}\n\nexport class BasicFunctionalityBase implements IBasicFunctionalityBase {\n private __editor: LexicalEditor;\n private __contentChangeCleanup?: () => void;\n private __trimWhitespaceCleanup?: () => void;\n private __enterHandlerCleanup?: () => void;\n\n private __enterHandler(event: KeyboardEvent) {\n const selection = $getSelection();\n if (!$isRangeSelection(selection)) {\n return false;\n }\n\n if (event === null) {\n return false;\n }\n\n event.preventDefault();\n\n if (event.shiftKey) {\n return this.__editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, undefined);\n }\n\n // Mark event handled to override default behavior\n return true;\n }\n\n constructor(editor: LexicalEditor) {\n this.__editor = editor;\n\n this.__enterHandlerCleanup = this.__editor.registerCommand(\n KEY_ENTER_COMMAND,\n this.__enterHandler.bind(this),\n COMMAND_PRIORITY_CRITICAL,\n );\n }\n\n insertDefaultValue(defaultValue: string) {\n if (defaultValue) {\n this.__editor.update(() => {\n $insertNodes([$createTextNode(defaultValue)]);\n });\n }\n }\n\n activateContentCallbacks(\n onContentChange?: ((value: string) => void) | undefined,\n onCountChanged?: ((count: number) => void) | undefined,\n ) {\n this.deactivateContentCallbacks();\n this.__contentChangeCleanup = this.__editor.registerTextContentListener(text => {\n onContentChange?.(text);\n onCountChanged?.(text.length);\n });\n }\n\n deactivateContentCallbacks() {\n this.__contentChangeCleanup?.();\n this.__contentChangeCleanup = undefined;\n }\n\n activateTrimWhitespace() {\n this.deactivateTrimWhitespace();\n this.__trimWhitespaceCleanup = this.__editor.registerTextContentListener(text => {\n if (text.trim() === '') {\n this.__editor.update(\n () => {\n $getRoot()\n .getAllTextNodes()\n .forEach(node => {\n node.remove();\n });\n },\n // Don't allow undoing this action\n { tag: 'historic' },\n );\n }\n });\n }\n\n deactivateTrimWhitespace() {\n this.__trimWhitespaceCleanup?.();\n this.__trimWhitespaceCleanup = undefined;\n }\n\n setIsDisabled(isDisabled: boolean) {\n this.__editor.setEditable(!isDisabled);\n }\n\n cleanup() {\n this.deactivateContentCallbacks();\n this.deactivateTrimWhitespace();\n this.__enterHandlerCleanup?.();\n this.__enterHandlerCleanup = undefined;\n }\n}\n"],"names":["$createTextNode","$getRoot","$getSelection","$insertNodes","$isRangeSelection","COMMAND_PRIORITY_CRITICAL","INSERT_PARAGRAPH_COMMAND","KEY_ENTER_COMMAND","BasicFunctionalityBase","__enterHandler","event","selection","preventDefault","shiftKey","__editor","dispatchCommand","undefined","insertDefaultValue","defaultValue","update","activateContentCallbacks","onContentChange","onCountChanged","deactivateContentCallbacks","__contentChangeCleanup","registerTextContentListener","text","length","activateTrimWhitespace","deactivateTrimWhitespace","__trimWhitespaceCleanup","trim","getAllTextNodes","forEach","node","remove","tag","setIsDisabled","isDisabled","setEditable","cleanup","__enterHandlerCleanup","constructor","editor","registerCommand","bind"],"mappings":";AACA,SACEA,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,YAAY,EACZC,iBAAiB,EACjBC,yBAAyB,EACzBC,wBAAwB,EACxBC,iBAAiB,QACZ,gCAAgC;AAYvC,OAAO,MAAMC;IAMHC,eAAeC,KAAoB,EAAE;QAC3C,MAAMC,YAAYT;QAClB,IAAI,CAACE,kBAAkBO,YAAY;YACjC,OAAO;QACT;QAEA,IAAID,UAAU,MAAM;YAClB,OAAO;QACT;QAEAA,MAAME,cAAc;QAEpB,IAAIF,MAAMG,QAAQ,EAAE;YAClB,OAAO,IAAI,CAACC,QAAQ,CAACC,eAAe,CAACT,0BAA0BU;QACjE;QAEA,kDAAkD;QAClD,OAAO;IACT;IAYAC,mBAAmBC,YAAoB,EAAE;QACvC,IAAIA,cAAc;YAChB,IAAI,CAACJ,QAAQ,CAACK,MAAM,CAAC;gBACnBhB,aAAa;oBAACH,gBAAgBkB;iBAAc;YAC9C;QACF;IACF;IAEAE,yBACEC,eAAuD,EACvDC,cAAsD,EACtD;QACA,IAAI,CAACC,0BAA0B;QAC/B,IAAI,CAACC,sBAAsB,GAAG,IAAI,CAACV,QAAQ,CAACW,2BAA2B,CAACC,CAAAA;YACtEL,4BAAAA,sCAAAA,gBAAkBK;YAClBJ,2BAAAA,qCAAAA,eAAiBI,KAAKC,MAAM;QAC9B;IACF;IAEAJ,6BAA6B;YAC3B,8BAAA;SAAA,+BAAA,CAAA,QAAA,IAAI,EAACC,sBAAsB,cAA3B,mDAAA,kCAAA;QACA,IAAI,CAACA,sBAAsB,GAAGR;IAChC;IAEAY,yBAAyB;QACvB,IAAI,CAACC,wBAAwB;QAC7B,IAAI,CAACC,uBAAuB,GAAG,IAAI,CAAChB,QAAQ,CAACW,2BAA2B,CAACC,CAAAA;YACvE,IAAIA,KAAKK,IAAI,OAAO,IAAI;gBACtB,IAAI,CAACjB,QAAQ,CAACK,MAAM,CAClB;oBACElB,WACG+B,eAAe,GACfC,OAAO,CAACC,CAAAA;wBACPA,KAAKC,MAAM;oBACb;gBACJ,GACA,kCAAkC;gBAClC;oBAAEC,KAAK;gBAAW;YAEtB;QACF;IACF;IAEAP,2BAA2B;YACzB,+BAAA;SAAA,gCAAA,CAAA,QAAA,IAAI,EAACC,uBAAuB,cAA5B,oDAAA,mCAAA;QACA,IAAI,CAACA,uBAAuB,GAAGd;IACjC;IAEAqB,cAAcC,UAAmB,EAAE;QACjC,IAAI,CAACxB,QAAQ,CAACyB,WAAW,CAAC,CAACD;IAC7B;IAEAE,UAAU;YAGR,6BAAA;QAFA,IAAI,CAACjB,0BAA0B;QAC/B,IAAI,CAACM,wBAAwB;SAC7B,8BAAA,CAAA,QAAA,IAAI,EAACY,qBAAqB,cAA1B,kDAAA,iCAAA;QACA,IAAI,CAACA,qBAAqB,GAAGzB;IAC/B;IAnEA0B,YAAYC,MAAqB,CAAE;QAzBnC,uBAAQ7B,YAAR,KAAA;QACA,uBAAQU,0BAAR,KAAA;QACA,uBAAQM,2BAAR,KAAA;QACA,uBAAQW,yBAAR,KAAA;QAuBE,IAAI,CAAC3B,QAAQ,GAAG6B;QAEhB,IAAI,CAACF,qBAAqB,GAAG,IAAI,CAAC3B,QAAQ,CAAC8B,eAAe,CACxDrC,mBACA,IAAI,CAACE,cAAc,CAACoC,IAAI,CAAC,IAAI,GAC7BxC;IAEJ;AA4DF"}
1
+ {"version":3,"sources":["BasicFunctionality.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport {\n $createTextNode,\n $getLeafNodes,\n $getNodeByKey,\n $getRoot,\n $getSelection,\n $insertNodes,\n $isRangeSelection,\n $normalizeSelection__EXPERIMENTAL,\n $setSelection,\n COMMAND_PRIORITY_CRITICAL,\n INSERT_PARAGRAPH_COMMAND,\n KEY_ENTER_COMMAND,\n PASTE_COMMAND,\n mergeRegister,\n} from '@fluentui-copilot/text-editor';\nimport { $createSentinelNode, $isSentinelNode, SENTINEL_VALUE, SentinelNode } from './SentinelNode';\n\nexport interface IBasicFunctionalityBase {\n insertDefaultValue: (defaultValue: string) => void;\n setIsDisabled: (isDisabled: boolean) => void;\n activateContentCallbacks(onContentChange?: (value: string) => void, onCountChanged?: (count: number) => void): void;\n deactivateContentCallbacks(): void;\n activateTrimWhitespace(): void;\n deactivateTrimWhitespace(): void;\n activatePasteCallback(onPaste: (event: ClipboardEvent) => void): void;\n deactivatePasteCallback(): void;\n cleanup(): void;\n}\n\nexport class BasicFunctionalityBase implements IBasicFunctionalityBase {\n private __editor: LexicalEditor;\n private __contentChangeCleanup?: () => void;\n private __trimWhitespaceCleanup?: () => void;\n private __baseHandlersCleanup?: () => void;\n private __pasteHandlerCleanup?: () => void;\n\n private __enterHandler(event: KeyboardEvent) {\n const selection = $getSelection();\n if (!$isRangeSelection(selection)) {\n return false;\n }\n\n if (event === null) {\n return false;\n }\n\n event.preventDefault();\n\n if (event.shiftKey) {\n return this.__editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, undefined);\n }\n\n // Mark event handled to override default behavior\n return true;\n }\n\n constructor(editor: LexicalEditor) {\n this.__editor = editor;\n\n this.__baseHandlersCleanup = mergeRegister(\n this.__editor.registerCommand(KEY_ENTER_COMMAND, this.__enterHandler.bind(this), COMMAND_PRIORITY_CRITICAL),\n\n // Add a sentinel node at the end of the input when there is content.\n // This sentinel node fixes a number of issues.\n // In Safari, Lexical's behaviour of adding <br /> tags to the end of the input when it ends\n // in a decorator node causes cursor location issues: https://github.com/facebook/lexical/issues/4487\n // Otherwise, when a decorator node is the last node in the input, the cursor can't move past it.\n // Adding an invisible text node that doesn't contribute to the content and can't be selected to the end of the input\n // mitigates these issues.\n this.__editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n const leaves = $getLeafNodes($getRoot());\n if (leaves.length === 0) {\n return;\n }\n\n const lastNode = leaves[leaves.length - 1];\n const lastNodeKey = lastNode.getKey();\n\n // If the last node isn't a sentinel, add one\n if (!$isSentinelNode(lastNode)) {\n this.__editor.update(\n () => {\n // We find the node by its key again in case the node was removed before this update runs\n $getNodeByKey(lastNodeKey)?.insertAfter($createSentinelNode());\n },\n { discrete: true },\n );\n return;\n }\n\n // If the sentinel node is not selected, we're done\n const previous = lastNode.getPreviousSibling();\n if (!previous || !lastNode.isSelected()) {\n return;\n }\n\n const selection = $getSelection();\n if (!$isRangeSelection(selection)) {\n return;\n }\n\n // If the cursor is inside the sentinel node, move it out (next to the beginning)\n // We allow selection on the boundary of the sentinel in case the adjacent node is a decorator node\n // where selection is ill-defined.\n if (selection.isCollapsed() && selection.anchor.offset > 0) {\n this.__editor.update(\n () => {\n $getNodeByKey(lastNodeKey)?.selectStart();\n },\n { discrete: true },\n );\n return;\n }\n\n // If the selection is a range which includes the sentinel, modify the range to exclude it\n if (!selection.isCollapsed()) {\n let selectionChanged = false;\n const newSelection = selection.clone();\n\n if (newSelection.anchor.getNode() === lastNode && newSelection.anchor.offset > 0) {\n newSelection.anchor.set(lastNodeKey, 0, 'text');\n selectionChanged = true;\n }\n if (newSelection.focus.getNode() === lastNode && newSelection.focus.offset > 0) {\n newSelection.focus.set(lastNodeKey, 0, 'text');\n selectionChanged = true;\n }\n\n if (selectionChanged) {\n this.__editor.update(\n () => {\n if ($getNodeByKey(lastNodeKey) !== null) {\n $setSelection($normalizeSelection__EXPERIMENTAL(newSelection));\n }\n },\n { discrete: true },\n );\n }\n }\n });\n }),\n this.__editor.registerNodeTransform(SentinelNode, node => {\n if (!node.getPreviousSibling() || node.getNextSibling()) {\n node.remove();\n return;\n }\n }),\n );\n }\n\n insertDefaultValue(defaultValue: string) {\n if (defaultValue) {\n this.__editor.update(() => {\n $insertNodes([$createTextNode(defaultValue)]);\n });\n }\n }\n\n activateContentCallbacks(\n onContentChange?: ((value: string) => void) | undefined,\n onCountChanged?: ((count: number) => void) | undefined,\n ) {\n this.deactivateContentCallbacks();\n this.__contentChangeCleanup = this.__editor.registerTextContentListener(text => {\n // Remove the sentinel node\n const processed = text.replace(SENTINEL_VALUE, '');\n onContentChange?.(processed);\n onCountChanged?.(processed.length);\n });\n }\n\n deactivateContentCallbacks() {\n this.__contentChangeCleanup?.();\n this.__contentChangeCleanup = undefined;\n }\n\n activatePasteCallback(onPaste: (event: ClipboardEvent) => void) {\n this.__pasteHandlerCleanup = this.__editor.registerCommand(\n PASTE_COMMAND,\n (event: ClipboardEvent) => {\n onPaste(event);\n\n if (event.defaultPrevented) {\n return true;\n }\n\n return false;\n },\n COMMAND_PRIORITY_CRITICAL,\n );\n }\n\n deactivatePasteCallback() {\n this.__pasteHandlerCleanup?.();\n this.__pasteHandlerCleanup = undefined;\n }\n\n activateTrimWhitespace() {\n this.deactivateTrimWhitespace();\n this.__trimWhitespaceCleanup = this.__editor.registerTextContentListener(text => {\n if (text.trim() === '') {\n this.__editor.update(\n () => {\n $getRoot()\n .getAllTextNodes()\n .forEach(node => {\n node.remove();\n });\n },\n // Don't allow undoing this action\n { tag: 'historic' },\n );\n }\n });\n }\n\n deactivateTrimWhitespace() {\n this.__trimWhitespaceCleanup?.();\n this.__trimWhitespaceCleanup = undefined;\n }\n\n setIsDisabled(isDisabled: boolean) {\n this.__editor.setEditable(!isDisabled);\n }\n\n cleanup() {\n this.deactivateContentCallbacks();\n this.deactivateTrimWhitespace();\n this.deactivatePasteCallback();\n this.__baseHandlersCleanup?.();\n this.__baseHandlersCleanup = undefined;\n }\n}\n"],"names":["$createTextNode","$getLeafNodes","$getNodeByKey","$getRoot","$getSelection","$insertNodes","$isRangeSelection","$normalizeSelection__EXPERIMENTAL","$setSelection","COMMAND_PRIORITY_CRITICAL","INSERT_PARAGRAPH_COMMAND","KEY_ENTER_COMMAND","PASTE_COMMAND","mergeRegister","$createSentinelNode","$isSentinelNode","SENTINEL_VALUE","SentinelNode","BasicFunctionalityBase","__enterHandler","event","selection","preventDefault","shiftKey","__editor","dispatchCommand","undefined","insertDefaultValue","defaultValue","update","activateContentCallbacks","onContentChange","onCountChanged","deactivateContentCallbacks","__contentChangeCleanup","registerTextContentListener","text","processed","replace","length","activatePasteCallback","onPaste","__pasteHandlerCleanup","registerCommand","defaultPrevented","deactivatePasteCallback","activateTrimWhitespace","deactivateTrimWhitespace","__trimWhitespaceCleanup","trim","getAllTextNodes","forEach","node","remove","tag","setIsDisabled","isDisabled","setEditable","cleanup","__baseHandlersCleanup","constructor","editor","bind","registerUpdateListener","editorState","read","leaves","lastNode","lastNodeKey","getKey","insertAfter","discrete","previous","getPreviousSibling","isSelected","isCollapsed","anchor","offset","selectStart","selectionChanged","newSelection","clone","getNode","set","focus","registerNodeTransform","getNextSibling"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AACA,SACEA,eAAe,EACfC,aAAa,EACbC,aAAa,EACbC,QAAQ,EACRC,aAAa,EACbC,YAAY,EACZC,iBAAiB,EACjBC,iCAAiC,EACjCC,aAAa,EACbC,yBAAyB,EACzBC,wBAAwB,EACxBC,iBAAiB,EACjBC,aAAa,EACbC,aAAa,QACR,gCAAgC;AACvC,SAASC,mBAAmB,EAAEC,eAAe,EAAEC,cAAc,EAAEC,YAAY,QAAQ,iBAAiB;AAcpG,OAAO,MAAMC;IAOHC,eAAeC,KAAoB,EAAE;QAC3C,MAAMC,YAAYjB;QAClB,IAAI,CAACE,kBAAkBe,YAAY;YACjC,OAAO;QACT;QAEA,IAAID,UAAU,MAAM;YAClB,OAAO;QACT;QAEAA,MAAME,cAAc;QAEpB,IAAIF,MAAMG,QAAQ,EAAE;YAClB,OAAO,IAAI,CAACC,QAAQ,CAACC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mBAAmB;oBACrB;oBAEA,IAAIA,kBAAkB;wBACpB,IAAI,CAACvD,QAAQ,CAACK,MAAM,CAClB;4BACE,IAAI3B,cAAckE,iBAAiB,MAAM;gCACvC5D,cAAcD,kCAAkCyE;4BAClD;wBACF,GACA;4BAAET,UAAU;wBAAK;oBAErB;gBACF;YACF;QACF,IACA,IAAI,CAAC/C,QAAQ,CAAC6D,qBAAqB,CAACpE,cAAcmC,CAAAA;YAChD,IAAI,CAACA,KAAKqB,kBAAkB,MAAMrB,KAAKkC,cAAc,IAAI;gBACvDlC,KAAKC,MAAM;gBACX;YACF;QACF;IAEJ;AAoFF"}
@@ -0,0 +1,25 @@
1
+ import { TextNode } from '@fluentui-copilot/text-editor';
2
+ export const SENTINEL_VALUE = '\u200b\u200c';
3
+ export class SentinelNode extends TextNode {
4
+ static getType() {
5
+ return 'sentinel';
6
+ }
7
+ static clone(node) {
8
+ return new SentinelNode(node.__key);
9
+ }
10
+ isToken() {
11
+ return true;
12
+ }
13
+ constructor(key) {
14
+ // 2 zero width characters will not be visible in the editor.
15
+ // These also happen to be markers for CIQ to ignore the following content.
16
+ super(SENTINEL_VALUE, key);
17
+ }
18
+ }
19
+ export function $createSentinelNode(key) {
20
+ return new SentinelNode(key);
21
+ }
22
+ export function $isSentinelNode(node) {
23
+ return node instanceof SentinelNode;
24
+ }
25
+ //# sourceMappingURL=SentinelNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SentinelNode.ts"],"sourcesContent":["import type { LexicalNode, NodeKey } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\n\nexport const SENTINEL_VALUE = '\\u200b\\u200c';\n\nexport class SentinelNode extends TextNode {\n constructor(key?: NodeKey) {\n // 2 zero width characters will not be visible in the editor.\n // These also happen to be markers for CIQ to ignore the following content.\n super(SENTINEL_VALUE, key);\n }\n\n static getType() {\n return 'sentinel';\n }\n static clone(node: SentinelNode) {\n return new SentinelNode(node.__key);\n }\n\n isToken() {\n return true;\n }\n}\n\nexport function $createSentinelNode(key?: NodeKey) {\n return new SentinelNode(key);\n}\n\nexport function $isSentinelNode(node: LexicalNode | null): node is SentinelNode {\n return node instanceof SentinelNode;\n}\n"],"names":["TextNode","SENTINEL_VALUE","SentinelNode","getType","clone","node","__key","isToken","constructor","key","$createSentinelNode","$isSentinelNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,QAAQ,QAAQ,gCAAgC;AAEzD,OAAO,MAAMC,iBAAiB,eAAe;AAE7C,OAAO,MAAMC,qBAAqBF;IAOhC,OAAOG,UAAU;QACf,OAAO;IACT;IACA,OAAOC,MAAMC,IAAkB,EAAE;QAC/B,OAAO,IAAIH,aAAaG,KAAKC,KAAK;IACpC;IAEAC,UAAU;QACR,OAAO;IACT;IAfAC,YAAYC,GAAa,CAAE;QACzB,6DAA6D;QAC7D,2EAA2E;QAC3E,KAAK,CAACR,gBAAgBQ;IACxB;AAYF;AAEA,OAAO,SAASC,oBAAoBD,GAAa;IAC/C,OAAO,IAAIP,aAAaO;AAC1B;AAEA,OAAO,SAASE,gBAAgBN,IAAwB;IACtD,OAAOA,gBAAgBH;AACzB"}
@@ -1,2 +1,3 @@
1
1
  export * from './BasicFunctionality.base';
2
+ export * from './SentinelNode';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './BasicFunctionality.base';\n"],"names":[],"mappings":"AAAA,cAAc,4BAA4B"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './BasicFunctionality.base';\nexport * from './SentinelNode';\n"],"names":[],"rangeMappings":";","mappings":"AAAA,cAAc,4BAA4B;AAC1C,cAAc,iBAAiB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["ChatInputEntityPlugin.base.ts"],"sourcesContent":["import type { LexicalEditor, LexicalNode, NodeKey, Klass } from '@fluentui-copilot/text-editor';\nimport {\n $createParagraphNode,\n $createTextNode,\n $getNodeByKey,\n $getSelection,\n $insertNodes,\n $isDecoratorNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $nodesOfType,\n $wrapNodeInElement,\n COMMAND_PRIORITY_CRITICAL,\n DELETE_CHARACTER_COMMAND,\n mergeRegister,\n} from '@fluentui-copilot/text-editor';\nimport type { ChatInputEntityData, IChatInputEntityPluginBase, IEntityNode } from './ChatInputEntityPlugin.types';\n\nexport class ChatInputEntityPluginBase<\n ExtraDataType,\n NodePropsType,\n NodeType extends IEntityNode<ExtraDataType, NodePropsType>,\n> implements IChatInputEntityPluginBase<ExtraDataType, NodePropsType>\n{\n private __nodeClass: Klass<NodeType>;\n private __editor: LexicalEditor;\n private __id: string;\n\n private __deleteDirection: 'forward' | 'backward' | null = null;\n private __$createNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => NodeType;\n\n private _cleanup: () => void;\n\n cleanup() {\n this._cleanup();\n }\n\n constructor(\n editor: LexicalEditor,\n id: string,\n nodeClass: Klass<NodeType>,\n $createNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => NodeType,\n $isChatInputEntityNode: (node: LexicalNode | null) => node is NodeType,\n onChatInputEntityAdded?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void,\n onChatInputEntityDeleted?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void,\n ) {\n this.__$createNode = $createNode;\n this.__editor = editor;\n this.__id = id;\n this.__nodeClass = nodeClass;\n\n this._cleanup = mergeRegister(\n // Keep track of delete direction so we know where to put the selection after adding back a space\n editor.registerCommand(\n DELETE_CHARACTER_COMMAND,\n isBackward => {\n this.__deleteDirection = isBackward ? 'backward' : 'forward';\n return false;\n },\n COMMAND_PRIORITY_CRITICAL,\n ),\n // Always maintain a space before, after, and between entities in order for selection to work properly\n editor.registerNodeTransform(this.__nodeClass, node => {\n const nextSibling = node.getNextSibling();\n if (!nextSibling || $isDecoratorNode(nextSibling)) {\n const selection = $getSelection();\n\n // If selection is between the two nodes, that means the user is trying to delete the space\n // If they deleted to the left, we should move the cursor to the end of the entity\n // If they delete to the right, we should move the cursor to the end of the newly added space\n // This mimics changing the delete into a cursor move action\n const shouldMoveSelection =\n selection &&\n $isRangeSelection(selection) &&\n selection.isCollapsed() &&\n selection.anchor.offset === node.getIndexWithinParent() + 1;\n const text = $createTextNode(' ');\n node.insertAfter(text);\n if (shouldMoveSelection) {\n if (this.__deleteDirection === 'forward') {\n text.selectEnd();\n } else {\n node.selectEnd();\n }\n }\n }\n\n // In the case the entity is the first node, we need a space before it.\n if (!node.getPreviousSibling()) {\n const text = $createTextNode(' ');\n node.insertBefore(text);\n }\n }),\n onChatInputEntityAdded || onChatInputEntityDeleted\n ? editor.registerMutationListener(this.__nodeClass, (nodes, payload) => {\n for (const [nodeKey, mutation] of nodes) {\n if (onChatInputEntityDeleted && mutation === 'destroyed') {\n payload.prevEditorState.read(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isChatInputEntityNode(node) && node.__pluginId === id) {\n onChatInputEntityDeleted(node.getEntityData());\n }\n });\n } else if (onChatInputEntityAdded && mutation === 'created') {\n editor.getEditorState().read(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isChatInputEntityNode(node) && node.__pluginId === id) {\n onChatInputEntityAdded(node.getEntityData());\n }\n });\n }\n }\n })\n : noop,\n );\n }\n insertChatInputEntity(props: ChatInputEntityData<ExtraDataType, NodePropsType>): string | undefined {\n let key: string | undefined = undefined;\n this.__editor.update(() => {\n const { text, data, entityProps } = props;\n\n const entityNode = this.__$createNode(this.__id, text, data, entityProps);\n\n $insertNodes([entityNode]);\n entityNode.selectEnd();\n if ($isRootOrShadowRoot(entityNode.getParentOrThrow())) {\n $wrapNodeInElement(entityNode, $createParagraphNode).selectEnd();\n }\n\n key = entityNode.getKey();\n });\n\n return key;\n }\n removeChatInputEntity(\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n ) {\n this.__editor.update(() => {\n if (typeof keyOrPredicate === 'function') {\n $nodesOfType(this.__nodeClass)\n .filter((node, i) => node.__pluginId === this.__id && keyOrPredicate(node.getEntityData(), i))\n .forEach(node => node.remove());\n } else {\n $getNodeByKey(keyOrPredicate)?.remove();\n }\n });\n }\n updateChatInputEntityProps(\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n props:\n | ChatInputEntityData<ExtraDataType, NodePropsType>\n | ((\n oldProps: ChatInputEntityData<ExtraDataType, NodePropsType>,\n ) => ChatInputEntityData<ExtraDataType, NodePropsType>),\n ) {\n const updateNode = (node: NodeType) => {\n const newProps = typeof props === 'function' ? props(node.getEntityData()) : props;\n node.updateEntityData(newProps);\n };\n\n this.__editor.update(\n () => {\n if (typeof keyOrPredicate === 'function') {\n $nodesOfType(this.__nodeClass)\n .filter((node, i) => node.__pluginId === this.__id && keyOrPredicate(node.getEntityData(), i))\n .forEach(updateNode);\n } else {\n const node = $getNodeByKey<NodeType>(keyOrPredicate);\n if (node) {\n updateNode(node);\n }\n }\n },\n { tag: 'historic' },\n );\n }\n\n getActiveEntities(): ChatInputEntityData<ExtraDataType, NodePropsType>[] {\n return this.__editor.getEditorState().read(() =>\n $nodesOfType(this.__nodeClass)\n .filter(node => node.__pluginId === this.__id)\n .map(node => node.getEntityData()),\n );\n }\n}\n\nfunction noop() {\n return;\n}\n"],"names":["$createParagraphNode","$createTextNode","$getNodeByKey","$getSelection","$insertNodes","$isDecoratorNode","$isRangeSelection","$isRootOrShadowRoot","$nodesOfType","$wrapNodeInElement","COMMAND_PRIORITY_CRITICAL","DELETE_CHARACTER_COMMAND","mergeRegister","ChatInputEntityPluginBase","cleanup","_cleanup","insertChatInputEntity","props","key","undefined","__editor","update","text","data","entityProps","entityNode","__$createNode","__id","selectEnd","getParentOrThrow","getKey","removeChatInputEntity","keyOrPredicate","__nodeClass","filter","node","i","__pluginId","getEntityData","forEach","remove","updateChatInputEntityProps","updateNode","newProps","updateEntityData","tag","getActiveEntities","getEditorState","read","map","constructor","editor","id","nodeClass","$createNode","$isChatInputEntityNode","onChatInputEntityAdded","onChatInputEntityDeleted","__deleteDirection","registerCommand","isBackward","registerNodeTransform","nextSibling","getNextSibling","selection","shouldMoveSelection","isCollapsed","anchor","offset","getIndexWithinParent","insertAfter","getPreviousSibling","insertBefore","registerMutationListener","nodes","payload","nodeKey","mutation","prevEditorState","noop"],"mappings":";AACA,SACEA,oBAAoB,EACpBC,eAAe,EACfC,aAAa,EACbC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,YAAY,EACZC,kBAAkB,EAClBC,yBAAyB,EACzBC,wBAAwB,EACxBC,aAAa,QACR,gCAAgC;AAGvC,OAAO,MAAMC;IAqBXC,UAAU;QACR,IAAI,CAACC,QAAQ;IACf;IAuFAC,sBAAsBC,KAAwD,EAAsB;QAClG,IAAIC,MAA0BC;QAC9B,IAAI,CAACC,QAAQ,CAACC,MAAM,CAAC;YACnB,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGP;YAEpC,MAAMQ,aAAa,IAAI,CAACC,aAAa,CAAC,IAAI,CAACC,IAAI,EAAEL,MAAMC,MAAMC;YAE7DpB,aAAa;gBAACqB;aAAW;YACzBA,WAAWG,SAAS;YACpB,IAAIrB,oBAAoBkB,WAAWI,gBAAgB,KAAK;gBACtDpB,mBAAmBgB,YAAYzB,sBAAsB4B,SAAS;YAChE;YAEAV,MAAMO,WAAWK,MAAM;QACzB;QAEA,OAAOZ;IACT;IACAa,sBACEC,cAA4G,EAC5G;QACA,IAAI,CAACZ,QAAQ,CAACC,MAAM,CAAC;YACnB,IAAI,OAAOW,mBAAmB,YAAY;gBACxCxB,aAAa,IAAI,CAACyB,WAAW,EAC1BC,MAAM,CAAC,CAACC,MAAMC,IAAMD,KAAKE,UAAU,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oBACxDF,QAAQG,eAAe,CAAC9B,IAAI,CAAC;wBAC3B,MAAMb,OAAOjC,cAAc0E;wBAC3B,IAAIrB,uBAAuBpB,SAASA,KAAKE,UAAU,KAAKe,IAAI;4BAC1DK,yBAAyBtB,KAAKG,aAAa;wBAC7C;oBACF;gBACF,OAAO,IAAIkB,0BAA0BqB,aAAa,WAAW;oBAC3D1B,OAAOJ,cAAc,GAAGC,IAAI,CAAC;wBAC3B,MAAMb,OAAOjC,cAAc0E;wBAC3B,IAAIrB,uBAAuBpB,SAASA,KAAKE,UAAU,KAAKe,IAAI;4BAC1DI,uBAAuBrB,KAAKG,aAAa;wBAC3C;oBACF;gBACF;YACF;QACF,KACAyC;IAER;AAqEF;AAEA,SAASA;IACP;AACF"}
1
+ {"version":3,"sources":["ChatInputEntityPlugin.base.ts"],"sourcesContent":["import type { LexicalEditor, LexicalNode, NodeKey, Klass } from '@fluentui-copilot/text-editor';\nimport {\n $createParagraphNode,\n $createTextNode,\n $getNodeByKey,\n $getSelection,\n $insertNodes,\n $isDecoratorNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $nodesOfType,\n $wrapNodeInElement,\n COMMAND_PRIORITY_CRITICAL,\n DELETE_CHARACTER_COMMAND,\n mergeRegister,\n} from '@fluentui-copilot/text-editor';\nimport type { ChatInputEntityData, IChatInputEntityPluginBase, IEntityNode } from './ChatInputEntityPlugin.types';\n\nexport class ChatInputEntityPluginBase<\n ExtraDataType,\n NodePropsType,\n NodeType extends IEntityNode<ExtraDataType, NodePropsType>,\n> implements IChatInputEntityPluginBase<ExtraDataType, NodePropsType>\n{\n private __nodeClass: Klass<NodeType>;\n private __editor: LexicalEditor;\n private __id: string;\n\n private __deleteDirection: 'forward' | 'backward' | null = null;\n private __$createNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => NodeType;\n\n private _cleanup: () => void;\n\n cleanup() {\n this._cleanup();\n }\n\n constructor(\n editor: LexicalEditor,\n id: string,\n nodeClass: Klass<NodeType>,\n $createNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => NodeType,\n $isChatInputEntityNode: (node: LexicalNode | null) => node is NodeType,\n onChatInputEntityAdded?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void,\n onChatInputEntityDeleted?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void,\n ) {\n this.__$createNode = $createNode;\n this.__editor = editor;\n this.__id = id;\n this.__nodeClass = nodeClass;\n\n this._cleanup = mergeRegister(\n // Keep track of delete direction so we know where to put the selection after adding back a space\n editor.registerCommand(\n DELETE_CHARACTER_COMMAND,\n isBackward => {\n this.__deleteDirection = isBackward ? 'backward' : 'forward';\n return false;\n },\n COMMAND_PRIORITY_CRITICAL,\n ),\n // Always maintain a space before, after, and between entities in order for selection to work properly\n editor.registerNodeTransform(this.__nodeClass, node => {\n const nextSibling = node.getNextSibling();\n if (!nextSibling || $isDecoratorNode(nextSibling)) {\n const selection = $getSelection();\n\n // If selection is between the two nodes, that means the user is trying to delete the space\n // If they deleted to the left, we should move the cursor to the end of the entity\n // If they delete to the right, we should move the cursor to the end of the newly added space\n // This mimics changing the delete into a cursor move action\n const shouldMoveSelection =\n selection &&\n $isRangeSelection(selection) &&\n selection.isCollapsed() &&\n selection.anchor.offset === node.getIndexWithinParent() + 1;\n const text = $createTextNode(' ');\n node.insertAfter(text);\n if (shouldMoveSelection) {\n if (this.__deleteDirection === 'forward') {\n text.selectEnd();\n } else {\n node.selectEnd();\n }\n }\n }\n\n // In the case the entity is the first node, we need a space before it.\n if (!node.getPreviousSibling()) {\n const text = $createTextNode(' ');\n node.insertBefore(text);\n }\n }),\n onChatInputEntityAdded || onChatInputEntityDeleted\n ? editor.registerMutationListener(this.__nodeClass, (nodes, payload) => {\n for (const [nodeKey, mutation] of nodes) {\n if (onChatInputEntityDeleted && mutation === 'destroyed') {\n payload.prevEditorState.read(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isChatInputEntityNode(node) && node.__pluginId === id) {\n onChatInputEntityDeleted(node.getEntityData());\n }\n });\n } else if (onChatInputEntityAdded && mutation === 'created') {\n editor.getEditorState().read(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isChatInputEntityNode(node) && node.__pluginId === id) {\n onChatInputEntityAdded(node.getEntityData());\n }\n });\n }\n }\n })\n : noop,\n );\n }\n insertChatInputEntity(props: ChatInputEntityData<ExtraDataType, NodePropsType>): string | undefined {\n let key: string | undefined = undefined;\n this.__editor.update(() => {\n const { text, data, entityProps } = props;\n\n const entityNode = this.__$createNode(this.__id, text, data, entityProps);\n\n $insertNodes([entityNode]);\n entityNode.selectEnd();\n if ($isRootOrShadowRoot(entityNode.getParentOrThrow())) {\n $wrapNodeInElement(entityNode, $createParagraphNode).selectEnd();\n }\n\n key = entityNode.getKey();\n });\n\n return key;\n }\n removeChatInputEntity(\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n ) {\n this.__editor.update(() => {\n if (typeof keyOrPredicate === 'function') {\n $nodesOfType(this.__nodeClass)\n .filter((node, i) => node.__pluginId === this.__id && keyOrPredicate(node.getEntityData(), i))\n .forEach(node => node.remove());\n } else {\n $getNodeByKey(keyOrPredicate)?.remove();\n }\n });\n }\n updateChatInputEntityProps(\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n props:\n | ChatInputEntityData<ExtraDataType, NodePropsType>\n | ((\n oldProps: ChatInputEntityData<ExtraDataType, NodePropsType>,\n ) => ChatInputEntityData<ExtraDataType, NodePropsType>),\n ) {\n const updateNode = (node: NodeType) => {\n const newProps = typeof props === 'function' ? props(node.getEntityData()) : props;\n node.updateEntityData(newProps);\n };\n\n this.__editor.update(\n () => {\n if (typeof keyOrPredicate === 'function') {\n $nodesOfType(this.__nodeClass)\n .filter((node, i) => node.__pluginId === this.__id && keyOrPredicate(node.getEntityData(), i))\n .forEach(updateNode);\n } else {\n const node = $getNodeByKey<NodeType>(keyOrPredicate);\n if (node) {\n updateNode(node);\n }\n }\n },\n { tag: 'historic' },\n );\n }\n\n getActiveEntities(): ChatInputEntityData<ExtraDataType, NodePropsType>[] {\n return this.__editor.getEditorState().read(() =>\n $nodesOfType(this.__nodeClass)\n .filter(node => node.__pluginId === this.__id)\n .map(node => node.getEntityData()),\n );\n }\n}\n\nfunction noop() {\n return;\n}\n"],"names":["$createParagraphNode","$createTextNode","$getNodeByKey","$getSelection","$insertNodes","$isDecoratorNode","$isRangeSelection","$isRootOrShadowRoot","$nodesOfType","$wrapNodeInElement","COMMAND_PRIORITY_CRITICAL","DELETE_CHARACTER_COMMAND","mergeRegister","ChatInputEntityPluginBase","cleanup","_cleanup","insertChatInputEntity","props","key","undefined","__editor","update","text","data","entityProps","entityNode","__$createNode","__id","selectEnd","getParentOrThrow","getKey","removeChatInputEntity","keyOrPredicate","__nodeClass","filter","node","i","__pluginId","getEntityData","forEach","remove","updateChatInputEntityProps","updateNode","newProps","updateEntityData","tag","getActiveEntities","getEditorState","read","map","constructor","editor","id","nodeClass","$createNode","$isChatInputEntityNode","onChatInputEntityAdded","onChatInputEntityDeleted","__deleteDirection","registerCommand","isBackward","registerNodeTransform","nextSibling","getNextSibling","selection","shouldMoveSelection","isCollapsed","anchor","offset","getIndexWithinParent","insertAfter","getPreviousSibling","insertBefore","registerMutationListener","nodes","payload","nodeKey","mutation","prevEditorState","noop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AACA,SACEA,oBAAoB,EACpBC,eAAe,EACfC,aAAa,EACbC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,YAAY,EACZC,kBAAkB,EAClBC,yB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1 +1 @@
1
- {"version":3,"sources":["ChatInputEntityPlugin.types.ts"],"sourcesContent":["import type { LexicalNode } from '@fluentui-copilot/text-editor';\n\nexport type ChatInputEntityData<ExtraDataType, NodePropsType> = {\n // Represents the string content of the entity that will returned inside the ChatInput's text content\n text: string;\n // Props to pass to the component rendered by the node\n // By default, `text` will be used as the entity's text content.\n // If entityProps contains information for rendering children, that will take priority\n entityProps?: NodePropsType;\n // Optional extra data that can be associated with the entity\n data?: ExtraDataType;\n};\n\nexport type ChatInputEntityPluginProps<ExtraDataType, NodePropsType> = {\n // An identifier for an instance of the ChatInputEntityPlugin\n // Only entities created by this instance of the plugin will be handled by it\n id: string;\n onChatInputEntityAdded?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;\n onChatInputEntityDeleted?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;\n};\n\n/**\n * A lexical node representing an entity should conform to this interface\n */\nexport interface IEntityNode<ExtraDataType, NodePropsType> extends LexicalNode {\n getEntityData: () => ChatInputEntityData<ExtraDataType, NodePropsType>;\n updateEntityData: (data: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;\n __pluginId: string;\n}\n\nexport interface IChatInputEntityPluginBase<ExtraDataType, NodePropsType> {\n // Inserts a new entity and returns its key, to be used by removeChatInputEntity or updateChatInputEntityProps\n insertChatInputEntity: (props: ChatInputEntityData<ExtraDataType, NodePropsType>) => string | undefined;\n // Removes an entity by its key, or removes all entities that match a predicate function\n removeChatInputEntity: (\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n ) => void;\n // Updates an entity by its key, or removes all entities that match a predicate function\n updateChatInputEntityProps: (\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n props:\n | ChatInputEntityData<ExtraDataType, NodePropsType>\n | ((\n oldProps: ChatInputEntityData<ExtraDataType, NodePropsType>,\n ) => ChatInputEntityData<ExtraDataType, NodePropsType>),\n ) => void;\n getActiveEntities: () => ChatInputEntityData<ExtraDataType, NodePropsType>[];\n}\n"],"names":[],"mappings":"AAAA,WA+CC"}
1
+ {"version":3,"sources":["ChatInputEntityPlugin.types.ts"],"sourcesContent":["import type { LexicalNode } from '@fluentui-copilot/text-editor';\n\nexport type ChatInputEntityData<ExtraDataType, NodePropsType> = {\n // Represents the string content of the entity that will returned inside the ChatInput's text content\n text: string;\n // Props to pass to the component rendered by the node\n // By default, `text` will be used as the entity's text content.\n // If entityProps contains information for rendering children, that will take priority\n entityProps?: NodePropsType;\n // Optional extra data that can be associated with the entity\n data?: ExtraDataType;\n};\n\nexport type ChatInputEntityPluginProps<ExtraDataType, NodePropsType> = {\n // An identifier for an instance of the ChatInputEntityPlugin\n // Only entities created by this instance of the plugin will be handled by it\n id: string;\n onChatInputEntityAdded?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;\n onChatInputEntityDeleted?: (entity: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;\n};\n\n/**\n * A lexical node representing an entity should conform to this interface\n */\nexport interface IEntityNode<ExtraDataType, NodePropsType> extends LexicalNode {\n getEntityData: () => ChatInputEntityData<ExtraDataType, NodePropsType>;\n updateEntityData: (data: ChatInputEntityData<ExtraDataType, NodePropsType>) => void;\n __pluginId: string;\n}\n\nexport interface IChatInputEntityPluginBase<ExtraDataType, NodePropsType> {\n // Inserts a new entity and returns its key, to be used by removeChatInputEntity or updateChatInputEntityProps\n insertChatInputEntity: (props: ChatInputEntityData<ExtraDataType, NodePropsType>) => string | undefined;\n // Removes an entity by its key, or removes all entities that match a predicate function\n removeChatInputEntity: (\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n ) => void;\n // Updates an entity by its key, or removes all entities that match a predicate function\n updateChatInputEntityProps: (\n keyOrPredicate: string | ((entity: ChatInputEntityData<ExtraDataType, NodePropsType>, i: number) => boolean),\n props:\n | ChatInputEntityData<ExtraDataType, NodePropsType>\n | ((\n oldProps: ChatInputEntityData<ExtraDataType, NodePropsType>,\n ) => ChatInputEntityData<ExtraDataType, NodePropsType>),\n ) => void;\n getActiveEntities: () => ChatInputEntityData<ExtraDataType, NodePropsType>[];\n}\n"],"names":[],"rangeMappings":"","mappings":"AA8BA,WAiBC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './ChatInputEntityPlugin.types';\nexport * from './ChatInputEntityPlugin.base';\n"],"names":[],"mappings":"AAAA,cAAc,gCAAgC;AAC9C,cAAc,+BAA+B"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './ChatInputEntityPlugin.types';\nexport * from './ChatInputEntityPlugin.base';\n"],"names":[],"rangeMappings":";","mappings":"AAAA,cAAc,gCAAgC;AAC9C,cAAc,+BAA+B"}
@@ -1,5 +1,6 @@
1
1
  import { _ as _define_property } from "@swc/helpers/_/_define_property";
2
- import { $createTextNode, $getNodeByKey, $getSelection, $setSelection, COMMAND_PRIORITY_LOW, KEY_TAB_COMMAND, mergeRegister } from '@fluentui-copilot/text-editor';
2
+ import { $createTextNode, $getNodeByKey, $getSelection, $isRangeSelection, $isTextNode, $setSelection, COMMAND_PRIORITY_LOW, KEY_TAB_COMMAND, mergeRegister } from '@fluentui-copilot/text-editor';
3
+ import { $isSentinelNode } from '../BasicFunctionality';
3
4
  export class GhostTextPluginBase {
4
5
  cleanup() {
5
6
  var _this___cleanup, _this;
@@ -34,12 +35,14 @@ export class GhostTextPluginBase {
34
35
  let ghostTextNodeKey = null;
35
36
  let lastText = undefined;
36
37
  let justRemovedGhostText = false;
38
+ let justAddedGhostText = false;
37
39
  function $clearGhostText() {
38
40
  const ghostTextNode = ghostTextNodeKey !== null ? $getNodeByKey(ghostTextNodeKey) : null;
39
41
  ghostTextNodeKey = null;
40
42
  lastText = undefined;
41
43
  if (ghostTextNode && ghostTextNode.isAttached()) {
42
44
  ghostTextNode.remove();
45
+ justRemovedGhostText = true;
43
46
  }
44
47
  }
45
48
  function handleGhostTextNodeTransform(node) {
@@ -58,7 +61,6 @@ export class GhostTextPluginBase {
58
61
  $clearGhostText();
59
62
  const selection = $getSelection();
60
63
  if (!text || !selection) {
61
- justRemovedGhostText = true;
62
64
  return;
63
65
  }
64
66
  const selectionCopy = selection.clone();
@@ -67,6 +69,8 @@ export class GhostTextPluginBase {
67
69
  lastText = text;
68
70
  selection.insertNodes([node]);
69
71
  $setSelection(selectionCopy);
72
+ justAddedGhostText = true;
73
+ justRemovedGhostText = false;
70
74
  }, {
71
75
  tag: 'historic'
72
76
  });
@@ -76,12 +80,50 @@ export class GhostTextPluginBase {
76
80
  editorState,
77
81
  prevEditorState
78
82
  } = props;
79
- // If this update was caused by deleting the previous ghost text, don't create a new one until a subsequent update
80
- if (justRemovedGhostText) {
83
+ // If this update was caused by adding or deleting ghost text, don't recheck the ghost text function until a subsequent update
84
+ if (justRemovedGhostText || justAddedGhostText) {
81
85
  justRemovedGhostText = false;
86
+ justAddedGhostText = false;
82
87
  return;
83
88
  }
84
89
  editorState.read(() => {
90
+ // We only update the ghost text if the user selection is inside the input
91
+ const selection = $getSelection();
92
+ if (!$getSelection()) {
93
+ return;
94
+ }
95
+ if ($isRangeSelection(selection) && selection.isCollapsed()) {
96
+ var _selectedNode_getPreviousSibling;
97
+ var _selection_getNodes_at;
98
+ // All the `$isXNode` functions prefer `null` over `undefined`
99
+ const selectedNode = (_selection_getNodes_at = selection.getNodes().at(0)) !== null && _selection_getNodes_at !== void 0 ? _selection_getNodes_at : null;
100
+ const previousNodeKey = selectedNode === null || selectedNode === void 0 ? void 0 : (_selectedNode_getPreviousSibling = selectedNode.getPreviousSibling()) === null || _selectedNode_getPreviousSibling === void 0 ? void 0 : _selectedNode_getPreviousSibling.getKey();
101
+ const previousNodeIsGhostText = previousNodeKey === ghostTextNodeKey;
102
+ // If the ghost text is active and we're navigating past it, act as if the ghost text is not there and move 1 extra character
103
+ if (previousNodeIsGhostText && !$isSentinelNode(selectedNode) && $isTextNode(selectedNode) && selection.anchor.offset === 0) {
104
+ editor.update(() => {
105
+ const selection = $getSelection();
106
+ if ($isRangeSelection(selection)) {
107
+ selection.modify('move', false, 'character');
108
+ }
109
+ $clearGhostText();
110
+ }, {
111
+ tag: 'historic'
112
+ });
113
+ // Defer checking the ghost text until after this update has finished
114
+ return;
115
+ }
116
+ // If the ghost text is the last node before the sentinel, we shouldn't let selection get past it
117
+ if (previousNodeIsGhostText && $isSentinelNode(selectedNode)) {
118
+ editor.update(() => {
119
+ var _$getNodeByKey_getPreviousSibling, _$getNodeByKey;
120
+ (_$getNodeByKey = $getNodeByKey(previousNodeKey)) === null || _$getNodeByKey === void 0 ? void 0 : (_$getNodeByKey_getPreviousSibling = _$getNodeByKey.getPreviousSibling()) === null || _$getNodeByKey_getPreviousSibling === void 0 ? void 0 : _$getNodeByKey_getPreviousSibling.selectEnd();
121
+ }, {
122
+ tag: 'historic'
123
+ });
124
+ return;
125
+ }
126
+ }
85
127
  const promise = this.__$getGhostText(editor, editorState, prevEditorState);
86
128
  promise.then(handleGhostTextResponse).catch(e => console.error(e));
87
129
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["GhostText.base.ts"],"sourcesContent":["import type { EditorState, Klass, LexicalEditor, LexicalNode, UpdateListener } from '@fluentui-copilot/text-editor';\nimport {\n $createTextNode,\n $getNodeByKey,\n $getSelection,\n $setSelection,\n COMMAND_PRIORITY_LOW,\n KEY_TAB_COMMAND,\n mergeRegister,\n} from '@fluentui-copilot/text-editor';\n\nexport type GetGhostTextFunction = (\n editor: LexicalEditor,\n editorState: EditorState,\n prevEditorState: EditorState,\n) => Promise<string | undefined>;\n\nexport interface IGhostTextNode<ComponentPropsType> extends LexicalNode {\n __content: string;\n __id: string;\n __allowCommitting?: boolean;\n __componentProps?: ComponentPropsType;\n __exposeText?: boolean;\n}\n\nexport class GhostTextPluginBase<ComponentPropsType> {\n private __id: string;\n private __$getGhostText: GetGhostTextFunction;\n private __componentProps?: ComponentPropsType;\n private __exposeText?: boolean;\n private __allowCompletion?: boolean;\n\n private __cleanup?: () => void;\n\n cleanup() {\n this.__cleanup?.();\n }\n\n constructor(\n editor: LexicalEditor,\n id: string,\n $getGhostText: GetGhostTextFunction,\n nodeClass: Klass<IGhostTextNode<ComponentPropsType>>,\n createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>,\n componentProps?: ComponentPropsType,\n // Whether or not the ghost text should count as text inside the input for submitting and character count\n exposeText?: boolean,\n allowCompletion?: boolean,\n ) {\n this.__id = id;\n this.__$getGhostText = $getGhostText;\n this.__componentProps = componentProps;\n this.__exposeText = exposeText;\n this.__allowCompletion = allowCompletion;\n\n let ghostTextNodeKey: string | null = null;\n let lastText: string | undefined = undefined;\n let justRemovedGhostText = false;\n\n function $clearGhostText() {\n const ghostTextNode = ghostTextNodeKey !== null ? $getNodeByKey(ghostTextNodeKey) : null;\n ghostTextNodeKey = null;\n lastText = undefined;\n if (ghostTextNode && ghostTextNode.isAttached()) {\n ghostTextNode.remove();\n }\n }\n function handleGhostTextNodeTransform(node: IGhostTextNode<ComponentPropsType>) {\n const key = node.getKey();\n\n if (node.__id === id && key !== ghostTextNodeKey) {\n // Only one ghost text\n node.remove();\n $clearGhostText();\n }\n }\n\n const handleGhostTextResponse = (text?: string) => {\n if (text === lastText) {\n return;\n }\n\n editor.update(\n () => {\n $clearGhostText();\n\n const selection = $getSelection();\n if (!text || !selection) {\n justRemovedGhostText = true;\n return;\n }\n\n const selectionCopy = selection.clone();\n\n const node = createNode(this.__id, text, this.__exposeText, this.__componentProps);\n ghostTextNodeKey = node.getKey();\n lastText = text;\n\n selection.insertNodes([node]);\n $setSelection(selectionCopy);\n },\n { tag: 'historic' },\n );\n };\n\n const handleUpdate: UpdateListener = props => {\n const { editorState, prevEditorState } = props;\n // If this update was caused by deleting the previous ghost text, don't create a new one until a subsequent update\n if (justRemovedGhostText) {\n justRemovedGhostText = false;\n return;\n }\n editorState.read(() => {\n const promise = this.__$getGhostText(editor, editorState, prevEditorState);\n promise.then(handleGhostTextResponse).catch(e => console.error(e));\n });\n };\n\n function unmountGhostText() {\n if (ghostTextNodeKey) {\n editor.update(\n () => {\n $clearGhostText();\n },\n { tag: 'historic' },\n );\n }\n }\n\n function $handleTabCommand(e: KeyboardEvent) {\n if (ghostTextNodeKey === null || lastText === null) {\n return false;\n }\n\n const ghostTextNode = $getNodeByKey(ghostTextNodeKey);\n if (!ghostTextNode) {\n return false;\n }\n\n e.preventDefault();\n\n const textNode = $createTextNode(lastText);\n ghostTextNode.replace(textNode);\n textNode.selectEnd();\n $clearGhostText();\n return true;\n }\n\n this.__cleanup = mergeRegister(\n editor.registerNodeTransform(nodeClass, handleGhostTextNodeTransform),\n editor.registerUpdateListener(handleUpdate),\n this.__allowCompletion ? editor.registerCommand(KEY_TAB_COMMAND, $handleTabCommand, COMMAND_PRIORITY_LOW) : noop,\n unmountGhostText,\n );\n }\n\n setExposeText(exposeText?: boolean) {\n this.__exposeText = exposeText;\n }\n\n setComponentProps(componentProps?: ComponentPropsType) {\n this.__componentProps = componentProps;\n }\n\n setGetGhostText($getGhostText: GetGhostTextFunction) {\n this.__$getGhostText = $getGhostText;\n }\n\n setAllowCompletion(allowCompletion?: boolean) {\n this.__allowCompletion = allowCompletion;\n }\n}\nfunction noop(): void {\n return;\n}\n"],"names":["$createTextNode","$getNodeByKey","$getSelection","$setSelection","COMMAND_PRIORITY_LOW","KEY_TAB_COMMAND","mergeRegister","GhostTextPluginBase","cleanup","__cleanup","setExposeText","exposeText","__exposeText","setComponentProps","componentProps","__componentProps","setGetGhostText","$getGhostText","__$getGhostText","setAllowCompletion","allowCompletion","__allowCompletion","constructor","editor","id","nodeClass","createNode","__id","ghostTextNodeKey","lastText","undefined","justRemovedGhostText","$clearGhostText","ghostTextNode","isAttached","remove","handleGhostTextNodeTransform","node","key","getKey","handleGhostTextResponse","text","update","selection","selectionCopy","clone","insertNodes","tag","handleUpdate","props","editorState","prevEditorState","read","promise","then","catch","e","console","error","unmountGhostText","$handleTabCommand","preventDefault","textNode","replace","selectEnd","registerNodeTransform","registerUpdateListener","registerCommand","noop"],"mappings":";AACA,SACEA,eAAe,EACfC,aAAa,EACbC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,eAAe,EACfC,aAAa,QACR,gCAAgC;AAgBvC,OAAO,MAAMC;IASXC,UAAU;YACR,iBAAA;SAAA,kBAAA,CAAA,QAAA,IAAI,EAACC,SAAS,cAAd,sCAAA,qBAAA;IACF;IA6HAC,cAAcC,UAAoB,EAAE;QAClC,IAAI,CAACC,YAAY,GAAGD;IACtB;IAEAE,kBAAkBC,cAAmC,EAAE;QACrD,IAAI,CAACC,gBAAgB,GAAGD;IAC1B;IAEAE,gBAAgBC,aAAmC,EAAE;QACnD,IAAI,CAACC,eAAe,GAAGD;IACzB;IAEAE,mBAAmBC,eAAyB,EAAE;QAC5C,IAAI,CAACC,iBAAiB,GAAGD;IAC3B;IAzIAE,YACEC,MAAqB,EACrBC,EAAU,EACVP,aAAmC,EACnCQ,SAAoD,EACpDC,UAKuC,EACvCZ,cAAmC,EACnC,yGAAyG;IACzGH,UAAoB,EACpBS,eAAyB,CACzB;QA3BF,uBAAQO,QAAR,KAAA;QACA,uBAAQT,mBAAR,KAAA;QACA,uBAAQH,oBAAR,KAAA;QACA,uBAAQH,gBAAR,KAAA;QACA,uBAAQS,qBAAR,KAAA;QAEA,uBAAQZ,aAAR,KAAA;QAsBE,IAAI,CAACkB,IAAI,GAAGH;QACZ,IAAI,CAACN,eAAe,GAAGD;QACvB,IAAI,CAACF,gBAAgB,GAAGD;QACxB,IAAI,CAACF,YAAY,GAAGD;QACpB,IAAI,CAACU,iBAAiB,GAAGD;QAEzB,IAAIQ,mBAAkC;QACtC,IAAIC,WAA+BC;QACnC,IAAIC,uBAAuB;QAE3B,SAASC;YACP,MAAMC,gBAAgBL,qBAAqB,OAAO3B,cAAc2B,oBAAoB;YACpFA,mBAAmB;Y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I5B,qBAAqB,QAAQC,aAAa,MAAM;gBAClD,OAAO;YACT;YAEA,MAAMI,gBAAgBhC,cAAc2B;YACpC,IAAI,CAACK,eAAe;gBAClB,OAAO;YACT;YAEAuB,EAAEK,cAAc;YAEhB,MAAMC,WAAW9D,gBAAgB6B;YACjCI,cAAc8B,OAAO,CAACD;YACtBA,SAASE,SAAS;YAClBhC;YACA,OAAO;QACT;QAEA,IAAI,CAACvB,SAAS,GAAGH,cACfiB,OAAO0C,qBAAqB,CAACxC,WAAWW,+BACxCb,OAAO2C,sBAAsB,CAAClB,eAC9B,IAAI,CAAC3B,iBAAiB,GAAGE,OAAO4C,eAAe,CAAC9D,iBAAiBuD,mBAAmBxD,wBAAwBgE,MAC5GT;IAEJ;AAiBF;AACA,SAASS;IACP;AACF"}
1
+ {"version":3,"sources":["GhostText.base.ts"],"sourcesContent":["import type { EditorState, Klass, LexicalEditor, LexicalNode, UpdateListener } from '@fluentui-copilot/text-editor';\nimport {\n $createTextNode,\n $getNodeByKey,\n $getSelection,\n $isRangeSelection,\n $isTextNode,\n $setSelection,\n COMMAND_PRIORITY_LOW,\n KEY_TAB_COMMAND,\n mergeRegister,\n} from '@fluentui-copilot/text-editor';\nimport { $isSentinelNode } from '../BasicFunctionality';\n\nexport type GetGhostTextFunction = (\n editor: LexicalEditor,\n editorState: EditorState,\n prevEditorState: EditorState,\n) => Promise<string | undefined>;\n\nexport interface IGhostTextNode<ComponentPropsType> extends LexicalNode {\n __content: string;\n __id: string;\n __allowCommitting?: boolean;\n __componentProps?: ComponentPropsType;\n __exposeText?: boolean;\n}\n\nexport class GhostTextPluginBase<ComponentPropsType> {\n private __id: string;\n private __$getGhostText: GetGhostTextFunction;\n private __componentProps?: ComponentPropsType;\n private __exposeText?: boolean;\n private __allowCompletion?: boolean;\n\n private __cleanup?: () => void;\n\n cleanup() {\n this.__cleanup?.();\n }\n\n constructor(\n editor: LexicalEditor,\n id: string,\n $getGhostText: GetGhostTextFunction,\n nodeClass: Klass<IGhostTextNode<ComponentPropsType>>,\n createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>,\n componentProps?: ComponentPropsType,\n // Whether or not the ghost text should count as text inside the input for submitting and character count\n exposeText?: boolean,\n allowCompletion?: boolean,\n ) {\n this.__id = id;\n this.__$getGhostText = $getGhostText;\n this.__componentProps = componentProps;\n this.__exposeText = exposeText;\n this.__allowCompletion = allowCompletion;\n\n let ghostTextNodeKey: string | null = null;\n let lastText: string | undefined = undefined;\n let justRemovedGhostText = false;\n let justAddedGhostText = false;\n\n function $clearGhostText() {\n const ghostTextNode = ghostTextNodeKey !== null ? $getNodeByKey(ghostTextNodeKey) : null;\n ghostTextNodeKey = null;\n lastText = undefined;\n if (ghostTextNode && ghostTextNode.isAttached()) {\n ghostTextNode.remove();\n justRemovedGhostText = true;\n }\n }\n function handleGhostTextNodeTransform(node: IGhostTextNode<ComponentPropsType>) {\n const key = node.getKey();\n\n if (node.__id === id && key !== ghostTextNodeKey) {\n // Only one ghost text\n node.remove();\n $clearGhostText();\n }\n }\n\n const handleGhostTextResponse = (text?: string) => {\n if (text === lastText) {\n return;\n }\n\n editor.update(\n () => {\n $clearGhostText();\n\n const selection = $getSelection();\n if (!text || !selection) {\n return;\n }\n\n const selectionCopy = selection.clone();\n\n const node = createNode(this.__id, text, this.__exposeText, this.__componentProps);\n ghostTextNodeKey = node.getKey();\n lastText = text;\n\n selection.insertNodes([node]);\n $setSelection(selectionCopy);\n justAddedGhostText = true;\n justRemovedGhostText = false;\n },\n { tag: 'historic' },\n );\n };\n\n const handleUpdate: UpdateListener = props => {\n const { editorState, prevEditorState } = props;\n\n // If this update was caused by adding or deleting ghost text, don't recheck the ghost text function until a subsequent update\n if (justRemovedGhostText || justAddedGhostText) {\n justRemovedGhostText = false;\n justAddedGhostText = false;\n return;\n }\n\n editorState.read(() => {\n // We only update the ghost text if the user selection is inside the input\n const selection = $getSelection();\n if (!$getSelection()) {\n return;\n }\n\n if ($isRangeSelection(selection) && selection.isCollapsed()) {\n // All the `$isXNode` functions prefer `null` over `undefined`\n const selectedNode = selection.getNodes().at(0) ?? null;\n const previousNodeKey = selectedNode?.getPreviousSibling()?.getKey();\n const previousNodeIsGhostText = previousNodeKey === ghostTextNodeKey;\n // If the ghost text is active and we're navigating past it, act as if the ghost text is not there and move 1 extra character\n if (\n previousNodeIsGhostText &&\n !$isSentinelNode(selectedNode) &&\n $isTextNode(selectedNode) &&\n selection.anchor.offset === 0\n ) {\n editor.update(\n () => {\n const selection = $getSelection();\n if ($isRangeSelection(selection)) {\n selection.modify('move', false, 'character');\n }\n $clearGhostText();\n },\n { tag: 'historic' },\n );\n // Defer checking the ghost text until after this update has finished\n return;\n }\n\n // If the ghost text is the last node before the sentinel, we shouldn't let selection get past it\n if (previousNodeIsGhostText && $isSentinelNode(selectedNode)) {\n editor.update(\n () => {\n $getNodeByKey(previousNodeKey)?.getPreviousSibling()?.selectEnd();\n },\n { tag: 'historic' },\n );\n return;\n }\n }\n\n const promise = this.__$getGhostText(editor, editorState, prevEditorState);\n promise.then(handleGhostTextResponse).catch(e => console.error(e));\n });\n };\n\n function unmountGhostText() {\n if (ghostTextNodeKey) {\n editor.update(\n () => {\n $clearGhostText();\n },\n { tag: 'historic' },\n );\n }\n }\n\n function $handleTabCommand(e: KeyboardEvent) {\n if (ghostTextNodeKey === null || lastText === null) {\n return false;\n }\n\n const ghostTextNode = $getNodeByKey(ghostTextNodeKey);\n if (!ghostTextNode) {\n return false;\n }\n\n e.preventDefault();\n\n const textNode = $createTextNode(lastText);\n ghostTextNode.replace(textNode);\n textNode.selectEnd();\n $clearGhostText();\n return true;\n }\n\n this.__cleanup = mergeRegister(\n editor.registerNodeTransform(nodeClass, handleGhostTextNodeTransform),\n editor.registerUpdateListener(handleUpdate),\n this.__allowCompletion ? editor.registerCommand(KEY_TAB_COMMAND, $handleTabCommand, COMMAND_PRIORITY_LOW) : noop,\n unmountGhostText,\n );\n }\n\n setExposeText(exposeText?: boolean) {\n this.__exposeText = exposeText;\n }\n\n setComponentProps(componentProps?: ComponentPropsType) {\n this.__componentProps = componentProps;\n }\n\n setGetGhostText($getGhostText: GetGhostTextFunction) {\n this.__$getGhostText = $getGhostText;\n }\n\n setAllowCompletion(allowCompletion?: boolean) {\n this.__allowCompletion = allowCompletion;\n }\n}\nfunction noop(): void {\n return;\n}\n"],"names":["$createTextNode","$getNodeByKey","$getSelection","$isRangeSelection","$isTextNode","$setSelection","COMMAND_PRIORITY_LOW","KEY_TAB_COMMAND","mergeRegister","$isSentinelNode","GhostTextPluginBase","cleanup","__cleanup","setExposeText","exposeText","__exposeText","setComponentProps","componentProps","__componentProps","setGetGhostText","$getGhostText","__$getGhostText","setAllowCompletion","allowCompletion","__allowCompletion","constructor","editor","id","nodeClass","createNode","__id","ghostTextNodeKey","lastText","undefined","justRemovedGhostText","justAddedGhostText","$clearGhostText","ghostTextNode","isAttached","remove","handleGhostTextNodeTransform","node","key","getKey","handleGhostTextResponse","text","update","selection","selectionCopy","clone","insertNodes","tag","handleUpdate","props","editorState","prevEditorState","read","isCollapsed","selectedNode","getNodes","at","previousNodeKey","getPreviousSibling","previousNodeIsGhostText","anchor","offset","modify","selectEnd","promise","then","catch","e","console","error","unmountGhostText","$handleTabCommand","preventDefault","textNode","replace","registerNodeTransform","registerUpdateListener","registerCommand","noop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AACA,SACEA,eAAe,EACfC,aAAa,EACbC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,aAAa,EACbC,oBAAoB,EACpBC,eAAe,EACfC,aAAa,QACR,gCAAgC;AACvC,SAASC,eAAe,QAAQ,wBAAwB;AA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B,iBAAiB,GAAGE,OAAOuD,eAAe,CAAC1E,iBAAiBoE,mBAAmBrE,wBAAwB4E,MAC5GR;IAEJ;AAiBF;AACA,SAASQ;IACP;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './GhostText.base';\n"],"names":[],"mappings":"AAAA,cAAc,mBAAmB"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './GhostText.base';\n"],"names":[],"rangeMappings":"","mappings":"AAAA,cAAc,mBAAmB"}