@fluentui-copilot/chat-input-plugins 0.0.6 → 0.0.8

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,37 @@
2
2
  "name": "@fluentui-copilot/chat-input-plugins",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 15 May 2024 23:57:19 GMT",
5
+ "date": "Thu, 13 Jun 2024 21:00:13 GMT",
6
+ "tag": "@fluentui-copilot/chat-input-plugins_v0.0.8",
7
+ "version": "0.0.8",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "owcampbe@microsoft.com",
12
+ "package": "@fluentui-copilot/chat-input-plugins",
13
+ "commit": "2a74bcd688f65f34bc8230487d70dfa310a353eb",
14
+ "comment": "feat: Add PasteUnfurling plugin."
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Fri, 17 May 2024 23:06:24 GMT",
21
+ "tag": "@fluentui-copilot/chat-input-plugins_v0.0.7",
22
+ "version": "0.0.7",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "owcampbe@microsoft.com",
27
+ "package": "@fluentui-copilot/chat-input-plugins",
28
+ "commit": "03d610bd40dea99f4fc8f1c0986e77bb619137aa",
29
+ "comment": "fix: Make SentinelNode aria hidden."
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Wed, 15 May 2024 23:57:34 GMT",
6
36
  "tag": "@fluentui-copilot/chat-input-plugins_v0.0.6",
7
37
  "version": "0.0.6",
8
38
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,30 @@
1
1
  # Change Log - @fluentui-copilot/chat-input-plugins
2
2
 
