@copilotkit/react-textarea 0.15.1 → 0.16.0

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @copilotkit/react-textarea@0.15.1 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-textarea
2
+ > @copilotkit/react-textarea@0.16.0 build /home/runner/work/CopilotKit/CopilotKit/CopilotKit/packages/react-textarea
3
3
  > tsup --treeshake
4
4
 
5
5
  CLI Building entry: src/index.tsx, src/components/index.ts, src/context/index.ts, src/hooks/index.ts, src/lib/debouncer.ts, src/lib/editor-to-text.ts, src/lib/get-text-around-cursor.ts, src/lib/utils.test.ts, src/lib/utils.ts, src/types/html-copilot-textarea-element.ts, src/types/index.ts, src/components/base-copilot-textarea/base-copilot-textarea.tsx, src/components/base-copilot-textarea/render-element.tsx, src/components/base-copilot-textarea/render-placeholder.tsx, src/components/base-copilot-textarea/use-add-branding-css.tsx, src/components/copilot-textarea/copilot-textarea.tsx, src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts, src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx, src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts, src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx, src/lib/slatejs-edits/add-autocompletions.ts, src/lib/slatejs-edits/clear-autocompletions.ts, src/lib/slatejs-edits/replace-text.ts, src/lib/slatejs-edits/with-partial-history.ts, src/types/base/autosuggestion-state.ts, src/types/base/autosuggestions-bare-function.ts, src/types/base/base-autosuggestions-config.tsx, src/types/base/base-copilot-textarea-props.tsx, src/types/base/custom-editor.tsx, src/types/base/editor-autocomplete-state.ts, src/types/base/index.ts, src/types/standard-autosuggestions/autosuggestions-config.tsx, src/types/standard-autosuggestions/chatlike-api-endpoint.tsx, src/types/standard-autosuggestions/index.ts, src/types/standard-autosuggestions/minimal-chat-gpt-message.tsx
@@ -57,18 +57,18 @@ Generated an empty chunk: "chunk-H4VKQGVU".
57
57
  ESM dist/components/copilot-textarea/copilot-textarea.mjs 907.00 B
58
58
  ESM dist/index.mjs 1.12 KB
59
59
  ESM dist/components/index.mjs 888.00 B
60
- ESM dist/chunk-K3P3PCV7.mjs 1.23 KB
60
+ ESM dist/chunk-ERPZ5XG5.mjs 1.23 KB
61
61
  ESM dist/chunk-4ES2IIB6.mjs 1.76 KB
62
62
  ESM dist/chunk-LGK56BTO.mjs 2.86 KB
63
63
  ESM dist/chunk-3A2CNIG5.mjs 949.00 B
64
- ESM dist/chunk-QZ2PN6ZU.mjs 6.02 KB
64
+ ESM dist/chunk-ZSQLGOES.mjs 6.02 KB
65
65
  ESM dist/chunk-HZGSG7ST.mjs 3.02 KB
66
66
  ESM dist/chunk-UW3ITU2Y.mjs 496.00 B
67
67
  ESM dist/chunk-CSGFJU3L.mjs 2.01 KB
68
- ESM dist/chunk-AOEXKPIX.mjs 2.57 KB
68
+ ESM dist/chunk-YFA7S5ER.mjs 2.57 KB
69
69
  ESM dist/chunk-WJYQWL4I.mjs 595.00 B
70
- ESM dist/chunk-4XYYSJ5C.mjs 527.00 B
71
- ESM dist/chunk-TSF4AJIK.mjs 716.00 B
70
+ ESM dist/chunk-F3MHL6ZY.mjs 680.00 B
71
+ ESM dist/chunk-42QG2O6L.mjs 832.00 B
72
72
  ESM dist/chunk-KCHYD3EB.mjs 3.08 KB
73
73
  ESM dist/chunk-KGKLUWKW.mjs 1.37 KB
74
74
  ESM dist/chunk-LNAIMEB2.mjs 1.09 KB
@@ -122,18 +122,18 @@ Generated an empty chunk: "chunk-H4VKQGVU".
122
122
  ESM dist/components/copilot-textarea/copilot-textarea.mjs.map 51.00 B
