@fluentui-copilot/chat-input-plugins 0.3.2 → 0.3.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 +45 -1
- package/CHANGELOG.md +21 -2
- package/dist/index.d.ts +1 -0
- package/lib/BasicFunctionality/SentinelNode.js +3 -0
- package/lib/BasicFunctionality/SentinelNode.js.map +1 -1
- package/lib/BasicFunctionality/SentinelNodeHandlers.js.map +1 -1
- package/lib/BasicFunctionality/index.js +2 -2
- package/lib/BasicFunctionality/index.js.map +1 -1
- package/lib/ChatInputEntity/index.js +1 -2
- package/lib/ChatInputEntity/index.js.map +1 -1
- package/lib/GhostText/index.js +1 -1
- package/lib/GhostText/index.js.map +1 -1
- package/lib/ImperativeControl/index.js +1 -1
- package/lib/ImperativeControl/index.js.map +1 -1
- package/lib/ManualGhostText/index.js +1 -1
- package/lib/ManualGhostText/index.js.map +1 -1
- package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js +163 -0
- package/lib/PasteUnfurling/PasteUnfurlingTestUtils.js.map +1 -0
- package/lib/PasteUnfurling/index.js +1 -2
- package/lib/PasteUnfurling/index.js.map +1 -1
- package/lib-commonjs/BasicFunctionality/SentinelNode.js +3 -0
- package/lib-commonjs/BasicFunctionality/SentinelNode.js.map +1 -1
- package/lib-commonjs/BasicFunctionality/SentinelNodeHandlers.js.map +1 -1
- package/lib-commonjs/BasicFunctionality/index.js +25 -3
- package/lib-commonjs/BasicFunctionality/index.js.map +1 -1
- package/lib-commonjs/ChatInputEntity/index.js +7 -3
- package/lib-commonjs/ChatInputEntity/index.js.map +1 -1
- package/lib-commonjs/GhostText/index.js +7 -2
- package/lib-commonjs/GhostText/index.js.map +1 -1
- package/lib-commonjs/ImperativeControl/index.js +7 -2
- package/lib-commonjs/ImperativeControl/index.js.map +1 -1
- package/lib-commonjs/ManualGhostText/index.js +7 -2
- package/lib-commonjs/ManualGhostText/index.js.map +1 -1
- package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js +197 -0
- package/lib-commonjs/PasteUnfurling/PasteUnfurlingTestUtils.js.map +1 -0
- package/lib-commonjs/PasteUnfurling/index.js +7 -3
- package/lib-commonjs/PasteUnfurling/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,51 @@
|
|
|
2
2
|
"name": "@fluentui-copilot/chat-input-plugins",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Wed,
|
|
5
|
+
"date": "Wed, 18 Dec 2024 08:54:34 GMT",
|
|
6
|
+
"tag": "@fluentui-copilot/chat-input-plugins_v0.3.4",
|
|
7
|
+
"version": "0.3.4",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "makotom@microsoft.com",
|
|
12
|
+
"package": "@fluentui-copilot/chat-input-plugins",
|
|
13
|
+
"commit": "cc179462507d13546b93c6330be325014286998c",
|
|
14
|
+
"comment": "chore: Banning * exports."
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Tue, 10 Dec 2024 20:22:06 GMT",
|
|
21
|
+
"tag": "@fluentui-copilot/chat-input-plugins_v0.3.3",
|
|
22
|
+
"version": "0.3.3",
|
|
23
|
+
"comments": {
|
|
24
|
+
"patch": [
|
|
25
|
+
{
|
|
26
|
+
"author": "owcampbe@microsoft.com",
|
|
27
|
+
"package": "@fluentui-copilot/chat-input-plugins",
|
|
28
|
+
"commit": "edf4a5e558c8f6f3fb45451a9557832c059d4e5a",
|
|
29
|
+
"comment": "chore: Add importJSON implementation for SentinelNode."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"author": "owcampbe@microsoft.com",
|
|
33
|
+
"package": "@fluentui-copilot/chat-input-plugins",
|
|
34
|
+
"commit": "b4a502d9b602517a583dd25b14d651828270fc1d",
|
|
35
|
+
"comment": "chore: Add paste unfurling tests."
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"none": [
|
|
39
|
+
{
|
|
40
|
+
"author": "owcampbe@microsoft.com",
|
|
41
|
+
"package": "@fluentui-copilot/chat-input-plugins",
|
|
42
|
+
"commit": "c5ad8962a0e32fedd5d915d15107f0e1398b7aae",
|
|
43
|
+
"comment": "chore: Applying package updates."
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"date": "Wed, 20 Nov 2024 23:38:56 GMT",
|
|
6
50
|
"tag": "@fluentui-copilot/chat-input-plugins_v0.3.2",
|
|
7
51
|
"version": "0.3.2",
|
|
8
52
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
# Change Log - @fluentui-copilot/chat-input-plugins
|
|
2
2
|
|
|
3
|
-
This log was last generated on Wed,
|
|
3
|
+
This log was last generated on Wed, 18 Dec 2024 08:54:34 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [0.3.4](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.3.4)
|
|
8
|
+
|
|
9
|
+
Wed, 18 Dec 2024 08:54:34 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.3.3..@fluentui-copilot/chat-input-plugins_v0.3.4)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- chore: Banning * exports. ([PR #2477](https://github.com/microsoft/fluentai/pull/2477) by makotom@microsoft.com)
|
|
15
|
+
|
|
16
|
+
## [0.3.3](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.3.3)
|
|
17
|
+
|
|
18
|
+
Tue, 10 Dec 2024 20:22:06 GMT
|
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.3.2..@fluentui-copilot/chat-input-plugins_v0.3.3)
|
|
20
|
+
|
|
21
|
+
### Patches
|
|
22
|
+
|
|
23
|
+
- chore: Add importJSON implementation for SentinelNode. ([PR #2438](https://github.com/microsoft/fluentai/pull/2438) by owcampbe@microsoft.com)
|
|
24
|
+
- chore: Add paste unfurling tests. ([PR #2417](https://github.com/microsoft/fluentai/pull/2417) by owcampbe@microsoft.com)
|
|
25
|
+
|
|
7
26
|
## [0.3.2](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.3.2)
|
|
8
27
|
|
|
9
|
-
Wed, 20 Nov 2024 23:38:
|
|
28
|
+
Wed, 20 Nov 2024 23:38:56 GMT
|
|
10
29
|
[Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.3.1..@fluentui-copilot/chat-input-plugins_v0.3.2)
|
|
11
30
|
|
|
12
31
|
### Patches
|
package/dist/index.d.ts
CHANGED
|
@@ -188,6 +188,7 @@ export declare class SentinelNode extends TextNode {
|
|
|
188
188
|
createDOM(config: EditorConfig): HTMLElement;
|
|
189
189
|
isToken(): boolean;
|
|
190
190
|
exportJSON(): SerializedTextNode;
|
|
191
|
+
static importJSON(serializedNode: SerializedTextNode): SentinelNode;
|
|
191
192
|
}
|
|
192
193
|
|
|
193
194
|
export { }
|
|
@@ -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\nexport function $createSentinelNode(key?: NodeKey) {\n return new SentinelNode(key);\n}\n\nexport function $isSentinelNode(node: LexicalNode | null): node is SentinelNode {\n return node instanceof SentinelNode;\n}\n"],"names":["TextNode","SENTINEL_VALUE","SentinelNode","getType","clone","node","__key","createDOM","config","element","ariaHidden","isToken","exportJSON","type","version","
|
|
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":["TextNode","SENTINEL_VALUE","SentinelNode","getType","clone","node","__key","createDOM","config","element","ariaHidden","isToken","exportJSON","type","version","importJSON","serializedNode","$createSentinelNode","constructor","key","$isSentinelNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,QAAQ,QAAQ,gCAAgC;AAEzD,6DAA6D;AAC7D,mFAAmF;AACnF,wHAAwH;AACxH,6GAA6G;AAC7G,OAAO,MAAMC,iBAAiB,eAAe;AAE7C,OAAO,MAAMC,qBAAqBF;IAKhC,OAAOG,UAAU;QACf,OAAO;IACT;IACA,OAAOC,MAAMC,IAAkB,EAAE;QAC/B,OAAO,IAAIH,aAAaG,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,OAAOC;IACT;IA/BAC,YAAYC,GAAa,CAAE;QACzB,KAAK,CAAClB,gBAAgBkB;IACxB;AA8BF;AAEA,OAAO,SAASF,oBAAoBE,GAAa;IAC/C,OAAO,IAAIjB,aAAaiB;AAC1B;AAEA,OAAO,SAASC,gBAAgBf,IAAwB;IACtD,OAAOA,gBAAgBH;AACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["SentinelNodeHandlers.ts"],"sourcesContent":["import {\n $getLeafNodes,\n $getNodeByKey,\n $getRoot,\n $getSelection,\n $isRangeSelection,\n $normalizeSelection__EXPERIMENTAL,\n $setSelection,\n
|
|
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":["$getLeafNodes","$getNodeByKey","$getRoot","$getSelection","$isRangeSelection","$normalizeSelection__EXPERIMENTAL","$setSelection","mergeRegister","$isSentinelNode","$createSentinelNode","SentinelNode","registerSentinelNodeHandlers","editor","sentinelNodeUpdateHandler","editorState","read","leaves","length","lastNode","lastNodeKey","getKey","update","insertAfter","discrete","tag","previous","getPreviousSibling","isSelected","selection","isCollapsed","anchor","offset","selectStart","selectionChanged","newSelection","clone","getNode","set","focus","registerUpdateListener","registerNodeTransform","node","getNextSibling","remove"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SACEA,aAAa,EACbC,aAAa,EACbC,QAAQ,EACRC,aAAa,EACbC,iBAAiB,EACjBC,iCAAiC,EACjCC,aAAa,EACbC,aAAa,QACR,gCAAgC;AACvC,SAASC,eAAe,EAAEC,mBAAmB,EAAEC,YAAY,QAAQ,iBAAiB;AAEpF,OAAO,SAASC,6BAA6BC,MAAqB;IAChE,qEAAqE;IACrE,+CAA+C;IAC/C,4FAA4F;IAC5F,qGAAqG;IACrG,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C,aAAaI,KAAK,CAACF,OAAO,OAAOlB,YAAYgB,aAAaI,KAAK,CAACP,MAAM,GAAG,GAAG;oBAC9EG,aAAaI,KAAK,CAACD,GAAG,CAAClB,aAAa,GAAG;oBACvCc,mBAAmB;gBACrB;gBAEA,IAAIA,kBAAkB;oBACpBrB,OAAOS,MAAM,CAAC;wBACZ,IAAIpB,cAAckB,iBAAiB,MAAM;4BACvCb,cAAcD,kCAAkC6B;wBAClD;oBACF;gBACF;YACF;QACF;IACF;IAEA,OAAO3B,cACLK,OAAO2B,sBAAsB,CAAC1B,4BAC9BD,OAAO4B,qBAAqB,CAAC9B,cAAc+B,CAAAA;QACzC,IAAI,CAACA,KAAKf,kBAAkB,MAAMe,KAAKC,cAAc,IAAI;YACvDD,KAAKE,MAAM;YACX;QACF;IACF;AAEJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { BasicFunctionalityBase } from './BasicFunctionality.base';
|
|
2
|
+
export { $createSentinelNode, $isSentinelNode, SENTINEL_VALUE, SentinelNode } from './SentinelNode';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { IBasicFunctionalityBase } from './BasicFunctionality.base';\nexport { BasicFunctionalityBase } from './BasicFunctionality.base';\nexport { $createSentinelNode, $isSentinelNode, SENTINEL_VALUE, SentinelNode } from './SentinelNode';\n"],"names":["BasicFunctionalityBase","$createSentinelNode","$isSentinelNode","SENTINEL_VALUE","SentinelNode"],"rangeMappings":";","mappings":"AACA,SAASA,sBAAsB,QAAQ,4BAA4B;AACnE,SAASC,mBAAmB,EAAEC,eAAe,EAAEC,cAAc,EAAEC,YAAY,QAAQ,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { ChatInputEntityData, ChatInputEntityPluginProps, IChatInputEntityPluginBase, IEntityNode } from './ChatInputEntityPlugin.types';\nexport { ChatInputEntityPluginBase } from './ChatInputEntityPlugin.base';\n"],"names":["ChatInputEntityPluginBase"],"rangeMappings":"","mappings":"AACA,SAASA,yBAAyB,QAAQ,+BAA+B"}
|
package/lib/GhostText/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { GhostTextPluginBase } from './GhostText.base';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { GetGhostTextFunction, IGhostTextNode } from './GhostText.base';\nexport { GhostTextPluginBase } from './GhostText.base';\n"],"names":["GhostTextPluginBase"],"rangeMappings":"","mappings":"AACA,SAASA,mBAAmB,QAAQ,mBAAmB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { ImperativeControlBase } from './ImperativeControl.base';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { IImperativeControlBase } from './ImperativeControl.base';\nexport { ImperativeControlBase } from './ImperativeControl.base';\n"],"names":["ImperativeControlBase"],"rangeMappings":"","mappings":"AACA,SAASA,qBAAqB,QAAQ,2BAA2B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { ManualGhostTextBase } from './ManualGhostText.base';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { IManualGhostTextBase } from './ManualGhostText.base';\nexport { ManualGhostTextBase } from './ManualGhostText.base';\n"],"names":["ManualGhostTextBase"],"rangeMappings":"","mappings":"AACA,SAASA,mBAAmB,QAAQ,yBAAyB"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
+
import { TextNode } from '@fluentui-copilot/text-editor';
|
|
3
|
+
export class MockClipboardEvent extends Event {
|
|
4
|
+
constructor(...args) {
|
|
5
|
+
super(...args);
|
|
6
|
+
_define_property(this, "clipboardData", null);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
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;
|
|
26
|
+
}
|
|
27
|
+
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
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function $createMockEntityNode(text, url) {
|
|
38
|
+
return new MockEntityNode(text, url);
|
|
39
|
+
}
|
|
40
|
+
export function $isMockEntityNode(node) {
|
|
41
|
+
return node instanceof MockEntityNode;
|
|
42
|
+
}
|
|
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
|
+
};
|
|
52
|
+
}
|
|
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
|
+
return {
|
|
63
|
+
handled: false
|
|
64
|
+
};
|
|
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
|
+
};
|
|
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) {
|
|
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);
|
|
114
|
+
return {
|
|
115
|
+
handled: true,
|
|
116
|
+
transformedParts
|
|
117
|
+
};
|
|
118
|
+
};
|
|
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) {
|
|
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);
|
|
158
|
+
return {
|
|
159
|
+
handled: true,
|
|
160
|
+
transformedParts
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=PasteUnfurlingTestUtils.js.map
|
|
@@ -0,0 +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 }[]) {\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 url: string;\n\n constructor(text: string, url: string) {\n super(text);\n this.url = url;\n }\n\n static getType(): string {\n return 'mockEntity';\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","constructor","text","url","$createMockEntityNode","$isMockEntityNode","node","parseLinkPreview","previewData","previewDataString","undefined","handled","JSON","parse","e","title","transformedParts","type","urlRegex","parseLink","parts","split","length","str","i","filter","parseEntity","re"],"rangeMappings":";;;;;;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aAAa,cAAnBG,2CAAAA,qBAAqBI,OAAO,CAAC;IAC1C,IAAI,CAACQ,MAAM;QACT,OAAO;YACLS,SAAS;QACX;IACF;IAEA,4DAA4D;IAC5D,MAAMgB,KAAK;IACX,MAAMP,QAAQlB,KAAKmB,KAAK,CAACM;IACzB,iEAAiE;IACjE,IAAIP,MAAME,MAAM,GAAG,GAAG;QACpB,OAAO;YAAEX,SAAS;QAAM;IAC1B;IAEA,oDAAoD;IACpD,oCAAoC;IACpC,MAAMK,mBAAmBI,MACtB5B,GAAG,CAAC,CAAC+B,KAAKC;QACT,IAAIA,IAAI,MAAM,GAAG;YACf,OAAO;gBAAEP,MAAM;gBAAQnB,OAAOyB;YAAI;QACpC,OAAO;YACL,OAAO;gBACLN,MAAM;gBACNnB,OAAO;oBAAEI,MAAMqB;oBAAKlC,MAAM;wBAAEc,KAAKoB;oBAAI;gBAAE;YACzC;QACF;IACF,EACA,6CAA6C;KAC5CE,MAAM,CAACnB,CAAAA,OAAQA,SAAS;IAE3B,OAAO;QAAEK,SAAS;QAAMK;IAAiB;AAC3C,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export { registerPasteUnfurlingPlugin } from './PasteUnfurling.base';\nexport type { PasteUnfurlingPluginBaseProps, PasteUnfurlingTransformFunction, PasteUnfurlingTransformResult, PasteUnfurlingTransformedPart } from './PasteUnfurling.types';\n"],"names":["registerPasteUnfurlingPlugin"],"rangeMappings":"","mappings":"AAAA,SAASA,4BAA4B,QAAQ,wBAAwB"}
|
|
@@ -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\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","constructor","key"],"rangeMappings":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["SentinelNodeHandlers.ts"],"sourcesContent":["import {\n $getLeafNodes,\n $getNodeByKey,\n $getRoot,\n $getSelection,\n $isRangeSelection,\n $normalizeSelection__EXPERIMENTAL,\n $setSelection,\n
|
|
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,M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A;QACF,IAAA,CAAAA,KAAAC,kBAAA,MAAAD,KAAAE,cAAA,IAAA;YAEJF,KAAAG,MAAA"}
|
|
@@ -2,7 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
$createSentinelNode: function() {
|
|
13
|
+
return _SentinelNode.$createSentinelNode;
|
|
14
|
+
},
|
|
15
|
+
$isSentinelNode: function() {
|
|
16
|
+
return _SentinelNode.$isSentinelNode;
|
|
17
|
+
},
|
|
18
|
+
BasicFunctionalityBase: function() {
|
|
19
|
+
return _BasicFunctionalitybase.BasicFunctionalityBase;
|
|
20
|
+
},
|
|
21
|
+
SENTINEL_VALUE: function() {
|
|
22
|
+
return _SentinelNode.SENTINEL_VALUE;
|
|
23
|
+
},
|
|
24
|
+
SentinelNode: function() {
|
|
25
|
+
return _SentinelNode.SentinelNode;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const _BasicFunctionalitybase = require("./BasicFunctionality.base");
|
|
29
|
+
const _SentinelNode = require("./SentinelNode");
|
|
8
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { IBasicFunctionalityBase } from './BasicFunctionality.base';\nexport { BasicFunctionalityBase } from './BasicFunctionality.base';\nexport { $createSentinelNode, $isSentinelNode, SENTINEL_VALUE, SentinelNode } from './SentinelNode';\n"],"names":["$createSentinelNode","$isSentinelNode","BasicFunctionalityBase","SENTINEL_VALUE","SentinelNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAESA,mBAAmB;eAAnBA,iCAAmB;;IAAEC,eAAe;eAAfA,6BAAe;;IADpCC,sBAAsB;eAAtBA,8CAAsB;;IACgBC,cAAc;eAAdA,4BAAc;;IAAEC,YAAY;eAAZA,0BAAY;;;wCADpC;8BAC4C"}
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "ChatInputEntityPluginBase", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _ChatInputEntityPluginbase.ChatInputEntityPluginBase;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _ChatInputEntityPluginbase = require("./ChatInputEntityPlugin.base");
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { ChatInputEntityData, ChatInputEntityPluginProps, IChatInputEntityPluginBase, IEntityNode } from './ChatInputEntityPlugin.types';\nexport { ChatInputEntityPluginBase } from './ChatInputEntityPlugin.base';\n"],"names":["ChatInputEntityPluginBase"],"rangeMappings":";;;;;;;;;;","mappings":";;;;+BACSA;;;eAAAA,oDAAyB;;;2CAAQ"}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(exports, "GhostTextPluginBase", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _GhostTextbase.GhostTextPluginBase;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _GhostTextbase = require("./GhostText.base");
|
|
7
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { GetGhostTextFunction, IGhostTextNode } from './GhostText.base';\nexport { GhostTextPluginBase } from './GhostText.base';\n"],"names":["GhostTextPluginBase"],"rangeMappings":";;;;;;;;;;","mappings":";;;;+BACSA;;;eAAAA,kCAAmB;;;+BAAQ"}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(exports, "ImperativeControlBase", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _ImperativeControlbase.ImperativeControlBase;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _ImperativeControlbase = require("./ImperativeControl.base");
|
|
7
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { IImperativeControlBase } from './ImperativeControl.base';\nexport { ImperativeControlBase } from './ImperativeControl.base';\n"],"names":["ImperativeControlBase"],"rangeMappings":";;;;;;;;;;","mappings":";;;;+BACSA;;;eAAAA,4CAAqB;;;uCAAQ"}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(exports, "ManualGhostTextBase", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _ManualGhostTextbase.ManualGhostTextBase;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _ManualGhostTextbase = require("./ManualGhostText.base");
|
|
7
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export type { IManualGhostTextBase } from './ManualGhostText.base';\nexport { ManualGhostTextBase } from './ManualGhostText.base';\n"],"names":["ManualGhostTextBase"],"rangeMappings":";;;;;;;;;;","mappings":";;;;+BACSA;;;eAAAA,wCAAmB;;;qCAAQ"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
$createMockEntityNode: function() {
|
|
13
|
+
return $createMockEntityNode;
|
|
14
|
+
},
|
|
15
|
+
$isMockEntityNode: function() {
|
|
16
|
+
return $isMockEntityNode;
|
|
17
|
+
},
|
|
18
|
+
MockClipboardEvent: function() {
|
|
19
|
+
return MockClipboardEvent;
|
|
20
|
+
},
|
|
21
|
+
MockEntityNode: function() {
|
|
22
|
+
return MockEntityNode;
|
|
23
|
+
},
|
|
24
|
+
createPasteEvent: function() {
|
|
25
|
+
return createPasteEvent;
|
|
26
|
+
},
|
|
27
|
+
parseEntity: function() {
|
|
28
|
+
return parseEntity;
|
|
29
|
+
},
|
|
30
|
+
parseLink: function() {
|
|
31
|
+
return parseLink;
|
|
32
|
+
},
|
|
33
|
+
parseLinkPreview: function() {
|
|
34
|
+
return parseLinkPreview;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const _define_property = require("@swc/helpers/_/_define_property");
|
|
38
|
+
const _texteditor = require("@fluentui-copilot/text-editor");
|
|
39
|
+
class MockClipboardEvent extends Event {
|
|
40
|
+
constructor(...args){
|
|
41
|
+
super(...args);
|
|
42
|
+
(0, _define_property._)(this, "clipboardData", null);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function createPasteEvent(data) {
|
|
46
|
+
const event = new MockClipboardEvent('paste');
|
|
47
|
+
event.clipboardData = {
|
|
48
|
+
types: [
|
|
49
|
+
data.map(({ mimeType })=>mimeType)
|
|
50
|
+
],
|
|
51
|
+
getData: (format)=>{
|
|
52
|
+
const item = data.find(({ mimeType })=>mimeType === format);
|
|
53
|
+
if (item) {
|
|
54
|
+
return item.value;
|
|
55
|
+
}
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return event;
|
|
60
|
+
}
|
|
61
|
+
class MockEntityNode extends _texteditor.TextNode {
|
|
62
|
+
static getType() {
|
|
63
|
+
return 'mockEntity';
|
|
64
|
+
}
|
|
65
|
+
constructor(text, url){
|
|
66
|
+
super(text);
|
|
67
|
+
(0, _define_property._)(this, "url", void 0);
|
|
68
|
+
this.url = url;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function $createMockEntityNode(text, url) {
|
|
72
|
+
return new MockEntityNode(text, url);
|
|
73
|
+
}
|
|
74
|
+
function $isMockEntityNode(node) {
|
|
75
|
+
return node instanceof MockEntityNode;
|
|
76
|
+
}
|
|
77
|
+
const parseLinkPreview = (event)=>{
|
|
78
|
+
let previewData;
|
|
79
|
+
try {
|
|
80
|
+
var _event_clipboardData;
|
|
81
|
+
const previewDataString = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/link-preview');
|
|
82
|
+
if (previewDataString === undefined || previewDataString === '') {
|
|
83
|
+
return {
|
|
84
|
+
handled: false
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
previewData = JSON.parse(previewDataString);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return {
|
|
90
|
+
handled: false
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const title = previewData.title;
|
|
94
|
+
const url = previewData.url;
|
|
95
|
+
if (!title || !url) {
|
|
96
|
+
return {
|
|
97
|
+
handled: false
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
handled: true,
|
|
102
|
+
transformedParts: [
|
|
103
|
+
{
|
|
104
|
+
type: 'entity',
|
|
105
|
+
value: {
|
|
106
|
+
text: title,
|
|
107
|
+
data: {
|
|
108
|
+
url
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
const urlRegex = /(\b(?:https?):\/\/[^\s]+)/gi;
|
|
116
|
+
const parseLink = (event)=>{
|
|
117
|
+
var _event_clipboardData;
|
|
118
|
+
const text = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/plain');
|
|
119
|
+
if (!text) {
|
|
120
|
+
return {
|
|
121
|
+
handled: false
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const parts = text.split(urlRegex);
|
|
125
|
+
// If an entity was found, parts will be at least 3 elements long
|
|
126
|
+
if (parts.length < 3) {
|
|
127
|
+
return {
|
|
128
|
+
handled: false
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const transformedParts = parts.map((str, i)=>{
|
|
132
|
+
if (i % 2 === 0) {
|
|
133
|
+
return {
|
|
134
|
+
type: 'text',
|
|
135
|
+
value: str
|
|
136
|
+
};
|
|
137
|
+
} else {
|
|
138
|
+
return {
|
|
139
|
+
type: 'entity',
|
|
140
|
+
value: {
|
|
141
|
+
text: str,
|
|
142
|
+
data: {
|
|
143
|
+
url: str
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}) // Filter out all the nulls for empty strings
|
|
149
|
+
.filter((node)=>node !== null);
|
|
150
|
+
return {
|
|
151
|
+
handled: true,
|
|
152
|
+
transformedParts
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
const parseEntity = async (event)=>{
|
|
156
|
+
var _event_clipboardData;
|
|
157
|
+
const text = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text/plain');
|
|
158
|
+
if (!text) {
|
|
159
|
+
return {
|
|
160
|
+
handled: false
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
// Assume entities come in the syntax <entity>title</entity>
|
|
164
|
+
const re = /<entity[^>]*>([^<]*)<\/entity>/g;
|
|
165
|
+
const parts = text.split(re);
|
|
166
|
+
// If an entity was found, parts will be at least 3 elements long
|
|
167
|
+
if (parts.length < 3) {
|
|
168
|
+
return {
|
|
169
|
+
handled: false
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
// Even elements are text, odd elements are entities
|
|
173
|
+
// ["", entity, "", entity, "", ...]
|
|
174
|
+
const transformedParts = parts.map((str, i)=>{
|
|
175
|
+
if (i % 2 === 0) {
|
|
176
|
+
return {
|
|
177
|
+
type: 'text',
|
|
178
|
+
value: str
|
|
179
|
+
};
|
|
180
|
+
} else {
|
|
181
|
+
return {
|
|
182
|
+
type: 'entity',
|
|
183
|
+
value: {
|
|
184
|
+
text: str,
|
|
185
|
+
data: {
|
|
186
|
+
url: str
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}) // Filter out all the nulls for empty strings
|
|
192
|
+
.filter((node)=>node !== null);
|
|
193
|
+
return {
|
|
194
|
+
handled: true,
|
|
195
|
+
transformedParts
|
|
196
|
+
};
|
|
197
|
+
}; //# sourceMappingURL=PasteUnfurlingTestUtils.js.map
|
|
@@ -0,0 +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 }[]) {\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 url: string;\n\n constructor(text: string, url: string) {\n super(text);\n this.url = url;\n }\n\n static getType(): string {\n return 'mockEntity';\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","item","find","value","TextNode","getType","constructor","url","text","_define_property","node","_event_clipboardData","undefined","previewDataString","handled","JSON","parse","title","previewData","transformedParts","urlRegex","parts","split","length","str","i","filter","re"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IA0CAA,qBAAA;eAAAA;;IAIAC,iBAAA;eAAAA;;IA1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;;;;;;;;;;AAE/B;AACA,MAAMC,WAAW;AAEV,MAAM7B,YAAYK,CAAAA;;UACvBY,OAAMA,CAAAA,uBAAOZ,MAAAA,aAAMF,MAAa,QAAAiB,yBAAnBf,KAAAA,IAAAA,KAAAA,IAAAA,qBAAAA,OAAqBI,CAAAA;QAClC,CAAAQ,MAAKA;eACH;qBACEM;;;UAIJO,QAAMA,KAAQb,KAAKc,CAAAA;qEACnB;QACAD,MAAIA,MAAME,GAAM,GAAG;eACjB;qBAAST;;;UAEXK,mBAAMA,MAAmBE,GACtBvB,CAAAA,CAAG0B,KAAEA;YACJC,IAAIA,MAAI,GAAA;mBACN;;;;eACF;mBACE;;;;;;;;;;OAKJ,6CACA;WACCC,CAAAA,CAAAA,OAAOhB,SAAQA;WAElB;iBAASI;;;AACX;AAGO,MAAMxB,cAAc,OAAAM;;UACzBY,OAAMA,CAAAA,uBAAOZ,MAAAA,aAAMF,MAAa,QAAAiB,yBAAnBf,KAAAA,IAAAA,KAAAA,IAAAA,qBAAAA,OAAqBI,CAAAA;QAClC,CAAAQ,MAAKA;eACH;qBACEM;;;gEAIJ;UACAa,KAAMA;UACNN,QAAMA,KAAQb,KAAKc,CAAAA;qEACnB;QACAD,MAAIA,MAAME,GAAM,GAAG;eACjB;qBAAST;;;wDAGX;wCACA;UACAK,mBAAMA,MAAmBE,GACtBvB,CAAAA,CAAG0B,KAAEA;YACJC,IAAIA,MAAI,GAAA;mBACN;;;;eACF;mBACE;;;;;;;;;;OAKJ,6CACA;WACCC,CAAAA,CAAAA,OAAOhB,SAAQA;WAElB;iBAASI;;;AACX"}
|
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "registerPasteUnfurlingPlugin", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _PasteUnfurlingbase.registerPasteUnfurlingPlugin;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _PasteUnfurlingbase = require("./PasteUnfurling.base");
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export { registerPasteUnfurlingPlugin } from './PasteUnfurling.base';\nexport type { PasteUnfurlingPluginBaseProps, PasteUnfurlingTransformFunction, PasteUnfurlingTransformResult, PasteUnfurlingTransformedPart } from './PasteUnfurling.types';\n"],"names":["registerPasteUnfurlingPlugin"],"rangeMappings":";;;;;;;;;;","mappings":";;;;+BAASA;;;eAAAA,gDAA4B;;;oCAAQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui-copilot/chat-input-plugins",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.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.2.
|
|
15
|
+
"@fluentui-copilot/text-editor": "^0.2.1",
|
|
16
16
|
"@swc/helpers": "^0.5.1"
|
|
17
17
|
},
|
|
18
18
|
"beachball": {
|