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

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 (50) hide show
  1. package/CHANGELOG.json +60 -0
  2. package/CHANGELOG.md +19 -1
  3. package/dist/index.d.ts +1 -1
  4. package/lib/BasicFunctionality/BasicFunctionality.base.js +94 -91
  5. package/lib/BasicFunctionality/BasicFunctionality.base.js.map +1 -1
  6. package/lib/BasicFunctionality/SentinelNode.js +29 -30
  7. package/lib/BasicFunctionality/SentinelNodeHandlers.js +73 -78
  8. package/lib/BasicFunctionality/index.js +0 -1
  9. package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js +109 -114
  10. package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js +1 -2
  11. package/lib/ChatInputEntity/index.js +0 -1
  12. package/lib/GhostText/GhostText.base.js +142 -145
  13. package/lib/GhostText/index.js +0 -1
  14. package/lib/ImperativeControl/ImperativeControl.base.js +82 -83
  15. package/lib/ImperativeControl/index.js +0 -1
  16. package/lib/ManualGhostText/ManualGhostText.base.js +68 -67
  17. package/lib/ManualGhostText/index.js +0 -1
  18. package/lib/PasteUnfurling/PasteUnfurling.base.js +52 -57
  19. package/lib/PasteUnfurling/PasteUnfurling.types.js +1 -2
  20. package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js +138 -139
  21. package/lib/PasteUnfurling/index.js +0 -1
  22. package/lib/index.js +0 -1
  23. package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js +7 -5
  24. package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js.map +1 -1
  25. package/lib-commonjs/BasicFunctionality/SentinelNode.js +1 -1
  26. package/lib-commonjs/BasicFunctionality/SentinelNode.js.map +1 -1
  27. package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js +3 -5
  28. package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js.map +1 -1
  29. package/lib-commonjs/BasicFunctionality/index.js +0 -1
  30. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js +3 -5
  31. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js.map +1 -1
  32. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js +0 -1
  33. package/lib-commonjs/ChatInputEntity/index.js +0 -1
  34. package/lib-commonjs/GhostText/GhostText.base.js +2 -3
  35. package/lib-commonjs/GhostText/GhostText.base.js.map +1 -1
  36. package/lib-commonjs/GhostText/index.js +0 -1
  37. package/lib-commonjs/ImperativeControl/ImperativeControl.base.js +1 -1
  38. package/lib-commonjs/ImperativeControl/ImperativeControl.base.js.map +1 -1
  39. package/lib-commonjs/ImperativeControl/index.js +0 -1
  40. package/lib-commonjs/ManualGhostText/ManualGhostText.base.js +1 -1
  41. package/lib-commonjs/ManualGhostText/ManualGhostText.base.js.map +1 -1
  42. package/lib-commonjs/ManualGhostText/index.js +0 -1
  43. package/lib-commonjs/PasteUnfurling/PasteUnfurling.base.js +1 -1
  44. package/lib-commonjs/PasteUnfurling/PasteUnfurling.base.js.map +1 -1
  45. package/lib-commonjs/PasteUnfurling/PasteUnfurling.types.js +0 -1
  46. package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js +1 -1
  47. package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js.map +1 -1
  48. package/lib-commonjs/PasteUnfurling/index.js +0 -1
  49. package/lib-commonjs/index.js +0 -1
  50. package/package.json +3 -7
@@ -1,163 +1,162 @@
1
1
  import { _ as _define_property } from "@swc/helpers/_/_define_property";
2
2
  import { TextNode } from '@fluentui-copilot/text-editor';
3
3
  export class MockClipboardEvent extends Event {
4
- constructor(...args) {
5
- super(...args);
6
- _define_property(this, "clipboardData", null);
7
- }
4
+ constructor(...args){
5
+ super(...args);
6
+ _define_property(this, "clipboardData", null);
7
+ }
8
8
  }
9
9
  export function createPasteEvent(data) {
10
- const event = new MockClipboardEvent('paste');
11
- event.clipboardData = {
12
- types: [data.map(({
13
- mimeType
14
- }) => mimeType)],
15
- getData: format => {
16
- const item = data.find(({
17
- mimeType
18
- }) => mimeType === format);
19
- if (item) {
20
- return item.value;
21
- }
22
- return '';
23
- }
24
- };
25
- return event;
10
+ const event = new MockClipboardEvent('paste');
11
+ event.clipboardData = {
12
+ types: [
13
+ data.map(({ mimeType })=>mimeType)
14
+ ],
15
+ getData: (format)=>{
16
+ const item = data.find(({ mimeType })=>mimeType === format);
17
+ if (item) {
18
+ return item.value;
19
+ }
20
+ return '';
21
+ }
22
+ };
23
+ return event;
26
24
  }
27
25
  export class MockEntityNode extends TextNode {
28
- static getType() {
29
- return 'mockEntity';
30
- }
31
- constructor(text, url) {
32
- super(text);
33
- _define_property(this, "url", void 0);
34
- this.url = url;
35
- }
26
+ static getType() {
27
+ return 'mockEntity';
28
+ }
29
+ constructor(text, url){
30
+ super(text);
31
+ _define_property(this, "url", void 0);
32
+ this.url = url;
33
+ }
36
34
  }
37
35
  export function $createMockEntityNode(text, url) {
38
- return new MockEntityNode(text, url);
36
+ return new MockEntityNode(text, url);
39
37
  }
40
38
  export function $isMockEntityNode(node) {
41
- return node instanceof MockEntityNode;
39
+ return node instanceof MockEntityNode;
42
40
  }
