@fluentui-copilot/chat-input-plugins 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.json +55 -1
  2. package/CHANGELOG.md +24 -2
  3. package/dist/index.d.ts +20 -1
  4. package/lib/BasicFunctionality/BasicFunctionality.base.js +106 -8
  5. package/lib/BasicFunctionality/BasicFunctionality.base.js.map +1 -1
  6. package/lib/BasicFunctionality/SentinelNode.js +25 -0
  7. package/lib/BasicFunctionality/SentinelNode.js.map +1 -0
  8. package/lib/BasicFunctionality/index.js +1 -0
  9. package/lib/BasicFunctionality/index.js.map +1 -1
  10. package/lib/ChatInputEntity/ChatInputEntityPlugin.base.js.map +1 -1
  11. package/lib/ChatInputEntity/ChatInputEntityPlugin.types.js.map +1 -1
  12. package/lib/ChatInputEntity/index.js.map +1 -1
  13. package/lib/GhostText/GhostText.base.js +46 -4
  14. package/lib/GhostText/GhostText.base.js.map +1 -1
  15. package/lib/GhostText/index.js.map +1 -1
  16. package/lib/ImperativeControl/ImperativeControl.base.js +4 -2
  17. package/lib/ImperativeControl/ImperativeControl.base.js.map +1 -1
  18. package/lib/ImperativeControl/index.js.map +1 -1
  19. package/lib/ManualGhostText/ManualGhostText.base.js.map +1 -1
  20. package/lib/ManualGhostText/index.js.map +1 -1
  21. package/lib/index.js +1 -1
  22. package/lib/index.js.map +1 -1
  23. package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js +101 -7
  24. package/lib-commonjs/BasicFunctionality/BasicFunctionality.base.js.map +1 -1
  25. package/lib-commonjs/BasicFunctionality/SentinelNode.js +48 -0
  26. package/lib-commonjs/BasicFunctionality/SentinelNode.js.map +1 -0
  27. package/lib-commonjs/BasicFunctionality/index.js +1 -0
  28. package/lib-commonjs/BasicFunctionality/index.js.map +1 -1
  29. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.base.js.map +1 -1
  30. package/lib-commonjs/ChatInputEntity/ChatInputEntityPlugin.types.js.map +1 -1
  31. package/lib-commonjs/ChatInputEntity/index.js.map +1 -1
  32. package/lib-commonjs/GhostText/GhostText.base.js +45 -3
  33. package/lib-commonjs/GhostText/GhostText.base.js.map +1 -1
  34. package/lib-commonjs/GhostText/index.js.map +1 -1
  35. package/lib-commonjs/ImperativeControl/ImperativeControl.base.js +4 -2
  36. package/lib-commonjs/ImperativeControl/ImperativeControl.base.js.map +1 -1
  37. package/lib-commonjs/ImperativeControl/index.js.map +1 -1
  38. package/lib-commonjs/ManualGhostText/ManualGhostText.base.js.map +1 -1
  39. package/lib-commonjs/ManualGhostText/index.js.map +1 -1
  40. package/lib-commonjs/index.js +12 -0
  41. package/lib-commonjs/index.js.map +1 -1
  42. package/package.json +2 -2
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "ImperativeControlBase", {
10
10
  });
11
11
  const _define_property = require("@swc/helpers/_/_define_property");
12
12
  const _texteditor = require("@fluentui-copilot/text-editor");