3
- This log was last generated on Wed, 15 May 2024 23:57:19 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 13 Jun 2024 21:00:13 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [0.0.8](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.0.8)
8
+
9
+ Thu, 13 Jun 2024 21:00:13 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.0.7..@fluentui-copilot/chat-input-plugins_v0.0.8)
11
+
12
+ ### Patches
13
+
14
+ - feat: Add PasteUnfurling plugin. ([PR #1696](https://github.com/microsoft/fluentai/pull/1696) by owcampbe@microsoft.com)
15
+
16
+ ## [0.0.7](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.0.7)
17
+
18
+ Fri, 17 May 2024 23:06:24 GMT
19
+ [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.0.6..@fluentui-copilot/chat-input-plugins_v0.0.7)
20
+
21
+ ### Patches
22
+
23
+ - fix: Make SentinelNode aria hidden. ([PR #1633](https://github.com/microsoft/fluentai/pull/1633) by owcampbe@microsoft.com)
24
+
7
25
  ## [0.0.6](https://github.com/microsoft/fluentai/tree/@fluentui-copilot/chat-input-plugins_v0.0.6)
8
26
 
9
- Wed, 15 May 2024 23:57:19 GMT
27
+ Wed, 15 May 2024 23:57:34 GMT
10
28
  [Compare changes](https://github.com/microsoft/fluentai/compare/@fluentui-copilot/chat-input-plugins_v0.0.5..@fluentui-copilot/chat-input-plugins_v0.0.6)
11
29
 
12
30
  ### Patches
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { EditorConfig } from 'lexical';
1
2
  import { EditorState } from 'lexical';
2
3
  import { Klass } from 'lexical';
3
4
  import { LexicalEditor } from 'lexical';
@@ -153,13 +154,37 @@ export declare class ManualGhostTextBase<ComponentPropsType> {
153
154
  cancelGhostText(): void;
154
155
  }
155
156
 
157
+ export declare type PasteUnfurlingPluginProps<ExtraDataType, NodePropsType> = {
158
+ entityPluginId: string;
159
+ transforms: TransformFunction<ExtraDataType, NodePropsType>[];
160
+ $createEntityNode: (pluginId: string, text: string, data?: ExtraDataType, entityProps?: NodePropsType, key?: NodeKey) => LexicalNode;
161
+ };
162
+
163
+ export declare function registerPasteUnfurlingPlugin<ExtraDataType, NodePropsType>(editor: LexicalEditor, props: PasteUnfurlingPluginProps<ExtraDataType, NodePropsType>): () => void;
164
+
156
165
  export declare const SENTINEL_VALUE = "\u200B\u200C";
157
166
 
158
167
  export declare class SentinelNode extends TextNode {
159
168
  constructor(key?: NodeKey);
160
169
  static getType(): string;
161
170
  static clone(node: SentinelNode): SentinelNode;
171
+ createDOM(config: EditorConfig): HTMLElement;
162
172
  isToken(): boolean;
163
173
  }
164
174
 
175
+ export declare type TransformedPart<ExtraDataType, NodePropsType> = {
176
+ type: 'text';
177
+ value: string;
178
+ } | {
179
+ type: 'entity';
180
+ value: ChatInputEntityData<ExtraDataType, NodePropsType>;
181
+ };
182
+
183
+ export declare type TransformFunction<ExtraDataType, NodePropsType> = (event: ClipboardEvent, editor: LexicalEditor) => TransformResult<ExtraDataType, NodePropsType>;
184
+
185
+ export declare type TransformResult<ExtraDataType, NodePropsType> = {
186
+ handled: boolean;
187
+ transformedParts?: TransformedPart<ExtraDataType, NodePropsType>[];
188
+ };
189
+
165
190
  export { }
@@ -7,6 +7,11 @@ export class SentinelNode extends TextNode {
7
7
  static clone(node) {
8
8
  return new SentinelNode(node.__key);
9
9
  }
10
+ createDOM(config) {
11
+ const element = super.createDOM(config);
12
+ element.ariaHidden = 'true';
13
+ return element;
14
+ }
10
15
  isToken() {
11
16
  return true;
12
17
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["SentinelNode.ts"],"sourcesContent":["import type { LexicalNode, NodeKey } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\n\nexport const SENTINEL_VALUE = '\\u200b\\u200c';\n\nexport class SentinelNode extends TextNode {\n constructor(key?: NodeKey) {\n // 2 zero width characters will not be visible in the editor.\n // These also happen to be markers for CIQ to ignore the following content.\n super(SENTINEL_VALUE, key);\n }\n\n static getType() {\n return 'sentinel';\n }\n static clone(node: SentinelNode) {\n return new SentinelNode(node.__key);\n }\n\n isToken() {\n return true;\n }\n}\n\nexport function $createSentinelNode(key?: NodeKey) {\n return new SentinelNode(key);\n}\n\nexport function $isSentinelNode(node: LexicalNode | null): node is SentinelNode {\n return node instanceof SentinelNode;\n}\n"],"names":["TextNode","SENTINEL_VALUE","SentinelNode","getType","clone","node","__key","isToken","constructor","key","$createSentinelNode","$isSentinelNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,QAAQ,QAAQ,gCAAgC;AAEzD,OAAO,MAAMC,iBAAiB,eAAe;AAE7C,OAAO,MAAMC,qBAAqBF;IAOhC,OAAOG,UAAU;QACf,OAAO;IACT;IACA,OAAOC,MAAMC,IAAkB,EAAE;QAC/B,OAAO,IAAIH,aAAaG,KAAKC,KAAK;IACpC;IAEAC,UAAU;QACR,OAAO;IACT;IAfAC,YAAYC,GAAa,CAAE;QACzB,6DAA6D;QAC7D,2EAA2E;QAC3E,KAAK,CAACR,gBAAgBQ;IACxB;AAYF;AAEA,OAAO,SAASC,oBAAoBD,GAAa;IAC/C,OAAO,IAAIP,aAAaO;AAC1B;AAEA,OAAO,SAASE,gBAAgBN,IAAwB;IACtD,OAAOA,gBAAgBH;AACzB"}
1
+ {"version":3,"sources":["SentinelNode.ts"],"sourcesContent":["import type { EditorConfig, LexicalNode, NodeKey } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\n\nexport const SENTINEL_VALUE = '\\u200b\\u200c';\n\nexport class SentinelNode extends TextNode {\n constructor(key?: NodeKey) {\n // 2 zero width characters will not be visible in the editor.\n // These also happen to be markers for CIQ to ignore the following content.\n super(SENTINEL_VALUE, key);\n }\n\n static getType() {\n return 'sentinel';\n }\n static clone(node: SentinelNode) {\n return new SentinelNode(node.__key);\n }\n\n 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\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","constructor","key","$createSentinelNode","$isSentinelNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AACA,SAASA,QAAQ,QAAQ,gCAAgC;AAEzD,OAAO,MAAMC,iBAAiB,eAAe;AAE7C,OAAO,MAAMC,qBAAqBF;IAOhC,OAAOG,UAAU;QACf,OAAO;IACT;IACA,OAAOC,MAAMC,IAAkB,EAAE;QAC/B,OAAO,IAAIH,aAAaG,KAAKC,KAAK;IACpC;IAEAC,UAAUC,MAAoB,EAAe;QAC3C,MAAMC,UAAU,KAAK,CAACF,UAAUC;QAChCC,QAAQC,UAAU,GAAG;QACrB,OAAOD;IACT;IAEAE,UAAU;QACR,OAAO;IACT;IArBAC,YAAYC,GAAa,CAAE;QACzB,6DAA6D;QAC7D,2EAA2E;QAC3E,KAAK,CAACZ,gBAAgBY;IACxB;AAkBF;AAEA,OAAO,SAASC,oBAAoBD,GAAa;IAC/C,OAAO,IAAIX,aAAaW;AAC1B;AAEA,OAAO,SAASE,gBAAgBV,IAAwB;IACtD,OAAOA,gBAAgBH;AACzB"}
@@ -0,0 +1,39 @@
1
+ import { PASTE_COMMAND, COMMAND_PRIORITY_HIGH, $insertNodes, $createTextNode } from '@fluentui-copilot/text-editor';
2
+ function unhandledPart(part) {
3
+ throw new Error(`Unhandled part: ${part}`);
4
+ }
5
+ export function registerPasteUnfurlingPlugin(editor, props) {
6
+ const {
7
+ entityPluginId,
8
+ transforms,
9
+ $createEntityNode
10
+ } = props;
11
+ function insertParts(parts) {
12
+ editor.update(() => {
13
+ const nodes = parts.map(part => {
14
+ switch (part.type) {
15
+ case 'entity':
16
+ return $createEntityNode(entityPluginId, part.value.text, part.value.data, part.value.entityProps);
17
+ case 'text':
18
+ return $createTextNode(part.value);
19
+ }
20
+ return unhandledPart(part);
21
+ });
22
+ $insertNodes(nodes);
23
+ });
24
+ }
25
+ function handlePaste(event) {
26
+ for (const transform of transforms) {
27
+ const result = transform(event, editor);
28
+ if (result.transformedParts) {
29
+ insertParts(result.transformedParts);
30
+ }
31
+ if (result.handled) {
32
+ return true;
33
+ }
34
+ }
35
+ return false;
36
+ }
37
+ return editor.registerCommand(PASTE_COMMAND, handlePaste, COMMAND_PRIORITY_HIGH);
38
+ }
39
+ //# sourceMappingURL=PasteUnfurling.base.js.map
@@ -0,0 +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 { PasteUnfurlingPluginProps, TransformedPart } 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: PasteUnfurlingPluginProps<ExtraDataType, NodePropsType>,\n): () => void {\n const { entityPluginId, transforms, $createEntityNode } = props;\n\n function insertParts(parts: TransformedPart<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,KAA8D;IAE9D,MAAM,EAAEC,cAAc,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GAAGH;IAE1D,SAASI,YAAYC,KAAsD;QACzEN,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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PasteUnfurling.types.js.map
@@ -0,0 +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 TransformedPart<ExtraDataType, NodePropsType> =\n | { type: 'text'; value: string }\n | { type: 'entity'; value: ChatInputEntityData<ExtraDataType, NodePropsType> };\n\nexport type TransformResult<ExtraDataType, NodePropsType> = {\n handled: boolean;\n transformedParts?: TransformedPart<ExtraDataType, NodePropsType>[];\n};\n\nexport type TransformFunction<ExtraDataType, NodePropsType> = (\n event: ClipboardEvent,\n editor: LexicalEditor,\n) => TransformResult<ExtraDataType, NodePropsType>;\n\nexport type PasteUnfurlingPluginProps<ExtraDataType, NodePropsType> = {\n entityPluginId: string;\n transforms: TransformFunction<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"}
@@ -0,0 +1,3 @@
1
+ export * from './PasteUnfurling.base';
2
+ export * from './PasteUnfurling.types';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './PasteUnfurling.base';\nexport * from './PasteUnfurling.types';\n"],"names":[],"rangeMappings":";","mappings":"AAAA,cAAc,wBAAwB;AACtC,cAAc,yBAAyB"}
package/lib/index.js CHANGED
@@ -3,4 +3,5 @@ export { ChatInputEntityPluginBase } from './ChatInputEntity';
3
3
  export { GhostTextPluginBase } from './GhostText';
4
4
  export { ImperativeControlBase } from './ImperativeControl';
5
5
  export { ManualGhostTextBase } from './ManualGhostText';
6
+ export { registerPasteUnfurlingPlugin } from './PasteUnfurling';
6
7
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export {\n BasicFunctionalityBase,\n SentinelNode,\n $createSentinelNode,\n $isSentinelNode,\n SENTINEL_VALUE,\n} from './BasicFunctionality';\nexport type { IBasicFunctionalityBase } from './BasicFunctionality';\n\nexport { ChatInputEntityPluginBase } from './ChatInputEntity';\nexport type {\n ChatInputEntityData,\n ChatInputEntityPluginProps,\n IChatInputEntityPluginBase,\n IEntityNode,\n} from './ChatInputEntity';\n\nexport { GhostTextPluginBase } from './GhostText';\nexport type { GetGhostTextFunction, IGhostTextNode } from './GhostText';\n\nexport { ImperativeControlBase } from './ImperativeControl';\nexport type { IImperativeControlBase } from './ImperativeControl';\n\nexport { ManualGhostTextBase } from './ManualGhostText';\nexport type { IManualGhostTextBase } from './ManualGhostText';\n"],"names":["BasicFunctionalityBase","SentinelNode","$createSentinelNode","$isSentinelNode","SENTINEL_VALUE","ChatInputEntityPluginBase","GhostTextPluginBase","ImperativeControlBase","ManualGhostTextBase"],"rangeMappings":";;;;","mappings":"AAAA,SACEA,sBAAsB,EACtBC,YAAY,EACZC,mBAAmB,EACnBC,eAAe,EACfC,cAAc,QACT,uBAAuB;AAG9B,SAASC,yBAAyB,QAAQ,oBAAoB;AAQ9D,SAASC,mBAAmB,QAAQ,cAAc;AAGlD,SAASC,qBAAqB,QAAQ,sBAAsB;AAG5D,SAASC,mBAAmB,QAAQ,oBAAoB"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export {\n BasicFunctionalityBase,\n SentinelNode,\n $createSentinelNode,\n $isSentinelNode,\n SENTINEL_VALUE,\n} from './BasicFunctionality';\nexport type { IBasicFunctionalityBase } from './BasicFunctionality';\n\nexport { ChatInputEntityPluginBase } from './ChatInputEntity';\nexport type {\n ChatInputEntityData,\n ChatInputEntityPluginProps,\n IChatInputEntityPluginBase,\n IEntityNode,\n} from './ChatInputEntity';\n\nexport { GhostTextPluginBase } from './GhostText';\nexport type { GetGhostTextFunction, IGhostTextNode } from './GhostText';\n\nexport { ImperativeControlBase } from './ImperativeControl';\nexport type { IImperativeControlBase } from './ImperativeControl';\n\nexport { ManualGhostTextBase } from './ManualGhostText';\nexport type { IManualGhostTextBase } from './ManualGhostText';\n\nexport { registerPasteUnfurlingPlugin } from './PasteUnfurling';\nexport type { PasteUnfurlingPluginProps, TransformFunction, TransformedPart, TransformResult } from './PasteUnfurling';\n"],"names":["BasicFunctionalityBase","SentinelNode","$createSentinelNode","$isSentinelNode","SENTINEL_VALUE","ChatInputEntityPluginBase","GhostTextPluginBase","ImperativeControlBase","ManualGhostTextBase","registerPasteUnfurlingPlugin"],"rangeMappings":";;;;;","mappings":"AAAA,SACEA,sBAAsB,EACtBC,YAAY,EACZC,mBAAmB,EACnBC,eAAe,EACfC,cAAc,QACT,uBAAuB;AAG9B,SAASC,yBAAyB,QAAQ,oBAAoB;AAQ9D,SAASC,mBAAmB,QAAQ,cAAc;AAGlD,SAASC,qBAAqB,QAAQ,sBAAsB;AAG5D,SAASC,mBAAmB,QAAQ,oBAAoB;AAGxD,SAASC,4BAA4B,QAAQ,mBAAmB"}
@@ -31,6 +31,11 @@ class SentinelNode extends _texteditor.TextNode {
31
31
  static clone(node) {
32
32
  return new SentinelNode(node.__key);
33
33
  }
34
+ createDOM(config) {
35
+ const element = super.createDOM(config);
36
+ element.ariaHidden = 'true';
37
+ return element;
38
+ }
34
39
  isToken() {
35
40
  return true;
36
41
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["SentinelNode.ts"],"sourcesContent":["import type { LexicalNode, NodeKey } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\n\nexport const SENTINEL_VALUE = '\\u200b\\u200c';\n\nexport class SentinelNode extends TextNode {\n constructor(key?: NodeKey) {\n // 2 zero width characters will not be visible in the editor.\n // These also happen to be markers for CIQ to ignore the following content.\n super(SENTINEL_VALUE, key);\n }\n\n static getType() {\n return 'sentinel';\n }\n static clone(node: SentinelNode) {\n return new SentinelNode(node.__key);\n }\n\n isToken() {\n return true;\n }\n}\n\nexport function $createSentinelNode(key?: NodeKey) {\n return new SentinelNode(key);\n}\n\nexport function $isSentinelNode(node: LexicalNode | null): node is SentinelNode {\n return node instanceof SentinelNode;\n}\n"],"names":["$createSentinelNode","$isSentinelNode","SENTINEL_VALUE","SentinelNode","TextNode","getType","clone","node","__key","isToken","constructor","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAwBgBA,mBAAAA;eAAAA;;IAIAC,eAAAA;eAAAA;;IAzBHC,cAAAA;eAAAA;;IAEAC,YAAAA;eAAAA;;;4BAJY;AAElB,MAAMD,iBAAiB;AAEvB,MAAMC,qBAAqBC,oBAAAA;WAOhCC,UAAOA;eACL;;WAEFC,MAAOA,IAAMC,EAAkB;eAC7B,IAAOJ,aAAIA,KAAaI,KAAKC;;cAG/BC;eACE;;gBAdFC,GAAYC,CAAa;qEACvB;mFACA;aACA,CAAAT,gBAAMA;;AAaV;AAEO,SAASF,oBAAoBW,GAAa;WAC/C,IAAOR,aAAIA;AACb;AAEO,SAASF,gBAAgBM,IAAwB;WACtDA,gBAAOA;AACT"}
1
+ {"version":3,"sources":["SentinelNode.ts"],"sourcesContent":["import type { EditorConfig, LexicalNode, NodeKey } from '@fluentui-copilot/text-editor';\nimport { TextNode } from '@fluentui-copilot/text-editor';\n\nexport const SENTINEL_VALUE = '\\u200b\\u200c';\n\nexport class SentinelNode extends TextNode {\n constructor(key?: NodeKey) {\n // 2 zero width characters will not be visible in the editor.\n // These also happen to be markers for CIQ to ignore the following content.\n super(SENTINEL_VALUE, key);\n }\n\n static getType() {\n return 'sentinel';\n }\n static clone(node: SentinelNode) {\n return new SentinelNode(node.__key);\n }\n\n 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\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","constructor","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IA8BgBA,mBAAAA;eAAAA;;IAIAC,eAAAA;eAAAA;;IA/BHC,cAAAA;eAAAA;;IAEAC,YAAAA;eAAAA;;;4BAJY;AAElB,MAAMD,iBAAiB;AAEvB,MAAMC,qBAAqBC,oBAAAA;WAOhCC,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;;gBApBFC,GAAYC,CAAa;qEACvB;mFACA;aACA,CAAAb,gBAAMA;;AAmBV;AAEO,SAASF,oBAAoBe,GAAa;WAC/C,IAAOZ,aAAIA;AACb;AAEO,SAASF,gBAAgBM,IAAwB;WACtDA,gBAAOA;AACT"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "registerPasteUnfurlingPlugin", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return registerPasteUnfurlingPlugin;
9
+ }
10
+ });
11
+ const _texteditor = require("@fluentui-copilot/text-editor");
12
+ function unhandledPart(part) {
13
+ throw new Error(`Unhandled part: ${part}`);
14
+ }
15
+ function registerPasteUnfurlingPlugin(editor, props) {
16
+ const { entityPluginId, transforms, $createEntityNode } = props;
17
+ function insertParts(parts) {
18
+ editor.update(()=>{
19
+ const nodes = parts.map((part)=>{
20
+ switch(part.type){
21
+ case 'entity':
22
+ return $createEntityNode(entityPluginId, part.value.text, part.value.data, part.value.entityProps);
23
+ case 'text':
24
+ return (0, _texteditor.$createTextNode)(part.value);
25
+ }
26
+ return unhandledPart(part);
27
+ });
28
+ (0, _texteditor.$insertNodes)(nodes);
29
+ });
30
+ }
31
+ function handlePaste(event) {
32
+ for (const transform of transforms){
33
+ const result = transform(event, editor);
34
+ if (result.transformedParts) {
35
+ insertParts(result.transformedParts);
36
+ }
37
+ if (result.handled) {
38
+ return true;
39
+ }
40
+ }
41
+ return false;
42
+ }
43
+ return editor.registerCommand(_texteditor.PASTE_COMMAND, handlePaste, _texteditor.COMMAND_PRIORITY_HIGH);
44
+ } //# sourceMappingURL=PasteUnfurling.base.js.map
@@ -0,0 +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 { PasteUnfurlingPluginProps, TransformedPart } 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: PasteUnfurlingPluginProps<ExtraDataType, NodePropsType>,\n): () => void {\n const { entityPluginId, transforms, $createEntityNode } = props;\n\n function insertParts(parts: TransformedPart<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,KAA8D;UAE9D,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"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ //# sourceMappingURL=PasteUnfurling.types.js.map
@@ -0,0 +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 TransformedPart<ExtraDataType, NodePropsType> =\n | { type: 'text'; value: string }\n | { type: 'entity'; value: ChatInputEntityData<ExtraDataType, NodePropsType> };\n\nexport type TransformResult<ExtraDataType, NodePropsType> = {\n handled: boolean;\n transformedParts?: TransformedPart<ExtraDataType, NodePropsType>[];\n};\n\nexport type TransformFunction<ExtraDataType, NodePropsType> = (\n event: ClipboardEvent,\n editor: LexicalEditor,\n) => TransformResult<ExtraDataType, NodePropsType>;\n\nexport type PasteUnfurlingPluginProps<ExtraDataType, NodePropsType> = {\n entityPluginId: string;\n transforms: TransformFunction<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":""}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./PasteUnfurling.base"), exports);
7
+ _export_star._(require("./PasteUnfurling.types"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './PasteUnfurling.base';\nexport * from './PasteUnfurling.types';\n"],"names":[],"rangeMappings":";;;;;;","mappings":";;;;;uBAAc;uBACA"}
@@ -35,6 +35,9 @@ _export(exports, {
35
35
  },
36
36
  SentinelNode: function() {
37
37
  return _BasicFunctionality.SentinelNode;
38
+ },
39
+ registerPasteUnfurlingPlugin: function() {
40
+ return _PasteUnfurling.registerPasteUnfurlingPlugin;
38
41
  }
39
42
  });
40
43
  const _BasicFunctionality = require("./BasicFunctionality");
@@ -42,4 +45,5 @@ const _ChatInputEntity = require("./ChatInputEntity");
42
45
  const _GhostText = require("./GhostText");
43
46
  const _ImperativeControl = require("./ImperativeControl");
44
47
  const _ManualGhostText = require("./ManualGhostText");
48
+ const _PasteUnfurling = require("./PasteUnfurling");
45
49
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export {\n BasicFunctionalityBase,\n SentinelNode,\n $createSentinelNode,\n $isSentinelNode,\n SENTINEL_VALUE,\n} from './BasicFunctionality';\nexport type { IBasicFunctionalityBase } from './BasicFunctionality';\n\nexport { ChatInputEntityPluginBase } from './ChatInputEntity';\nexport type {\n ChatInputEntityData,\n ChatInputEntityPluginProps,\n IChatInputEntityPluginBase,\n IEntityNode,\n} from './ChatInputEntity';\n\nexport { GhostTextPluginBase } from './GhostText';\nexport type { GetGhostTextFunction, IGhostTextNode } from './GhostText';\n\nexport { ImperativeControlBase } from './ImperativeControl';\nexport type { IImperativeControlBase } from './ImperativeControl';\n\nexport { ManualGhostTextBase } from './ManualGhostText';\nexport type { IManualGhostTextBase } from './ManualGhostText';\n"],"names":["$createSentinelNode","$isSentinelNode","BasicFunctionalityBase","ChatInputEntityPluginBase","GhostTextPluginBase","ImperativeControlBase","ManualGhostTextBase","SENTINEL_VALUE","SentinelNode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAGEA,mBAAmB;eAAnBA,uCAAmB;;IACnBC,eAAe;eAAfA,mCAAe;;IAHfC,sBAAsB;eAAtBA,0CAAsB;;IAQfC,yBAAyB;eAAzBA,0CAAyB;;IAQzBC,mBAAmB;eAAnBA,8BAAmB;;IAGnBC,qBAAqB;eAArBA,wCAAqB;;IAGrBC,mBAAmB;eAAnBA,oCAAmB;;IAlB1BC,cAAc;eAAdA,kCAAc;;IAHdC,YAAY;eAAZA,gCAAY;;;oCAIP;iCAGmC;2BAQN;mCAGE;iCAGF"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export {\n BasicFunctionalityBase,\n SentinelNode,\n $createSentinelNode,\n $isSentinelNode,\n SENTINEL_VALUE,\n} from './BasicFunctionality';\nexport type { IBasicFunctionalityBase } from './BasicFunctionality';\n\nexport { ChatInputEntityPluginBase } from './ChatInputEntity';\nexport type {\n ChatInputEntityData,\n ChatInputEntityPluginProps,\n IChatInputEntityPluginBase,\n IEntityNode,\n} from './ChatInputEntity';\n\nexport { GhostTextPluginBase } from './GhostText';\nexport type { GetGhostTextFunction, IGhostTextNode } from './GhostText';\n\nexport { ImperativeControlBase } from './ImperativeControl';\nexport type { IImperativeControlBase } from './ImperativeControl';\n\nexport { ManualGhostTextBase } from './ManualGhostText';\nexport type { IManualGhostTextBase } from './ManualGhostText';\n\nexport { registerPasteUnfurlingPlugin } from './PasteUnfurling';\nexport type { PasteUnfurlingPluginProps, TransformFunction, TransformedPart, TransformResult } from './PasteUnfurling';\n"],"names":["$createSentinelNode","$isSentinelNode","BasicFunctionalityBase","ChatInputEntityPluginBase","GhostTextPluginBase","ImperativeControlBase","ManualGhostTextBase","SENTINEL_VALUE","SentinelNode","registerPasteUnfurlingPlugin"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAGEA,mBAAmB;eAAnBA,uCAAmB;;IACnBC,eAAe;eAAfA,mCAAe;;IAHfC,sBAAsB;eAAtBA,0CAAsB;;IAQfC,yBAAyB;eAAzBA,0CAAyB;;IAQzBC,mBAAmB;eAAnBA,8BAAmB;;IAGnBC,qBAAqB;eAArBA,wCAAqB;;IAGrBC,mBAAmB;eAAnBA,oCAAmB;;IAlB1BC,cAAc;eAAdA,kCAAc;;IAHdC,YAAY;eAAZA,gCAAY;;IAwBLC,4BAA4B;eAA5BA,4CAA4B;;;oCApB9B;iCAGmC;2BAQN;mCAGE;iCAGF;gCAGS"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-copilot/chat-input-plugins",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
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.0.3",
15
+ "@fluentui-copilot/text-editor": "^0.0.4",
16
16
  "@swc/helpers": "^0.5.1"
17
17
  },
18
18
  "beachball": {