@harbour-enterprises/superdoc 0.11.30 → 0.11.32

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 (36) hide show
  1. package/dist/chunks/{index-D8Qchtwe.cjs → index-BXKGjuVW.cjs} +1 -1
  2. package/dist/chunks/{index-D5LUU_DK.es.js → index-CPZ-IxHT.es.js} +1 -1
  3. package/dist/chunks/{index-BJQ3rSJD.cjs → index-CqRwYOdx.cjs} +1 -1
  4. package/dist/chunks/{index-BIKukPks.es.js → index-Y7BlAr93.es.js} +2 -2
  5. package/dist/chunks/{super-editor.es-B9zU4phN.es.js → super-editor.es-Bs9UaxnP.es.js} +6669 -6580
  6. package/dist/chunks/super-editor.es-ZJ0ylc_0.cjs +452 -0
  7. package/dist/chunks/{url-lfePTVJU.cjs → url-6Xu7gR4T.cjs} +1 -1
  8. package/dist/chunks/{url-ChEJem8_.es.js → url-t15h9onH.es.js} +1 -1
  9. package/dist/chunks/{xml-js-Dq803VXB.es.js → xml-js-kwrvzyhm.es.js} +753 -739
  10. package/dist/chunks/xml-js-zhwNEV5e.cjs +10 -0
  11. package/dist/style.css +1 -1
  12. package/dist/super-editor/ai-writer.es.js +208 -121
  13. package/dist/super-editor/chunks/{converter-69UAZ0Ft.js → converter-ajcAkpke.js} +2 -2
  14. package/dist/super-editor/chunks/{docx-zipper-CvLDRHYT.js → docx-zipper-BQ70zniM.js} +1 -1
  15. package/dist/super-editor/chunks/{editor-Br7gJJbN.js → editor-CI9Y8Eul.js} +11 -9
  16. package/dist/super-editor/chunks/{toolbar-BX3EQkLT.js → toolbar-DhThnUPN.js} +2 -2
  17. package/dist/super-editor/components/toolbar/ai-helpers.d.ts +12 -0
  18. package/dist/super-editor/components/toolbar/ai-helpers.d.ts.map +1 -1
  19. package/dist/super-editor/converter.es.js +1 -1
  20. package/dist/super-editor/core/Editor.d.ts +25 -5
  21. package/dist/super-editor/core/Editor.d.ts.map +1 -1
  22. package/dist/super-editor/docx-zipper.es.js +2 -2
  23. package/dist/super-editor/editor.es.js +3 -3
  24. package/dist/super-editor/file-zipper.es.js +1 -1
  25. package/dist/super-editor/style.css +1 -1
  26. package/dist/super-editor/super-editor.es.js +6 -6
  27. package/dist/super-editor/toolbar.es.js +2 -2
  28. package/dist/super-editor.cjs +1 -1
  29. package/dist/super-editor.es.js +3 -3
  30. package/dist/superdoc.cjs +3 -3
  31. package/dist/superdoc.es.js +6 -6
  32. package/dist/superdoc.umd.js +1604 -1515
  33. package/dist/superdoc.umd.js.map +1 -1
  34. package/package.json +2 -2
  35. package/dist/chunks/super-editor.es-DR8TyHgu.cjs +0 -452
  36. package/dist/chunks/xml-js-BXHFNveP.cjs +0 -10