123
123
  ESM dist/index.mjs.map 51.00 B
124
124
  ESM dist/components/index.mjs.map 51.00 B
125
- ESM dist/chunk-K3P3PCV7.mjs.map 2.17 KB
125
+ ESM dist/chunk-ERPZ5XG5.mjs.map 2.17 KB
126
126
  ESM dist/chunk-4ES2IIB6.mjs.map 4.41 KB
127
127
  ESM dist/chunk-LGK56BTO.mjs.map 4.17 KB
128
128
  ESM dist/chunk-3A2CNIG5.mjs.map 2.15 KB
129
- ESM dist/chunk-QZ2PN6ZU.mjs.map 10.79 KB
129
+ ESM dist/chunk-ZSQLGOES.mjs.map 10.79 KB
130
130
  ESM dist/chunk-HZGSG7ST.mjs.map 5.83 KB
131
131
  ESM dist/chunk-UW3ITU2Y.mjs.map 878.00 B
132
132
  ESM dist/chunk-CSGFJU3L.mjs.map 3.82 KB
133
- ESM dist/chunk-AOEXKPIX.mjs.map 4.80 KB
133
+ ESM dist/chunk-YFA7S5ER.mjs.map 4.80 KB
134
134
  ESM dist/chunk-WJYQWL4I.mjs.map 1.04 KB
135
- ESM dist/chunk-4XYYSJ5C.mjs.map 921.00 B
136
- ESM dist/chunk-TSF4AJIK.mjs.map 1.31 KB
135
+ ESM dist/chunk-F3MHL6ZY.mjs.map 1.14 KB
136
+ ESM dist/chunk-42QG2O6L.mjs.map 1.50 KB
137
137
  ESM dist/chunk-KCHYD3EB.mjs.map 6.12 KB
138
138
  ESM dist/chunk-KGKLUWKW.mjs.map 2.45 KB
139
139
  ESM dist/chunk-LNAIMEB2.mjs.map 1.73 KB
@@ -159,12 +159,12 @@ Generated an empty chunk: "chunk-H4VKQGVU".
159
159
  ESM dist/types/standard-autosuggestions/autosuggestions-config.mjs.map 51.00 B
160
160
  ESM dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map 51.00 B
161
161
  ESM dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map 51.00 B
162
- ESM ⚡️ Build success in 3598ms
162
+ ESM ⚡️ Build success in 2717ms
163
163
  Export "AutosuggestionsConfig" of module "src/types/standard-autosuggestions/autosuggestions-config.tsx" was reexported through module "src/types/standard-autosuggestions/index.ts" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
164
164
  Either change the import in "src/components/copilot-textarea/copilot-textarea.tsx" to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.
165
165
  Export "MakeSystemPrompt" of module "src/types/standard-autosuggestions/autosuggestions-config.tsx" was reexported through module "src/types/standard-autosuggestions/index.ts" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.
166
166
  Either change the import in "src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx" to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.
167
- DTS ⚡️ Build success in 6637ms
167
+ DTS ⚡️ Build success in 5119ms
168
168
  DTS dist/index.d.ts 1.01 KB
169
169
  DTS dist/components/base-copilot-textarea/base-copilot-textarea.d.ts 669.00 B
170
170
  DTS dist/components/copilot-textarea/copilot-textarea.d.ts 875.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # ui
2
2
 
3
+ ## 0.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e182a29: copilottextarea: remove nodes conditionally with try catch
8
+
3
9
  ## 0.15.1
4
10
 
5
11
  ### Patch Changes
@@ -9,7 +9,11 @@ function replaceEditorText(editor, newText) {
9
9
  }
10
10
  }
11
11
  for (const path of paths) {
12
- Transforms.removeNodes(editor, { at: path });
12
+ try {
13
+ Transforms.removeNodes(editor, { at: path });
14
+ } catch (e) {
15
+ console.log("CopilotTextarea.replaceEditorText: error removing node", e);
16
+ }
13
17
  }
