@fluentui-copilot/chat-input-plugins 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +31 -1
- package/CHANGELOG.md +11 -2
- package/lib/GhostText/GhostText.base.js +2 -2
- package/lib/GhostText/GhostText.base.js.map +1 -1
- package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js +22 -4
- package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js.map +1 -1
- package/lib-commonjs/GhostText/GhostText.base.js +2 -2
- package/lib-commonjs/GhostText/GhostText.base.js.map +1 -1
- package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js +22 -4
- package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,37 @@
|
|
|
2
2
|
"name": "@fluentui-copilot/chat-input-plugins",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 12 Mar 2026 17:20:18 GMT",
|
|
6
|
+
"tag": "@fluentui-copilot/chat-input-plugins_v0.5.4",
|
|
7
|
+
"version": "0.5.4",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "twatanabe@microsoft.com",
|
|
12
|
+
"package": "@fluentui-copilot/chat-input-plugins",
|
|
13
|
+
"commit": "d0b3b5b550052d89ff3ef10926b487acbb621a5f",
|
|
14
|
+
"comment": "chore: bump lexical to ^0.39."
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Wed, 22 Oct 2025 17:51:31 GMT",
|
|
21
|
+
"tag": "@fluentui-copilot/chat-input-plugins_v0.5.3",
|
|
22
|
+
"version": "0.5.3",
|
|
23
|
+
"comments": {
|
|
24
|
+
"none": [
|
|
25
|
+
{
|
|
26
|
+
"author": "hochelmartin@gmail.com",
|
|
27
|
+
"package": "@fluentui-copilot/chat-input-plugins",
|
|
28
|
+
"commit": "85efb411485b778327290c03aacb479fc9779dab",
|
|
29
|
+
"comment": "chore: migrate to dts generation against public api instead of internal path aliases tsc resolution"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"date": "Tue, 14 Oct 2025 00:04:52 GMT",
|
|
6
36
|
"tag": "@fluentui-copilot/chat-input-plugins_v0.5.2",
|
|
7
37
|
"version": "0.5.2",
|
|
8
38
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
# Change Log - @fluentui-copilot/chat-input-plugins
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 12 Mar 2026 17:20:18 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [0.5.4](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.5.4)
|
|
8
|
+
|
|
9
|
+
Thu, 12 Mar 2026 17:20:18 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.5.3..@fluentui-copilot/chat-input-plugins_v0.5.4)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- chore: bump lexical to ^0.39. ([PR #3471](https://github.com/microsoft/fluentai/pull/3471) by twatanabe@microsoft.com)
|
|
15
|
+
|
|
7
16
|
## [0.5.2](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.5.2)
|
|
8
17
|
|
|
9
|
-
Tue, 14 Oct 2025 00:
|
|
18
|
+
Tue, 14 Oct 2025 00:04:52 GMT
|
|
10
19
|
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.5.1..@fluentui-copilot/chat-input-plugins_v0.5.2)
|
|
11
20
|
|
|
12
21
|
### Patches
|
|
@@ -92,9 +92,9 @@ export class GhostTextPluginBase {
|
|
|
92
92
|
}
|
|
93
93
|
if ($isRangeSelection(selection) && selection.isCollapsed()) {
|
|
94
94
|
var _selectedNode_getPreviousSibling;
|
|
95
|
-
var
|
|
95
|
+
var _selection_getNodes_;
|
|
96
96
|
// All the `$isXNode` functions prefer `null` over `undefined`
|
|
97
|
-
const selectedNode = (
|
|
97
|
+
const selectedNode = (_selection_getNodes_ = selection.getNodes()[0]) !== null && _selection_getNodes_ !== void 0 ? _selection_getNodes_ : null;
|
|
98
98
|
const previousNodeKey = selectedNode === null || selectedNode === void 0 ? void 0 : (_selectedNode_getPreviousSibling = selectedNode.getPreviousSibling()) === null || _selectedNode_getPreviousSibling === void 0 ? void 0 : _selectedNode_getPreviousSibling.getKey();
|
|
99
99
|
const previousNodeIsGhostText = previousNodeKey === ghostTextNodeKey;
|
|
100
100
|
// 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
|
|
@@ -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 $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(): void {\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): void {\n this.__exposeText = exposeText;\n }\n\n setComponentProps(componentProps?: ComponentPropsType): void {\n this.__componentProps = componentProps;\n }\n\n setGetGhostText($getGhostText: GetGhostTextFunction): void {\n this.__$getGhostText = $getGhostText;\n }\n\n setAllowCompletion(allowCompletion?: boolean): void {\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AMC,WAAW7E,gBAAgBgC;YACjCK,cAAcyC,OAAO,CAACD;YACtBA,SAASV,SAAS;YAClB/B;YACA,OAAO;QACT;QAEA,IAAI,CAACxB,SAAS,GAAGJ,cACfkB,OAAOqD,qBAAqB,CAACnD,WAAWY,+BACxCd,OAAOsD,sBAAsB,CAAC5B,eAC9B,IAAI,CAAC5B,iBAAiB,GAAGE,OAAOuD,eAAe,CAAC1E,iBAAiBoE,mBAAmBrE,wBAAwB4E,MAC5GR;IAEJ;AAiBF;AACA,SAASQ;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(): void {\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()[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): void {\n this.__exposeText = exposeText;\n }\n\n setComponentProps(componentProps?: ComponentPropsType): void {\n this.__componentProps = componentProps;\n }\n\n setGetGhostText($getGhostText: GetGhostTextFunction): void {\n this.__$getGhostText = $getGhostText;\n }\n\n setAllowCompletion(allowCompletion?: boolean): void {\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","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;AAgBxD,OAAO,MAAMC;IASXC,UAAgB;YACd,iBAAA;SAAA,kBAAA,CAAA,QAAA,IAAI,EAACC,SAAS,cAAd,sCAAA,qBAAA;IACF;IA+KAC,cAAcC,UAAoB,EAAQ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@ export class MockEntityNode extends TextNode {
|
|
|
26
26
|
static getType() {
|
|
27
27
|
return 'mockEntity';
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
static clone(node) {
|
|
30
|
+
return new MockEntityNode(node.__text, node.__url, node.__key);
|
|
31
|
+
}
|
|
32
|
+
static importJSON(serializedNode) {
|
|
33
|
+
return $createMockEntityNode(serializedNode.text, serializedNode.url);
|
|
34
|
+
}
|
|
35
|
+
get url() {
|
|
36
|
+
const self = this.getLatest();
|
|
37
|
+
return self.__url;
|
|
38
|
+
}
|
|
39
|
+
exportJSON() {
|
|
40
|
+
return {
|
|
41
|
+
...super.exportJSON(),
|
|
42
|
+
type: 'mockEntity',
|
|
43
|
+
url: this.__url,
|
|
44
|
+
version: 1
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
constructor(text, url, key){
|
|
48
|
+
super(text, key);
|
|
49
|
+
_define_property(this, "__url", void 0);
|
|
50
|
+
this.__url = url;
|
|
33
51
|
}
|
|
34
52
|
}
|
|
35
53
|
export function $createMockEntityNode(text, url) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PasteUnfurlingTestUtils.ts"],"sourcesContent":["import type { LexicalNode } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\nimport type { PasteUnfurlingTransformedPart, PasteUnfurlingTransformResult } from '..';\n\nexport class MockClipboardEvent extends Event implements ClipboardEvent {\n clipboardData: DataTransfer | null = null;\n}\n\nexport function createPasteEvent(data: { mimeType: string; value: string }[]): MockClipboardEvent {\n const event = new MockClipboardEvent('paste');\n\n event.clipboardData = {\n types: [data.map(({ mimeType }) => mimeType)],\n getData: (format: string) => {\n const item = data.find(({ mimeType }) => mimeType === format);\n if (item) {\n return item.value;\n }\n return '';\n },\n } as unknown as DataTransfer;\n\n return event;\n}\n\nexport class MockEntityNode extends TextNode {\n
|
|
1
|
+
{"version":3,"sources":["PasteUnfurlingTestUtils.ts"],"sourcesContent":["import type { LexicalNode, NodeKey, SerializedTextNode } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\nimport type { PasteUnfurlingTransformedPart, PasteUnfurlingTransformResult } from '..';\n\nexport class MockClipboardEvent extends Event implements ClipboardEvent {\n clipboardData: DataTransfer | null = null;\n}\n\nexport function createPasteEvent(data: { mimeType: string; value: string }[]): MockClipboardEvent {\n const event = new MockClipboardEvent('paste');\n\n event.clipboardData = {\n types: [data.map(({ mimeType }) => mimeType)],\n getData: (format: string) => {\n const item = data.find(({ mimeType }) => mimeType === format);\n if (item) {\n return item.value;\n }\n return '';\n },\n } as unknown as DataTransfer;\n\n return event;\n}\n\nexport interface SerializedMockEntityNode extends SerializedTextNode {\n url: string;\n}\n\nexport class MockEntityNode extends TextNode {\n __url: string;\n\n constructor(text: string, url: string, key?: NodeKey) {\n super(text, key);\n this.__url = url;\n }\n\n static getType(): string {\n return 'mockEntity';\n }\n\n static clone(node: MockEntityNode): MockEntityNode {\n return new MockEntityNode(node.__text, node.__url, node.__key);\n }\n\n static importJSON(serializedNode: SerializedMockEntityNode): MockEntityNode {\n return $createMockEntityNode(serializedNode.text, serializedNode.url);\n }\n\n get url(): string {\n const self = this.getLatest();\n return self.__url;\n }\n\n exportJSON(): SerializedMockEntityNode {\n return {\n ...super.exportJSON(),\n type: 'mockEntity',\n url: this.__url,\n version: 1,\n };\n }\n}\n\nexport type ExtraDataType = { url: string };\n\nexport function $createMockEntityNode(text: string, url: string): MockEntityNode {\n return new MockEntityNode(text, url);\n}\n\nexport function $isMockEntityNode(node: LexicalNode | null | undefined): node is MockEntityNode {\n return node instanceof MockEntityNode;\n}\n\nexport const parseLinkPreview = (event: ClipboardEvent): PasteUnfurlingTransformResult<ExtraDataType, {}> => {\n let previewData;\n try {\n const previewDataString = event.clipboardData?.getData('text/link-preview');\n if (previewDataString === undefined || previewDataString === '') {\n return { handled: false };\n }\n\n previewData = JSON.parse(previewDataString);\n } catch (e) {\n return { handled: false };\n }\n\n const title: string | undefined = previewData.title;\n const url: string | undefined = previewData.url;\n if (!title || !url) {\n return { handled: false };\n }\n\n return {\n handled: true,\n transformedParts: [{ type: 'entity', value: { text: title, data: { url } } }],\n };\n};\nconst urlRegex = /(\\b(?:https?):\\/\\/[^\\s]+)/gi;\n\nexport const parseLink = (event: ClipboardEvent): PasteUnfurlingTransformResult<ExtraDataType, {}> => {\n const text = event.clipboardData?.getData('text/plain');\n if (!text) {\n return {\n handled: false,\n };\n }\n\n const parts = text.split(urlRegex);\n // If an entity was found, parts will be at least 3 elements long\n if (parts.length < 3) {\n return { handled: false };\n }\n const transformedParts = parts\n .map((str, i) => {\n if (i % 2 === 0) {\n return { type: 'text', value: str };\n } else {\n return {\n type: 'entity',\n value: { text: str, data: { url: str } },\n };\n }\n })\n // Filter out all the nulls for empty strings\n .filter(node => node !== null) as PasteUnfurlingTransformedPart<ExtraDataType, {}>[];\n\n return { handled: true, transformedParts };\n};\n\n// A transform can be async in case it needs to fetch data from a server.\nexport const parseEntity = async (event: ClipboardEvent): Promise<PasteUnfurlingTransformResult<ExtraDataType, {}>> => {\n const text = event.clipboardData?.getData('text/plain');\n if (!text) {\n return {\n handled: false,\n };\n }\n\n // Assume entities come in the syntax <entity>title</entity>\n const re = /<entity[^>]*>([^<]*)<\\/entity>/g;\n const parts = text.split(re);\n // If an entity was found, parts will be at least 3 elements long\n if (parts.length < 3) {\n return { handled: false };\n }\n\n // Even elements are text, odd elements are entities\n // [\"\", entity, \"\", entity, \"\", ...]\n const transformedParts = parts\n .map((str, i) => {\n if (i % 2 === 0) {\n return { type: 'text', value: str };\n } else {\n return {\n type: 'entity',\n value: { text: str, data: { url: str } },\n };\n }\n })\n // Filter out all the nulls for empty strings\n .filter(node => node !== null) as PasteUnfurlingTransformedPart<ExtraDataType, {}>[];\n\n return { handled: true, transformedParts };\n};\n"],"names":["TextNode","MockClipboardEvent","Event","clipboardData","createPasteEvent","data","event","types","map","mimeType","getData","format","item","find","value","MockEntityNode","getType","clone","node","__text","__url","__key","importJSON","serializedNode","$createMockEntityNode","text","url","self","getLatest","exportJSON","type","version","constructor","key","$isMockEntityNode","parseLinkPreview","previewData","previewDataString","undefined","handled","JSON","parse","e","title","transformedParts","urlRegex","parseLink","parts","split","length","str","i","filter","parseEntity","re"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AACA,SAASA,QAAQ,QAAQ,gCAAgC;AAGzD,OAAO,MAAMC,2BAA2BC;;;QACtCC,uBAAAA,iBAAqC;;AACvC;AAEA,OAAO,SAASC,iBAAiBC,IAA2C;IAC1E,MAAMC,QAAQ,IAAIL,mBAAmB;IAErCK,MAAMH,aAAa,GAAG;QACpBI,OAAO;YAACF,KAAKG,GAAG,CAAC,CAAC,EAAEC,QAAQ,EAAE,GAAKA;SAAU;QAC7CC,SAAS,CAACC;YACR,MAAMC,OAAOP,KAAKQ,IAAI,CAAC,CAAC,EAAEJ,QAAQ,EAAE,GAAKA,aAAaE;YACtD,IAAIC,MAAM;gBACR,OAAOA,KAAKE,KAAK;YACnB;YACA,OAAO;QACT;IACF;IAEA,OAAOR;AACT;AAMA,OAAO,MAAMS,uBAAuBf;IAQlC,OAAOgB,UAAkB;QACvB,OAAO;IACT;IAEA,OAAOC,MAAMC,IAAoB,EAAkB;QACjD,OAAO,IAAIH,eAAeG,KAAKC,MAAM,EAAED,KAAKE,KAAK,EAAEF,KAAKG,KAAK;IAC/D;IAEA,OAAOC,WAAWC,cAAwC,EAAkB;QAC1E,OAAOC,sBAAsBD,eAAeE,IAAI,EAAEF,eAAeG,GAAG;IACtE;IAEA,IAAIA,MAAc;QAChB,MAAM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C,MAAM;wBAAEqB,KAAKwB;oBAAI;gBAAE;YACzC;QACF;IACF,EACA,6CAA6C;KAC5CE,MAAM,CAAClC,CAAAA,OAAQA,SAAS;IAE3B,OAAO;QAAEqB,SAAS;QAAMK;IAAiB;AAC3C,EAAE"}
|
|
@@ -101,9 +101,9 @@ class GhostTextPluginBase {
|
|
|
101
101
|
}
|
|
102
102
|
if ((0, _texteditor.$isRangeSelection)(selection) && selection.isCollapsed()) {
|
|
103
103
|
var _selectedNode_getPreviousSibling;
|
|
104
|
-
var
|
|
104
|
+
var _selection_getNodes_;
|
|
105
105
|
// All the `$isXNode` functions prefer `null` over `undefined`
|
|
106
|
-
const selectedNode = (
|
|
106
|
+
const selectedNode = (_selection_getNodes_ = selection.getNodes()[0]) !== null && _selection_getNodes_ !== void 0 ? _selection_getNodes_ : null;
|
|
107
107
|
const previousNodeKey = selectedNode === null || selectedNode === void 0 ? void 0 : (_selectedNode_getPreviousSibling = selectedNode.getPreviousSibling()) === null || _selectedNode_getPreviousSibling === void 0 ? void 0 : _selectedNode_getPreviousSibling.getKey();
|
|
108
108
|
const previousNodeIsGhostText = previousNodeKey === ghostTextNodeKey;
|
|
109
109
|
// 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
|
|
@@ -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 $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(): void {\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): void {\n this.__exposeText = exposeText;\n }\n\n setComponentProps(componentProps?: ComponentPropsType): void {\n this.__componentProps = componentProps;\n }\n\n setGetGhostText($getGhostText: GetGhostTextFunction): void {\n this.__$getGhostText = $getGhostText;\n }\n\n setAllowCompletion(allowCompletion?: boolean): void {\n this.__allowCompletion = allowCompletion;\n }\n}\nfunction noop(): void {\n return;\n}\n"],"names":["GhostTextPluginBase","cleanup","_this___cleanup","_this","__cleanup","call","setExposeText","exposeText","__exposeText","setComponentProps","componentProps","__componentProps","setGetGhostText","$getGhostText","__$getGhostText","setAllowCompletion","allowCompletion","__allowCompletion","constructor","editor","id","nodeClass","createNode","_define_property","__id","ghostTextNodeKey","lastText","undefined","justRemovedGhostText","justAddedGhostText","$clearGhostText","ghostTextNode","$getNodeByKey","isAttached","remove","handleGhostTextNodeTransform","node","key","getKey","handleGhostTextResponse","text","update","selection","$getSelection","selectionCopy","clone","insertNodes","$setSelection","tag","handleUpdate","props","editorState","prevEditorState","read","$isRangeSelection","isCollapsed","selectedNode","getNodes","at","previousNodeKey","getPreviousSibling","previousNodeIsGhostText","$isSentinelNode","$isTextNode","anchor","offset","modify","selectEnd","promise","then","catch","e","console","error","unmountGhostText","$handleTabCommand","preventDefault","textNode","$createTextNode","replace","mergeRegister","registerNodeTransform","registerUpdateListener","registerCommand","KEY_TAB_COMMAND","COMMAND_PRIORITY_LOW","noop"],"rangeMappings":";;;;;;;;;;;;;;;;;;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AkB,EAAA,MAAA,QAAlD5B,sCAAAA,KAAAA,IAAAA,KAAAA,IAAAA,kCAAsDmC,SAAS;wBACjE,GACA;4BAAEnB,KAAK;wBAAW;wBAEpB;oBACF;gBACF;gBAEA,MAAMoB,UAAU,IAAI,CAACtD,eAAe,CAACK,QAAQgC,aAAaC;gBAC1DgB,QAAQC,IAAI,CAAC9B,yBAAyB+B,KAAK,CAACC,CAAAA,IAAKC,QAAQC,KAAK,CAACF;YACjE;QACF;QAEA,SAASG;YACP,IAAIjD,kBAAkB;gBACpBN,OAAOsB,MAAM,CACX;oBACEX;gBACF,GACA;oBAAEkB,KAAK;gBAAW;YAEtB;QACF;QAEA,SAAS2B,kBAAkBJ,CAAgB;YACzC,IAAI9C,qBAAqB,QAAQC,aAAa,MAAM;gBAClD,OAAO;YACT;YAEA,MAAMK,gBAAgBC,IAAAA,yBAAAA,EAAcP;YACpC,IAAI,CAACM,eAAe;gBAClB,OAAO;YACT;YAEAwC,EAAEK,cAAc;YAEhB,MAAMC,WAAWC,IAAAA,2BAAAA,EAAgBpD;YACjCK,cAAcgD,OAAO,CAACF;YACtBA,SAASV,SAAS;YAClBrC;YACA,OAAO;QACT;QAEA,IAAI,CAAC1B,SAAS,GAAG4E,IAAAA,yBAAAA,EACf7D,OAAO8D,qBAAqB,CAAC5D,WAAWc,+BACxChB,OAAO+D,sBAAsB,CAACjC,eAC9B,IAAI,CAAChC,iBAAiB,GAAGE,OAAOgE,eAAe,CAACC,2BAAAA,EAAiBT,mBAAmBU,gCAAAA,IAAwBC,MAC5GZ;IAEJ;AAiBF;AACA,SAASY;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(): void {\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()[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): void {\n this.__exposeText = exposeText;\n }\n\n setComponentProps(componentProps?: ComponentPropsType): void {\n this.__componentProps = componentProps;\n }\n\n setGetGhostText($getGhostText: GetGhostTextFunction): void {\n this.__$getGhostText = $getGhostText;\n }\n\n setAllowCompletion(allowCompletion?: boolean): void {\n this.__allowCompletion = allowCompletion;\n }\n}\nfunction noop(): void {\n return;\n}\n"],"names":["GhostTextPluginBase","cleanup","_this___cleanup","_this","__cleanup","call","setExposeText","exposeText","__exposeText","setComponentProps","componentProps","__componentProps","setGetGhostText","$getGhostText","__$getGhostText","setAllowCompletion","allowCompletion","__allowCompletion","constructor","editor","id","nodeClass","createNode","_define_property","__id","ghostTextNodeKey","lastText","undefined","justRemovedGhostText","justAddedGhostText","$clearGhostText","ghostTextNode","$getNodeByKey","isAttached","remove","handleGhostTextNodeTransform","node","key","getKey","handleGhostTextResponse","text","update","selection","$getSelection","selectionCopy","clone","insertNodes","$setSelection","tag","handleUpdate","props","editorState","prevEditorState","read","$isRangeSelection","isCollapsed","selectedNode","getNodes","previousNodeKey","getPreviousSibling","previousNodeIsGhostText","$isSentinelNode","$isTextNode","anchor","offset","modify","selectEnd","promise","then","catch","e","console","error","unmountGhostText","$handleTabCommand","preventDefault","textNode","$createTextNode","replace","mergeRegister","registerNodeTransform","registerUpdateListener","registerCommand","KEY_TAB_COMMAND","COMMAND_PRIORITY_LOW","noop"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA4BaA;;;eAAAA;;;;4BAjBN;oCACyB;AAgBzB,MAAMA;IASXC,UAAgB;YACdC,iBAAAC;QAAAD,CAAAA,kBAAA,AAAAC,CAAAA,QAAA,IAAI,AAAJ,EAAKC,SAAS,AAATA,MAAS,QAAdF,oBAAA,KAAA,IAAA,KAAA,IAAAA,gBAAAG,IAAA,CAAAF;IACF;IA+KAG,cAAcC,UAAoB,EAAQ;QACxC,IAAI,CAACC,YAAY,GAAGD;IACtB;IAEAE,kBAAkBC,cAAmC,EAAQ;QAC3D,IAAI,CAACC,gBAAgB,GAAGD;IAC1B;IAEAE,gBAAgBC,aAAmC,EAAQ;QACzD,IAAI,CAACC,eAAe,GAAGD;IACzB;IAEAE,mBAAmBC,eAAyB,EAAQ;QAClD,IAAI,CAACC,iBAAiB,GAAGD;IAC3B;IA3LAE,YACEC,MAAqB,EACrBC,EAAU,EACVP,aAAmC,EACnCQ,SAAoD,EACpDC,UAKuC,EACvCZ,cAAmC,EAEnCH,UAAoB,EACpBS,eAAyB,CACzB;QA3BFO,IAAAA,kBAAA,EAAA,IAAA,EAAQC,QAAR,KAAA;QACAD,IAAAA,kBAAA,EAAA,IAAA,EAAQT,mBAAR,KAAA;QACAS,IAAAA,kBAAA,EAAA,IAAA,EAAQZ,oBAAR,KAAA;QACAY,IAAAA,kBAAA,EAAA,IAAA,EAAQf,gBAA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teditor.TextNode {
|
|
|
62
62
|
static getType() {
|
|
63
63
|
return 'mockEntity';
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
static clone(node) {
|
|
66
|
+
return new MockEntityNode(node.__text, node.__url, node.__key);
|
|
67
|
+
}
|
|
68
|
+
static importJSON(serializedNode) {
|
|
69
|
+
return $createMockEntityNode(serializedNode.text, serializedNode.url);
|
|
70
|
+
}
|
|
71
|
+
get url() {
|
|
72
|
+
const self = this.getLatest();
|
|
73
|
+
return self.__url;
|
|
74
|
+
}
|
|
75
|
+
exportJSON() {
|
|
76
|
+
return {
|
|
77
|
+
...super.exportJSON(),
|
|
78
|
+
type: 'mockEntity',
|
|
79
|
+
url: this.__url,
|
|
80
|
+
version: 1
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
constructor(text, url, key){
|
|
84
|
+
super(text, key);
|
|
85
|
+
(0, _define_property._)(this, "__url", void 0);
|
|
86
|
+
this.__url = url;
|
|
69
87
|
}
|
|
70
88
|
}
|
|
71
89
|
function $createMockEntityNode(text, url) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PasteUnfurlingTestUtils.ts"],"sourcesContent":["import type { LexicalNode } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\nimport type { PasteUnfurlingTransformedPart, PasteUnfurlingTransformResult } from '..';\n\nexport class MockClipboardEvent extends Event implements ClipboardEvent {\n clipboardData: DataTransfer | null = null;\n}\n\nexport function createPasteEvent(data: { mimeType: string; value: string }[]): MockClipboardEvent {\n const event = new MockClipboardEvent('paste');\n\n event.clipboardData = {\n types: [data.map(({ mimeType }) => mimeType)],\n getData: (format: string) => {\n const item = data.find(({ mimeType }) => mimeType === format);\n if (item) {\n return item.value;\n }\n return '';\n },\n } as unknown as DataTransfer;\n\n return event;\n}\n\nexport class MockEntityNode extends TextNode {\n
|
|
1
|
+
{"version":3,"sources":["PasteUnfurlingTestUtils.ts"],"sourcesContent":["import type { LexicalNode, NodeKey, SerializedTextNode } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\nimport type { PasteUnfurlingTransformedPart, PasteUnfurlingTransformResult } from '..';\n\nexport class MockClipboardEvent extends Event implements ClipboardEvent {\n clipboardData: DataTransfer | null = null;\n}\n\nexport function createPasteEvent(data: { mimeType: string; value: string }[]): MockClipboardEvent {\n const event = new MockClipboardEvent('paste');\n\n event.clipboardData = {\n types: [data.map(({ mimeType }) => mimeType)],\n getData: (format: string) => {\n const item = data.find(({ mimeType }) => mimeType === format);\n if (item) {\n return item.value;\n }\n return '';\n },\n } as unknown as DataTransfer;\n\n return event;\n}\n\nexport interface SerializedMockEntityNode extends SerializedTextNode {\n url: string;\n}\n\nexport class MockEntityNode extends TextNode {\n __url: string;\n\n constructor(text: string, url: string, key?: NodeKey) {\n super(text, key);\n this.__url = url;\n }\n\n static getType(): string {\n return 'mockEntity';\n }\n\n static clone(node: MockEntityNode): MockEntityNode {\n return new MockEntityNode(node.__text, node.__url, node.__key);\n }\n\n static importJSON(serializedNode: SerializedMockEntityNode): MockEntityNode {\n return $createMockEntityNode(serializedNode.text, serializedNode.url);\n }\n\n get url(): string {\n const self = this.getLatest();\n return self.__url;\n }\n\n exportJSON(): SerializedMockEntityNode {\n return {\n ...super.exportJSON(),\n type: 'mockEntity',\n url: this.__url,\n version: 1,\n };\n }\n}\n\nexport type ExtraDataType = { url: string };\n\nexport function $createMockEntityNode(text: string, url: string): MockEntityNode {\n return new MockEntityNode(text, url);\n}\n\nexport function $isMockEntityNode(node: LexicalNode | null | undefined): node is MockEntityNode {\n return node instanceof MockEntityNode;\n}\n\nexport const parseLinkPreview = (event: ClipboardEvent): PasteUnfurlingTransformResult<ExtraDataType, {}> => {\n let previewData;\n try {\n const previewDataString = event.clipboardData?.getData('text/link-preview');\n if (previewDataString === undefined || previewDataString === '') {\n return { handled: false };\n }\n\n previewData = JSON.parse(previewDataString);\n } catch (e) {\n return { handled: false };\n }\n\n const title: string | undefined = previewData.title;\n const url: string | undefined = previewData.url;\n if (!title || !url) {\n return { handled: false };\n }\n\n return {\n handled: true,\n transformedParts: [{ type: 'entity', value: { text: title, data: { url } } }],\n };\n};\nconst urlRegex = /(\\b(?:https?):\\/\\/[^\\s]+)/gi;\n\nexport const parseLink = (event: ClipboardEvent): PasteUnfurlingTransformResult<ExtraDataType, {}> => {\n const text = event.clipboardData?.getData('text/plain');\n if (!text) {\n return {\n handled: false,\n };\n }\n\n const parts = text.split(urlRegex);\n // If an entity was found, parts will be at least 3 elements long\n if (parts.length < 3) {\n return { handled: false };\n }\n const transformedParts = parts\n .map((str, i) => {\n if (i % 2 === 0) {\n return { type: 'text', value: str };\n } else {\n return {\n type: 'entity',\n value: { text: str, data: { url: str } },\n };\n }\n })\n // Filter out all the nulls for empty strings\n .filter(node => node !== null) as PasteUnfurlingTransformedPart<ExtraDataType, {}>[];\n\n return { handled: true, transformedParts };\n};\n\n// A transform can be async in case it needs to fetch data from a server.\nexport const parseEntity = async (event: ClipboardEvent): Promise<PasteUnfurlingTransformResult<ExtraDataType, {}>> => {\n const text = event.clipboardData?.getData('text/plain');\n if (!text) {\n return {\n handled: false,\n };\n }\n\n // Assume entities come in the syntax <entity>title</entity>\n const re = /<entity[^>]*>([^<]*)<\\/entity>/g;\n const parts = text.split(re);\n // If an entity was found, parts will be at least 3 elements long\n if (parts.length < 3) {\n return { handled: false };\n }\n\n // Even elements are text, odd elements are entities\n // [\"\", entity, \"\", entity, \"\", ...]\n const transformedParts = parts\n .map((str, i) => {\n if (i % 2 === 0) {\n return { type: 'text', value: str };\n } else {\n return {\n type: 'entity',\n value: { text: str, data: { url: str } },\n };\n }\n })\n // Filter out all the nulls for empty strings\n .filter(node => node !== null) as PasteUnfurlingTransformedPart<ExtraDataType, {}>[];\n\n return { handled: true, transformedParts };\n};\n"],"names":["$createMockEntityNode","$isMockEntityNode","MockClipboardEvent","MockEntityNode","createPasteEvent","parseEntity","parseLink","parseLinkPreview","Event","clipboardData","data","event","types","map","mimeType","getData","format","item","find","value","TextNode","getType","clone","node","__text","__url","__key","importJSON","serializedNode","text","url","self","getLatest","exportJSON","type","version","constructor","key","previewData","previewDataString","undefined","handled","JSON","parse","e","title","transformedParts","urlRegex","parts","split","length","str","i","filter","re"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAkEgBA,qBAAAA;eAAAA;;IAIAC,iBAAAA;eAAAA;;IAlEHC,kBAAAA;eAAAA;;IAyBAC,cAAAA;eAAAA;;IArBGC,gBAAAA;eAAAA;;IA2HHC,WAAAA;eAAAA;;IA/BAC,SAAAA;eAAAA;;IA1BAC,gBAAAA;eAAAA;;;;4BAzEY;AAGlB,MAAML,2BAA2BM;;;QACtCC,IAAAA,kBAAAA,EAAAA,IAAAA,EAAAA,iBAAqC;;AACvC;AAEO,SAASL,iBAAiBM,IAA2C;IAC1E,MAAMC,QAAQ,IAAIT,mBAAmB;IAErCS,MAAMF,aAAa,GAAG;QACpBG,OAAO;YAACF,KAAKG,GAAG,CAAC,CAAC,EAAEC,QAAQ,EAAE,GAAKA;SAAU;QAC7CC,SAAS,CAACC;YACR,MAAMC,OAAOP,KAAKQ,IAAI,CAAC,CAAC,EAAEJ,QAAQ,EAAE,GAAKA,aAAaE;YACtD,IAAIC,MAAM;gBACR,OAAOA,KAAKE,KAAK;YACnB;YACA,OAAO;QACT;IACF;IAEA,OAAOR;AACT;AAMO,MAAMR,uBAAuBiB,oBAAAA;IAQlC,OAAOC,UAAkB;QACvB,OAAO;IACT;IAEA,OAA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AMa,KAAK;IACX,MAAMN,QAAQnB,KAAKoB,KAAK,CAACK;IACzB,iEAAiE;IACjE,IAAIN,MAAME,MAAM,GAAG,GAAG;QACpB,OAAO;YAAET,SAAS;QAAM;IAC1B;IAEA,oDAAoD;IACpD,oCAAoC;IACpC,MAAMK,mBAAmBE,MACtBnC,GAAG,CAAC,CAACsC,KAAKC;QACT,IAAIA,IAAI,MAAM,GAAG;YACf,OAAO;gBAAElB,MAAM;gBAAQf,OAAOgC;YAAI;QACpC,OAAO;YACL,OAAO;gBACLjB,MAAM;gBACNf,OAAO;oBAAEU,MAAMsB;oBAAKzC,MAAM;wBAAEoB,KAAKqB;oBAAI;gBAAE;YACzC;QACF;IACF,GACA,6CAA6C;KAC5CE,MAAM,CAAC9B,CAAAA,OAAQA,SAAS;IAE3B,OAAO;QAAEkB,SAAS;QAAMK;IAAiB;AAC3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-copilot/chat-input-plugins",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "A Fluent AI package for non-react specific chat input plugins.",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@fluentui-copilot/text-editor": "^0.3.
|
|
15
|
+
"@fluentui-copilot/text-editor": "^0.3.4",
|
|
16
16
|
"@swc/helpers": "^0.5.1"
|
|
17
17
|
},
|
|
18
18
|
"beachball": {
|