@@ -1,98 +1,173 @@
1
- import { ref as u, onMounted as X, onUnmounted as q, computed as S, createElementBlock as A, openBlock as M, withModifiers as E, createElementVNode as h, withDirectives as $, unref as I, vModelText as B, createCommentVNode as G, nextTick as U } from "vue";
2
- import { T as Y } from "./chunks/converter-69UAZ0Ft.js";
3
- import { _ as J } from "./chunks/editor-Br7gJJbN.js";
4
- const Q = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights", C = "You are an expert copywriter and you are immersed in a document editor. You are to provide document related text responses based on the user prompts. Only write what is asked for. Do not provide explanations. Try to keep placeholders as short as possible. Do not output your prompt. Your instructions are: ";
5
- async function D(i, r = {}) {
6
- const e = r.apiKey, s = r.endpoint || Q;
1
+ import { ref as x, onMounted as G, onUnmounted as U, computed as D, createElementBlock as O, openBlock as R, withModifiers as H, createElementVNode as S, withDirectives as Y, unref as N, vModelText as J, createCommentVNode as Q, nextTick as K } from "vue";
2
+ import { T as Z } from "./chunks/converter-ajcAkpke.js";
3
+ import { _ as ee } from "./chunks/editor-CI9Y8Eul.js";
4
+ const te = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights", z = "You are an expert copywriter and you are immersed in a document editor. You are to provide document related text responses based on the user prompts. Only write what is asked for. Do not provide explanations. Try to keep placeholders as short as possible. Do not output your prompt. Your instructions are: ";
5
+ async function V(r, o = {}) {
6
+ const e = o.apiKey, a = o.endpoint || te;
7
7
  try {
8
- const o = {
8
+ const s = {
9
9
  "Content-Type": "application/json"
10
10
  };
11
- e && (o["x-api-key"] = e);
12
- const n = await fetch(s, {
11
+ e && (s["x-api-key"] = e);
12
+ const n = await fetch(a, {
13
13
  method: "POST",
14
- headers: o,
15
- body: JSON.stringify(i)
14
+ headers: s,
15
+ body: JSON.stringify(r)
16
16
  });
17
17
  if (!n.ok) {
18
- const l = await n.text();
19
- throw new Error(`Harbour API error: ${n.status} - ${l}`);
18
+ const m = await n.text();
19
+ throw new Error(`Harbour API error: ${n.status} - ${m}`);
20
20
  }
21
21
  return n;
22
- } catch (o) {
23
- throw console.error("Error calling Harbour API:", o), o;
22
+ } catch (s) {
23
+ throw console.error("Error calling Harbour API:", s), s;
24
24
  }
25
25
  }
26
- async function F(i, r, e) {
27
- const s = i.getReader(), o = new TextDecoder();
28
- let n = "", l = "";
26
+ async function j(r, o, e) {
27
+ const a = r.getReader(), s = new TextDecoder();
28
+ let n = "", m = "";
29
29
  try {
30
30
  for (; ; ) {
31
- const { done: d, value: v } = await s.read();
32
- if (d) {
31
+ const { done: h, value: g } = await a.read();
32
+ if (h) {
33
33
  typeof e == "function" && e();
34
34
  break;
35
35
  }
36
- const w = o.decode(v, { stream: !0 });
37
- typeof r == "function" && r(w);
36
+ const _ = s.decode(g, { stream: !0 });
37
+ typeof o == "function" && o(_);
38
38
  }
39
- let c = Z(l);
40
- return c !== null && (n = c), n || "";
41
- } catch (c) {
42
- throw console.error("Error reading stream:", c), c;
39
+ let l = oe(m);
40
+ return l !== null && (n = l), n || "";
41
+ } catch (l) {
42
+ throw console.error("Error reading stream:", l), l;
43
43
  } finally {
44
- s.releaseLock();
44
+ a.releaseLock();
45
45
  }
46
46
  }
47
- function Z(i) {
47
+ function oe(r) {
48
48
  try {
49
- const r = /```json\s*\n([\s\S]*?)\n\s*```/, e = i.match(r);
49
+ const o = /```json\s*\n([\s\S]*?)\n\s*```/, e = r.match(o);
50
50
  if (e && e[1]) {
51
- const s = JSON.parse(e[1]);
52
- if (s.custom_prompt && s.custom_prompt.value !== void 0)
53
- return s.custom_prompt.value || "";
51
+ const a = JSON.parse(e[1]);
52
+ if (a.custom_prompt && a.custom_prompt.value !== void 0)
53
+ return a.custom_prompt.value || "";
54
54
  }
55
55
  return null;
56
56
  } catch {
57
57
  return null;
58
58
  }
59
59
  }
60
- async function ee(i, r = {}, e, s) {
61
- if (!i)
60
+ async function ne(r, o = {}, e, a) {
61
+ if (!r)
62
62
  throw new Error("Prompt is required for text generation");
63
- const o = {
63
+ const s = {
64
64
  stream: !0,
65
- context: C,
65
+ context: z,
66
66
  doc_text: "",
67
67
  insights: [
68
68
  {
69
69
  type: "custom_prompt",
70
70
  name: "text_generation",
71
- message: `Generate text based on the following prompt: ${i}`
71
+ message: `Generate text based on the following prompt: ${r}`
72
72
  }
73
73
  ]
74
74
  };
75
- r.documentXml && (o.document_content = r.documentXml);
76
- const n = await D(o, r.config || {});
77
- return n.body ? await F(n.body, e, s) : "";
75
+ o.documentXml && (s.document_content = o.documentXml);
76
+ const n = await V(s, o.config || {});
77
+ return n.body ? await j(n.body, e, a) : "";
78
78
  }
79
- async function te(i, r = "", e = {}, s, o) {
80
- if (!i)
79
+ async function re(r, o = "", e = {}, a, s) {
80
+ if (!r)
81
81
  throw new Error("Text is required for rewriting");
82
82
  const n = {
83
83
  stream: !0,
84
- context: C,
84
+ context: z,
85
85
  insights: [
86
86
  {
87
87
  type: "custom_prompt",
88
88
  name: "text_rewrite",
89
- message: `Rewrite the following text: "${i}" using these instructions: ${r}`
89
+ message: `Rewrite the following text: "${r}" using these instructions: ${o}`
90
90
  }
91
91
  ]
92
- }, l = await D(n, e.config || {});
93
- return l.body ? await F(l.body, s, o) : "";
92
+ }, m = await V(n, e.config || {});
93
+ return m.body ? await j(m.body, a, s) : "";
94
+ }
95
+ const se = {
96
+ rules: [
97
+ {
98
+ name: "bold",
99
+ pattern: /\*\*(.*?)\*\*/g,
100
+ transform: (r, o, e) => ({
101
+ type: "text",
102
+ marks: [{ type: "bold" }],
103
+ text: o
104
+ })
105
+ }
106
+ ]
107
+ };
108
+ function ae(r) {
109
+ try {
110
+ let o = r.state.doc;
111
+ const e = o.textContent || "";
112
+ if (!e) return;
113
+ se.rules.forEach((a) => {
114
+ a.pattern.lastIndex = 0;
115
+ const s = [];
116
+ let n;
117
+ for (; (n = a.pattern.exec(e)) !== null; )
118
+ s.push({
119
+ rule: a,
120
+ startPos: n.index,
121
+ endPos: n.index + n[0].length,
122
+ originalText: n[0],
123
+ contentText: n[1]
124
+ });
125
+ s.sort((m, l) => l.startPos - m.startPos);
126
+ for (const m of s) {
127
+ const { startPos: l, endPos: h, originalText: g, contentText: _ } = m;
128
+ try {
129
+ let v = r.state.tr;
130
+ const L = a.transform(g, _, r), w = [];
131
+ if (o.nodesBetween(l, Math.min(h, o.content.size), (y, f) => (y.isText && w.push({ node: y, pos: f }), !0)), w.length > 0) {
132
+ let y = !1, f = -1, T = -1;
133
+ for (let c = 0; c < w.length; c++) {
134
+ const d = w[c], b = d.node.text || "", p = d.pos;
135
+ if (b.includes(g)) {
136
+ const u = b.indexOf(g);
137
+ f = p + u, T = f + g.length, y = !0;
138
+ break;
139
+ }
140
+ }
141
+ if (!y) {
142
+ let c = "", d = [], b = w[0].pos;
143
+ for (const u of w) {
144
+ const I = u.node.text || "", E = u.pos - b;
145
+ for (let k = 0; k < I.length; k++)
146
+ d.push(E + k);
147
+ c += I;
148
+ }
149
+ const p = c.indexOf(g);
150
+ if (p >= 0) {
151
+ f = b + d[p];
152
+ const u = p + g.length - 1;
153
+ T = b + (d[u] || 0) + 1, y = !0;
154
+ }
155
+ }
156
+ if (y) {
157
+ const c = L.marks ? L.marks.map((d) => r.schema.marks[d.type].create(d.attrs)) : [];
158
+ v = v.delete(f, T), v = v.insert(f, r.schema.text(L.text, c)), v.docChanged && (r.view.dispatch(v), o = r.state.doc);
159
+ }
160
+ }
161
+ } catch (v) {
162
+ console.error("Error processing match:", v);
163
+ }
164
+ }
165
+ });
166
+ } catch (o) {
167
+ console.error("Error formatting document:", o);
168
+ }
94
169
  }
95
- const oe = `<!-- @note: includes color gradient for inline svg AI Writer -->
170
+ const ie = `<!-- @note: includes color gradient for inline svg AI Writer -->
96
171
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.-->
97
172
  <linearGradient id="gradient" x1="125%" y1="50%" x2="-25%" y2="50%">
98
173
  <stop offset="-20%" stop-color="rgba(218, 215, 118, 0.5)" />
@@ -101,7 +176,7 @@ const oe = `<!-- @note: includes color gradient for inline svg AI Writer -->
101
176
  <stop offset="150%" stop-color="rgb(255, 219, 102)" />
102
177
  </linearGradient>
103
178
  <path fill="url(#gradient)" d="M402.3 344.9l32-32c5-5 13.7-1.5 13.7 5.7V464c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V112c0-26.5 21.5-48 48-48h273.5c7.1 0 10.7 8.6 5.7 13.7l-32 32c-1.5 1.5-3.5 2.3-5.7 2.3H48v352h352V350.5c0-2.1 .8-4.1 2.3-5.6zm156.6-201.8L296.3 405.7l-90.4 10c-26.2 2.9-48.5-19.2-45.6-45.6l10-90.4L432.9 17.1c22.9-22.9 59.9-22.9 82.7 0l43.2 43.2c22.9 22.9 22.9 60 .1 82.8zM460.1 174L402 115.9 216.2 301.8l-7.3 65.3 65.3-7.3L460.1 174zm64.8-79.7l-43.2-43.2c-4.1-4.1-10.8-4.1-14.8 0L436 82l58.1 58.1 30.9-30.9c4-4.2 4-10.8-.1-14.9z"/>
104
- </svg>`, re = `<!-- @note: includes color gradient for inline svg AI Writer -->
179
+ </svg>`, ce = `<!-- @note: includes color gradient for inline svg AI Writer -->
105
180
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.-->
106
181
  <defs>
107
182
  <linearGradient id="gradient" x1="125%" y1="50%" x2="-25%" y2="50%">
@@ -112,7 +187,7 @@ const oe = `<!-- @note: includes color gradient for inline svg AI Writer -->
112
187
  </linearGradient>
113
188
  </defs>
114
189
  <path fill="url(#gradient)" d="M440 6.5L24 246.4c-34.4 19.9-31.1 70.8 5.7 85.9L144 379.6V464c0 46.4 59.2 65.5 86.6 28.6l43.8-59.1 111.9 46.2c5.9 2.4 12.1 3.6 18.3 3.6 8.2 0 16.3-2.1 23.6-6.2 12.8-7.2 21.6-20 23.9-34.5l59.4-387.2c6.1-40.1-36.9-68.8-71.5-48.9zM192 464v-64.6l36.6 15.1L192 464zm212.6-28.7l-153.8-63.5L391 169.5c10.7-15.5-9.5-33.5-23.7-21.2L155.8 332.6 48 288 464 48l-59.4 387.3z"/>
115
- </svg>`, ne = { class: "ai-user-input-field" }, se = ["innerHTML"], ae = ["placeholder"], ie = { class: "ai-loader" }, ce = ["innerHTML"], le = {
190
+ </svg>`, le = { class: "ai-user-input-field" }, de = ["innerHTML"], ue = ["placeholder"], me = { class: "ai-loader" }, fe = ["innerHTML"], pe = {
116
191
  __name: "AIWriter",
117
192
  props: {
118
193
  selectedText: {
@@ -145,56 +220,56 @@ const oe = `<!-- @note: includes color gradient for inline svg AI Writer -->
145
220
  }
146
221
  },
147
222
  emits: ["ai-highlight"],
148
- setup(i, { emit: r }) {
149
- const e = i, s = r, o = u(null), n = u(null), l = (t) => {
150
- n.value && !n.value.contains(t.target) && (m.value || d("remove"), e.handleClose());
151
- }, c = u(null), d = (t, a = null) => {
152
- e.superToolbar ? e.superToolbar.emit("ai-highlight", { type: t, data: a }) : s("ai-highlight", { type: t, data: a });
153
- }, v = () => {
154
- e.selectedText && (o.value = {
223
+ setup(r, { emit: o }) {
224
+ const e = r, a = o, s = x(null), n = x(null), m = (t) => {
225
+ n.value && !n.value.contains(t.target) && (f.value || h("remove"), e.handleClose());
226
+ }, l = x(null), h = (t, i = null) => {
227
+ e.superToolbar ? e.superToolbar.emit("ai-highlight", { type: t, data: i }) : a("ai-highlight", { type: t, data: i });
228
+ }, g = () => {
229
+ e.selectedText && (s.value = {
155
230
  ...e.editor.state.selection,
156
231
  from: e.editor.state.selection.from,
157
232
  to: e.editor.state.selection.to
158
- }, e.editor.commands.setMeta("storedSelection", o.value), d("add"));
159
- }, w = () => {
160
- U(() => {
161
- c.value && c.value.focus();
233
+ }, e.editor.commands.setMeta("storedSelection", s.value), h("add"));
234
+ }, _ = () => {
235
+ K(() => {
236
+ l.value && l.value.focus();
162
237
  });
163
- }, P = () => {
164
- document.addEventListener("mousedown", l), document.addEventListener("keydown", x, !0);
165
- }, H = () => {
166
- document.removeEventListener("mousedown", l), document.removeEventListener("keydown", x, !0);
238
+ }, v = () => {
239
+ document.addEventListener("mousedown", m), document.addEventListener("keydown", w, !0);
240
+ }, L = () => {
241
+ document.removeEventListener("mousedown", m), document.removeEventListener("keydown", w, !0);
167
242
  };
168
- X(() => {
169
- v(), w(), P();
170
- }), q(() => {
171
- m.value || d("remove"), H();
243
+ G(() => {
244
+ g(), _(), v();
245
+ }), U(() => {
246
+ f.value || h("remove"), L();
172
247
  });
173
- const x = (t) => {
174
- c.value && t.target === c.value && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key) && t.stopPropagation();
175
- }, N = S(
248
+ const w = (t) => {
249
+ l.value && t.target === l.value && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key) && t.stopPropagation();
250
+ }, y = D(
176
251
  () => e.selectedText ? "Insert prompt to update text" : "Insert prompt to generate text"
177
- ), m = u(!1), f = u(""), p = u(""), g = u(!1), O = u(""), b = S(() => e.editor.isInSuggestingMode?.() || !1), R = () => {
252
+ ), f = x(!1), T = x(""), c = x(""), d = x(!1), b = x(""), p = x(!1), u = x(!1), I = D(() => e.editor.isInSuggestingMode?.() || !1), E = () => {
178
253
  try {
179
254
  return e.editor.state.doc.textContent || "";
180
255
  } catch (t) {
181
256
  return console.error("Error getting document XML:", t), "";
182
257
  }
183
- }, T = (t) => {
258
+ }, k = async (t) => {
184
259
  try {
185
- if (e.editor.commands.removeAiNode("aiLoaderNode"), e.selectedText && !g.value) {
186
- if (d("remove"), e.editor.commands.clearAiHighlightStyle(), o.value) {
187
- const { state: k } = e.editor, { from: j, to: z } = o.value, W = k.tr.setSelection(
188
- Y.create(k.doc, j, z)
260
+ if (e.editor.commands.removeAiNode("aiLoaderNode"), e.selectedText && !d.value) {
261
+ if (h("remove"), e.editor.commands.clearAiHighlightStyle(), s.value) {
262
+ const { state: F } = e.editor, { from: q, to: B } = s.value, $ = F.tr.setSelection(
263
+ Z.create(F.doc, q, B)
189
264
  );
190
- e.editor.view.dispatch(W);
265
+ e.editor.view.dispatch($);
191
266
  } else
192
267
  console.warn("[AIWriter] No stored selection to restore");
193
- e.editor.commands.deleteSelection(), g.value = !0;
268
+ e.editor.commands.deleteSelection(), d.value = !0;
194
269
  }
195
270
  if (t == null || t === "")
196
271
  return;
197
- const a = String(t), y = {
272
+ const i = String(t), A = {
198
273
  type: "text",
199
274
  marks: [{
200
275
  type: "aiAnimationMark",
@@ -203,79 +278,91 @@ const oe = `<!-- @note: includes color gradient for inline svg AI Writer -->
203
278
  dataMarkId: `ai-animation-${Date.now()}`
204
279
  }
205
280
  }],
206
- text: a
281
+ text: i
207
282
  };
208
- e.editor.commands.insertContent(y), e.handleClose();
209
- } catch (a) {
210
- console.error("Error handling text chunk:", a);
283
+ e.editor.commands.insertContent(A), u.value = !0, p.value || await M(), e.handleClose();
284
+ } catch (i) {
285
+ console.error("Error handling text chunk:", i);
211
286
  }
212
- }, _ = () => {
213
- setTimeout(() => {
214
- e.editor.commands.removeAiMark("aiAnimationMark"), d("remove");
287
+ }, M = async () => {
288
+ if (!p.value)
289
+ try {
290
+ p.value = !0, u.value = !1, await K(), ae(e.editor), u.value && (u.value = !1, await M());
291
+ } finally {
292
+ p.value = !1;
293
+ }
294
+ }, P = async () => {
295
+ (u.value || p.value) && (u.value = !0, await new Promise((t) => {
296
+ const i = () => {
297
+ !p.value && !u.value ? t() : setTimeout(i, 100);
298
+ };
299
+ i();
300
+ })), await M(), setTimeout(() => {
301
+ e.editor.commands.removeAiMark("aiAnimationMark"), h("remove");
215
302
  }, 1e3);
216
- }, L = async () => {
217
- f.value = "", g.value = !1, O.value = "", m.value = !0;
303
+ }, C = async () => {
304
+ T.value = "", d.value = !1, b.value = "", f.value = !0;
218
305
  try {
219
- e.handleClose(), e.selectedText ? d("update") : e.editor.commands.insertContent({
306
+ e.handleClose(), e.selectedText ? h("update") : e.editor.commands.insertContent({
220
307
  type: "aiLoaderNode"
221
- }), b.value && e.editor.commands.enableTrackChanges();
222
- const a = {
308
+ }), I.value && e.editor.commands.enableTrackChanges();
309
+ const i = {
223
310
  // @todo: implement grabbing document text
224
311
  docText: "",
225
- documentXml: R(),
312
+ documentXml: E(),
226
313
  config: {
227
314
  // Pass the aiApiKey to the AI helper functions
228
315
  apiKey: e.apiKey,
229
316
  endpoint: e.endpoint
230
317
  }
231
318
  };
232
- e.selectedText ? await te(e.selectedText, p.value, a, T, _) : await ee(p.value, a, T, _);
319
+ e.selectedText ? await re(e.selectedText, c.value, i, k, P) : await ne(c.value, i, k, P);
233
320
  } catch (t) {
234
- console.error("AI generation error:", t), f.value = t.message || "An error occurred";
321
+ console.error("AI generation error:", t), T.value = t.message || "An error occurred";
235
322
  } finally {
236
- p.value = "", b.value && e.editor.commands.disableTrackChanges(), m.value = !1, g.value = !1;
323
+ c.value = "", I.value && e.editor.commands.disableTrackChanges(), f.value = !1, d.value = !1;
237
324
  }
238
- }, K = (t) => {
239
- t.key === "Enter" && !t.shiftKey && (t.preventDefault(), L());
240
- }, V = (t) => {
241
- f.value && (f.value = ""), p.value = t.target.value;
325
+ }, W = (t) => {
326
+ t.key === "Enter" && !t.shiftKey && (t.preventDefault(), C());
327
+ }, X = (t) => {
328
+ T.value && (T.value = ""), c.value = t.target.value;
242
329
  };
243
- return (t, a) => (M(), A("div", {
330
+ return (t, i) => (R(), O("div", {
244
331
  class: "ai-writer prosemirror-isolated",
245
332
  ref_key: "aiWriterRef",
246
333
  ref: n,
247
- onMousedown: a[1] || (a[1] = E(() => {
334
+ onMousedown: i[1] || (i[1] = H(() => {
248
335
  }, ["stop"]))
249
336
  }, [
250
- h("div", ne, [
251
- h("span", {
337
+ S("div", le, [
338
+ S("span", {
252
339
  class: "ai-textarea-icon",
253
- innerHTML: I(oe)
254
- }, null, 8, se),
255
- $(h("textarea", {
340
+ innerHTML: N(ie)
341
+ }, null, 8, de),
342
+ Y(S("textarea", {
256
343
  ref_key: "editableRef",
257
- ref: c,
344
+ ref: l,
258
345
  class: "ai-textarea",
259
- placeholder: N.value,
260
- onKeydown: K,
261
- onInput: V,
262
- "onUpdate:modelValue": a[0] || (a[0] = (y) => p.value = y),
346
+ placeholder: y.value,
347
+ onKeydown: W,
348
+ onInput: X,
349
+ "onUpdate:modelValue": i[0] || (i[0] = (A) => c.value = A),
263
350
  rows: "4"
264
- }, null, 40, ae), [
265
- [B, p.value]
351
+ }, null, 40, ue), [
352
+ [J, c.value]
266
353
  ])
267
354
  ]),
268
- h("div", ie, [
269
- p.value ? (M(), A("span", {
355
+ S("div", me, [
356
+ c.value ? (R(), O("span", {
270
357
  key: 0,
271
358
  class: "ai-textarea-icon ai-submit-button",
272
- onClick: E(L, ["stop"]),
273
- innerHTML: I(re)
274
- }, null, 8, ce)) : G("", !0)
359
+ onClick: H(C, ["stop"]),
360
+ innerHTML: N(ce)
361
+ }, null, 8, fe)) : Q("", !0)
275
362
  ])
276
363
  ], 544));
277
364
  }
278
- }, me = /* @__PURE__ */ J(le, [["__scopeId", "data-v-b140a4fa"]]);
365
+ }, xe = /* @__PURE__ */ ee(pe, [["__scopeId", "data-v-4cf86e1f"]]);
279
366
  export {
280
- me as default
367
+ xe as default
281
368
  };
@@ -16739,7 +16739,7 @@ const pt = class pt {
16739
16739
  return;
16740
16740
  }
16741
16741
  }
16742
- static updateDocumentVersion(e = this.convertedXml, t = "0.11.30") {
16742
+ static updateDocumentVersion(e = this.convertedXml, t = "0.11.32") {
16743
16743
  const n = "docProps/custom.xml";
16744
16744
  e[n] || (e[n] = Fu());
16745
16745
  const i = e["docProps/custom.xml"];
@@ -17002,7 +17002,7 @@ function Cp(r) {
17002
17002
  function Fu() {
17003
17003
  return Gf;
17004
17004
  }
17005
- function Bu(r = 2, e = "0.11.30") {
17005
+ function Bu(r = 2, e = "0.11.32") {
17006
17006
  return {
17007
17007
  type: "element",
17008
17008
  name: "property",
@@ -1,4 +1,4 @@
1
- import { p as Tt, a0 as wt, B as ut, a1 as Bt, a2 as Rt } from "./converter-69UAZ0Ft.js";
1
+ import { p as Tt, a0 as wt, B as ut, a1 as Bt, a2 as Rt } from "./converter-ajcAkpke.js";
2
2
  function kt(bt) {
3
3
  throw new Error('Could not dynamically require "' + bt + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
4
4
  }
@@ -7,9 +7,9 @@ var L = (t, e, n) => zf(t, typeof e != "symbol" ? e + "" : e, n), Zi = (t, e, n)
7
7
  var Qe = (t, e, n) => (Zi(t, e, "read from private field"), n ? n.call(t) : e.get(t)), ft = (t, e, n) => e.has(t) ? ua("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), Qi = (t, e, n, r) => (Zi(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n), E = (t, e, n) => (Zi(t, e, "access private method"), n);
8
8
  import * as N from "yjs";
9
9
  import { UndoManager as _f, Item as $f, ContentType as Vf, Text as Hf, XmlElement as jf } from "yjs";
10
- import { P as X, a as J, M as pr, c as Y, N as _, S as ee, T as j, b as W, D as jn, F as T, d as rn, e as Wf, f as gc, A as Er, p as ie, B as Uf, i as qf, g as yc, h as Kf, j as wt, l as Pr, k as jt, m as bc, r as wc, R as ln, o as hr, n as fa, q as Vt, s as Eo, t as vc, u as Xf, v as Jf, w as de, x as Ve, y as Ir, z as xn, C as xi, E as Yf, G as Se, H as ui, I as kc, J as Sn, K as eo, L as to, O as no, Q as fi, U as Rt, V as _i, W as Gf, X as pa, Y as ha, Z as Zf, _ as Qf, $ as ep } from "./converter-69UAZ0Ft.js";
10
+ import { P as X, a as J, M as pr, c as Y, N as _, S as ee, T as j, b as W, D as jn, F as T, d as rn, e as Wf, f as gc, A as Er, p as ie, B as Uf, i as qf, g as yc, h as Kf, j as wt, l as Pr, k as jt, m as bc, r as wc, R as ln, o as hr, n as fa, q as Vt, s as Eo, t as vc, u as Xf, v as Jf, w as de, x as Ve, y as Ir, z as xn, C as xi, E as Yf, G as Se, H as ui, I as kc, J as Sn, K as eo, L as to, O as no, Q as fi, U as Rt, V as _i, W as Gf, X as pa, Y as ha, Z as Zf, _ as Qf, $ as ep } from "./converter-ajcAkpke.js";
11
11
  import { ref as ma, computed as tp, createElementBlock as Xt, openBlock as Jt, withModifiers as ro, Fragment as np, renderList as rp, normalizeClass as ip, createCommentVNode as ga, toDisplayString as io, createElementVNode as op, createApp as sp } from "vue";
12
- import { D as ya } from "./docx-zipper-CvLDRHYT.js";
12
+ import { D as ya } from "./docx-zipper-BQ70zniM.js";
13
13
  function $i(t) {
14
14
  const { from: e, to: n, empty: r } = t.selection, i = [];
15
15
  return r ? (t.storedMarks && i.push(...t.storedMarks), i.push(...t.selection.$head.marks())) : t.doc.nodesBetween(e, n, (o) => {
@@ -10178,7 +10178,7 @@ const ca = class ca extends Fg {
10178
10178
  * @returns {Y.Doc | undefined} Updated Y.Doc if any, otherwise undefined
10179
10179
  */
10180
10180
  processCollaborationMigrations() {
10181
- if (console.debug("[checkVersionMigrations] Current editor version", "0.11.30"), !this.options.ydoc) return;
10181
+ if (console.debug("[checkVersionMigrations] Current editor version", "0.11.32"), !this.options.ydoc) return;
10182
10182
  let r = this.options.ydoc.getMap("meta").get("version");
10183
10183
  r || (r = "initial"), console.debug("[checkVersionMigrations] Document version", r);
10184
10184
  const i = hl(r) || [], s = this.state.plugins.find((c) => c.key.startsWith("y-sync"));
@@ -10218,18 +10218,20 @@ const ca = class ca extends Fg {
10218
10218
  * pre-process the document as needed prior to running in the annotator.
10219
10219
  *
10220
10220
  * Currently this is only used for table generation but additional pre-processing can be done here.
10221
- * @param {Array[Object]} annotationValues
10221
+ *
10222
+ * @param {FieldValue[]} annotationValues
10222
10223
  * @returns {void}
10223
10224
  */
10224
- prepareForAnnotations(n = [], r = []) {
10225
- const { tr: i } = this.state, { dispatch: o } = this.view, s = ko.processTables({ editor: this, tr: i, annotationValues: n, hiddenIds: r });
10226
- this.view.dispatch(s);
10225
+ prepareForAnnotations(n = []) {
10226
+ const { tr: r } = this.state, { dispatch: i } = this.view, o = ko.processTables({ editor: this, tr: r, annotationValues: n });
10227
+ this.view.dispatch(o);
10227
10228
  }
10228
10229
  /**
10229
10230
  * Annotate the document with the given annotation values.
10230
10231
  *
10231
- * @param {Array[Object]} annotationValues
10232
- * @param {Array[String]} hiddenIds
10232
+ * @param {FieldValue[]} annotationValues List of field values to apply.
10233
+ * @param {String[]} hiddenIds List of field ids to remove from the document.
10234
+ * @returns {void}
10233
10235
  */
10234
10236
  annotate(n = [], r = []) {
10235
10237
  const { state: i, view: o, schema: s } = this;
@@ -1,6 +1,6 @@
1
1
  import { computed as _, createElementBlock as ie, openBlock as q, createElementVNode as Ot, createCommentVNode as he, normalizeClass as en, normalizeStyle as Tt, ref as R, unref as W, createBlock as Ge, toDisplayString as Xn, withDirectives as ft, withKeys as Hr, withModifiers as jr, vModelText as Wr, getCurrentInstance as Lt, createVNode as ct, readonly as tn, watch as we, onMounted as Ke, onBeforeUnmount as Be, reactive as Us, onBeforeMount as fr, inject as te, onActivated as Gs, onDeactivated as oi, createTextVNode as ht, Fragment as _e, Comment as hr, defineComponent as ee, provide as Se, h as A, Teleport as Xs, toRef as se, nextTick as ii, renderSlot as qs, isVNode as Ys, shallowRef as Zs, watchEffect as pt, mergeProps as gt, Transition as nn, vShow as Js, cloneVNode as Qs, Text as el, renderList as tl, withCtx as xt } from "vue";
2
- import { p as rn } from "./converter-69UAZ0Ft.js";
3
- import { _ as mt, g as kt } from "./editor-Br7gJJbN.js";
2
+ import { p as rn } from "./converter-ajcAkpke.js";
3
+ import { _ as mt, g as kt } from "./editor-CI9Y8Eul.js";
4
4
  const I0 = (e, t) => {
5
5
  let n = e.replace(/[^0-9.]/g, "");
6
6
  return n = parseFloat(n), isNaN(n) && (n = t), n = parseFloat(n), n;
@@ -62,4 +62,16 @@ export function rewrite(text: string, prompt?: string, options?: {
62
62
  url: string;
63
63
  config: any;
64
64
  }): Promise<string>;
65
+ /**
66
+ * Converts markdown-style formatting in the document text to ProseMirror's native formatting.
67
+ * Uses a node-aware approach that safely handles formatting across node boundaries.
68
+ *
69
+ * This function processes the entire document content and applies formatting rules defined in formatRegistry.
70
+ * It handles cases where formatting markers (like **bold**) span across multiple text nodes by tracking
71
+ * node positions and boundaries. The function works from the end of the document to the start to avoid
72
+ * position shifts when making replacements.
73
+ *
74
+ * @param {Object} editor - The ProseMirror editor instance containing the document state and view
75
+ */
76
+ export function formatDocument(editor: any): void;
65
77
  //# sourceMappingURL=ai-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ai-helpers.d.ts","sourceRoot":"","sources":["../../../src/components/toolbar/ai-helpers.js"],"names":[],"mappings":"AAuJA;;;;;;;;;;GAUG;AACH,uCATW,MAAM,WAEd;IAAwB,OAAO,EAAvB,MAAM;IACU,WAAW,EAA3B,MAAM;IACU,GAAG,EAAnB,MAAM;IACU,MAAM;CAC9B,mCACU,OAAO,CAAC,MAAM,CAAC,CA6B3B;AAED;;;;;;;;;GASG;AACH,8BARW,MAAM,YAEd;IAAwB,OAAO,EAAvB,MAAM;IACU,WAAW,EAA3B,MAAM;IACU,GAAG,EAAnB,MAAM;IACU,MAAM;CAC9B,GAAU,OAAO,CAAC,MAAM,CAAC,CAsB3B;AAED;;;;;;;;;;GAUG;AACH,uCATW,MAAM,UACN,MAAM,WAEd;IAAwB,WAAW,EAA3B,MAAM;IACU,GAAG,EAAnB,MAAM;IACU,MAAM;CAC9B,mCACU,OAAO,CAAC,MAAM,CAAC,CA4B3B;AAED;;;;;;;;;GASG;AACH,8BARW,MAAM,WACN,MAAM,YAEd;IAAwB,WAAW,EAA3B,MAAM;IACU,GAAG,EAAnB,MAAM;IACU,MAAM;CAC9B,GAAU,OAAO,CAAC,MAAM,CAAC,CA0B3B"}
1
+ {"version":3,"file":"ai-helpers.d.ts","sourceRoot":"","sources":["../../../src/components/toolbar/ai-helpers.js"],"names":[],"mappings":"AAuJA;;;;;;;;;;GAUG;AACH,uCATW,MAAM,WAEd;IAAwB,OAAO,EAAvB,MAAM;IACU,WAAW,EAA3B,MAAM;IACU,GAAG,EAAnB,MAAM;IACU,MAAM;CAC9B,mCACU,OAAO,CAAC,MAAM,CAAC,CA6B3B;AAED;;;;;;;;;GASG;AACH,8BARW,MAAM,YAEd;IAAwB,OAAO,EAAvB,MAAM;IACU,WAAW,EAA3B,MAAM;IACU,GAAG,EAAnB,MAAM;IACU,MAAM;CAC9B,GAAU,OAAO,CAAC,MAAM,CAAC,CAsB3B;AAED;;;;;;;;;;GAUG;AACH,uCATW,MAAM,UACN,MAAM,WAEd;IAAwB,WAAW,EAA3B,MAAM;IACU,GAAG,EAAnB,MAAM;IACU,MAAM;CAC9B,mCACU,OAAO,CAAC,MAAM,CAAC,CA4B3B;AAED;;;;;;;;;GASG;AACH,8BARW,MAAM,WACN,MAAM,YAEd;IAAwB,WAAW,EAA3B,MAAM;IACU,GAAG,EAAnB,MAAM;IACU,MAAM;CAC9B,GAAU,OAAO,CAAC,MAAM,CAAC,CA0B3B;AAqBD;;;;;;;;;;GAUG;AACH,kDAgIC"}
@@ -1,4 +1,4 @@
1
- import { O as o } from "./chunks/converter-69UAZ0Ft.js";
1
+ import { O as o } from "./chunks/converter-ajcAkpke.js";
2
2
  export {
3
3
  o as SuperConverter
4
4
  };
@@ -1,5 +1,13 @@
1
+ /**
2
+ * @typedef {Object} FieldValue
3
+ * @property {string} input_id The id of the input field
4
+ * @property {string} input_value The value to insert into the field
5
+ */
1
6
  /**
2
7
  * Editor main class.
8
+ *
9
+ * Expects a config object.
10
+ * @class
3
11
  */
4
12
  export class Editor extends EventEmitter {
5
13
  /**
@@ -223,18 +231,30 @@ export class Editor extends EventEmitter {
223
231
  * pre-process the document as needed prior to running in the annotator.
224
232
  *
225
233
  * Currently this is only used for table generation but additional pre-processing can be done here.
226
- * @param {Array[Object]} annotationValues
234
+ *
235
+ * @param {FieldValue[]} annotationValues
227
236
  * @returns {void}
228
237
  */
229
- prepareForAnnotations(annotationValues?: any, hiddenIds?: any[]): void;
238
+ prepareForAnnotations(annotationValues?: FieldValue[]): void;
230
239
  /**
231
240
  * Annotate the document with the given annotation values.
232
241
  *
233
- * @param {Array[Object]} annotationValues
234
- * @param {Array[String]} hiddenIds
242
+ * @param {FieldValue[]} annotationValues List of field values to apply.
243
+ * @param {String[]} hiddenIds List of field ids to remove from the document.
244
+ * @returns {void}
235
245
  */
236
- annotate(annotationValues?: any, hiddenIds?: any): void;
246
+ annotate(annotationValues?: FieldValue[], hiddenIds?: string[]): void;
237
247
  #private;
238
248
  }
249
+ export type FieldValue = {
250
+ /**
251
+ * The id of the input field
252
+ */
253
+ input_id: string;
254
+ /**
255
+ * The value to insert into the field
256
+ */
257
+ input_value: string;
258
+ };
239
259
  import { EventEmitter } from './EventEmitter.js';
240
260
  //# sourceMappingURL=Editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/core/Editor.js"],"names":[],"mappings":"AA0BA;;GAEG;AACH;IAwgBE;;;OAGG;IACH,sEAQC;IAED,6CAGC;IAED,8DAGC;IAsiBD,sDAKC;IA7/BD,0BAmBC;IA5FD,sBAAiB;IAEjB,qBAAsB;IAEtB,YAAO;IAEP,UAAK;IAEL,mBAAkB;IAIlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2DE;IAmIF,+BAEC;IADC,aAAsB;IAgBxB;;OAEG;IACH,cAEC;IAED;;OAEG;IACH,iBAEC;IAED;;OAEG;IACH,kBAEC;IAED;;OAEG;IACH,oBAEC;IAED;;OAEG;IACH,sBAEC;IAED;;OAEG;IACH,uBAEC;IAED;;OAEG;IACH,mBAEC;IAED;;OAEG;IACH,mBAEC;IAED;;OAEG;IACH,aAEC;IAED;;OAEG;IACH,WAEC;IAED,yCA8BC;IAED;;;OAGG;IACH,oCAYC;IA0BD;;;OAGG;IACH,+BA0BC;IAED;;;;OAIG;IACH,uDAMC;IAED;;;;OAIG;IACH,sDAQC;IAED;;;OAGG;IACH,6CAUC;IAgCG,eAAuC;IAiK3C;;OAEG;IACH,wBAIC;IAED;;;;;;MAeC;IAED;;;;OAIG;IACH,uCAgDC;IAED,qCAkDC;IA2HD;;;;OAIG;IACH,oCAEC;IAED;;;;;;OAMG;IACH,qEAKC;IAED;;OAEG;IACH,eAEC;IAED;;OAEG;IACH,kBAMC;IAED;;OAEG;IACH,qBAEC;IAED;;;;;;OAMG;IACH,iCAHG;QAAuB,WAAW;KAClC,GAAU,IAAI,CAiBhB;IA6CD;;OAEG;IACH;;;qBA+DC;IAcD;;OAEG;IACH,gBAKC;IASD;;;;OAIG;IACH,kCAFa,CAAC,CAAC,GAAG,GAAG,SAAS,CA8B7B;IAED,yCA4BC;IAED,+BAGC;IAED,sDAUC;IAED;;;;;;;OAOG;IACH,kEAFa,IAAI,CAOhB;IAED;;;;;OAKG;IACH,wDAgBC;;CAEF;6BA5tC4B,mBAAmB"}
1
+ {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/core/Editor.js"],"names":[],"mappings":"AA0BA;;;;GAIG;AAEH;;;;;GAKG;AACH;IAwgBE;;;OAGG;IACH,sEAQC;IAED,6CAGC;IAED,8DAGC;IAsiBD,sDAKC;IA7/BD,0BAmBC;IA5FD,sBAAiB;IAEjB,qBAAsB;IAEtB,YAAO;IAEP,UAAK;IAEL,mBAAkB;IAIlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2DE;IAmIF,+BAEC;IADC,aAAsB;IAgBxB;;OAEG;IACH,cAEC;IAED;;OAEG;IACH,iBAEC;IAED;;OAEG;IACH,kBAEC;IAED;;OAEG;IACH,oBAEC;IAED;;OAEG;IACH,sBAEC;IAED;;OAEG;IACH,uBAEC;IAED;;OAEG;IACH,mBAEC;IAED;;OAEG;IACH,mBAEC;IAED;;OAEG;IACH,aAEC;IAED;;OAEG;IACH,WAEC;IAED,yCA8BC;IAED;;;OAGG;IACH,oCAYC;IA0BD;;;OAGG;IACH,+BA0BC;IAED;;;;OAIG;IACH,uDAMC;IAED;;;;OAIG;IACH,sDAQC;IAED;;;OAGG;IACH,6CAUC;IAgCG,eAAuC;IAiK3C;;OAEG;IACH,wBAIC;IAED;;;;;;MAeC;IAED;;;;OAIG;IACH,uCAgDC;IAED,qCAkDC;IA2HD;;;;OAIG;IACH,oCAEC;IAED;;;;;;OAMG;IACH,qEAKC;IAED;;OAEG;IACH,eAEC;IAED;;OAEG;IACH,kBAMC;IAED;;OAEG;IACH,qBAEC;IAED;;;;;;OAMG;IACH,iCAHG;QAAuB,WAAW;KAClC,GAAU,IAAI,CAiBhB;IA6CD;;OAEG;IACH;;;qBA+DC;IAcD;;OAEG;IACH,gBAKC;IASD;;;;OAIG;IACH,kCAFa,CAAC,CAAC,GAAG,GAAG,SAAS,CA8B7B;IAED,yCA4BC;IAED,+BAGC;IAED,sDAUC;IAED;;;;;;;;OAQG;IACH,yCAHW,UAAU,EAAE,GACV,IAAI,CAOhB;IAED;;;;;;OAMG;IACH,4BAJW,UAAU,EAAE,cACZ,QAAQ,GACN,IAAI,CAgBhB;;CAEF;;;;;cA9sCa,MAAM;;;;iBACN,MAAM;;6BAxBS,mBAAmB"}