14
18
  Transforms.insertNodes(
15
19
  editor,
@@ -27,4 +31,4 @@ function replaceEditorText(editor, newText) {
27
31
 
28
32
  export { replaceEditorText };
29
33
  //# sourceMappingURL=out.js.map
30
- //# sourceMappingURL=chunk-TSF4AJIK.mjs.map
34
+ //# sourceMappingURL=chunk-42QG2O6L.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/slatejs-edits/replace-text.ts"],"names":[],"mappings":";AAAA,SAAiB,SAAS,MAAY,kBAAkB;AAEjD,SAAS,kBAAkB,QAAgB,SAAiB;AAEjE,QAAM,QAAgB,CAAC;AACvB,aAAW,CAAC,MAAM,IAAI,KAAK,KAAK,MAAM,MAAM,GAAG;AAC7C,QACE,QAAQ,UAAU,IAAI,MACrB,KAAK,SAAS,eAAe,KAAK,SAAS,iBAC5C,KAAK,WAAW,GAChB;AACA,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,aAAW,QAAQ,OAAO;AACxB,QAAI;AACF,iBAAW,YAAY,QAAQ,EAAE,IAAI,KAAK,CAAC;AAAA,IAC7C,SAAS,GAAP;AACA,cAAQ,IAAI,0DAA0D,CAAC;AAAA,IACzE;AAAA,EACF;AAGA,aAAW;AAAA,IACT;AAAA,IACA;AAAA,MACE;AAAA,QACE,MAAM;AAAA,QACN,UAAU,CAAC,EAAE,MAAM,QAAQ,CAAC;AAAA,MAC9B;AAAA,IACF;AAAA,IACA;AAAA,MACE,IAAI,CAAC,CAAC;AAAA,IACR;AAAA,EACF;AACF","sourcesContent":["import { Editor, Element, Node, Path, Transforms } from \"slate\";\n\nexport function replaceEditorText(editor: Editor, newText: string) {\n // clear all previous text\n const paths: Path[] = [];\n for (const [node, path] of Node.nodes(editor)) {\n if (\n Element.isElement(node) &&\n (node.type === \"paragraph\" || node.type === \"suggestion\") &&\n path.length === 1\n ) {\n paths.push(path);\n }\n }\n for (const path of paths) {\n try {\n Transforms.removeNodes(editor, { at: path });\n } catch (e) {\n console.log(\"CopilotTextarea.replaceEditorText: error removing node\", e);\n }\n }\n\n // insert new text\n Transforms.insertNodes(\n editor,\n [\n {\n type: \"paragraph\",\n children: [{ text: newText }],\n },\n ],\n {\n at: [0],\n }\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { useMakeStandardAutosuggestionFunction } from './chunk-4ES2IIB6.mjs';
2
2
  import { defaultAutosuggestionsConfig } from './chunk-LGK56BTO.mjs';
3
- import { BaseCopilotTextarea } from './chunk-QZ2PN6ZU.mjs';
3
+ import { BaseCopilotTextarea } from './chunk-ZSQLGOES.mjs';
4
4
  import { __spreadValues, __spreadProps } from './chunk-MRXNTQOX.mjs';
5
5
  import React from 'react';
6
6
  import { jsx, Fragment } from 'react/jsx-runtime';
@@ -29,4 +29,4 @@ var CopilotTextarea = React.forwardRef(
29
29
 
30
30
  export { CopilotTextarea };
31
31
  //# sourceMappingURL=out.js.map
32
- //# sourceMappingURL=chunk-K3P3PCV7.mjs.map
32
+ //# sourceMappingURL=chunk-ERPZ5XG5.mjs.map
@@ -9,10 +9,17 @@ function clearAutocompletionsFromEditor(editor) {
9
9
  }
10
10
  }
11
11
  for (const path of paths) {
12
- Transforms.removeNodes(editor, { at: path });
12
+ try {
13
+ Transforms.removeNodes(editor, { at: path });
14
+ } catch (e) {
15
+ console.log(
16
+ "CopilotTextarea.clearAutocompletionsFromEditor: error removing node",
17
+ e
18
+ );
19
+ }
13
20
  }
14
21
  }
15
22
 
16
23
  export { clearAutocompletionsFromEditor };
17
24
  //# sourceMappingURL=out.js.map
18
- //# sourceMappingURL=chunk-4XYYSJ5C.mjs.map
25
+ //# sourceMappingURL=chunk-F3MHL6ZY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/slatejs-edits/clear-autocompletions.ts"],"names":[],"mappings":";AAAA,SAAS,SAAS,MAAY,kBAAkB;AAGzC,SAAS,+BAA+B,QAAsB;AAEnE,QAAM,QAAgB,CAAC;AACvB,aAAW,CAAC,MAAM,IAAI,KAAK,KAAK,MAAM,MAAM,GAAG;AAC7C,QAAI,QAAQ,UAAU,IAAI,KAAK,KAAK,SAAS,cAAc;AACzD,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,aAAW,QAAQ,OAAO;AACxB,QAAI;AACF,iBAAW,YAAY,QAAQ,EAAE,IAAI,KAAK,CAAC;AAAA,IAC7C,SAAS,GAAP;AACA,cAAQ;AAAA,QACN;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF","sourcesContent":["import { Element, Node, Path, Transforms } from \"slate\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nexport function clearAutocompletionsFromEditor(editor: CustomEditor) {\n // clear previous suggestion\n const paths: Path[] = [];\n for (const [node, path] of Node.nodes(editor)) {\n if (Element.isElement(node) && node.type === \"suggestion\") {\n paths.push(path);\n }\n }\n for (const path of paths) {\n try {\n Transforms.removeNodes(editor, { at: path });\n } catch (e) {\n console.log(\n \"CopilotTextarea.clearAutocompletionsFromEditor: error removing node\",\n e\n );\n }\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { replaceEditorText } from './chunk-TSF4AJIK.mjs';
1
+ import { replaceEditorText } from './chunk-42QG2O6L.mjs';
2
2
  import { getFullEditorTextWithNewlines } from './chunk-3UQM3NLM.mjs';
3
3
  import React from 'react';
4
4
  import { ReactEditor } from 'slate-react';
@@ -80,4 +80,4 @@ function usePopulateCopilotTextareaRef(editor, ref) {
80
80
 
81
81
  export { usePopulateCopilotTextareaRef };
82
82
  //# sourceMappingURL=out.js.map
83
- //# sourceMappingURL=chunk-AOEXKPIX.mjs.map
83
+ //# sourceMappingURL=chunk-YFA7S5ER.mjs.map
@@ -1,9 +1,9 @@
1
1
  import { useAutosuggestions } from './chunk-HZGSG7ST.mjs';
2
2
  import { useCopilotTextareaEditor } from './chunk-CSGFJU3L.mjs';
3
- import { usePopulateCopilotTextareaRef } from './chunk-AOEXKPIX.mjs';
3
+ import { usePopulateCopilotTextareaRef } from './chunk-YFA7S5ER.mjs';
4
4
  import { addAutocompletionsToEditor } from './chunk-WJYQWL4I.mjs';
5
- import { clearAutocompletionsFromEditor } from './chunk-4XYYSJ5C.mjs';
6
- import { replaceEditorText } from './chunk-TSF4AJIK.mjs';
5
+ import { clearAutocompletionsFromEditor } from './chunk-F3MHL6ZY.mjs';
6
+ import { replaceEditorText } from './chunk-42QG2O6L.mjs';
7
7
  import { defaultBaseAutosuggestionsConfig } from './chunk-7KWRVIYV.mjs';
8
8
  import { makeRenderElementFunction } from './chunk-LNAIMEB2.mjs';
9
9
  import { makeRenderPlaceholderFunction } from './chunk-OELUUJZY.mjs';
@@ -160,4 +160,4 @@ function makeSemiFakeReactTextAreaEvent(currentText) {
160
160
 
161
161
  export { BaseCopilotTextarea };
162
162
  //# sourceMappingURL=out.js.map
163
- //# sourceMappingURL=chunk-QZ2PN6ZU.mjs.map
163
+ //# sourceMappingURL=chunk-ZSQLGOES.mjs.map
@@ -1,11 +1,11 @@
1
- export { BaseCopilotTextarea } from '../../chunk-QZ2PN6ZU.mjs';
1
+ export { BaseCopilotTextarea } from '../../chunk-ZSQLGOES.mjs';
2
2
  import '../../chunk-HZGSG7ST.mjs';
3
3
  import '../../chunk-UW3ITU2Y.mjs';
4
4
  import '../../chunk-CSGFJU3L.mjs';
5
- import '../../chunk-AOEXKPIX.mjs';
5
+ import '../../chunk-YFA7S5ER.mjs';
6
6
  import '../../chunk-WJYQWL4I.mjs';
7
- import '../../chunk-4XYYSJ5C.mjs';
8
- import '../../chunk-TSF4AJIK.mjs';
7
+ import '../../chunk-F3MHL6ZY.mjs';
8
+ import '../../chunk-42QG2O6L.mjs';
9
9
  import '../../chunk-KCHYD3EB.mjs';
10
10
  import '../../chunk-KGKLUWKW.mjs';
11
11
  import '../../chunk-WJHSY5T6.mjs';
@@ -1,16 +1,16 @@
1
- export { CopilotTextarea } from '../../chunk-K3P3PCV7.mjs';
1
+ export { CopilotTextarea } from '../../chunk-ERPZ5XG5.mjs';
2
2
  import '../../chunk-4ES2IIB6.mjs';
3
3
  import '../../chunk-SL4J5HMW.mjs';
4
4
  import '../../chunk-LGK56BTO.mjs';
5
5
  import '../../chunk-3A2CNIG5.mjs';
6
- import '../../chunk-QZ2PN6ZU.mjs';
6
+ import '../../chunk-ZSQLGOES.mjs';
7
7
  import '../../chunk-HZGSG7ST.mjs';
8
8
  import '../../chunk-UW3ITU2Y.mjs';
9
9
  import '../../chunk-CSGFJU3L.mjs';
10
- import '../../chunk-AOEXKPIX.mjs';
10
+ import '../../chunk-YFA7S5ER.mjs';
11
11
  import '../../chunk-WJYQWL4I.mjs';
12
- import '../../chunk-4XYYSJ5C.mjs';
13
- import '../../chunk-TSF4AJIK.mjs';
12
+ import '../../chunk-F3MHL6ZY.mjs';
13
+ import '../../chunk-42QG2O6L.mjs';
14
14
  import '../../chunk-KCHYD3EB.mjs';
15
15
  import '../../chunk-KGKLUWKW.mjs';
16
16
  import '../../chunk-WJHSY5T6.mjs';
@@ -1,17 +1,17 @@
1
1
  import '../chunk-MMVDU6DF.mjs';
2
- export { CopilotTextarea } from '../chunk-K3P3PCV7.mjs';
2
+ export { CopilotTextarea } from '../chunk-ERPZ5XG5.mjs';
3
3
  import '../chunk-4ES2IIB6.mjs';
4
4
  import '../chunk-SL4J5HMW.mjs';
5
5
  import '../chunk-LGK56BTO.mjs';
6
6
  import '../chunk-3A2CNIG5.mjs';
7
- export { BaseCopilotTextarea } from '../chunk-QZ2PN6ZU.mjs';
7
+ export { BaseCopilotTextarea } from '../chunk-ZSQLGOES.mjs';
8
8
  import '../chunk-HZGSG7ST.mjs';
9
9
  import '../chunk-UW3ITU2Y.mjs';
10
10
  import '../chunk-CSGFJU3L.mjs';
11
- import '../chunk-AOEXKPIX.mjs';
11
+ import '../chunk-YFA7S5ER.mjs';
12
12
  import '../chunk-WJYQWL4I.mjs';
13
- import '../chunk-4XYYSJ5C.mjs';
14
- import '../chunk-TSF4AJIK.mjs';
13
+ import '../chunk-F3MHL6ZY.mjs';
14
+ import '../chunk-42QG2O6L.mjs';
15
15
  import '../chunk-KCHYD3EB.mjs';
16
16
  import '../chunk-KGKLUWKW.mjs';
17
17
  import '../chunk-WJHSY5T6.mjs';
@@ -1,5 +1,5 @@
1
- export { usePopulateCopilotTextareaRef } from '../../chunk-AOEXKPIX.mjs';
2
- import '../../chunk-TSF4AJIK.mjs';
1
+ export { usePopulateCopilotTextareaRef } from '../../chunk-YFA7S5ER.mjs';
2
+ import '../../chunk-42QG2O6L.mjs';
3
3
  import '../../chunk-3UQM3NLM.mjs';
4
4
  import '../../chunk-MRXNTQOX.mjs';
5
5
  //# sourceMappingURL=out.js.map
package/dist/index.mjs CHANGED
@@ -1,19 +1,19 @@
1
1
  import './chunk-DE5K76I2.mjs';
2
2
  import './chunk-WADHCMPK.mjs';
3
3
  import './chunk-MMVDU6DF.mjs';
4
- export { CopilotTextarea } from './chunk-K3P3PCV7.mjs';
4
+ export { CopilotTextarea } from './chunk-ERPZ5XG5.mjs';
5
5
  import './chunk-4ES2IIB6.mjs';
6
6
  import './chunk-SL4J5HMW.mjs';
7
7
  export { defaultAutosuggestionsConfig, defaultFewShotMessages, defaultMakeSystemPrompt } from './chunk-LGK56BTO.mjs';
8
8
  export { ChatlikeApiEndpoint } from './chunk-3A2CNIG5.mjs';
9
- export { BaseCopilotTextarea } from './chunk-QZ2PN6ZU.mjs';
9
+ export { BaseCopilotTextarea } from './chunk-ZSQLGOES.mjs';
10
10
  import './chunk-HZGSG7ST.mjs';
11
11
  import './chunk-UW3ITU2Y.mjs';
12
12
  import './chunk-CSGFJU3L.mjs';
13
- import './chunk-AOEXKPIX.mjs';
13
+ import './chunk-YFA7S5ER.mjs';
14
14
  import './chunk-WJYQWL4I.mjs';
15
- import './chunk-4XYYSJ5C.mjs';
16
- import './chunk-TSF4AJIK.mjs';
15
+ import './chunk-F3MHL6ZY.mjs';
16
+ import './chunk-42QG2O6L.mjs';
17
17
  import './chunk-KCHYD3EB.mjs';
18
18
  import './chunk-KGKLUWKW.mjs';
19
19
  import './chunk-WJHSY5T6.mjs';
@@ -1,4 +1,4 @@
1
- export { clearAutocompletionsFromEditor } from '../../chunk-4XYYSJ5C.mjs';
1
+ export { clearAutocompletionsFromEditor } from '../../chunk-F3MHL6ZY.mjs';
2
2
  import '../../chunk-MRXNTQOX.mjs';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=clear-autocompletions.mjs.map
@@ -1,4 +1,4 @@
1
- export { replaceEditorText } from '../../chunk-TSF4AJIK.mjs';
1
+ export { replaceEditorText } from '../../chunk-42QG2O6L.mjs';
2
2
  import '../../chunk-MRXNTQOX.mjs';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=replace-text.mjs.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.15.1",
7
+ "version": "0.16.0",
8
8
  "sideEffects": [
9
9
  "**/*.css"
10
10
  ],
@@ -1,4 +1,4 @@
1
- import { Path, Node, Element, Transforms } from "slate";
1
+ import { Element, Node, Path, Transforms } from "slate";
2
2
  import { CustomEditor } from "../../types/base/custom-editor";
3
3
 
4
4
  export function clearAutocompletionsFromEditor(editor: CustomEditor) {
@@ -10,6 +10,13 @@ export function clearAutocompletionsFromEditor(editor: CustomEditor) {
10
10
  }
11
11
  }
12
12
  for (const path of paths) {
13
- Transforms.removeNodes(editor, { at: path });
13
+ try {
14
+ Transforms.removeNodes(editor, { at: path });
15
+ } catch (e) {
16
+ console.log(
17
+ "CopilotTextarea.clearAutocompletionsFromEditor: error removing node",
18
+ e
19
+ );
20
+ }
14
21
  }
15
22
  }
@@ -1,4 +1,4 @@
1
- import { Editor, Path, Transforms, Node, Element } from "slate";
1
+ import { Editor, Element, Node, Path, Transforms } from "slate";
2
2
 
3
3
  export function replaceEditorText(editor: Editor, newText: string) {
4
4
  // clear all previous text
@@ -13,7 +13,11 @@ export function replaceEditorText(editor: Editor, newText: string) {
13
13
  }
14
14
  }
15
15
  for (const path of paths) {
16
- Transforms.removeNodes(editor, { at: path });
16
+ try {
17
+ Transforms.removeNodes(editor, { at: path });
18
+ } catch (e) {
19
+ console.log("CopilotTextarea.replaceEditorText: error removing node", e);
20
+ }
17
21
  }
18
22
 
19
23
  // insert new text
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/slatejs-edits/clear-autocompletions.ts"],"names":[],"mappings":";AAAA,SAAe,MAAM,SAAS,kBAAkB;AAGzC,SAAS,+BAA+B,QAAsB;AAEnE,QAAM,QAAgB,CAAC;AACvB,aAAW,CAAC,MAAM,IAAI,KAAK,KAAK,MAAM,MAAM,GAAG;AAC7C,QAAI,QAAQ,UAAU,IAAI,KAAK,KAAK,SAAS,cAAc;AACzD,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,aAAW,QAAQ,OAAO;AACxB,eAAW,YAAY,QAAQ,EAAE,IAAI,KAAK,CAAC;AAAA,EAC7C;AACF","sourcesContent":["import { Path, Node, Element, Transforms } from \"slate\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nexport function clearAutocompletionsFromEditor(editor: CustomEditor) {\n // clear previous suggestion\n const paths: Path[] = [];\n for (const [node, path] of Node.nodes(editor)) {\n if (Element.isElement(node) && node.type === \"suggestion\") {\n paths.push(path);\n }\n }\n for (const path of paths) {\n Transforms.removeNodes(editor, { at: path });\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/slatejs-edits/replace-text.ts"],"names":[],"mappings":";AAAA,SAAuB,YAAY,MAAM,eAAe;AAEjD,SAAS,kBAAkB,QAAgB,SAAiB;AAEjE,QAAM,QAAgB,CAAC;AACvB,aAAW,CAAC,MAAM,IAAI,KAAK,KAAK,MAAM,MAAM,GAAG;AAC7C,QACE,QAAQ,UAAU,IAAI,MACrB,KAAK,SAAS,eAAe,KAAK,SAAS,iBAC5C,KAAK,WAAW,GAChB;AACA,YAAM,KAAK,IAAI;AAAA,IACjB;AAAA,EACF;AACA,aAAW,QAAQ,OAAO;AACxB,eAAW,YAAY,QAAQ,EAAE,IAAI,KAAK,CAAC;AAAA,EAC7C;AAGA,aAAW;AAAA,IACT;AAAA,IACA;AAAA,MACE;AAAA,QACE,MAAM;AAAA,QACN,UAAU,CAAC,EAAE,MAAM,QAAQ,CAAC;AAAA,MAC9B;AAAA,IACF;AAAA,IACA;AAAA,MACE,IAAI,CAAC,CAAC;AAAA,IACR;AAAA,EACF;AACF","sourcesContent":["import { Editor, Path, Transforms, Node, Element } from \"slate\";\n\nexport function replaceEditorText(editor: Editor, newText: string) {\n // clear all previous text\n const paths: Path[] = [];\n for (const [node, path] of Node.nodes(editor)) {\n if (\n Element.isElement(node) &&\n (node.type === \"paragraph\" || node.type === \"suggestion\") &&\n path.length === 1\n ) {\n paths.push(path);\n }\n }\n for (const path of paths) {\n Transforms.removeNodes(editor, { at: path });\n }\n\n // insert new text\n Transforms.insertNodes(\n editor,\n [\n {\n type: \"paragraph\",\n children: [{ text: newText }],\n },\n ],\n {\n at: [0],\n }\n );\n}\n"]}