@fluentui-copilot/chat-input-plugins 0.3.0 → 0.3.1

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 CHANGED
@@ -2,7 +2,34 @@
2
2
  "name": "@fluentui-copilot/chat-input-plugins",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 25 Sep 2024 19:49:21 GMT",
5
+ "date": "Thu, 31 Oct 2024 17:39:46 GMT",
6
+ "tag": "@fluentui-copilot/chat-input-plugins_v0.3.1",
7
+ "version": "0.3.1",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "Humberto.Morimoto@microsoft.com",
12
+ "package": "@fluentui-copilot/chat-input-plugins",
13
+ "commit": "49fcd13f2ab4e6635394196e53ef1de79638e6d6",
14
+ "comment": "feat: Enabling async transforms in the PasteUnfurlingPlugin of ChatInput."
15
+ },
16
+ {
17
+ "author": "Humberto.Morimoto@microsoft.com",
18
+ "package": "@fluentui-copilot/chat-input-plugins",
19
+ "commit": "db6349629aa22001ea83df218e61e6d938e04198",
20
+ "comment": "chore: Chaining getters into single line in paste unfurling plugin."
21
+ },
22
+ {
23
+ "author": "owcampbe@microsoft.com",
24
+ "package": "@fluentui-copilot/chat-input-plugins",
25
+ "commit": "2bdb166cd12430b68d776c012dbb574b88e47fc8",
26
+ "comment": "feat: Add discrete update options to ghost text functions."
27
+ }
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ "date": "Wed, 25 Sep 2024 19:50:22 GMT",
6
33
  "tag": "@fluentui-copilot/chat-input-plugins_v0.3.0",
7
34
  "version": "0.3.0",
8
35
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,23 @@
1
1
  # Change Log - @fluentui-copilot/chat-input-plugins
2
2
 