43
- export const parseLinkPreview = event => {
44
- let previewData;
45
- try {
46
- var _event_clipboardData;
47
- const previewDataString = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/link-preview');
48
- if (previewDataString === undefined || previewDataString === '') {
49
- return {
50
- handled: false
51
- };
41
+ export const parseLinkPreview = (event)=>{
42
+ let previewData;
43
+ try {
44
+ var _event_clipboardData;
45
+ const previewDataString = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/link-preview');
46
+ if (previewDataString === undefined || previewDataString === '') {
47
+ return {
48
+ handled: false
49
+ };
50
+ }
51
+ previewData = JSON.parse(previewDataString);
52
+ } catch (e) {
53
+ return {
54
+ handled: false
55
+ };
56
+ }
57
+ const title = previewData.title;
58
+ const url = previewData.url;
59
+ if (!title || !url) {
60
+ return {
61
+ handled: false
62
+ };
52
63
  }
53
- previewData = JSON.parse(previewDataString);
54
- } catch (e) {
55
- return {
56
- handled: false
57
- };
58
- }
59
- const title = previewData.title;
60
- const url = previewData.url;
61
- if (!title || !url) {
62
64
  return {
63
- handled: false
65
+ handled: true,
66
+ transformedParts: [
67
+ {
68
+ type: 'entity',
69
+ value: {
70
+ text: title,
71
+ data: {
72
+ url
73
+ }
74
+ }
75
+ }
76
+ ]
64
77
  };
65
- }
66
- return {
67
- handled: true,
68
- transformedParts: [{
69
- type: 'entity',
70
- value: {
71
- text: title,
72
- data: {
73
- url
74
- }
75
- }
76
- }]
77
- };
78
78
  };
79
79
  const urlRegex = /(\b(?:https?):\/\/[^\s]+)/gi;
80
- export const parseLink = event => {
81
- var _event_clipboardData;
82
- const text = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/plain');
83
- if (!text) {
84
- return {
85
- handled: false
86
- };
87
- }
88
- const parts = text.split(urlRegex);
89
- // If an entity was found, parts will be at least 3 elements long
90
- if (parts.length < 3) {
80
+ export const parseLink = (event)=>{
81
+ var _event_clipboardData;
82
+ const text = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/plain');
83
+ if (!text) {
84
+ return {
85
+ handled: false
86
+ };
87
+ }
88
+ const parts = text.split(urlRegex);
89
+ // If an entity was found, parts will be at least 3 elements long
90
+ if (parts.length < 3) {
91
+ return {
92
+ handled: false
93
+ };
94
+ }
95
+ const transformedParts = parts.map((str, i)=>{
96
+ if (i % 2 === 0) {
97
+ return {
98
+ type: 'text',
99
+ value: str
100
+ };
101
+ } else {
102
+ return {
103
+ type: 'entity',
104
+ value: {
105
+ text: str,
106
+ data: {
107
+ url: str
108
+ }
109
+ }
110
+ };
111
+ }
112
+ })// Filter out all the nulls for empty strings
113
+ .filter((node)=>node !== null);
91
114
  return {
92
- handled: false
115
+ handled: true,
116
+ transformedParts
93
117
  };
94
- }
95
- const transformedParts = parts.map((str, i) => {
96
- if (i % 2 === 0) {
97
- return {
98
- type: 'text',
99
- value: str
100
- };
101
- } else {
102
- return {
103
- type: 'entity',
104
- value: {
105
- text: str,
106
- data: {
107
- url: str
108
- }
109
- }
110
- };
111
- }
112
- }) // Filter out all the nulls for empty strings
113
- .filter(node => node !== null);
114
- return {
115
- handled: true,
116
- transformedParts
117
- };
118
118
  };
119
119
  // A transform can be async in case it needs to fetch data from a server.
120
- export const parseEntity = async event => {
121
- var _event_clipboardData;
122
- const text = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/plain');
123
- if (!text) {
124
- return {
125
- handled: false
126
- };
127
- }
128
- // Assume entities come in the syntax <entity>title</entity>
129
- const re = /<entity[^>]*>([^<]*)<\/entity>/g;
130
- const parts = text.split(re);
131
- // If an entity was found, parts will be at least 3 elements long
132
- if (parts.length < 3) {
120
+ export const parseEntity = async (event)=>{
121
+ var _event_clipboardData;
122
+ const text = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/plain');
123
+ if (!text) {
124
+ return {
125
+ handled: false
126
+ };
127
+ }
128
+ // Assume entities come in the syntax <entity>title</entity>
129
+ const re = /<entity[^>]*>([^<]*)<\/entity>/g;
130
+ const parts = text.split(re);
131
+ // If an entity was found, parts will be at least 3 elements long
132
+ if (parts.length < 3) {
133
+ return {
134
+ handled: false
135
+ };
136
+ }
137
+ // Even elements are text, odd elements are entities
138
+ // ["", entity, "", entity, "", ...]
139
+ const transformedParts = parts.map((str, i)=>{
140
+ if (i % 2 === 0) {
141
+ return {
142
+ type: 'text',
143
+ value: str
144
+ };
145
+ } else {
146
+ return {
147
+ type: 'entity',
148
+ value: {
149
+ text: str,
150
+ data: {
151
+ url: str
152
+ }
153
+ }
154
+ };
155
+ }
156
+ })// Filter out all the nulls for empty strings
157
+ .filter((node)=>node !== null);
133
158
  return {
134
- handled: false
159
+ handled: true,
160
+ transformedParts
135
161
  };
136
- }
137
- // Even elements are text, odd elements are entities
138
- // ["", entity, "", entity, "", ...]
139
- const transformedParts = parts.map((str, i) => {
140
- if (i % 2 === 0) {
141
- return {
142
- type: 'text',
143
- value: str
144
- };
145
- } else {
146
- return {
147
- type: 'entity',
148
- value: {
149
- text: str,
150
- data: {
151
- url: str
152
- }
153
- }
154
- };
155
- }
156
- }) // Filter out all the nulls for empty strings
157
- .filter(node => node !== null);
158
- return {
159
- handled: true,
160
- transformedParts
161
- };
162
162
  };
163
- //# sourceMappingURL=PasteUnfurlingTestUtils.js.map
@@ -1,2 +1 @@
1
1
  export { registerPasteUnfurlingPlugin } from './PasteUnfurling.base';
2
- //# sourceMappingURL=index.js.map
package/lib/index.js CHANGED
@@ -4,4 +4,3 @@ export { GhostTextPluginBase } from './GhostText';
4
4
  export { ImperativeControlBase } from './ImperativeControl';
5
5
  export { ManualGhostTextBase } from './ManualGhostText';
6
6
  export { registerPasteUnfurlingPlugin } from './PasteUnfurling';
7
- //# sourceMappingURL=index.js.map
@@ -79,8 +79,7 @@ class BasicFunctionalityBase {
79
79
  (0, _texteditor.$getRoot)().getAllTextNodes().forEach((node)=>{
80
80
  node.remove();
81
81
  });
82
- }, // Don't allow undoing this action
83
- {
82
+ }, {
84
83
  tag: 'historic'
85
84
  });
86
85
  }
@@ -102,13 +101,16 @@ class BasicFunctionalityBase {
102
101
  (_this___baseHandlersCleanup = (_this = this).__baseHandlersCleanup) === null || _this___baseHandlersCleanup === void 0 ? void 0 : _this___baseHandlersCleanup.call(_this);
103
102
  this.__baseHandlersCleanup = undefined;
104
103
  }
105
- constructor(editor){
104
+ constructor(editor, isSentinelNodeEnabled = true){
106
105
  (0, _define_property._)(this, "__editor", void 0);
107
106
  (0, _define_property._)(this, "__contentChangeCleanup", void 0);
108
107
  (0, _define_property._)(this, "__trimWhitespaceCleanup", void 0);
109
108
  (0, _define_property._)(this, "__baseHandlersCleanup", void 0);
110
109
  (0, _define_property._)(this, "__pasteHandlerCleanup", void 0);
111
110
  this.__editor = editor;
112
- this.__baseHandlersCleanup = (0, _texteditor.mergeRegister)(this.__editor.registerCommand(_texteditor.KEY_ENTER_COMMAND, this.__enterHandler.bind(this), _texteditor.COMMAND_PRIORITY_HIGH), (0, _SentinelNodeHandlers.registerSentinelNodeHandlers)(editor));
111
+ this.__baseHandlersCleanup = (0, _texteditor.mergeRegister)(this.__editor.registerCommand(_texteditor.KEY_ENTER_COMMAND, this.__enterHandler.bind(this), _texteditor.COMMAND_PRIORITY_HIGH), isSentinelNodeEnabled ? (0, _SentinelNodeHandlers.registerSentinelNodeHandlers)(editor) : noop);
113
112
  }
114
- } //# sourceMappingURL=BasicFunctionality.base.js.map
113
+ }
114
+ function noop() {
115
+ return;
116
+ }
@@ -1 +1 @@
1
- {"version":3,"sources":["BasicFunctionality.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport { COMMAND_PRIORITY_HIGH } from '@fluentui-copilot/text-editor';\nimport {\n $createTextNode,\n $getRoot,\n $getSelection,\n $insertNodes,\n $isRangeSelection,\n INSERT_PARAGRAPH_COMMAND,\n KEY_ENTER_COMMAND,\n PASTE_COMMAND,\n mergeRegister,\n} from '@fluentui-copilot/text-editor';\nimport { SENTINEL_VALUE } from './SentinelNode';\nimport { registerSentinelNodeHandlers } from './SentinelNodeHandlers';\n\nfunction isClipboardEvent(event: ClipboardEvent | KeyboardEvent | InputEvent): event is ClipboardEvent {\n return event.type === 'paste';\n}\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_HIGH),\n registerSentinelNodeHandlers(editor),\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 | KeyboardEvent | InputEvent) => {\n if (!isClipboardEvent(event)) {\n return false;\n }\n\n onPaste(event);\n\n if (event.defaultPrevented) {\n return true;\n }\n\n return false;\n },\n COMMAND_PRIORITY_HIGH,\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":["BasicFunctionalityBase","isClipboardEvent","event","type","__enterHandler","selection","$getSelection","$isRangeSelection","preventDefault","shiftKey","__editor","dispatchCommand","INSERT_PARAGRAPH_COMMAND","insertDefaultValue","defaultValue","update","$insertNodes","onContentChange","onCountChanged","deactivateContentCallbacks","activateContentCallbacks","text","processed","__contentChangeCleanup","SENTINEL_VALUE","registerTextContentListener","length","_this___contentChangeCleanup","_this","call","undefined","__pasteHandlerCleanup","registerCommand","PASTE_COMMAND","activatePasteCallback","onPaste","defaultPrevented","COMMAND_PRIORITY_HIGH","_this___pasteHandlerCleanup","deactivatePasteCallback","deactivateTrimWhitespace","activateTrimWhitespace","__trimWhitespaceCleanup","trim","forEach","node","remove","_this___trimWhitespaceCleanup","isDisabled","setIsDisabled","cleanup","__baseHandlersCleanup","_this___baseHandlersCleanup","editor","constructor"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAgCaA;;;eAAAA;;;;4BA/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,EAAAA,IAAAA,CAAAA,QAAAA,CAAAA,eAAAA,CAAAA,6BAAAA,EAAAA,IAAAA,CAAAA,cAAAA,CAAAA,IAAAA,CAAAA,IAAAA,GAAAA,iCAAAA,GAAAA,IAAAA,kDAAAA,EAAAA;;EA8FpB,mDAAA"}
1
+ {"version":3,"sources":["BasicFunctionality.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport { COMMAND_PRIORITY_HIGH } from '@fluentui-copilot/text-editor';\nimport {\n $createTextNode,\n $getRoot,\n $getSelection,\n $insertNodes,\n $isRangeSelection,\n INSERT_PARAGRAPH_COMMAND,\n KEY_ENTER_COMMAND,\n PASTE_COMMAND,\n mergeRegister,\n} from '@fluentui-copilot/text-editor';\nimport { SENTINEL_VALUE } from './SentinelNode';\nimport { registerSentinelNodeHandlers } from './SentinelNodeHandlers';\n\nfunction isClipboardEvent(event: ClipboardEvent | KeyboardEvent | InputEvent): event is ClipboardEvent {\n return event.type === 'paste';\n}\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, isSentinelNodeEnabled = true) {\n this.__editor = editor;\n\n this.__baseHandlersCleanup = mergeRegister(\n this.__editor.registerCommand(KEY_ENTER_COMMAND, this.__enterHandler.bind(this), COMMAND_PRIORITY_HIGH),\n isSentinelNodeEnabled ? registerSentinelNodeHandlers(editor) : noop,\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 | KeyboardEvent | InputEvent) => {\n if (!isClipboardEvent(event)) {\n return false;\n }\n\n onPaste(event);\n\n if (event.defaultPrevented) {\n return true;\n }\n\n return false;\n },\n COMMAND_PRIORITY_HIGH,\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\nfunction noop() {\n return;\n}\n"],"names":["BasicFunctionalityBase","isClipboardEvent","event","type","__enterHandler","selection","$getSelection","$isRangeSelection","preventDefault","shiftKey","__editor","dispatchCommand","INSERT_PARAGRAPH_COMMAND","undefined","insertDefaultValue","defaultValue","update","$insertNodes","$createTextNode","activateContentCallbacks","onContentChange","onCountChanged","deactivateContentCallbacks","__contentChangeCleanup","registerTextContentListener","text","processed","replace","SENTINEL_VALUE","length","_this___contentChangeCleanup","_this","call","activatePasteCallback","onPaste","__pasteHandlerCleanup","registerCommand","PASTE_COMMAND","defaultPrevented","COMMAND_PRIORITY_HIGH","deactivatePasteCallback","_this___pasteHandlerCleanup","activateTrimWhitespace","deactivateTrimWhitespace","__trimWhitespaceCleanup","trim","$getRoot","getAllTextNodes","forEach","node","remove","tag","_this___trimWhitespaceCleanup","setIsDisabled","isDisabled","setEditable","cleanup","_this___baseHandlersCleanup","__baseHandlersCleanup","constructor","editor","isSentinelNodeEnabled","_define_property","mergeRegister","KEY_ENTER_COMMAND","bind","registerSentinelNodeHandlers","noop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAgCaA;;;eAAAA;;;;4BA/ByB;8BAYP;sCACc;AAE7C,SAASC,iBAAiBC,KAAkD;IAC1E,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAcO,MAAMH;IAOHI,eAAeF,KAAoB,EAAE;QAC3C,MAAMG,YAAYC,IAAAA,yBAAAA;QAClB,IAAI,CAACC,IAAAA,6BAAAA,EAA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AC2B,qBAAqB,GAAG7C;IAC/B;IA9FA8C,YAAYC,MAAqB,EAAEC,wBAAwB,IAAI,CAAE;QA1BjEC,IAAAA,kBAAA,EAAA,IAAA,EAAQpD,YAAR,KAAA;QACAoD,IAAAA,kBAAA,EAAA,IAAA,EAAQvC,0BAAR,KAAA;QACAuC,IAAAA,kBAAA,EAAA,IAAA,EAAQlB,2BAAR,KAAA;QACAkB,IAAAA,kBAAA,EAAA,IAAA,EAAQJ,yBAAR,KAAA;QACAI,IAAAA,kBAAA,EAAA,IAAA,EAAQ3B,yBAAR,KAAA;QAuBE,IAAI,CAACzB,QAAQ,GAAGkD;QAEhB,IAAI,CAACF,qBAAqB,GAAGK,IAAAA,yBAAAA,EAC3B,IAAI,CAACrD,QAAQ,CAAC0B,eAAe,CAAC4B,6BAAAA,EAAmB,IAAI,CAAC5D,cAAc,CAAC6D,IAAI,CAAC,IAAI,GAAG1B,iCAAAA,GACjFsB,wBAAwBK,IAAAA,kDAAAA,EAA6BN,UAAUO;IAEnE;AAwFF;AAEA,SAASA;IACP;AACF"}
@@ -58,4 +58,4 @@ function $createSentinelNode(key) {
58
58
  }
59
59
  function $isSentinelNode(node) {
60
60
  return node instanceof SentinelNode;
61
- } //# sourceMappingURL=SentinelNode.js.map
61
+ }
@@ -1 +1 @@
1
- {"version":3,"sources":["SentinelNode.ts"],"sourcesContent":["import type { EditorConfig, LexicalNode, NodeKey, SerializedTextNode } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\n\n// 2 zero width characters will not be visible in the editor.\n// \\u200b is the zero width space character which can allow line wrapping in a word\n// \\u200c is the zero width non-joiner character which prevents ligatures from connecting the two surrounding characters\n// These two characters together are a no-op and should not be present together in any legitimate user input.\nexport const SENTINEL_VALUE = '\\u200b\\u200c';\n\nexport class SentinelNode extends TextNode {\n constructor(key?: NodeKey) {\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 createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n element.ariaHidden = 'true';\n return element;\n }\n\n isToken() {\n return true;\n }\n\n exportJSON(): SerializedTextNode {\n return {\n ...super.exportJSON(),\n type: 'sentinel',\n version: 1,\n };\n }\n\n static importJSON(serializedNode: SerializedTextNode): SentinelNode {\n return $createSentinelNode();\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":["$createSentinelNode","$isSentinelNode","SENTINEL_VALUE","SentinelNode","TextNode","getType","clone","node","__key","createDOM","config","element","ariaHidden","isToken","exportJSON","type","version","importJSON","serializedNode","constructor","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IA4CgBA,mBAAAA;eAAAA;;IAIAC,eAAAA;eAAAA;;IAzCHC,cAAAA;eAAAA;;IAEAC,YAAAA;eAAAA;;;4BARY;AAMlB,MAAMD,iBAAiB;AAEvB,MAAMC,qBAAqBC,oBAAAA;WAKhCC,UAAOA;eACL;;WAEFC,MAAOA,IAAMC,EAAkB;eAC7B,IAAOJ,aAAIA,KAAaI,KAAKC;;cAG/BC,MAAUC,EAAoB;cAC5BC,UAAMA,KAAU,CAAAF,UAAMA;gBACtBE,UAAQC,GAAAA;eACRD;;cAGFE;eACE;;iBAGFC;eACE;oBACE,CAAGA,YAAMA;kBACTC;qBACAC;;;WAIJC,WAAOA,cAAWC,EAAkC;eAClDlB;;gBA9BFmB,GAAYC,CAAa;aACvB,CAAAlB,gBAAMA;;AA+BV;AAEO,SAASF,oBAAoBoB,GAAa;WAC/C,IAAOjB,aAAIA;AACb;AAEO,SAASF,gBAAgBM,IAAwB;WACtDA,gBAAOA;AACT"}
1
+ {"version":3,"sources":["SentinelNode.ts"],"sourcesContent":["import type { EditorConfig, LexicalNode, NodeKey, SerializedTextNode } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\n\n// 2 zero width characters will not be visible in the editor.\n// \\u200b is the zero width space character which can allow line wrapping in a word\n// \\u200c is the zero width non-joiner character which prevents ligatures from connecting the two surrounding characters\n// These two characters together are a no-op and should not be present together in any legitimate user input.\nexport const SENTINEL_VALUE = '\\u200b\\u200c';\n\nexport class SentinelNode extends TextNode {\n constructor(key?: NodeKey) {\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 createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n element.ariaHidden = 'true';\n return element;\n }\n\n isToken() {\n return true;\n }\n\n exportJSON(): SerializedTextNode {\n return {\n ...super.exportJSON(),\n type: 'sentinel',\n version: 1,\n };\n }\n\n static importJSON(serializedNode: SerializedTextNode): SentinelNode {\n return $createSentinelNode();\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":["$createSentinelNode","$isSentinelNode","SENTINEL_VALUE","SentinelNode","TextNode","getType","clone","node","__key","createDOM","config","element","ariaHidden","isToken","exportJSON","type","version","importJSON","serializedNode","constructor","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IA4CgBA,mBAAAA;eAAAA;;IAIAC,eAAAA;eAAAA;;IAzCHC,cAAAA;eAAAA;;IAEAC,YAAAA;eAAAA;;;4BARY;AAMlB,MAAMD,iBAAiB;AAEvB,MAAMC,qBAAqBC,oBAAAA;IAKhC,OAAOC,UAAU;QACf,OAAO;IACT;IACA,OAAOC,MAAMC,IAAkB,EAAE;QAC/B,OAAO,IAAIJ,aAAaI,KAAKC,KAAK;IACpC;IAEAC,UAAUC,MAAoB,EAAe;QAC3C,MAAMC,UAAU,KAAK,CAACF,UAAUC;QAChCC,QAAQC,UAAU,GAAG;QACrB,OAAOD;IACT;IAEAE,UAAU;QACR,OAAO;IACT;IAEAC,aAAiC;QAC/B,OAAO;YACL,GAAG,KAAK,CAACA,YAAY;YACrBC,MAAM;YACNC,SAAS;QACX;IACF;IAEA,OAAOC,WAAWC,cAAkC,EAAgB;QAClE,OAAOlB;IACT;IA/BAmB,YAAYC,GAAa,CAAE;QACzB,KAAK,CAAClB,gBAAgBkB;IACxB;AA8BF;AAEO,SAASpB,oBAAoBoB,GAAa;IAC/C,OAAO,IAAIjB,aAAaiB;AAC1B;AAEO,SAASnB,gBAAgBM,IAAwB;IACtD,OAAOA,gBAAgBJ;AACzB"}
@@ -29,11 +29,9 @@ function registerSentinelNodeHandlers(editor) {
29
29
  // If the last node isn't a sentinel, add one
30
30
  if (!(0, _SentinelNode.$isSentinelNode)(lastNode)) {
31
31
  editor.update(()=>{
32
- var // We find the node by its key again in case the node was removed before this update runs
33
- _$getNodeByKey;
32
+ var _$getNodeByKey;
34
33
  (_$getNodeByKey = (0, _texteditor.$getNodeByKey)(lastNodeKey)) === null || _$getNodeByKey === void 0 ? void 0 : _$getNodeByKey.insertAfter((0, _SentinelNode.$createSentinelNode)());
35
- }, // historic tag prevents every sentinel node addition from being added to LexicalHistoryPlugin undo stack
36
- {
34
+ }, {
37
35
  discrete: true,
38
36
  tag: 'historic'
39
37
  });
@@ -86,4 +84,4 @@ function registerSentinelNodeHandlers(editor) {
86
84
  return;
87
85
  }
88
86
  }));
89
- } //# sourceMappingURL=SentinelNodeHandlers.js.map
87
+ }
@@ -1 +1 @@
1
- {"version":3,"sources":["SentinelNodeHandlers.ts"],"sourcesContent":["import type {\n LexicalEditor,\n UpdateListener} from '@fluentui-copilot/text-editor';\nimport {\n $getLeafNodes,\n $getNodeByKey,\n $getRoot,\n $getSelection,\n $isRangeSelection,\n $normalizeSelection__EXPERIMENTAL,\n $setSelection,\n mergeRegister\n} from '@fluentui-copilot/text-editor';\nimport { $isSentinelNode, $createSentinelNode, SentinelNode } from './SentinelNode';\n\nexport function registerSentinelNodeHandlers(editor: LexicalEditor) {\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 const sentinelNodeUpdateHandler: UpdateListener = ({ 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 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 // historic tag prevents every sentinel node addition from being added to LexicalHistoryPlugin undo stack\n { discrete: true, tag: 'historic' },\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 editor.update(() => {\n $getNodeByKey(lastNodeKey)?.selectStart();\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 editor.update(() => {\n if ($getNodeByKey(lastNodeKey) !== null) {\n $setSelection($normalizeSelection__EXPERIMENTAL(newSelection));\n }\n });\n }\n }\n });\n };\n\n return mergeRegister(\n editor.registerUpdateListener(sentinelNodeUpdateHandler),\n editor.registerNodeTransform(SentinelNode, node => {\n if (!node.getPreviousSibling() || node.getNextSibling()) {\n node.remove();\n return;\n }\n }),\n );\n}\n"],"names":["registerSentinelNodeHandlers","editor","sentinelNodeUpdateHandler","editorState","leaves","$getLeafNodes","$getRoot","length","lastNode","lastNodeKey","$isSentinelNode","$getNodeByKey","discrete","_$getNodeByKey","insertAfter","$createSentinelNode","previous","selection","$getSelection","$isRangeSelection","isCollapsed","anchor","offset","selectStart","newSelection","selectionChanged","clone","getNode","focus","update","$setSelection","$normalizeSelection__EXPERIMENTAL","mergeRegister","registerUpdateListener","registerNodeTransform","SentinelNode","node","getPreviousSibling","getNextSibling","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAegBA;;;eAAAA;;;4BAHT;8BAC4D;AAE5D,SAASA,6BAA6BC,MAAqB;yEAChE;mDACA;gGACA;yGACA;qGACA;yHACA;8BACA;UACAC,4BAAMA,CAAAA,aACJC;oBAEMC,IAAAA,CAAAA;2BACFC,IAAAA,yBAAA,EAAAC,IAAAA,oBAAA;uBACFC,MAAA,KAAA,GAAA;;;kBAKAC,WAAAJ,MAAA,CAAAA,OAAAG,MAAA,GAAA,EAAA;kBACAE,cAAKC,SAAgBF,MAAAA;yDAEjB;kDACE,EAAAA,WAAA;6BACAG,CAAAA;iHAEF;;sCACEC,IAAAA,yBAAU,EA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\nimport {\n $getLeafNodes,\n $getNodeByKey,\n $getRoot,\n $getSelection,\n $isRangeSelection,\n $normalizeSelection__EXPERIMENTAL,\n $setSelection,\n mergeRegister\n} from '@fluentui-copilot/text-editor';\nimport { $isSentinelNode, $createSentinelNode, SentinelNode } from './SentinelNode';\n\nexport function registerSentinelNodeHandlers(editor: LexicalEditor) {\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 const sentinelNodeUpdateHandler: UpdateListener = ({ 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 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 // historic tag prevents every sentinel node addition from being added to LexicalHistoryPlugin undo stack\n { discrete: true, tag: 'historic' },\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 editor.update(() => {\n $getNodeByKey(lastNodeKey)?.selectStart();\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 editor.update(() => {\n if ($getNodeByKey(lastNodeKey) !== null) {\n $setSelection($normalizeSelection__EXPERIMENTAL(newSelection));\n }\n });\n }\n }\n });\n };\n\n return mergeRegister(\n editor.registerUpdateListener(sentinelNodeUpdateHandler),\n editor.registerNodeTransform(SentinelNode, node => {\n if (!node.getPreviousSibling() || node.getNextSibling()) {\n node.remove();\n return;\n }\n }),\n );\n}\n"],"names":["registerSentinelNodeHandlers","editor","sentinelNodeUpdateHandler","editorState","read","leaves","$getLeafNodes","$getRoot","length","lastNode","lastNodeKey","getKey","$isSentinelNode","update","$getNodeByKey","insertAfter","$createSentinelNode","discrete","tag","previous","getPreviousSibling","isSelected","selection","$getSelection","$isRangeSelection","isCollapsed","anchor","offset","selectStart","selectionChanged","newSelection","clone","getNode","set","focus","$setSelection","$normalizeSelection__EXPERIMENTAL","mergeRegister","registerUpdateListener","registerNodeTransform","SentinelNode","node","getNextSibling","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAegBA;;;eAAAA;;;4BAHT;8BAC4D;AAE5D,SAASA,6BAA6BC,MAAqB;IAChE,qEAAqE;IACrE,+CAA+C;IAC/C,4FAA4F;IAC5F,qGAAqG;IACrG,iGAAiG;IACjG,qHAAqH;IACrH,0BAA0B;IAC1B,MAAMC,4BAA4C,CAAC,EAAEC,WAAW,EAAE;QAChEA,YAAYC,IAAI,CAAC;YACf,MAAMC,SAASC,IAAAA,yBAAAA,EAAcC,IAAAA,oBAAAA;YAC7B,IAAIF,OAAOG,MAAM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AAK,CAACF,OAAO,OAAOvB,YAAYqB,aAAaI,KAAK,CAACP,MAAM,GAAG,GAAG;oBAC9EG,aAAaI,KAAK,CAACD,GAAG,CAACvB,aAAa,GAAG;oBACvCmB,mBAAmB;gBACrB;gBAEA,IAAIA,kBAAkB;oBACpB5B,OAAOY,MAAM,CAAC;wBACZ,IAAIC,IAAAA,yBAAAA,EAAcJ,iBAAiB,MAAM;4BACvCyB,IAAAA,yBAAAA,EAAcC,IAAAA,6CAAAA,EAAkCN;wBAClD;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAOO,IAAAA,yBAAAA,EACLpC,OAAOqC,sBAAsB,CAACpC,4BAC9BD,OAAOsC,qBAAqB,CAACC,0BAAAA,EAAcC,CAAAA;QACzC,IAAI,CAACA,KAAKrB,kBAAkB,MAAMqB,KAAKC,cAAc,IAAI;YACvDD,KAAKE,MAAM;YACX;QACF;IACF;AAEJ"}
@@ -27,4 +27,3 @@ _export(exports, {
27
27
  });
28
28
  const _BasicFunctionalitybase = require("./BasicFunctionality.base");
29
29
  const _SentinelNode = require("./SentinelNode");
30
- //# sourceMappingURL=index.js.map
@@ -72,12 +72,10 @@ class ChatInputEntityPluginBase {
72
72
  this.__editor = editor;
73
73
  this.__id = id;
74
74
  this.__nodeClass = nodeClass;
75
- this._cleanup = (0, _texteditor.mergeRegister)(// Keep track of delete direction so we know where to put the selection after adding back a space
76
- editor.registerCommand(_texteditor.DELETE_CHARACTER_COMMAND, (isBackward)=>{
75
+ this._cleanup = (0, _texteditor.mergeRegister)(editor.registerCommand(_texteditor.DELETE_CHARACTER_COMMAND, (isBackward)=>{
77
76
  this.__deleteDirection = isBackward ? 'backward' : 'forward';
78
77
  return false;
79
- }, _texteditor.COMMAND_PRIORITY_CRITICAL), // Always maintain a space before, after, and between entities in order for selection to work properly
80
- editor.registerNodeTransform(this.__nodeClass, (node)=>{
78
+ }, _texteditor.COMMAND_PRIORITY_CRITICAL), editor.registerNodeTransform(this.__nodeClass, (node)=>{
81
79
  const nextSibling = node.getNextSibling();
82
80
  if (!nextSibling || (0, _texteditor.$isDecoratorNode)(nextSibling)) {
83
81
  const selection = (0, _texteditor.$getSelection)();
@@ -124,4 +122,4 @@ class ChatInputEntityPluginBase {
124
122
  }
125
123
  function noop() {
126
124
  return;
127
- } //# sourceMappingURL=ChatInputEntityPlugin.base.js.map
125
+ }
@@ -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 {\n ChatInputEntityData,\n ChatInputEntityPluginProps,\n IChatInputEntityPluginBase,\n IEntityNode,\n} 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?: ChatInputEntityPluginProps<ExtraDataType, NodePropsType>['onChatInputEntityAdded'],\n onChatInputEntityDeleted?: ChatInputEntityPluginProps<ExtraDataType, NodePropsType>['onChatInputEntityDeleted'],\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(), nodeKey);\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(), nodeKey);\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":["ChatInputEntityPluginBase","cleanup","_cleanup","insertChatInputEntity","props","key","__editor","update","$insertNodes","entityNode","selectEnd","__id","text","data","entityProps","$isRootOrShadowRoot","$wrapNodeInElement","getParentOrThrow","$createParagraphNode","removeChatInputEntity","keyOrPredicate","$nodesOfType","$getNodeByKey","_$getNodeByKey","remove","updateChatInputEntityProps","updateEntityData","newProps","node","getEntityData","updateNode","tag","getActiveEntities","constructor","editor","id","$createNode","$isChatInputEntityNode","onChatInputEntityAdded","onChatInputEntityDeleted","map","nodeClass","__deleteDirection","__$createNode","__nodeClass","registerCommand","COMMAND_PRIORITY_CRITICAL","isBackward","registerNodeTransform","$isDecoratorNode","$getSelection","getNextSibling","nextSibling","isCollapsed","$isRangeSelection","selection","anchor","offset","getIndexWithinParent","$createTextNode","mutation","nodeKey","read","getEditorState","__pluginId","noop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAuBaA;;;eAAAA;;;;4BARN;AAQA,MAAMA;cAqBXC;YACE,CAAAC,QAAKA;;0BAwFPC,KAAsBC,EAAwD;YAC5EC,MAAIA;YACJ,CAAAC,QAAKA,CAAAA,MAASC,CAAAA;kBACZ,MAEA,MAEAC,aAAcC;kBACdA,aAAWC,IAAAA,CAAAA,aAAS,CAAA,IAAA,CAAAC,IAAA,EAAAC,MAAAC,MAAAC;wCAChBC,EAAAA;gBAAAA;aAAAA;uBACFC,SAAAA;mDACF,EAAAP,WAAAQ,gBAAA,KAAA;kDAEMR,EAAAA,YAAiBS,gCAAA,EAAAR,SAAA;;kBAGzBD,WAA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AuC;4BACFxB,uBAAWC,SAAAA,KAA0BsB,UAAAA,KAAazB,IAAA;qDACzC4B,KAAiBD,aAAK,IAAAD;;;qDAGzBvB,aAA4BT,WAAa;yCAC3C,GAAAiC,IAAA,CAAA;qCACFxC,IAAAA,yBAAA,EAAAuC;4BACFxB,uBAAAT,SAAAA,KAAAoC,UAAA,KAAA7B,IAAA;4BACFG,uBAAAV,KAAAC,aAAA,IAAAgC;wBACF;oBAGR;gBAqEF;YAEA;QACE,KAAAI;IACF"}
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 {\n ChatInputEntityData,\n ChatInputEntityPluginProps,\n IChatInputEntityPluginBase,\n IEntityNode,\n} 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?: ChatInputEntityPluginProps<ExtraDataType, NodePropsType>['onChatInputEntityAdded'],\n onChatInputEntityDeleted?: ChatInputEntityPluginProps<ExtraDataType, NodePropsType>['onChatInputEntityDeleted'],\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(), nodeKey);\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(), nodeKey);\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":["ChatInputEntityPluginBase","cleanup","_cleanup","insertChatInputEntity","props","key","undefined","__editor","update","text","data","entityProps","entityNode","__$createNode","__id","$insertNodes","selectEnd","$isRootOrShadowRoot","getParentOrThrow","$wrapNodeInElement","$createParagraphNode","getKey","removeChatInputEntity","keyOrPredicate","$nodesOfType","__nodeClass","filter","node","i","__pluginId","getEntityData","forEach","remove","$getNodeByKey","updateChatInputEntityProps","updateNode","newProps","updateEntityData","tag","getActiveEntities","getEditorState","read","map","constructor","editor","id","nodeClass","$createNode","$isChatInputEntityNode","onChatInputEntityAdded","onChatInputEntityDeleted","_define_property","__deleteDirection","mergeRegister","registerCommand","DELETE_CHARACTER_COMMAND","isBackward","COMMAND_PRIORITY_CRITICAL","registerNodeTransform","nextSibling","getNextSibling","$isDecoratorNode","selection","$getSelection","shouldMoveSelection","$isRangeSelection","isCollapsed","anchor","offset","getIndexWithinParent","$createTextNode","insertAfter","getPreviousSibling","insertBefore","registerMutationListener","nodes","payload","nodeKey","mutation","prevEditorState","noop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAuBaA;;;eAAAA;;;;4BARN;AAQA,MAAMA;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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A,yBAAAA,EAAc4C;wBAC3B,IAAI7B,uBAAuBrB,SAASA,KAAKE,UAAU,KAAKgB,IAAI;4BAC1DI,uBAAuBtB,KAAKG,aAAa,IAAI+C;wBAC/C;oBACF;gBACF;YACF;QACF,KACAG;IAER;AAqEF;AAEA,SAASA;IACP;AACF"}
@@ -2,4 +2,3 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- //# sourceMappingURL=ChatInputEntityPlugin.types.js.map
@@ -9,4 +9,3 @@ Object.defineProperty(exports, "ChatInputEntityPluginBase", {
9
9
  }
10
10
  });
11
11
  const _ChatInputEntityPluginbase = require("./ChatInputEntityPlugin.base");
12
- //# sourceMappingURL=index.js.map
@@ -28,8 +28,7 @@ class GhostTextPluginBase {
28
28
  setAllowCompletion(allowCompletion) {
29
29
  this.__allowCompletion = allowCompletion;
30
30
  }
31
- constructor(editor, id, $getGhostText, nodeClass, createNode, componentProps, // Whether or not the ghost text should count as text inside the input for submitting and character count
32
- exposeText, allowCompletion){
31
+ constructor(editor, id, $getGhostText, nodeClass, createNode, componentProps, exposeText, allowCompletion){
33
32
  (0, _define_property._)(this, "__id", void 0);
34
33
  (0, _define_property._)(this, "__$getGhostText", void 0);
35
34
  (0, _define_property._)(this, "__componentProps", void 0);
@@ -165,4 +164,4 @@ class GhostTextPluginBase {
165
164
  }
166
165
  function noop() {
167
166
  return;
168
- } //# sourceMappingURL=GhostText.base.js.map
167
+ }