13
+ const _BasicFunctionality = require("../BasicFunctionality");
13
14
  class ImperativeControlBase {
14
15
  moveCursor(location) {
15
16
  this.__editor.update(()=>{
@@ -62,12 +63,13 @@ class ImperativeControlBase {
62
63
  insertTextAtCursor(text) {
63
64
  this.__editor.update(()=>{
64
65
  var _$getSelection;
65
- (_$getSelection = (0, _texteditor.$getSelection)()) === null || _$getSelection === void 0 ? void 0 : _$getSelection.insertText(text);
66
+ const selection = (_$getSelection = (0, _texteditor.$getSelection)()) !== null && _$getSelection !== void 0 ? _$getSelection : (0, _texteditor.$getRoot)().selectEnd();
67
+ selection.insertText(text);
66
68
  });
67
69
  }
68
70
  getInputText() {
69
71
  return this.__editor.getEditorState().read(()=>{
70
- return (0, _texteditor.$getRoot)().getTextContent();
72
+ return (0, _texteditor.$getRoot)().getTextContent().replace(_BasicFunctionality.SENTINEL_VALUE, '');
71
73
  });
72
74
  }
73
75
  scrollToBottom() {
@@ -1 +1 @@
1
- {"version":3,"sources":["ImperativeControl.base.js"],"sourcesContent":["import { _ as _define_property } from \"@swc/helpers/_/_define_property\";\nimport { $createParagraphNode, $createRangeSelection, $createTextNode, $getLeafNodes, $getRoot, $getSelection, $isTextNode, $normalizeSelection__EXPERIMENTAL, $setSelection } from '@fluentui-copilot/text-editor';\nexport class ImperativeControlBase {\n moveCursor(location) {\n this.__editor.update(() => {\n const children = $getLeafNodes($getRoot());\n let baseOffset = 0;\n let currentNode = children.shift();\n while (baseOffset < location && currentNode) {\n const nodeLength = $isTextNode(currentNode) && !currentNode.isToken() ? currentNode.getTextContent().length : 1;\n if (baseOffset + nodeLength >= location) {\n const elementType = $isTextNode(currentNode) ? 'text' : 'element';\n const localOffset = location - baseOffset;\n const nodeKey = currentNode.getKey();\n const selection = $createRangeSelection();\n selection.anchor.set(nodeKey, localOffset, elementType);\n selection.focus.set(nodeKey, localOffset, elementType);\n $setSelection($normalizeSelection__EXPERIMENTAL(selection));\n return;\n }\n baseOffset += nodeLength;\n currentNode = children.shift();\n }\n if (location > baseOffset) {\n $getRoot().selectEnd();\n }\n });\n }\n setInputText(inputText) {\n this.__editor.update(() => {\n const root = $getRoot();\n root.clear();\n if (inputText !== '') {\n const newParagraph = $createParagraphNode();\n const newText = $createTextNode(inputText);\n newParagraph.append(newText);\n root.append(newParagraph);\n root.selectEnd();\n }\n });\n }\n appendText(text) {\n this.__editor.update(() => {\n $getRoot().selectEnd().insertText(text);\n });\n }\n prependText(text) {\n this.__editor.update(() => {\n $getRoot().selectStart().insertText(text);\n });\n }\n insertTextAtCursor(text) {\n this.__editor.update(() => {\n var _$getSelection;\n (_$getSelection = $getSelection()) === null || _$getSelection === void 0 ? void 0 : _$getSelection.insertText(text);\n });\n }\n getInputText() {\n return this.__editor.getEditorState().read(() => {\n return $getRoot().getTextContent();\n });\n }\n scrollToBottom() {\n var _this___editor_getRootElement;\n (_this___editor_getRootElement = this.__editor.getRootElement()) === null || _this___editor_getRootElement === void 0 ? void 0 : _this___editor_getRootElement.scrollIntoView({\n behavior: 'smooth',\n block: 'end'\n });\n return;\n }\n constructor(editor) {\n _define_property(this, \"__editor\", void 0);\n this.__editor = editor;\n }\n}\n//# sourceMappingURL=ImperativeControl.base.js.map"],"names":["ImperativeControlBase","moveCursor","location","__editor","update","children","$getLeafNodes","$getRoot","baseOffset","currentNode","shift","nodeLength","$isTextNode","isToken","getTextContent","length","elementType","localOffset","nodeKey","getKey","selection","$createRangeSelection","anchor","set","focus","$setSelection","$normalizeSelection__EXPERIMENTAL","selectEnd","setInputText","inputText","root","clear","newParagraph","$createParagraphNode","newText","$createTextNode","append","appendText","text","insertText","prependText","selectStart","insertTextAtCursor","_$getSelection","$getSelection","getInputText","getEditorState","read","scrollToBottom","_this___editor_getRootElement","getRootElement","scrollIntoView","behavior","block","constructor","editor","_define_property"],"mappings":";;;;+BAEaA;;;eAAAA;;;iCAFyB;4BAC8I;AAC7K,MAAMA;IACXC,WAAWC,QAAQ,EAAE;QACnB,IAAI,CAACC,QAAQ,CAACC,MAAM,CAAC;YACnB,MAAMC,WAAWC,IAAAA,yBAAa,EAACC,IAAAA,oBAAQ;YACvC,IAAIC,aAAa;YACjB,IAAIC,cAAcJ,SAASK,KAAK;YAChC,MAAOF,aAAaN,YAAYO,YAAa;gBAC3C,MAAME,aAAaC,IAAAA,uBAAW,EAACH,gBAAgB,CAACA,YAAYI,OAAO,KAAKJ,YAAYK,cAAc,GAAGC,MAAM,GAAG;gBAC9G,IAAIP,aAAaG,cAAcT,UAAU;oBACvC,MAAMc,cAAcJ,IAAAA,uBAAW,EAACH,eAAe,SAAS;oBACxD,MAAMQ,cAAcf,WAAWM;oBAC/B,MAAMU,UAAUT,YAAYU,MAAM;oBAClC,MAAMC,YAAYC,IAAAA,iCAAqB;oBACvCD,UAAUE,MAAM,CAACC,GAAG,CAACL,SAASD,aAAaD;oBAC3CI,UAAUI,KAAK,CAACD,GAAG,CAACL,SAASD,aAAaD;oBAC1CS,IAAAA,yBAAa,EAACC,IAAAA,6CAAiC,EAACN;oBAChD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c,CAAC;YAC5KC,UAAU;YACVC,OAAO;QACT;QACA;IACF;IACAC,YAAYC,MAAM,CAAE;QAClBC,IAAAA,kBAAgB,EAAC,IAAI,EAAE,YAAY,KAAK;QACxC,IAAI,CAACrD,QAAQ,GAAGoD;IAClB;AACF,EACA,kDAAkD"}
1
+ {"version":3,"sources":["ImperativeControl.base.ts"],"sourcesContent":["import type { LexicalEditor } from '@fluentui-copilot/text-editor';\nimport {\n $createParagraphNode,\n $createRangeSelection,\n $createTextNode,\n $getLeafNodes,\n $getRoot,\n $getSelection,\n $isTextNode,\n $normalizeSelection__EXPERIMENTAL,\n $setSelection,\n} from '@fluentui-copilot/text-editor';\nimport { SENTINEL_VALUE } from '../BasicFunctionality';\n\nexport interface IImperativeControlBase {\n setInputText: (inputText: string) => void;\n appendText: (text: string) => void;\n prependText: (text: string) => void;\n insertTextAtCursor: (text: string) => void;\n getInputText: () => string;\n scrollToBottom: () => void;\n moveCursor: (location: number) => void;\n}\n\nexport class ImperativeControlBase implements IImperativeControlBase {\n private __editor: LexicalEditor;\n\n constructor(editor: LexicalEditor) {\n this.__editor = editor;\n }\n\n moveCursor(location: number): void {\n this.__editor.update(() => {\n const children = $getLeafNodes($getRoot());\n\n let baseOffset = 0;\n let currentNode = children.shift();\n while (baseOffset < location && currentNode) {\n const nodeLength =\n $isTextNode(currentNode) && !currentNode.isToken()\n ? currentNode.getTextContent().length\n : // Token text nodes and non-text nodes are considered to be a single entry in the input\n 1;\n\n if (baseOffset + nodeLength >= location) {\n const elementType = $isTextNode(currentNode) ? 'text' : 'element';\n const localOffset = location - baseOffset;\n const nodeKey = currentNode.getKey();\n\n const selection = $createRangeSelection();\n selection.anchor.set(nodeKey, localOffset, elementType);\n selection.focus.set(nodeKey, localOffset, elementType);\n\n $setSelection($normalizeSelection__EXPERIMENTAL(selection));\n return;\n }\n\n baseOffset += nodeLength;\n currentNode = children.shift();\n }\n\n if (location > baseOffset) {\n $getRoot().selectEnd();\n }\n });\n }\n setInputText(inputText: string) {\n this.__editor.update(() => {\n const root = $getRoot();\n root.clear();\n if (inputText !== '') {\n const newParagraph = $createParagraphNode();\n const newText = $createTextNode(inputText);\n\n newParagraph.append(newText);\n root.append(newParagraph);\n root.selectEnd();\n }\n });\n }\n appendText(text: string) {\n this.__editor.update(() => {\n $getRoot().selectEnd().insertText(text);\n });\n }\n prependText(text: string) {\n this.__editor.update(() => {\n $getRoot().selectStart().insertText(text);\n });\n }\n insertTextAtCursor(text: string) {\n this.__editor.update(() => {\n const selection = $getSelection() ?? $getRoot().selectEnd();\n selection.insertText(text);\n });\n }\n getInputText() {\n return this.__editor.getEditorState().read(() => {\n return $getRoot().getTextContent().replace(SENTINEL_VALUE, '');\n });\n }\n scrollToBottom() {\n this.__editor.getRootElement()?.scrollIntoView({ behavior: 'smooth', block: 'end' });\n return;\n }\n}\n"],"names":["ImperativeControlBase","moveCursor","location","__editor","update","children","$getLeafNodes","$getRoot","baseOffset","currentNode","nodeLength","$isTextNode","isToken","getTextContent","length","elementType","localOffset","nodeKey","selection","$createRangeSelection","anchor","focus","$setSelection","$normalizeSelection__EXPERIMENTAL","selectEnd","setInputText","inputText","root","newParagraph","$createParagraphNode","newText","$createTextNode","appendText","text","insertText","prependText","selectStart","insertTextAtCursor","$getSelection","getInputText","getEditorState","read","replace","SENTINEL_VALUE","scrollToBottom","getRootElement","_this___editor_getRootElement","scrollIntoView","behavior","block","constructor","editor"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAwBaA;;;eAAAA;;;;4BAbN;oCACwB;AAYxB,MAAMA;eAOXC,QAAWC,EAAgB;YACzB,CAAAC,QAAKA,CAAAA,MAASC,CAAAA;kBACZC,WAAMA,IAAAA,yBAAWC,EAAAA,IAAAA,oBAAcC;6BAE3BC;8BACAC,SAAcJ,KAAAA;kBAClBG,aAAOA,YAAaN,YAAYO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AAA,cAAWM,GAAAA,OAAiB6B,CAAAA,kCAAQC,EAAAA;;;qBAG/CC;;yCACE,IAAA,CAAAzC,QAAKA,CAAAA,cAAS0C,EAAAA,MAAc,QAAAC,kCAA5B,KAAA,IAAA,KAAA,IAAAA,8BAAAC,cAAgCA,CAAAA;sBAAiBC;mBAAoBC;;;;gBA3EvEC,MAAYC,CAAqB;8BAFjC,EAAA,IAAA,EAAA,YAAQhD,KAAR;YAGE,CAAAA,QAAKA,GAAAA;;AA6ET"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export * from './ImperativeControl.base';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;uBAAc;CACd,iCAAiC"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './ImperativeControl.base';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
@@ -1 +1 @@
1
- {"version":3,"sources":["ManualGhostText.base.js"],"sourcesContent":["import { _ as _define_property } from \"@swc/helpers/_/_define_property\";\nimport { $createTextNode, $getNodeByKey, $insertNodes } from '@fluentui-copilot/text-editor';\nexport class ManualGhostTextBase {\n getGhostText() {\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 setGhostText(text, exposeText, componentProps) {\n this.__editor.update(() => {\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 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 commitGhostText(finalText) {\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 cancelGhostText() {\n if (this.__nodeKey) {\n this.__editor.update(() => {\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 constructor(editor, id, $isNodeType, $createNode) {\n _define_property(this, \"__editor\", void 0);\n _define_property(this, \"__nodeKey\", void 0);\n _define_property(this, \"__id\", void 0);\n _define_property(this, \"__$isNodeType\", void 0);\n _define_property(this, \"__$createNode\", void 0);\n this.__editor = editor;\n this.__id = id;\n this.__$isNodeType = $isNodeType;\n this.__$createNode = $createNode;\n }\n}\n//# sourceMappingURL=ManualGhostText.base.js.map"],"names":["ManualGhostTextBase","getGhostText","__editor","getEditorState","read","__nodeKey","node","$getNodeByKey","__$isNodeType","__content","setGhostText","text","exposeText","componentProps","update","getWritable","__$createNode","__id","getKey","$insertNodes","selectStart","tag","commitGhostText","finalText","textNode","$createTextNode","replace","selectEnd","undefined","cancelGhostText","remove","constructor","editor","id","$isNodeType","$createNode","_define_property"],"mappings":";;;;+BAEaA;;;eAAAA;;;iCAFyB;4BACuB;AACtD,MAAMA;IACXC,eAAe;QACb,OAAO,IAAI,CAACC,QAAQ,CAACC,cAAc,GAAGC,IAAI,CAAC;YACzC,IAAI,IAAI,CAACC,SAAS,EAAE;gBAClB,MAAMC,OAAOC,IAAAA,yBAAa,EAAC,IAAI,CAACF,SAAS;gBACzC,IAAI,IAAI,CAACG,aAAa,CAACF,OAAO;oBAC5B,OAAOA,KAAKG,SAAS;gBACvB;YACF;QACF;IACF;IACAC,aAAaC,IAAI,EAAEC,UAAU,EAAEC,cAAc,EAAE;QAC7C,IAAI,CAACX,QAAQ,CAACY,MAAM,CAAC;YACnB,IAAI,IAAI,CAACT,SAAS,EAAE;gBAClB,MAAMC,OAAOC,IAAAA,yBAAa,EAAC,IAAI,CAACF,SAAS;gB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,aAAa,KAAK;QACzCA,IAAAA,kBAAgB,EAAC,IAAI,EAAE,QAAQ,KAAK;QACpCA,IAAAA,kBAAgB,EAAC,IAAI,EAAE,iBAAiB,KAAK;QAC7CA,IAAAA,kBAAgB,EAAC,IAAI,EAAE,iBAAiB,KAAK;QAC7C,IAAI,CAAClC,QAAQ,GAAG8B;QAChB,IAAI,CAACf,IAAI,GAAGgB;QACZ,IAAI,CAACzB,aAAa,GAAG0B;QACrB,IAAI,CAAClB,aAAa,GAAGmB;IACvB;AACF,EACA,gDAAgD"}
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,GAAAA,IAAiBC,CAAAA;oBACpC,CAAAC,SAASA,EAAAA;6BACPC,IAAAA,yBAAaA,EAAAA,IAAAA,CAAAA,SAAmBD;wBAChC,CAAAE,aAASA,CAAAA,OAAa;gCACpBC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A,IAAA,EAAA,iBAAA,KAAA;YACA,CAAAA,QAAA,GAAAwB;YACA,CAAAT,IAAA,GAAAU;YAkBE,CAAApB,aAAa,GAAGmB;YAChB,CAAAV,aAAYW,GAAAA;;kDAGd"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export * from './ManualGhostText.base';\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;uBAAc;CACd,iCAAiC"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './ManualGhostText.base';\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;uBAAc"}
@@ -9,6 +9,12 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
+ $createSentinelNode: function() {
13
+ return _BasicFunctionality.$createSentinelNode;
14
+ },
15
+ $isSentinelNode: function() {
16
+ return _BasicFunctionality.$isSentinelNode;
17
+ },
12
18
  BasicFunctionalityBase: function() {
13
19
  return _BasicFunctionality.BasicFunctionalityBase;
14
20
  },
@@ -23,6 +29,12 @@ _export(exports, {
23
29
  },
24
30
  ManualGhostTextBase: function() {
25
31
  return _ManualGhostText.ManualGhostTextBase;
32
+ },
33
+ SENTINEL_VALUE: function() {
34
+ return _BasicFunctionality.SENTINEL_VALUE;
35
+ },
36
+ SentinelNode: function() {
37
+ return _BasicFunctionality.SentinelNode;
26
38
  }
27
39
  });
28
40
  const _BasicFunctionality = require("./BasicFunctionality");
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export { BasicFunctionalityBase } from './BasicFunctionality';\nexport { ChatInputEntityPluginBase } from './ChatInputEntity';\nexport { GhostTextPluginBase } from './GhostText';\nexport { ImperativeControlBase } from './ImperativeControl';\nexport { ManualGhostTextBase } from './ManualGhostText';\n//# sourceMappingURL=index.js.map"],"names":["BasicFunctionalityBase","ChatInputEntityPluginBase","GhostTextPluginBase","ImperativeControlBase","ManualGhostTextBase"],"mappings":";;;;;;;;;;;IAASA,sBAAsB;eAAtBA,0CAAsB;;IACtBC,yBAAyB;eAAzBA,0CAAyB;;IACzBC,mBAAmB;eAAnBA,8BAAmB;;IACnBC,qBAAqB;eAArBA,wCAAqB;;IACrBC,mBAAmB;eAAnBA,oCAAmB;;;oCAJW;iCACG;2BACN;mCACE;iCACF;CACpC,iCAAiC"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-copilot/chat-input-plugins",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
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.2",
15
+ "@fluentui-copilot/text-editor": "^0.0.3",
16
16
  "@swc/helpers": "^0.5.1"
17
17
  },
18
18
  "beachball": {