3
- This log was last generated on Wed, 25 Sep 2024 19:49:21 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 31 Oct 2024 17:39:46 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [0.3.1](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.3.1)
8
+
9
+ Thu, 31 Oct 2024 17:39:46 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.3.0..@fluentui-copilot/chat-input-plugins_v0.3.1)
11
+
12
+ ### Patches
13
+
14
+ - feat: Enabling async transforms in the PasteUnfurlingPlugin of ChatInput. ([PR #2326](https://github.com/microsoft/fluentai/pull/2326) by Humberto.Morimoto@microsoft.com)
15
+ - chore: Chaining getters into single line in paste unfurling plugin. ([PR #2328](https://github.com/microsoft/fluentai/pull/2328) by Humberto.Morimoto@microsoft.com)
16
+ - feat: Add discrete update options to ghost text functions. ([PR #2251](https://github.com/microsoft/fluentai/pull/2251) by owcampbe@microsoft.com)
17
+
7
18
  ## [0.3.0](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.3.0)
8
19
 
9
- Wed, 25 Sep 2024 19:49:21 GMT
20
+ Wed, 25 Sep 2024 19:50:22 GMT
10
21
  [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.2.2..@fluentui-copilot/chat-input-plugins_v0.3.0)
11
22
 
12
23
  ### Minor changes
package/dist/index.d.ts CHANGED
@@ -126,9 +126,9 @@ export declare interface IImperativeControlBase {
126
126
 
127
127
  export declare interface IManualGhostTextBase<ComponentPropsType> {
128
128
  getGhostText: () => string | undefined;
129
- setGhostText: (text: string, componentProps?: ComponentPropsType) => void;
130
- commitGhostText: (finalText: string) => void;
131
- cancelGhostText: () => void;
129
+ setGhostText: (text: string, exposeText?: boolean, componentProps?: ComponentPropsType, discrete?: boolean) => void;
130
+ commitGhostText: (finalText: string, discrete?: boolean) => void;
131
+ cancelGhostText: (discrete?: boolean) => void;
132
132
  }
133
133
 
134
134
  export declare class ImperativeControlBase implements IImperativeControlBase {
@@ -143,7 +143,7 @@ export declare class ImperativeControlBase implements IImperativeControlBase {
143
143
  scrollToBottom(): void;
144
144
  }
145
145
 
146
- export declare class ManualGhostTextBase<ComponentPropsType> {
146
+ export declare class ManualGhostTextBase<ComponentPropsType> implements IManualGhostTextBase<ComponentPropsType> {
147
147
  private __editor;
148
148
  private __nodeKey?;
149
149
  private __id;
@@ -151,9 +151,9 @@ export declare class ManualGhostTextBase<ComponentPropsType> {
151
151
  private __$createNode;
152
152
  constructor(editor: LexicalEditor, id: string, $isNodeType: (node: LexicalNode | null) => node is IGhostTextNode<ComponentPropsType>, $createNode: (id: string, content: string, exposeText?: boolean, componentProps?: ComponentPropsType) => IGhostTextNode<ComponentPropsType>);
153
153
  getGhostText(): string | undefined;
154
- setGhostText(text: string, exposeText?: boolean, componentProps?: ComponentPropsType): void;
155
- commitGhostText(finalText: string): void;
156
- cancelGhostText(): void;
154
+ setGhostText(text: string, exposeText?: boolean, componentProps?: ComponentPropsType, discrete?: boolean): void;
155
+ commitGhostText(finalText: string, discrete?: boolean): void;
156
+ cancelGhostText(discrete?: boolean): void;
157
157
  }
158
158
 
159
159
  export declare type PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType> = {
@@ -170,7 +170,7 @@ export declare type PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>
170
170
  value: ChatInputEntityData<ExtraDataType, NodePropsType>;
171
171
  };
172
172
 
173
- export declare type PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType> = (event: ClipboardEvent, editor: LexicalEditor) => PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>;
173
+ export declare type PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType> = (event: ClipboardEvent, editor: LexicalEditor) => PasteUnfurlingTransformResult<ExtraDataType, NodePropsType> | Promise<PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>>;
174
174
 
175
175
  export declare type PasteUnfurlingTransformResult<ExtraDataType, NodePropsType> = {
176
176
  handled: boolean;
@@ -11,7 +11,7 @@ export class ManualGhostTextBase {
11
11
  }
12
12
  });
13
13
  }
14
- setGhostText(text, exposeText, componentProps) {
14
+ setGhostText(text, exposeText, componentProps, discrete) {
15
15
  this.__editor.update(() => {
16
16
  if (this.__nodeKey) {
17
17
  const node = $getNodeByKey(this.__nodeKey);
@@ -25,10 +25,11 @@ export class ManualGhostTextBase {
25
25
  $insertNodes([node]);
26
26
  node.selectStart();
27
27
  }, {
28
- tag: 'historic'
28
+ tag: 'historic',
29
+ discrete: discrete ? true : undefined
29
30
  });
30
31
  }
31
- commitGhostText(finalText) {
32
+ commitGhostText(finalText, discrete) {
32
33
  if (this.__nodeKey) {
33
34
  this.__editor.update(() => {
34
35
  if (this.__nodeKey) {
@@ -39,11 +40,13 @@ export class ManualGhostTextBase {
39
40
  textNode.selectEnd();
40
41
  }
41
42
  }
43
+ }, {
44
+ discrete: discrete ? true : undefined
42
45
  });
43
46
  this.__nodeKey = undefined;
44
47
  }
45
48
  }
46
- cancelGhostText() {
49
+ cancelGhostText(discrete) {
47
50
  if (this.__nodeKey) {
48
51
  this.__editor.update(() => {
49
52
  if (this.__nodeKey) {
@@ -53,7 +56,8 @@ export class ManualGhostTextBase {
53
56
  }
54
57
  }
55
58
  }, {
56
- tag: 'historic'
59
+ tag: 'historic',
60
+ discrete: discrete ? true : undefined
57
61
  });
58
62
  this.__nodeKey = undefined;
59
63
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["ManualGhostText.base.ts"],"sourcesContent":["import {\n $createTextNode,\n $getNodeByKey,\n $insertNodes,\n type LexicalEditor,\n type LexicalNode,\n} from '@fluentui-copilot/text-editor';\nimport type { IGhostTextNode } from '../GhostText';\n\nexport interface IManualGhostTextBase<ComponentPropsType> {\n getGhostText: () => string | undefined;\n setGhostText: (text: string, componentProps?: ComponentPropsType) => void;\n commitGhostText: (finalText: string) => void;\n cancelGhostText: () => void;\n}\n\nexport class ManualGhostTextBase<ComponentPropsType> {\n private __editor: LexicalEditor;\n private __nodeKey?: string;\n\n private __id: string;\n private __$isNodeType: (node: LexicalNode | null) => node is IGhostTextNode<ComponentPropsType>;\n private __$createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>;\n\n constructor(\n editor: LexicalEditor,\n id: string,\n $isNodeType: (node: LexicalNode | null) => node is IGhostTextNode<ComponentPropsType>,\n $createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>,\n ) {\n this.__editor = editor;\n this.__id = id;\n this.__$isNodeType = $isNodeType;\n this.__$createNode = $createNode;\n }\n\n getGhostText(): string | undefined {\n return this.__editor.getEditorState().read(() => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n return node.__content;\n }\n }\n });\n }\n\n setGhostText(text: string, exposeText?: boolean, componentProps?: ComponentPropsType): void {\n this.__editor.update(\n () => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n node.getWritable().__content = text;\n return;\n }\n }\n\n const node = this.__$createNode(this.__id, text, exposeText, componentProps);\n this.__nodeKey = node.getKey();\n $insertNodes([node]);\n node.selectStart();\n },\n { tag: 'historic' },\n );\n }\n\n commitGhostText(finalText: string): void {\n if (this.__nodeKey) {\n this.__editor.update(() => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n const textNode = $createTextNode(finalText);\n node.replace(textNode);\n textNode.selectEnd();\n }\n }\n });\n this.__nodeKey = undefined;\n }\n }\n\n cancelGhostText(): void {\n if (this.__nodeKey) {\n this.__editor.update(\n () => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n node.remove();\n }\n }\n },\n { tag: 'historic' },\n );\n this.__nodeKey = undefined;\n }\n }\n}\n"],"names":["$createTextNode","$getNodeByKey","$insertNodes","ManualGhostTextBase","getGhostText","__editor","getEditorState","read","__nodeKey","node","__$isNodeType","__content","setGhostText","text","exposeText","componentProps","update","getWritable","__$createNode","__id","getKey","selectStart","tag","commitGhostText","finalText","textNode","replace","selectEnd","undefined","cancelGhostText","remove","constructor","editor","id","$isNodeType","$createNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SACEA,eAAe,EACfC,aAAa,EACbC,YAAY,QAGP,gCAAgC;AAUvC,OAAO,MAAMC;IA8BXC,eAAmC;QACjC,OAAO,IAAI,CAACC,QAAQ,CAACC,cAAc,GAAGC,IAAI,CAAC;YACzC,IAAI,IAAI,CAACC,SAAS,EAAE;gBAClB,MAAMC,OAAOR,cAAc,IAAI,CAACO,SAAS;gBACzC,IAAI,IAAI,CAACE,aAAa,CAACD,OAAO;oBAC5B,OAAOA,KAAKE,SAAS;gBACvB;YACF;QACF;IACF;IAEAC,aAAaC,IAAY,EAAEC,UAAoB,EAAEC,cAAmC,EAAQ;QAC1F,IAAI,CAACV,QAAQ,CAACW,MAAM,CAClB;YACE,IAAI,IAAI,CAACR,SAAS,EAAE;gBAClB,MAAMC,OAAOR,cAAc,IAAI,CAACO,SAAS;gBACzC,IAAI,IAAI,CAACE,aAAa,CAACD,OAAO;oBAC5BA,KAAKQ,WAAW,GAAGN,SAAS,GAAGE;oBAC/B;gBACF;YACF;YAEA,MAAMJ,OAAO,IAAI,CAACS,aAAa,CAAC,IAAI,CAACC,IAAI,EAAEN,MAAMC,YAAYC;YAC7D,IAAI,CAACP,SAAS,GAAGC,KAAKW,MAAM;YAC5BlB,aAAa;gBAACO;aAAK;YACnBA,KAAKY,WAAW;QAClB,GACA;YAAEC,KAAK;QAAW;IAEtB;IAEAC,gBAAgBC,SAAiB,EAAQ;QACvC,IAAI,IAAI,CAAChB,SAAS,EAAE;YAClB,IAAI,CAACH,QAAQ,CAACW,MAAM,CAAC;gBACnB,IAAI,IAAI,CAACR,SAAS,EAAE;oBAClB,MAAMC,OAAOR,cAAc,IAAI,CAACO,SAAS;oBACzC,IAAI,IAAI,CAACE,aAAa,CAACD,OAAO;wBAC5B,MAAMgB,WAAWzB,gBAAgBwB;wBACjCf,KAAKiB,OAAO,CAACD;wBACbA,SAASE,SAAS;oBACpB;gBACF;YACF;YACA,IAAI,CAACnB,SAAS,GAAGoB;QACnB;IACF;IAEAC,kBAAwB;QACtB,IAAI,IAAI,CAACrB,SAAS,EAAE;YAClB,IAAI,CAACH,QAAQ,CAACW,MAAM,CAClB;gBACE,IAAI,IAAI,CAACR,SAAS,EAAE;oBAClB,MAAMC,OAAOR,cAAc,IAAI,CAACO,SAAS;oBACzC,IAAI,IAAI,CAACE,aAAa,CAACD,OAAO;wBAC5BA,KAAKqB,MAAM;oBACb;gBACF;YACF,GACA;gBAAER,KAAK;YAAW;YAEpB,IAAI,CAACd,SAAS,GAAGoB;QACnB;IACF;IA/EAG,YACEC,MAAqB,EACrBC,EAAU,EACVC,WAAqF,EACrFC,WAKuC,CACvC;QAtBF,uBAAQ9B,YAAR,KAAA;QACA,uBAAQG,aAAR,KAAA;QAEA,uBAAQW,QAAR,KAAA;QACA,uBAAQT,iBAAR,KAAA;QACA,uBAAQQ,iBAAR,KAAA;QAkBE,IAAI,CAACb,QAAQ,GAAG2B;QAChB,IAAI,CAACb,IAAI,GAAGc;QACZ,IAAI,CAACvB,aAAa,GAAGwB;QACrB,IAAI,CAAChB,aAAa,GAAGiB;IACvB;AAiEF"}
1
+ {"version":3,"sources":["ManualGhostText.base.ts"],"sourcesContent":["import {\n $createTextNode,\n $getNodeByKey,\n $insertNodes,\n type LexicalEditor,\n type LexicalNode,\n} from '@fluentui-copilot/text-editor';\nimport type { IGhostTextNode } from '../GhostText';\n\nexport interface IManualGhostTextBase<ComponentPropsType> {\n getGhostText: () => string | undefined;\n setGhostText: (text: string, exposeText?: boolean, componentProps?: ComponentPropsType, discrete?: boolean) => void;\n commitGhostText: (finalText: string, discrete?: boolean) => void;\n cancelGhostText: (discrete?: boolean) => void;\n}\n\nexport class ManualGhostTextBase<ComponentPropsType> implements IManualGhostTextBase<ComponentPropsType> {\n private __editor: LexicalEditor;\n private __nodeKey?: string;\n\n private __id: string;\n private __$isNodeType: (node: LexicalNode | null) => node is IGhostTextNode<ComponentPropsType>;\n private __$createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>;\n\n constructor(\n editor: LexicalEditor,\n id: string,\n $isNodeType: (node: LexicalNode | null) => node is IGhostTextNode<ComponentPropsType>,\n $createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>,\n ) {\n this.__editor = editor;\n this.__id = id;\n this.__$isNodeType = $isNodeType;\n this.__$createNode = $createNode;\n }\n\n getGhostText(): string | undefined {\n return this.__editor.getEditorState().read(() => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n return node.__content;\n }\n }\n });\n }\n\n setGhostText(text: string, exposeText?: boolean, componentProps?: ComponentPropsType, discrete?: boolean): void {\n this.__editor.update(\n () => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n node.getWritable().__content = text;\n return;\n }\n }\n\n const node = this.__$createNode(this.__id, text, exposeText, componentProps);\n this.__nodeKey = node.getKey();\n $insertNodes([node]);\n node.selectStart();\n },\n { tag: 'historic', discrete: discrete ? true : undefined },\n );\n }\n\n commitGhostText(finalText: string, discrete?: boolean): void {\n if (this.__nodeKey) {\n this.__editor.update(\n () => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n const textNode = $createTextNode(finalText);\n node.replace(textNode);\n textNode.selectEnd();\n }\n }\n },\n { discrete: discrete ? true : undefined },\n );\n this.__nodeKey = undefined;\n }\n }\n\n cancelGhostText(discrete?: boolean): void {\n if (this.__nodeKey) {\n this.__editor.update(\n () => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n node.remove();\n }\n }\n },\n { tag: 'historic', discrete: discrete ? true : undefined },\n );\n this.__nodeKey = undefined;\n }\n }\n}\n"],"names":["$createTextNode","$getNodeByKey","$insertNodes","ManualGhostTextBase","getGhostText","__editor","getEditorState","read","__nodeKey","node","__$isNodeType","__content","setGhostText","text","exposeText","componentProps","discrete","update","getWritable","__$createNode","__id","getKey","selectStart","tag","undefined","commitGhostText","finalText","textNode","replace","selectEnd","cancelGhostText","remove","constructor","editor","id","$isNodeType","$createNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SACEA,eAAe,EACfC,aAAa,EACbC,YAAY,QAGP,gCAAgC;AAUvC,OAAO,MAAMC;IA8BXC,eAAmC;QACjC,OAAO,IAAI,CAACC,QAAQ,CAACC,cAAc,GAAGC,IAAI,CAAC;YACzC,IAAI,IAAI,CAACC,SAAS,EAAE;gBAClB,MAAMC,OAAOR,cAAc,IAAI,CAACO,SAAS;gBACzC,IAAI,IAAI,CAACE,aAAa,CAACD,OAAO;oBAC5B,OAAOA,KAAKE,SAAS;gBACvB;YACF;QACF;IACF;IAEAC,aAAaC,IAAY,EAAEC,UAAoB,EAAEC,cAAmC,EAAEC,QAAkB,EAAQ;QAC9G,IAAI,CAACX,QAAQ,CAACY,MAAM,CAClB;YACE,IAAI,IAAI,CAACT,SAAS,EAAE;gBAClB,MAAMC,OAAOR,cAAc,IAAI,CAACO,SAAS;gBACzC,IAAI,IAAI,CAACE,aAAa,CAACD,OAAO;oBAC5BA,KAAKS,WAAW,GAAGP,SAAS,GAAGE;oBAC/B;gBACF;YACF;YAEA,MAAMJ,OAAO,IAAI,CAACU,aAAa,CAAC,IAAI,CAACC,IAAI,EAA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G4B;QAChB,IAAI,CAACb,IAAI,GAAGc;QACZ,IAAI,CAACxB,aAAa,GAAGyB;QACrB,IAAI,CAAChB,aAAa,GAAGiB;IACvB;AAoEF"}
@@ -1,4 +1,4 @@
1
- import { PASTE_COMMAND, COMMAND_PRIORITY_HIGH, $insertNodes, $createTextNode } from '@fluentui-copilot/text-editor';
1
+ import { COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_LOW, PASTE_COMMAND, $insertNodes, $createTextNode } from '@fluentui-copilot/text-editor';
2
2
  function unhandledPart(part) {
3
3
  throw new Error(`Unhandled part: ${part}`);
4
4
  }
@@ -23,17 +23,40 @@ export function registerPasteUnfurlingPlugin(editor, props) {
23
23
  });
24
24
  }
25
25
  function handlePaste(event) {
26
+ const transformPromises = [];
26
27
  for (const transform of transforms) {
27
- const result = transform(event, editor);
28
- if (result.transformedParts) {
29
- insertParts(result.transformedParts);
28
+ transformPromises.push(Promise.resolve(transform(event, editor)));
29
+ }
30
+ Promise.allSettled(transformPromises).then(results => {
31
+ let handledPaste = false;
32
+ for (const result of results) {
33
+ if (result.status === 'fulfilled') {
34
+ const transformResult = result.value;
35
+ if (transformResult.transformedParts) {
36
+ insertParts(transformResult.transformedParts);
37
+ }
38
+ if (transformResult.handled) {
39
+ handledPaste = true;
40
+ break;
41
+ }
42
+ }
30
43
  }
31
- if (result.handled) {
32
- return true;
44
+ if (!handledPaste) {
45
+ var _commandsMap_get;
46
+ const commandsMap = editor._commands;
47
+ const defaultEditorListeners = (_commandsMap_get = commandsMap.get(PASTE_COMMAND)) === null || _commandsMap_get === void 0 ? void 0 : _commandsMap_get[COMMAND_PRIORITY_EDITOR];
48
+ if (defaultEditorListeners) {
49
+ for (const listener of defaultEditorListeners) {
50
+ const defaultHandled = listener(event, editor);
51
+ if (defaultHandled) {
52
+ break;
53
+ }
54
+ }
55
+ }
33
56
  }
34
- }
35
- return false;
57
+ });
58
+ return true;
36
59
  }
37
- return editor.registerCommand(PASTE_COMMAND, handlePaste, COMMAND_PRIORITY_HIGH);
60
+ return editor.registerCommand(PASTE_COMMAND, handlePaste, COMMAND_PRIORITY_LOW);
38
61
  }
39
62
  //# sourceMappingURL=PasteUnfurling.base.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["PasteUnfurling.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport { PASTE_COMMAND, COMMAND_PRIORITY_HIGH, $insertNodes, $createTextNode } from '@fluentui-copilot/text-editor';\nimport type { PasteUnfurlingPluginBaseProps, PasteUnfurlingTransformedPart } from './PasteUnfurling.types';\n\nfunction unhandledPart(part: never): never {\n throw new Error(`Unhandled part: ${part}`);\n}\n\nexport function registerPasteUnfurlingPlugin<ExtraDataType, NodePropsType>(\n editor: LexicalEditor,\n props: PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType>,\n): () => void {\n const { entityPluginId, transforms, $createEntityNode } = props;\n\n function insertParts(parts: PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>[]) {\n editor.update(() => {\n const nodes = parts.map(part => {\n switch (part.type) {\n case 'entity':\n return $createEntityNode(entityPluginId, part.value.text, part.value.data, part.value.entityProps);\n case 'text':\n return $createTextNode(part.value);\n }\n return unhandledPart(part);\n });\n $insertNodes(nodes);\n });\n }\n\n function handlePaste(event: ClipboardEvent): boolean {\n for (const transform of transforms) {\n const result = transform(event, editor);\n\n if (result.transformedParts) {\n insertParts(result.transformedParts);\n }\n\n if (result.handled) {\n return true;\n }\n }\n\n return false;\n }\n\n return editor.registerCommand(PASTE_COMMAND, handlePaste, COMMAND_PRIORITY_HIGH);\n}\n"],"names":["PASTE_COMMAND","COMMAND_PRIORITY_HIGH","$insertNodes","$createTextNode","unhandledPart","part","Error","registerPasteUnfurlingPlugin","editor","props","entityPluginId","transforms","$createEntityNode","insertParts","parts","update","nodes","map","type","value","text","data","entityProps","handlePaste","event","transform","result","transformedParts","handled","registerCommand"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,aAAa,EAAEC,qBAAqB,EAAEC,YAAY,EAAEC,eAAe,QAAQ,gCAAgC;AAGpH,SAASC,cAAcC,IAAW;IAChC,MAAM,IAAIC,MAAM,CAAC,gBAAgB,EAAED,KAAK,CAAC;AAC3C;AAEA,OAAO,SAASE,6BACdC,MAAqB,EACrBC,KAAkE;IAElE,MAAM,EAAEC,cAAc,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GAAGH;IAE1D,SAASI,YAAYC,KAAoE;QACvFN,OAAOO,MAAM,CAAC;YACZ,MAAMC,QAAQF,MAAMG,GAAG,CAACZ,CAAAA;gBACtB,OAAQA,KAAKa,IAAI;oBACf,KAAK;wBACH,OAAON,kBAAkBF,gBAAgBL,KAAKc,KAAK,CAACC,IAAI,EAAEf,KAAKc,KAAK,CAACE,IAAI,EAAEhB,KAAKc,KAAK,CAACG,WAAW;oBACnG,KAAK;wBACH,OAAOnB,gBAAgBE,KAAKc,KAAK;gBACrC;gBACA,OAAOf,cAAcC;YACvB;YACAH,aAAac;QACf;IACF;IAEA,SAASO,YAAYC,KAAqB;QACxC,KAAK,MAAMC,aAAad,WAAY;YAClC,MAAMe,SAASD,UAAUD,OAAOhB;YAEhC,IAAIkB,OAAOC,gBAAgB,EAAE;gBAC3Bd,YAAYa,OAAOC,gBAAgB;YACrC;YAEA,IAAID,OAAOE,OAAO,EAAE;gBAClB,OAAO;YACT;QACF;QAEA,OAAO;IACT;IAEA,OAAOpB,OAAOqB,eAAe,CAAC7B,eAAeuB,aAAatB;AAC5D"}
1
+ {"version":3,"sources":["PasteUnfurling.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport {\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n PASTE_COMMAND,\n $insertNodes,\n $createTextNode,\n} from '@fluentui-copilot/text-editor';\nimport type {\n PasteUnfurlingPluginBaseProps,\n PasteUnfurlingTransformedPart,\n PasteUnfurlingTransformResult,\n} from './PasteUnfurling.types';\n\nfunction unhandledPart(part: never): never {\n throw new Error(`Unhandled part: ${part}`);\n}\n\nexport function registerPasteUnfurlingPlugin<ExtraDataType, NodePropsType>(\n editor: LexicalEditor,\n props: PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType>,\n): () => void {\n const { entityPluginId, transforms, $createEntityNode } = props;\n\n function insertParts(parts: PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>[]) {\n editor.update(() => {\n const nodes = parts.map(part => {\n switch (part.type) {\n case 'entity':\n return $createEntityNode(entityPluginId, part.value.text, part.value.data, part.value.entityProps);\n case 'text':\n return $createTextNode(part.value);\n }\n return unhandledPart(part);\n });\n $insertNodes(nodes);\n });\n }\n\n function handlePaste(event: ClipboardEvent): boolean {\n const transformPromises: Promise<PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>>[] = [];\n\n for (const transform of transforms) {\n transformPromises.push(Promise.resolve(transform(event, editor)));\n }\n\n Promise.allSettled(transformPromises).then(results => {\n let handledPaste = false;\n\n for (const result of results) {\n if (result.status === 'fulfilled') {\n const transformResult = result.value;\n if (transformResult.transformedParts) {\n insertParts(transformResult.transformedParts);\n }\n\n if (transformResult.handled) {\n handledPaste = true;\n break;\n }\n }\n }\n\n if (!handledPaste) {\n const commandsMap = editor._commands;\n const defaultEditorListeners = commandsMap.get(PASTE_COMMAND)?.[COMMAND_PRIORITY_EDITOR];\n if (defaultEditorListeners) {\n for (const listener of defaultEditorListeners) {\n const defaultHandled = listener(event, editor);\n if (defaultHandled) {\n break;\n }\n }\n }\n }\n });\n\n return true;\n }\n\n return editor.registerCommand(PASTE_COMMAND, handlePaste, COMMAND_PRIORITY_LOW);\n}\n"],"names":["COMMAND_PRIORITY_EDITOR","COMMAND_PRIORITY_LOW","PASTE_COMMAND","$insertNodes","$createTextNode","unhandledPart","part","Error","registerPasteUnfurlingPlugin","editor","props","entityPluginId","transforms","$createEntityNode","insertParts","parts","update","nodes","map","type","value","text","data","entityProps","handlePaste","event","transformPromises","transform","push","Promise","resolve","allSettled","then","results","handledPaste","result","status","transformResult","transformedParts","handled","commandsMap","_commands","defaultEditorListeners","get","listener","defaultHandled","registerCommand"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SACEA,uBAAuB,EACvBC,oBAAoB,EACpBC,aAAa,EACbC,YAAY,EACZC,eAAe,QACV,gCAAgC;AAOvC,SAASC,cAAcC,IAAW;IAChC,MAAM,IAAIC,MAAM,CAAC,gBAAgB,EAAED,KAAK,CAAC;AAC3C;AAEA,OAAO,SAASE,6BACdC,MAAqB,EACrBC,KAAkE;IAElE,MAAM,EAAEC,cAAc,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GAAGH;IAE1D,SAASI,YAAYC,KAAoE;QACvFN,OAAOO,MAAM,CAAC;YACZ,MAAMC,QAAQF,MAAMG,GAAG,CAACZ,CAAAA;gBACtB,OAAQA,KAAKa,IAAI;oBACf,KAAK;wBACH,OAAON,kBAAkBF,gBAAgBL,KAAKc,KAAK,CAACC,IAAI,EAAEf,KAAKc,KAAK,CAACE,IAAI,EAAEhB,KAAKc,KAAK,CAACG,WAAW;oBACnG,KAAK;wBACH,OAAOnB,gBAAgBE,KAAKc,KAAK;gBACrC;gBACA,OAAOf,cAAcC;YACvB;YACAH,aAAac;QACf;IACF;IAEA,SAASO,YAAYC,KAAqB;QACxC,MAAMC,oBAA4F,EAAE;QAEpG,KAAK,MAAMC,aAAaf,WAAY;YAClCc,kBAAkBE,IAAI,CAACC,QAAQC,OAAO,CAACH,UAAUF,OAAOhB;QAC1D;QAEAoB,QAAQE,UAAU,CAACL,mBAAmBM,IAAI,CAACC,CAAAA;YACzC,IAAIC,eAAe;YAEnB,KAAK,MAAMC,UAAUF,QAAS;gBAC5B,IAAIE,OAAOC,MAAM,KAAK,aAAa;oBACjC,MAAMC,kBAAkBF,OAAOf,KAAK;oBACpC,IAAIiB,gBAAgBC,gBAAgB,EAAE;wBACpCxB,YAAYuB,gBAAgBC,gBAAgB;oBAC9C;oBAEA,IAAID,gBAAgBE,OAAO,EAAE;wBAC3BL,eAAe;wBACf;oBACF;gBACF;YACF;YAEA,IAAI,CAACA,cAAc;oBAEcM;gBAD/B,MAAMA,cAAc/B,OAAOgC,SAAS;gBACpC,MAAMC,0BAAyBF,mBAAAA,YAAYG,GAAG,CAACzC,4BAAhBsC,uCAAAA,gBAAgC,CAACxC,wBAAwB;gBACxF,IAAI0C,wBAAwB;oBAC1B,KAAK,MAAME,YAAYF,uBAAwB;wBAC7C,MAAMG,iBAAiBD,SAASnB,OAAOhB;wBACvC,IAAIoC,gBAAgB;4BAClB;wBACF;oBACF;gBACF;YACF;QACF;QAEA,OAAO;IACT;IAEA,OAAOpC,OAAOqC,eAAe,CAAC5C,eAAesB,aAAavB;AAC5D"}
@@ -1 +1 @@
1
- {"version":3,"sources":["PasteUnfurling.types.ts"],"sourcesContent":["import type { LexicalEditor, LexicalNode, NodeKey } from '@fluentui-copilot/text-editor';\nimport type { ChatInputEntityData } from '../ChatInputEntity';\n\nexport type PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType> =\n | { type: 'text'; value: string }\n | { type: 'entity'; value: ChatInputEntityData<ExtraDataType, NodePropsType> };\n\nexport type PasteUnfurlingTransformResult<ExtraDataType, NodePropsType> = {\n handled: boolean;\n transformedParts?: PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>[];\n};\n\nexport type PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType> = (\n event: ClipboardEvent,\n editor: LexicalEditor,\n) => PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>;\n\nexport type PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType> = {\n entityPluginId: string;\n transforms: PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType>[];\n $createEntityNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => LexicalNode;\n};\n"],"names":[],"rangeMappings":"","mappings":"AAiBA,WAUE"}
1
+ {"version":3,"sources":["PasteUnfurling.types.ts"],"sourcesContent":["import type { LexicalEditor, LexicalNode, NodeKey } from '@fluentui-copilot/text-editor';\nimport type { ChatInputEntityData } from '../ChatInputEntity';\n\nexport type PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType> =\n | { type: 'text'; value: string }\n | { type: 'entity'; value: ChatInputEntityData<ExtraDataType, NodePropsType> };\n\nexport type PasteUnfurlingTransformResult<ExtraDataType, NodePropsType> = {\n handled: boolean;\n transformedParts?: PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>[];\n};\n\nexport type PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType> = (\n event: ClipboardEvent,\n editor: LexicalEditor,\n) =>\n | PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>\n | Promise<PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>>;\n\nexport type PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType> = {\n entityPluginId: string;\n transforms: PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType>[];\n $createEntityNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => LexicalNode;\n};\n"],"names":[],"rangeMappings":"","mappings":"AAmBA,WAUE"}
@@ -21,7 +21,7 @@ class ManualGhostTextBase {
21
21
  }
22
22
  });
23
23
  }
24
- setGhostText(text, exposeText, componentProps) {
24
+ setGhostText(text, exposeText, componentProps, discrete) {
25
25
  this.__editor.update(()=>{
26
26
  if (this.__nodeKey) {
27
27
  const node = (0, _texteditor.$getNodeByKey)(this.__nodeKey);
@@ -37,10 +37,11 @@ class ManualGhostTextBase {
37
37
  ]);
38
38
  node.selectStart();
39
39
  }, {
40
- tag: 'historic'
40
+ tag: 'historic',
41
+ discrete: discrete ? true : undefined
41
42
  });
42
43
  }
43
- commitGhostText(finalText) {
44
+ commitGhostText(finalText, discrete) {
44
45
  if (this.__nodeKey) {
45
46
  this.__editor.update(()=>{
46
47
  if (this.__nodeKey) {
@@ -51,11 +52,13 @@ class ManualGhostTextBase {
51
52
  textNode.selectEnd();
52
53
  }
53
54
  }
55
+ }, {
56
+ discrete: discrete ? true : undefined
54
57
  });
55
58
  this.__nodeKey = undefined;
56
59
  }
57
60
  }
58
- cancelGhostText() {
61
+ cancelGhostText(discrete) {
59
62
  if (this.__nodeKey) {
60
63
  this.__editor.update(()=>{
61
64
  if (this.__nodeKey) {
@@ -65,7 +68,8 @@ class ManualGhostTextBase {
65
68
  }
66
69
  }
67
70
  }, {
68
- tag: 'historic'
71
+ tag: 'historic',
72
+ discrete: discrete ? true : undefined
69
73
  });
70
74
  this.__nodeKey = undefined;
71
75
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["ManualGhostText.base.ts"],"sourcesContent":["import {\n $createTextNode,\n $getNodeByKey,\n $insertNodes,\n type LexicalEditor,\n type LexicalNode,\n} from '@fluentui-copilot/text-editor';\nimport type { IGhostTextNode } from '../GhostText';\n\nexport interface IManualGhostTextBase<ComponentPropsType> {\n getGhostText: () => string | undefined;\n setGhostText: (text: string, componentProps?: ComponentPropsType) => void;\n commitGhostText: (finalText: string) => void;\n cancelGhostText: () => void;\n}\n\nexport class ManualGhostTextBase<ComponentPropsType> {\n private __editor: LexicalEditor;\n private __nodeKey?: string;\n\n private __id: string;\n private __$isNodeType: (node: LexicalNode | null) => node is IGhostTextNode<ComponentPropsType>;\n private __$createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>;\n\n constructor(\n editor: LexicalEditor,\n id: string,\n $isNodeType: (node: LexicalNode | null) => node is IGhostTextNode<ComponentPropsType>,\n $createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>,\n ) {\n this.__editor = editor;\n this.__id = id;\n this.__$isNodeType = $isNodeType;\n this.__$createNode = $createNode;\n }\n\n getGhostText(): string | undefined {\n return this.__editor.getEditorState().read(() => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n return node.__content;\n }\n }\n });\n }\n\n setGhostText(text: string, exposeText?: boolean, componentProps?: ComponentPropsType): void {\n this.__editor.update(\n () => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n node.getWritable().__content = text;\n return;\n }\n }\n\n const node = this.__$createNode(this.__id, text, exposeText, componentProps);\n this.__nodeKey = node.getKey();\n $insertNodes([node]);\n node.selectStart();\n },\n { tag: 'historic' },\n );\n }\n\n commitGhostText(finalText: string): void {\n if (this.__nodeKey) {\n this.__editor.update(() => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n const textNode = $createTextNode(finalText);\n node.replace(textNode);\n textNode.selectEnd();\n }\n }\n });\n this.__nodeKey = undefined;\n }\n }\n\n cancelGhostText(): void {\n if (this.__nodeKey) {\n this.__editor.update(\n () => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n node.remove();\n }\n }\n },\n { tag: 'historic' },\n );\n this.__nodeKey = undefined;\n }\n }\n}\n"],"names":["ManualGhostTextBase","getGhostText","__editor","getEditorState","read","__nodeKey","$getNodeByKey","__$isNodeType","__content","node","setGhostText","text","exposeText","componentProps","update","getWritable","__$createNode","__id","getKey","$insertNodes","finalText","commitGhostText","textNode","undefined","cancelGhostText","tag","editor","id","$isNodeType","$createNode","_define_property","constructor"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAgBaA;;;eAAAA;;;;4BAVN;AAUA,MAAMA;mBA8BXC;eACE,IAAO,CAAAC,QAAKA,CAAAA,cAASC,GAA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,IAAAA,kBACEL,EAAAA,IACAC,EAAU,aAC2E,KACrFE;8BAhBF,EAAA,IAAA,EAAA,QAAQ3B,KAAAA;8BACR,EAAA,IAAA,EAAA,iBAAA,KAAA;8BAEA,EAAA,IAAA,EAAA,iBAAA,KAAA;YACA,CAAAA,QAAA,GAAAwB;YACA,CAAAT,IAAA,GAAAU;YAkBE,CAAApB,aAAa,GAAGmB;YAChB,CAAAV,aAAYW,GAAAA;;kDAGd"}
1
+ {"version":3,"sources":["ManualGhostText.base.ts"],"sourcesContent":["import {\n $createTextNode,\n $getNodeByKey,\n $insertNodes,\n type LexicalEditor,\n type LexicalNode,\n} from '@fluentui-copilot/text-editor';\nimport type { IGhostTextNode } from '../GhostText';\n\nexport interface IManualGhostTextBase<ComponentPropsType> {\n getGhostText: () => string | undefined;\n setGhostText: (text: string, exposeText?: boolean, componentProps?: ComponentPropsType, discrete?: boolean) => void;\n commitGhostText: (finalText: string, discrete?: boolean) => void;\n cancelGhostText: (discrete?: boolean) => void;\n}\n\nexport class ManualGhostTextBase<ComponentPropsType> implements IManualGhostTextBase<ComponentPropsType> {\n private __editor: LexicalEditor;\n private __nodeKey?: string;\n\n private __id: string;\n private __$isNodeType: (node: LexicalNode | null) => node is IGhostTextNode<ComponentPropsType>;\n private __$createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>;\n\n constructor(\n editor: LexicalEditor,\n id: string,\n $isNodeType: (node: LexicalNode | null) => node is IGhostTextNode<ComponentPropsType>,\n $createNode: (\n id: string,\n content: string,\n exposeText?: boolean,\n componentProps?: ComponentPropsType,\n ) => IGhostTextNode<ComponentPropsType>,\n ) {\n this.__editor = editor;\n this.__id = id;\n this.__$isNodeType = $isNodeType;\n this.__$createNode = $createNode;\n }\n\n getGhostText(): string | undefined {\n return this.__editor.getEditorState().read(() => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n return node.__content;\n }\n }\n });\n }\n\n setGhostText(text: string, exposeText?: boolean, componentProps?: ComponentPropsType, discrete?: boolean): void {\n this.__editor.update(\n () => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n node.getWritable().__content = text;\n return;\n }\n }\n\n const node = this.__$createNode(this.__id, text, exposeText, componentProps);\n this.__nodeKey = node.getKey();\n $insertNodes([node]);\n node.selectStart();\n },\n { tag: 'historic', discrete: discrete ? true : undefined },\n );\n }\n\n commitGhostText(finalText: string, discrete?: boolean): void {\n if (this.__nodeKey) {\n this.__editor.update(\n () => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n const textNode = $createTextNode(finalText);\n node.replace(textNode);\n textNode.selectEnd();\n }\n }\n },\n { discrete: discrete ? true : undefined },\n );\n this.__nodeKey = undefined;\n }\n }\n\n cancelGhostText(discrete?: boolean): void {\n if (this.__nodeKey) {\n this.__editor.update(\n () => {\n if (this.__nodeKey) {\n const node = $getNodeByKey(this.__nodeKey);\n if (this.__$isNodeType(node)) {\n node.remove();\n }\n }\n },\n { tag: 'historic', discrete: discrete ? true : undefined },\n );\n this.__nodeKey = undefined;\n }\n }\n}\n"],"names":["ManualGhostTextBase","getGhostText","__editor","getEditorState","read","__nodeKey","$getNodeByKey","__$isNodeType","__content","node","setGhostText","text","exposeText","componentProps","discrete","update","getWritable","__$createNode","__id","getKey","$insertNodes","undefined","finalText","commitGhostText","textNode","cancelGhostText","editor","id","$isNodeType","$createNode","_define_property","constructor"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAgBaA;;;eAAAA;;;;4BAVN;AAUA,MAAMA;mBA8BXC;eACE,IAAO,CAAAC,QAAKA,CAAAA,cAASC,GAAAA,IAAiBC,CAAAA;oBACpC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,WAAA,EAAAC,WAAA,CAAA;QACFC,IAAAA,kBAAA,EAAA,IAAA,EAAA,YAAA,KAAA;QAlFAC,IAAAA,kBACEL,EAAAA,IACAC,EAAU,aAC2E,KACrFE;8BAhBF,EAAA,IAAA,EAAA,QAAQ3B,KAAAA;8BACR,EAAA,IAAA,EAAA,iBAAA,KAAA;8BAEA,EAAA,IAAA,EAAA,iBAAA,KAAA;YACA,CAAAA,QAAA,GAAAwB;YACA,CAAAR,IAAA,GAAAS;YAkBE,CAAApB,aAAa,GAAGmB;YAChB,CAAAT,aAAYU,GAAAA;;kDAGd"}
@@ -29,16 +29,39 @@ function registerPasteUnfurlingPlugin(editor, props) {
29
29
  });
30
30
  }
31
31
  function handlePaste(event) {
32
+ const transformPromises = [];
32
33
  for (const transform of transforms){
33
- const result = transform(event, editor);
34
- if (result.transformedParts) {
35
- insertParts(result.transformedParts);
34
+ transformPromises.push(Promise.resolve(transform(event, editor)));
35
+ }
36
+ Promise.allSettled(transformPromises).then((results)=>{
37
+ let handledPaste = false;
38
+ for (const result of results){
39
+ if (result.status === 'fulfilled') {
40
+ const transformResult = result.value;
41
+ if (transformResult.transformedParts) {
42
+ insertParts(transformResult.transformedParts);
43
+ }
44
+ if (transformResult.handled) {
45
+ handledPaste = true;
46
+ break;
47
+ }
48
+ }
36
49
  }
37
- if (result.handled) {
38
- return true;
50
+ if (!handledPaste) {
51
+ var _commandsMap_get;
52
+ const commandsMap = editor._commands;
53
+ const defaultEditorListeners = (_commandsMap_get = commandsMap.get(_texteditor.PASTE_COMMAND)) === null || _commandsMap_get === void 0 ? void 0 : _commandsMap_get[_texteditor.COMMAND_PRIORITY_EDITOR];
54
+ if (defaultEditorListeners) {
55
+ for (const listener of defaultEditorListeners){
56
+ const defaultHandled = listener(event, editor);
57
+ if (defaultHandled) {
58
+ break;
59
+ }
60
+ }
61
+ }
39
62
  }
40
- }
41
- return false;
63
+ });
64
+ return true;
42
65
  }
43
- return editor.registerCommand(_texteditor.PASTE_COMMAND, handlePaste, _texteditor.COMMAND_PRIORITY_HIGH);
66
+ return editor.registerCommand(_texteditor.PASTE_COMMAND, handlePaste, _texteditor.COMMAND_PRIORITY_LOW);
44
67
  } //# sourceMappingURL=PasteUnfurling.base.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["PasteUnfurling.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport { PASTE_COMMAND, COMMAND_PRIORITY_HIGH, $insertNodes, $createTextNode } from '@fluentui-copilot/text-editor';\nimport type { PasteUnfurlingPluginBaseProps, PasteUnfurlingTransformedPart } from './PasteUnfurling.types';\n\nfunction unhandledPart(part: never): never {\n throw new Error(`Unhandled part: ${part}`);\n}\n\nexport function registerPasteUnfurlingPlugin<ExtraDataType, NodePropsType>(\n editor: LexicalEditor,\n props: PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType>,\n): () => void {\n const { entityPluginId, transforms, $createEntityNode } = props;\n\n function insertParts(parts: PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>[]) {\n editor.update(() => {\n const nodes = parts.map(part => {\n switch (part.type) {\n case 'entity':\n return $createEntityNode(entityPluginId, part.value.text, part.value.data, part.value.entityProps);\n case 'text':\n return $createTextNode(part.value);\n }\n return unhandledPart(part);\n });\n $insertNodes(nodes);\n });\n }\n\n function handlePaste(event: ClipboardEvent): boolean {\n for (const transform of transforms) {\n const result = transform(event, editor);\n\n if (result.transformedParts) {\n insertParts(result.transformedParts);\n }\n\n if (result.handled) {\n return true;\n }\n }\n\n return false;\n }\n\n return editor.registerCommand(PASTE_COMMAND, handlePaste, COMMAND_PRIORITY_HIGH);\n}\n"],"names":["registerPasteUnfurlingPlugin","unhandledPart","part","Error","editor","props","entityPluginId","insertParts","nodes","parts","map","$createEntityNode","$insertNodes","transform","result","transforms","event","transformedParts","handled"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAQgBA;;;eAAAA;;;4BAPoE;AAGpF,SAASC,cAAcC,IAAW;UAChC,IAAMC,MAAIA,CAAAA,gBAAO,EAAgBD,KAAEA,CAAAA;AACrC;AAEO,SAASF,6BACdI,MAAqB,EACrBC,KAAkE;UAElE,EAEAC,cAASC,YACPH,mBACQI;yBAEFC,KAAK;;0BAELA,MAAKC,GAAA,CAAAR,CAAAA;gCACH;;+BAEJS,kBAAqBT,gBAAAA,KAAAA,KAAAA,CAAAA,IAAAA,EAAAA,KAAAA,KAAAA,CAAAA,IAAAA,EAAAA,KAAAA,KAAAA,CAAAA,WAAAA;yBACvB;wBACAU,OAAAA,IAAAA,2BAAaJ,EAAAA,KAAAA,KAAAA;gBACf;gBACF,OAAAP,cAAAC;YAEA;wCACO,EAAMW;;;yBAIPN,KAAYO;mBACdD,aAAAE,WAAA;kBAEAD,SAAIA,UAAcE,OAAEZ;uBAClBa,gBAAO,EAAA;4BACTH,OAAAG,gBAAA;;gBAGFH,OAAOI,OAAA,EAAA;gBACT,OAAA;YAEA;QACF"}
1
+ {"version":3,"sources":["PasteUnfurling.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport {\n COMMAND_PRIORITY_EDITOR,\n COMMAND_PRIORITY_LOW,\n PASTE_COMMAND,\n $insertNodes,\n $createTextNode,\n} from '@fluentui-copilot/text-editor';\nimport type {\n PasteUnfurlingPluginBaseProps,\n PasteUnfurlingTransformedPart,\n PasteUnfurlingTransformResult,\n} from './PasteUnfurling.types';\n\nfunction unhandledPart(part: never): never {\n throw new Error(`Unhandled part: ${part}`);\n}\n\nexport function registerPasteUnfurlingPlugin<ExtraDataType, NodePropsType>(\n editor: LexicalEditor,\n props: PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType>,\n): () => void {\n const { entityPluginId, transforms, $createEntityNode } = props;\n\n function insertParts(parts: PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>[]) {\n editor.update(() => {\n const nodes = parts.map(part => {\n switch (part.type) {\n case 'entity':\n return $createEntityNode(entityPluginId, part.value.text, part.value.data, part.value.entityProps);\n case 'text':\n return $createTextNode(part.value);\n }\n return unhandledPart(part);\n });\n $insertNodes(nodes);\n });\n }\n\n function handlePaste(event: ClipboardEvent): boolean {\n const transformPromises: Promise<PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>>[] = [];\n\n for (const transform of transforms) {\n transformPromises.push(Promise.resolve(transform(event, editor)));\n }\n\n Promise.allSettled(transformPromises).then(results => {\n let handledPaste = false;\n\n for (const result of results) {\n if (result.status === 'fulfilled') {\n const transformResult = result.value;\n if (transformResult.transformedParts) {\n insertParts(transformResult.transformedParts);\n }\n\n if (transformResult.handled) {\n handledPaste = true;\n break;\n }\n }\n }\n\n if (!handledPaste) {\n const commandsMap = editor._commands;\n const defaultEditorListeners = commandsMap.get(PASTE_COMMAND)?.[COMMAND_PRIORITY_EDITOR];\n if (defaultEditorListeners) {\n for (const listener of defaultEditorListeners) {\n const defaultHandled = listener(event, editor);\n if (defaultHandled) {\n break;\n }\n }\n }\n }\n });\n\n return true;\n }\n\n return editor.registerCommand(PASTE_COMMAND, handlePaste, COMMAND_PRIORITY_LOW);\n}\n"],"names":["registerPasteUnfurlingPlugin","unhandledPart","part","Error","editor","props","entityPluginId","insertParts","nodes","parts","map","$createEntityNode","$insertNodes","transformPromises","handlePaste","event","Promise","transform","handledPaste","result","results","transformResult","handled","transformedParts","defaultEditorListeners","defaultHandled","commandsMap","get","PASTE_COMMAND","_commandsMap_get","COMMAND_PRIORITY_EDITOR","listener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAkBgBA;;;eAAAA;;;4BAXT;AAOP,SAASC,cAAcC,IAAW;UAChC,IAAMC,MAAIA,CAAAA,gBAAO,EAAgBD,KAAEA,CAAAA;AACrC;AAEO,SAASF,6BACdI,MAAqB,EACrBC,KAAkE;UAElE,EAEAC,cAASC,YACPH,mBACQI;yBAEFC,KAAK;;0BAELA,MAAKC,GAAA,CAAAR,CAAAA;gCACH;;+BAEJS,kBAAqBT,gBAAAA,KAAAA,KAAAA,CAAAA,IAAAA,EAAAA,KAAAA,KAAAA,CAAAA,IAAAA,EAAAA,KAAAA,KAAAA,CAAAA,WAAAA;yBACvB;wBACAU,OAAAA,IAAAA,2BAAaJ,EAAAA,KAAAA,KAAAA;gBACf;gBACF,OAAAP,cAAAC;YAEA;wCACQW,EAAAA;;;aAINC,YAAAC,KAAA;cAEAC,oBAAmBH,EAAAA;mBACjBI,aAAIC,WAAe;8BAERC,IAAAA,CAAAA,QAAUC,OAAS,CAAAH,UAAAF,OAAAX;;0BAE1B,CAAAS,mBAAMQ,IAAkBF,CAAAA,CAAAA;+BACpBE;iCACFd,QAAYc;iCACd,KAAA,aAAA;4CAEIA,OAAgBC,KAAAA;wCAClBJ,gBAAe,EAAA;oCACfG,gBAAAE,gBAAA;;wCAEJD,OAAA,EAAA;wBACFJ,eAAA;wBAEA;;;;+BAGMM;;oCAEApB,OAAMqB,SAAAA;+CACFA,CAAAA,mBAAgBC,YAAAC,GAAA,CAAAC,yBAAA,CAAA,MAAA,QAAAC,qBAAA,KAAA,IAAA,KAAA,IAAAA,gBAAA,CAAAC,mCAAA,CAAA;4CAClB;2CACFN,uBAAA;+CACFO,SAAAhB,OAAAX;4BACFqB,gBAAA;4BACF;wBACF;oBAEA;gBACF;YAEA;QACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["PasteUnfurling.types.ts"],"sourcesContent":["import type { LexicalEditor, LexicalNode, NodeKey } from '@fluentui-copilot/text-editor';\nimport type { ChatInputEntityData } from '../ChatInputEntity';\n\nexport type PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType> =\n | { type: 'text'; value: string }\n | { type: 'entity'; value: ChatInputEntityData<ExtraDataType, NodePropsType> };\n\nexport type PasteUnfurlingTransformResult<ExtraDataType, NodePropsType> = {\n handled: boolean;\n transformedParts?: PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>[];\n};\n\nexport type PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType> = (\n event: ClipboardEvent,\n editor: LexicalEditor,\n) => PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>;\n\nexport type PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType> = {\n entityPluginId: string;\n transforms: PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType>[];\n $createEntityNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => LexicalNode;\n};\n"],"names":[],"rangeMappings":"","mappings":""}
1
+ {"version":3,"sources":["PasteUnfurling.types.ts"],"sourcesContent":["import type { LexicalEditor, LexicalNode, NodeKey } from '@fluentui-copilot/text-editor';\nimport type { ChatInputEntityData } from '../ChatInputEntity';\n\nexport type PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType> =\n | { type: 'text'; value: string }\n | { type: 'entity'; value: ChatInputEntityData<ExtraDataType, NodePropsType> };\n\nexport type PasteUnfurlingTransformResult<ExtraDataType, NodePropsType> = {\n handled: boolean;\n transformedParts?: PasteUnfurlingTransformedPart<ExtraDataType, NodePropsType>[];\n};\n\nexport type PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType> = (\n event: ClipboardEvent,\n editor: LexicalEditor,\n) =>\n | PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>\n | Promise<PasteUnfurlingTransformResult<ExtraDataType, NodePropsType>>;\n\nexport type PasteUnfurlingPluginBaseProps<ExtraDataType, NodePropsType> = {\n entityPluginId: string;\n transforms: PasteUnfurlingTransformFunction<ExtraDataType, NodePropsType>[];\n $createEntityNode: (\n pluginId: string,\n text: string,\n data?: ExtraDataType,\n entityProps?: NodePropsType,\n key?: NodeKey,\n ) => LexicalNode;\n};\n"],"names":[],"rangeMappings":"","mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-copilot/chat-input-plugins",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
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",