@eigenpal/docx-editor-vue 0.0.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.
Files changed (92) hide show
  1. package/LICENSE +204 -0
  2. package/README.md +60 -0
  3. package/dist/KeyboardShortcutsDialog-BtJB9UOD.js +2902 -0
  4. package/dist/KeyboardShortcutsDialog-D72k5DXR.cjs +1 -0
  5. package/dist/MenuBar-BrQW4COn.cjs +4 -0
  6. package/dist/MenuBar-D_Dvwb0F.js +3313 -0
  7. package/dist/RenderedDomContext-CHc18N_2.js +2 -0
  8. package/dist/TablePropertiesDialog-Ct5XChwd.cjs +1 -0
  9. package/dist/TablePropertiesDialog-cJx_xxxE.js +987 -0
  10. package/dist/_plugin-vue_export-helper-B52Kst-M.js +8 -0
  11. package/dist/_plugin-vue_export-helper-CX7YVcP6.cjs +1 -0
  12. package/dist/components/DocxEditor/types.d.ts +100 -0
  13. package/dist/components/EditorToolbarContext.d.ts +9 -0
  14. package/dist/components/Toolbar/presets.d.ts +42 -0
  15. package/dist/components/dialogs/index.d.ts +27 -0
  16. package/dist/components/imageContextMenuTypes.d.ts +30 -0
  17. package/dist/components/imageSelectionTypes.d.ts +14 -0
  18. package/dist/components/insertTableState.d.ts +9 -0
  19. package/dist/components/sidebar/cardStyles.d.ts +3 -0
  20. package/dist/components/sidebar/cardUtils.d.ts +1 -0
  21. package/dist/components/sidebar/resolveItemPositions.d.ts +4 -0
  22. package/dist/components/sidebar/sidebarUtils.d.ts +4 -0
  23. package/dist/components/tableStylePresets.d.ts +53 -0
  24. package/dist/components/toolbarUtils.d.ts +1 -0
  25. package/dist/components/ui/Icons.d.ts +1 -0
  26. package/dist/components/ui/hyperlinkPopupTypes.d.ts +20 -0
  27. package/dist/composables/index.d.ts +30 -0
  28. package/dist/composables/useAutoSave.d.ts +40 -0
  29. package/dist/composables/useClipboard.d.ts +22 -0
  30. package/dist/composables/useCommentLifecycle.d.ts +52 -0
  31. package/dist/composables/useCommentManagement.d.ts +41 -0
  32. package/dist/composables/useCommentSidebarItems.d.ts +24 -0
  33. package/dist/composables/useContextMenus.d.ts +39 -0
  34. package/dist/composables/useDocumentLifecycle.d.ts +11 -0
  35. package/dist/composables/useDocxEditor.d.ts +56 -0
  36. package/dist/composables/useDocxEditorRefApi.d.ts +49 -0
  37. package/dist/composables/useDragAutoScroll.d.ts +11 -0
  38. package/dist/composables/useFileIO.d.ts +30 -0
  39. package/dist/composables/useFindReplace.d.ts +34 -0
  40. package/dist/composables/useFixedDropdown.d.ts +14 -0
  41. package/dist/composables/useFormattingActions.d.ts +40 -0
  42. package/dist/composables/useHistory.d.ts +9 -0
  43. package/dist/composables/useHyperlinkManagement.d.ts +38 -0
  44. package/dist/composables/useImageActions.d.ts +30 -0
  45. package/dist/composables/useKeyboardShortcuts.d.ts +17 -0
  46. package/dist/composables/useMenuActions.d.ts +23 -0
  47. package/dist/composables/useOutlineSidebar.d.ts +17 -0
  48. package/dist/composables/usePageSetupControls.d.ts +22 -0
  49. package/dist/composables/usePagesPointer.d.ts +70 -0
  50. package/dist/composables/useSelectionHighlight.d.ts +19 -0
  51. package/dist/composables/useSelectionSync.d.ts +13 -0
  52. package/dist/composables/useTableResize.d.ts +7 -0
  53. package/dist/composables/useTableSelection.d.ts +10 -0
  54. package/dist/composables/useToolbarDropdowns.d.ts +14 -0
  55. package/dist/composables/useTrackedChanges.d.ts +12 -0
  56. package/dist/composables/useVisualLineNavigation.d.ts +11 -0
  57. package/dist/composables/useWheelZoom.d.ts +10 -0
  58. package/dist/composables/useZoom.d.ts +16 -0
  59. package/dist/composables.cjs +1 -0
  60. package/dist/composables.js +485 -0
  61. package/dist/dialogs.cjs +1 -0
  62. package/dist/dialogs.js +3 -0
  63. package/dist/docx-editor-vue.css +2 -0
  64. package/dist/i18n/LocaleContext.d.ts +1 -0
  65. package/dist/i18n/index.d.ts +26 -0
  66. package/dist/index.cjs +20 -0
  67. package/dist/index.d.ts +23 -0
  68. package/dist/index.js +3600 -0
  69. package/dist/lib/utils.d.ts +10 -0
  70. package/dist/plugin-api/RenderedDomContext.d.ts +1 -0
  71. package/dist/plugin-api/index.d.ts +18 -0
  72. package/dist/plugin-api/types.d.ts +28 -0
  73. package/dist/plugin-api.cjs +1 -0
  74. package/dist/plugin-api.js +62 -0
  75. package/dist/renderAsync.d.ts +31 -0
  76. package/dist/styles/index.d.ts +12 -0
  77. package/dist/styles/zIndex.d.ts +24 -0
  78. package/dist/styles.cjs +1 -0
  79. package/dist/styles.js +5 -0
  80. package/dist/ui.cjs +18 -0
  81. package/dist/ui.d.ts +79 -0
  82. package/dist/ui.js +963 -0
  83. package/dist/useTableResize-1oSe9Kjk.js +480 -0
  84. package/dist/useTableResize-lWdIgX9x.cjs +1 -0
  85. package/dist/utils/commentFactories.d.ts +7 -0
  86. package/dist/utils/domQueries.d.ts +28 -0
  87. package/dist/utils/imageClipboard.d.ts +9 -0
  88. package/dist/utils/paraTextHelpers.d.ts +29 -0
  89. package/dist/utils/refApiQueries.d.ts +46 -0
  90. package/dist/zIndex-CH0jZ7U7.cjs +1 -0
  91. package/dist/zIndex-CxELVe_L.js +12 -0
  92. package/package.json +119 -0
package/dist/index.js ADDED
@@ -0,0 +1,3600 @@
1
+ import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, p as c, r as l, s as u, t as d, u as f } from "./KeyboardShortcutsDialog-BtJB9UOD.js";
2
+ import { a as p, c as m, h, i as g, o as _, s as ee, t as v, x as y } from "./MenuBar-D_Dvwb0F.js";
3
+ import { t as b } from "./_plugin-vue_export-helper-B52Kst-M.js";
4
+ import { n as x } from "./RenderedDomContext-CHc18N_2.js";
5
+ import { t as te } from "./zIndex-CxELVe_L.js";
6
+ import { n as ne, r as re, t as S } from "./useTableResize-1oSe9Kjk.js";
7
+ import { Fragment as C, Teleport as ie, computed as w, createApp as ae, createBlock as T, createCommentVNode as E, createElementBlock as D, createElementVNode as O, createSlots as oe, createStaticVNode as se, createVNode as k, defineComponent as A, h as ce, nextTick as j, normalizeClass as le, normalizeStyle as M, onBeforeUnmount as N, onMounted as P, openBlock as F, ref as I, renderList as L, renderSlot as ue, resolveDynamicComponent as de, shallowRef as fe, toDisplayString as R, unref as z, vModelText as B, watch as V, withCtx as H, withDirectives as U, withKeys as W, withModifiers as G } from "vue";
8
+ import { clearFormatting as pe, findHyperlinkRangeAt as K } from "@eigenpal/docx-editor-core/prosemirror/commands/formatting";
9
+ import { SIDEBAR_DOCUMENT_SHIFT as me, findWordBoundaries as he, pixelsToEmu as ge, readDocxFileFromInput as q, toArrayBuffer as _e } from "@eigenpal/docx-editor-core/utils";
10
+ import { getTableContext as ve } from "@eigenpal/docx-editor-core/prosemirror/extensions/nodes/TableExtension";
11
+ import { EditorState as ye, NodeSelection as be, TextSelection as xe } from "prosemirror-state";
12
+ import { clickToPositionDom as Se, getCaretPositionFromDom as Ce, getSelectionRectsFromDom as we } from "@eigenpal/docx-editor-core/layout-bridge/clickToPositionDom";
13
+ import { IMAGE_LAYOUT_OPTIONS as Te, captureInlinePositionEmu as Ee, deriveLayoutChoice as J, findImageElement as De, isImageLayoutOptionEnabled as Oe, toolbarValueToLayoutTarget as ke } from "@eigenpal/docx-editor-core/layout-painter";
14
+ import { EditorView as Ae } from "prosemirror-view";
15
+ import { singletonManager as je } from "@eigenpal/docx-editor-core/prosemirror/schema";
16
+ import { headerFooterToProseDoc as Me, proseDocToBlocks as Ne } from "@eigenpal/docx-editor-core/prosemirror/conversion";
17
+ import "prosemirror-view/style/prosemirror.css";
18
+ import { pointsToHalfPoints as Pe, twipsToPixels as Fe } from "@eigenpal/docx-editor-core/utils/units";
19
+ import { clickToPositionDom as Y, findBodyPmSpans as X } from "@eigenpal/docx-editor-core/layout-bridge";
20
+ import { findPageIndexContainingPmPos as Ie } from "@eigenpal/docx-editor-core/layout-engine";
21
+ import { applyStyle as Z, removeTabStop as Le, setIndentFirstLine as Re, setIndentLeft as ze, setIndentRight as Be } from "@eigenpal/docx-editor-core/prosemirror/commands/paragraph";
22
+ import { createStyleResolver as Ve } from "@eigenpal/docx-editor-core/prosemirror/styles";
23
+ import { insertPageBreak as He } from "@eigenpal/docx-editor-core/prosemirror/commands/pageBreak";
24
+ import { mapHexToHighlightName as Ue } from "@eigenpal/docx-editor-core/utils/highlightColors";
25
+ import { collectHeadings as We } from "@eigenpal/docx-editor-core/utils/headingCollector";
26
+ import { acceptChange as Ge, rejectChange as Ke } from "@eigenpal/docx-editor-core/prosemirror/commands";
27
+ import { extractTrackedChanges as qe } from "@eigenpal/docx-editor-core/prosemirror/utils/extractTrackedChanges";
28
+ import { TABLE_INSERT_HIDE_DELAY_MS as Je, detectTableInsertHover as Ye } from "@eigenpal/docx-editor-core/layout-bridge/tableInsertHover";
29
+ import { openReportIssue as Xe } from "@eigenpal/docx-editor-core/utils/reportIssue";
30
+ import { LayoutSelectionGate as Ze } from "@eigenpal/docx-editor-core/prosemirror";
31
+ //#region src/utils/paraTextHelpers.ts
32
+ function Qe(e, t) {
33
+ if (!t.trim()) return null;
34
+ let n = null;
35
+ return e.descendants((e, r) => n ? !1 : e.isTextblock && e.attrs?.paraId === t ? (n = {
36
+ from: r,
37
+ to: r + e.nodeSize
38
+ }, !1) : !0), n;
39
+ }
40
+ function $e(e) {
41
+ let t = [];
42
+ return e.descendants((e) => !e.isText || !e.text ? !0 : e.marks.some((e) => e.type.name === "insertion") ? !1 : (t.push(e.text), !0)), t.join("");
43
+ }
44
+ function et(e, t, n) {
45
+ if (t >= n) return "";
46
+ let r = [];
47
+ return e.nodesBetween(t, n, (e, i) => {
48
+ if (!e.isText || !e.text || e.marks.some((e) => e.type.name === "insertion")) return;
49
+ let a = Math.max(t, i), o = Math.min(n, i + e.text.length);
50
+ a < o && r.push(e.text.slice(a - i, o - i));
51
+ }), r.join("");
52
+ }
53
+ function tt(e, t, n, r) {
54
+ if (!r) return null;
55
+ let i = "", a = [];
56
+ e.nodesBetween(t, n, (e, t) => {
57
+ !e.isText || !e.text || e.marks.some((e) => e.type.name === "insertion") || (a.push({
58
+ pos: t,
59
+ len: e.text.length
60
+ }), i += e.text);
61
+ });
62
+ let o = i.indexOf(r);
63
+ if (o === -1 || i.indexOf(r, o + 1) !== -1) return null;
64
+ let s = 0, c = t, l = t;
65
+ for (let e of a) {
66
+ let t = s + e.len;
67
+ if (s <= o && o < t && (c = e.pos + (o - s)), s <= o + r.length && o + r.length <= t) {
68
+ l = e.pos + (o + r.length - s);
69
+ break;
70
+ }
71
+ s = t;
72
+ }
73
+ return {
74
+ from: c,
75
+ to: l
76
+ };
77
+ }
78
+ //#endregion
79
+ //#region src/utils/refApiQueries.ts
80
+ function nt(e, t, n) {
81
+ if (!e || !t) return [];
82
+ let r = n?.caseSensitive ?? !1, i = n?.limit ?? 20, a = r ? t : t.toLowerCase(), o = [];
83
+ return e.state.doc.descendants((e) => {
84
+ if (o.length >= i) return !1;
85
+ if (!e.isTextblock) return !0;
86
+ let n = e.attrs?.paraId;
87
+ if (!n) return !1;
88
+ let s = $e(e), c = r ? s : s.toLowerCase(), l = c.indexOf(a);
89
+ return l === -1 || c.indexOf(a, l + 1) !== -1 || o.push({
90
+ paraId: n,
91
+ match: s.slice(l, l + t.length),
92
+ before: s.slice(Math.max(0, l - 40), l),
93
+ after: s.slice(l + t.length, l + t.length + 40)
94
+ }), !1;
95
+ }), o;
96
+ }
97
+ function rt(e) {
98
+ if (!e) return null;
99
+ let { selection: t, doc: n } = e.state, r = t.$from, i = r.depth;
100
+ for (; i > 0 && !r.node(i).isTextblock;) i--;
101
+ let a = i > 0 ? r.node(i) : null;
102
+ if (!a) return null;
103
+ let o = a.attrs?.paraId ?? null, s = r.start(i), c = s + a.content.size, l = et(n, s, t.from), u = et(n, t.from, t.to), d = et(n, t.to, c);
104
+ return {
105
+ paraId: o,
106
+ selectedText: u,
107
+ paragraphText: l + u + d,
108
+ before: l,
109
+ after: d
110
+ };
111
+ }
112
+ function it(e, t, n) {
113
+ if (!t || !e) return null;
114
+ let r = t.pages[n - 1];
115
+ if (!r) return null;
116
+ let i = /* @__PURE__ */ new Set(), a = [];
117
+ for (let t of r.fragments) {
118
+ if (t.kind !== "paragraph") continue;
119
+ let n = t.pmStart;
120
+ if (n == null) continue;
121
+ let r = e.state.doc.nodeAt(n);
122
+ if (!r || !r.isTextblock) continue;
123
+ let o = r.attrs?.paraId;
124
+ !o || i.has(o) || (i.add(o), a.push({
125
+ paraId: o,
126
+ text: $e(r),
127
+ styleId: r.attrs?.styleId ?? void 0
128
+ }));
129
+ }
130
+ return {
131
+ pageNumber: n,
132
+ text: a.map((e) => `[${e.paraId}] ${e.text}`).join("\n"),
133
+ paragraphs: a
134
+ };
135
+ }
136
+ //#endregion
137
+ //#region src/components/DecorationLayer.vue
138
+ var at = /* @__PURE__ */ A({
139
+ __name: "DecorationLayer",
140
+ props: {
141
+ getView: { type: Function },
142
+ getPagesContainer: { type: Function },
143
+ zoom: {},
144
+ transactionVersion: {},
145
+ syncCoordinator: {}
146
+ },
147
+ setup(e) {
148
+ let t = e, n = I(null), r = I(0), i = null, a = null;
149
+ function o() {
150
+ i !== null && cancelAnimationFrame(i), i = requestAnimationFrame(() => {
151
+ i = null;
152
+ let e = t.getView(), r = t.getPagesContainer(), a = n.value;
153
+ !e || !r || !a || t.syncCoordinator.isSafeToRender() && s(e, r, a, t.zoom);
154
+ });
155
+ }
156
+ P(() => {
157
+ a = t.syncCoordinator.onRender(() => {
158
+ r.value++;
159
+ }), o();
160
+ }), N(() => {
161
+ i !== null && (cancelAnimationFrame(i), i = null), a?.();
162
+ }), V(() => [
163
+ t.zoom,
164
+ t.transactionVersion,
165
+ r.value
166
+ ], () => o());
167
+ function s(e, t, n, r) {
168
+ let i = c(e.state);
169
+ if (i.length === 0) {
170
+ n.firstChild && n.replaceChildren();
171
+ return;
172
+ }
173
+ let a = x(t, r), o = a.getContainerOffset(), s = document.createDocumentFragment();
174
+ for (let { decoration: t, from: n, to: r } of i) {
175
+ if (n === r) {
176
+ let r = l(t, e);
177
+ if (!r) continue;
178
+ let i = a.getCoordinatesForPosition(n);
179
+ if (!i) continue;
180
+ let c = document.createElement("div");
181
+ c.style.cssText = `position:absolute;left:${i.x + o.x}px;top:${i.y + o.y}px;height:${i.height}px;`, c.appendChild(r), s.appendChild(c);
182
+ continue;
183
+ }
184
+ let i = u(t);
185
+ if (!i) continue;
186
+ let c = a.getRectsForRange(n, r);
187
+ for (let e of c) {
188
+ let t = document.createElement("div");
189
+ for (let [e, n] of Object.entries(i)) e !== "nodeName" && t.setAttribute(e, n);
190
+ let n = `position:absolute;left:${e.x + o.x}px;top:${e.y + o.y}px;width:${e.width}px;height:${e.height}px;`;
191
+ t.style.cssText = n + (i.style ?? ""), s.appendChild(t);
192
+ }
193
+ }
194
+ n.replaceChildren(s);
195
+ }
196
+ function c(e) {
197
+ let t = [];
198
+ for (let n of e.plugins) {
199
+ let r = n.props.decorations;
200
+ if (!r) continue;
201
+ let i = r.call(n, e);
202
+ i && i.forEachSet((e) => {
203
+ e.find().forEach((e) => {
204
+ e.spec?.noOverlay || t.push({
205
+ decoration: e,
206
+ from: e.from,
207
+ to: e.to
208
+ });
209
+ });
210
+ });
211
+ }
212
+ return t;
213
+ }
214
+ function l(e, t) {
215
+ let n = e.type;
216
+ if (!n) return null;
217
+ let r = n.toDOM;
218
+ return typeof r == "function" ? r(t, () => e.from) : r instanceof HTMLElement ? r.cloneNode(!0) : null;
219
+ }
220
+ function u(e) {
221
+ return e.type?.attrs ?? null;
222
+ }
223
+ return (e, t) => (F(), D("div", {
224
+ ref_key: "overlayRef",
225
+ ref: n,
226
+ class: "paged-editor__decoration-overlay",
227
+ "aria-hidden": "true"
228
+ }, null, 512));
229
+ }
230
+ }), ot = ["data-handle", "onMousedown"], st = ["title"], ct = {
231
+ key: 0,
232
+ class: "image-overlay__dim"
233
+ }, lt = {
234
+ key: 1,
235
+ class: "image-overlay__dim image-overlay__dim--rotate"
236
+ }, ut = 4, dt = 15, ft = /* @__PURE__ */ b(/* @__PURE__ */ A({
237
+ __name: "ImageSelectionOverlay",
238
+ props: {
239
+ imageInfo: {},
240
+ zoom: {},
241
+ view: {}
242
+ },
243
+ emits: [
244
+ "deselect",
245
+ "interact-start",
246
+ "interact-end",
247
+ "context-menu"
248
+ ],
249
+ setup(e, { emit: t }) {
250
+ let { t: r } = n(), i = e, a = t, o = I(null), s = I(!1), c = I(!1), l = I(!1), u = I(0), d = I(0), f = I(0), p = I(null), m = "se", h = 0, g = 0, _ = 0, ee = 0, v = null, y = null, b = null, x = null;
251
+ function ne(e, t) {
252
+ if (!e) return null;
253
+ try {
254
+ let n = e.state.doc.nodeAt(t);
255
+ return n && n.type.name === "image" ? n : null;
256
+ } catch {
257
+ return null;
258
+ }
259
+ }
260
+ function re() {
261
+ let e = i.imageInfo;
262
+ if (!e) return null;
263
+ if (e.element.isConnected) return e.element;
264
+ let t = o.value?.closest(".docx-editor-vue__pages-viewport")?.querySelector(".docx-editor-vue__pages");
265
+ if (!t) return null;
266
+ for (let n of t.querySelectorAll(`[data-pm-start="${e.pmPos}"]`)) {
267
+ let e = De(n);
268
+ if (e) return e;
269
+ }
270
+ return null;
271
+ }
272
+ function S() {
273
+ let e = re();
274
+ if (!e || !o.value) {
275
+ p.value = null;
276
+ return;
277
+ }
278
+ let t = o.value.offsetParent;
279
+ if (!t) {
280
+ p.value = null;
281
+ return;
282
+ }
283
+ let n = t.getBoundingClientRect(), r = e.getBoundingClientRect(), a = i.zoom;
284
+ p.value = {
285
+ left: (r.left - n.left) / a,
286
+ top: (r.top - n.top) / a,
287
+ width: r.width / a,
288
+ height: r.height / a
289
+ };
290
+ }
291
+ V(() => i.imageInfo, async () => {
292
+ await j(), S();
293
+ }, { immediate: !0 }), V(() => i.imageInfo, (e, t, n) => {
294
+ if (!i.imageInfo) return;
295
+ let r = () => {
296
+ y && cancelAnimationFrame(y), y = requestAnimationFrame(S);
297
+ }, a = o.value?.closest(".docx-editor-vue__pages-viewport")?.parentElement;
298
+ a?.addEventListener("scroll", r, { passive: !0 }), window.addEventListener("resize", r, { passive: !0 }), n(() => {
299
+ a?.removeEventListener("scroll", r), window.removeEventListener("resize", r), y && cancelAnimationFrame(y);
300
+ });
301
+ }, { immediate: !0 });
302
+ let ie = w(() => s.value ? u.value : p.value?.width || 0), ae = w(() => s.value ? d.value : p.value?.height || 0), T = w(() => {
303
+ let e = p.value;
304
+ if (!e) return {
305
+ position: "absolute",
306
+ top: "0px",
307
+ left: "0px",
308
+ visibility: "hidden",
309
+ pointerEvents: "none"
310
+ };
311
+ let t = s.value ? u.value : e.width, n = s.value ? d.value : e.height;
312
+ return {
313
+ position: "absolute",
314
+ left: `${e.left}px`,
315
+ top: `${e.top}px`,
316
+ width: `${t}px`,
317
+ height: `${n}px`,
318
+ zIndex: te.imageOverlay,
319
+ pointerEvents: "auto"
320
+ };
321
+ }), oe = w(() => {
322
+ let e = ie.value, t = ae.value, n = `${e / 2 - 5}px`, r = `${t / 2 - 5}px`, i = `${e - 5}px`, a = `${t - 5}px`, o = "-5px";
323
+ return [
324
+ {
325
+ pos: "nw",
326
+ style: {
327
+ left: o,
328
+ top: o,
329
+ cursor: "nwse-resize"
330
+ }
331
+ },
332
+ {
333
+ pos: "n",
334
+ style: {
335
+ left: n,
336
+ top: o,
337
+ cursor: "ns-resize"
338
+ }
339
+ },
340
+ {
341
+ pos: "ne",
342
+ style: {
343
+ left: i,
344
+ top: o,
345
+ cursor: "nesw-resize"
346
+ }
347
+ },
348
+ {
349
+ pos: "e",
350
+ style: {
351
+ left: i,
352
+ top: r,
353
+ cursor: "ew-resize"
354
+ }
355
+ },
356
+ {
357
+ pos: "se",
358
+ style: {
359
+ left: i,
360
+ top: a,
361
+ cursor: "nwse-resize"
362
+ }
363
+ },
364
+ {
365
+ pos: "s",
366
+ style: {
367
+ left: n,
368
+ top: a,
369
+ cursor: "ns-resize"
370
+ }
371
+ },
372
+ {
373
+ pos: "sw",
374
+ style: {
375
+ left: o,
376
+ top: a,
377
+ cursor: "nesw-resize"
378
+ }
379
+ },
380
+ {
381
+ pos: "w",
382
+ style: {
383
+ left: o,
384
+ top: r,
385
+ cursor: "ew-resize"
386
+ }
387
+ }
388
+ ];
389
+ }), se = (e) => e.length === 2;
390
+ function k(e, t, n, r, i, a) {
391
+ let o = e.includes("w") ? -1 : +!!e.includes("e"), s = e.includes("n") ? -1 : +!!e.includes("s"), c = r + t * o, l = i + n * s;
392
+ if (se(e) && a) {
393
+ let e = Math.max(c / r, l / i);
394
+ c = r * e, l = i * e;
395
+ }
396
+ return {
397
+ width: o === 0 ? r : Math.max(20, Math.min(2e3, c)),
398
+ height: s === 0 ? i : Math.max(20, Math.min(2e3, l))
399
+ };
400
+ }
401
+ function A(e, t) {
402
+ !i.imageInfo || !p.value || (m = t, h = e.clientX, g = e.clientY, _ = p.value.width, ee = p.value.height, v = { ...p.value }, u.value = Math.round(_), d.value = Math.round(ee), s.value = !0, a("interact-start"), document.addEventListener("mousemove", ce), document.addEventListener("mouseup", le));
403
+ }
404
+ function ce(e) {
405
+ let t = i.zoom, n = (e.clientX - h) / t, r = (e.clientY - g) / t, a = !e.shiftKey, o = k(m, n, r, _, ee, a);
406
+ u.value = Math.round(o.width), d.value = Math.round(o.height);
407
+ let s = v;
408
+ s && (p.value = {
409
+ left: m.includes("w") ? s.left + (s.width - o.width) : s.left,
410
+ top: m.includes("n") ? s.top + (s.height - o.height) : s.top,
411
+ width: s.width,
412
+ height: s.height
413
+ });
414
+ }
415
+ function le() {
416
+ document.removeEventListener("mousemove", ce), document.removeEventListener("mouseup", le), s.value = !1, v = null, a("interact-end");
417
+ let e = i.view, t = i.imageInfo;
418
+ if (!e || !t) {
419
+ S();
420
+ return;
421
+ }
422
+ let n = ne(e, t.pmPos);
423
+ if (n) try {
424
+ e.dispatch(e.state.tr.setNodeMarkup(t.pmPos, void 0, {
425
+ ...n.attrs,
426
+ width: u.value,
427
+ height: d.value
428
+ }));
429
+ } catch {}
430
+ j(() => S());
431
+ }
432
+ let P = 0, ue = 0, de = 0, fe = 0, B = null, H = null;
433
+ function U(e) {
434
+ if (!e) return 0;
435
+ let t = e.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/);
436
+ return t ? parseFloat(t[1]) : 0;
437
+ }
438
+ function W(e, t) {
439
+ let n = /scaleX\(-1\)/.test(e || ""), r = /scaleY\(-1\)/.test(e || ""), i = [], a = (t % 360 + 360) % 360;
440
+ return a !== 0 && i.push(`rotate(${a}deg)`), n && i.push("scaleX(-1)"), r && i.push("scaleY(-1)"), i.length > 0 ? i.join(" ") : null;
441
+ }
442
+ function pe(e, t) {
443
+ return Math.atan2(e - P, -(t - ue)) * 180 / Math.PI;
444
+ }
445
+ function K(e) {
446
+ if (!i.imageInfo) return;
447
+ let t = i.imageInfo.element.getBoundingClientRect();
448
+ P = t.left + t.width / 2, ue = t.top + t.height / 2;
449
+ let n = ne(i.view, i.imageInfo.pmPos);
450
+ B = n && n.attrs.transform || null, fe = U(B), H = i.imageInfo.element.querySelector("img"), de = pe(e.clientX, e.clientY), f.value = fe, l.value = !0, a("interact-start"), document.addEventListener("mousemove", me), document.addEventListener("mouseup", he);
451
+ }
452
+ function me(e) {
453
+ let t = pe(e.clientX, e.clientY) - de, n = fe + t;
454
+ e.shiftKey || (n = Math.round(n / dt) * dt), f.value = (n % 360 + 360) % 360, H && (H.style.transform = W(B, f.value) || "");
455
+ }
456
+ function he() {
457
+ document.removeEventListener("mousemove", me), document.removeEventListener("mouseup", he), l.value = !1, a("interact-end");
458
+ let e = i.view, t = i.imageInfo;
459
+ try {
460
+ let n = e && t ? ne(e, t.pmPos) : null;
461
+ e && t && n && e.dispatch(e.state.tr.setNodeMarkup(t.pmPos, void 0, {
462
+ ...n.attrs,
463
+ transform: W(n.attrs.transform, f.value)
464
+ }));
465
+ } catch {} finally {
466
+ H && (H.style.transform = ""), H = null, B = null;
467
+ }
468
+ j(() => S());
469
+ }
470
+ let q = null;
471
+ function _e(e) {
472
+ if (!i.imageInfo || !p.value) return;
473
+ let t = e.clientX, n = e.clientY, r = p.value, o = !1, s = (e) => {
474
+ let s = e.clientX - t, l = e.clientY - n;
475
+ if (!(!o && Math.sqrt(s * s + l * l) < ut)) {
476
+ if (!o) {
477
+ o = !0, c.value = !0, a("interact-start"), q = document.createElement("div"), q.style.cssText = "position: fixed; pointer-events: none; z-index: 10000; opacity: 0.5; border: 2px dashed #2563eb; border-radius: 4px; background: rgba(37, 99, 235, 0.1);";
478
+ let e = i.zoom;
479
+ q.style.width = `${r.width * e}px`, q.style.height = `${r.height * e}px`, document.body.appendChild(q);
480
+ }
481
+ if (q) {
482
+ let t = i.zoom;
483
+ q.style.left = `${e.clientX - r.width * t / 2}px`, q.style.top = `${e.clientY - r.height * t / 2}px`;
484
+ }
485
+ }
486
+ }, l = (e) => {
487
+ document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", l), b = null, x = null, q &&= (q.remove(), null), c.value = !1, o && (a("interact-end"), ve(e.clientX, e.clientY));
488
+ };
489
+ b = s, x = l, document.addEventListener("mousemove", s), document.addEventListener("mouseup", l);
490
+ }
491
+ function ve(e, t) {
492
+ let n = i.view, r = i.imageInfo;
493
+ if (!n || !r) return;
494
+ let a = ne(n, r.pmPos);
495
+ if (!a) return;
496
+ let s = a.attrs.wrapType, c = a.attrs.displayMode === "float" || (s ? [
497
+ "square",
498
+ "tight",
499
+ "through"
500
+ ].includes(s) : !1);
501
+ try {
502
+ if (c) {
503
+ let s = (o.value?.closest(".docx-editor-vue__pages-viewport"))?.querySelectorAll(".layout-page");
504
+ if (!s || s.length === 0) return;
505
+ let c = null;
506
+ for (let e of s) {
507
+ let n = e.getBoundingClientRect();
508
+ if (t >= n.top && t <= n.bottom) {
509
+ c = e.querySelector(".layout-page-content");
510
+ break;
511
+ }
512
+ }
513
+ if (c ||= s[s.length - 1].querySelector(".layout-page-content"), !c) return;
514
+ let l = c.getBoundingClientRect(), u = i.zoom, d = (e - l.left) / u, f = (t - l.top) / u, p = {
515
+ horizontal: {
516
+ posOffset: ge(d),
517
+ relativeTo: "margin"
518
+ },
519
+ vertical: {
520
+ posOffset: ge(f),
521
+ relativeTo: "margin"
522
+ }
523
+ }, m = n.state.tr.setNodeMarkup(r.pmPos, void 0, {
524
+ ...a.attrs,
525
+ position: p
526
+ });
527
+ n.dispatch(m), ye(r.pmPos);
528
+ } else {
529
+ let i = o.value?.closest(".docx-editor-vue__pages-viewport")?.querySelector(".docx-editor-vue__pages");
530
+ if (!i) return;
531
+ let s = Se(i, e, t, 1);
532
+ if (s == null || s < 0 || s === r.pmPos || s === r.pmPos + 1) return;
533
+ let c = n.state.tr, l = a.nodeSize;
534
+ if (s <= r.pmPos) c = c.delete(r.pmPos, r.pmPos + l), c = c.insert(s, a), n.dispatch(c), ye(s);
535
+ else {
536
+ c = c.delete(r.pmPos, r.pmPos + l);
537
+ let e = Math.min(s - l, c.doc.content.size);
538
+ c = c.insert(e, a), n.dispatch(c), ye(Math.min(e, n.state.doc.content.size - 1));
539
+ }
540
+ }
541
+ } catch {}
542
+ j(() => S());
543
+ }
544
+ function ye(e) {
545
+ let t = i.view;
546
+ if (t) try {
547
+ let n = be.create(t.state.doc, e);
548
+ t.dispatch(t.state.tr.setSelection(n));
549
+ } catch {}
550
+ }
551
+ return N(() => {
552
+ document.removeEventListener("mousemove", ce), document.removeEventListener("mouseup", le), document.removeEventListener("mousemove", me), document.removeEventListener("mouseup", he), b && document.removeEventListener("mousemove", b), x && document.removeEventListener("mouseup", x), q &&= (q.remove(), null), y && cancelAnimationFrame(y);
553
+ }), (t, n) => e.imageInfo ? (F(), D("div", {
554
+ key: 0,
555
+ ref_key: "overlayRootRef",
556
+ ref: o,
557
+ class: "image-overlay",
558
+ style: M(T.value),
559
+ onMousedown: n[3] ||= G(() => {}, ["stop"])
560
+ }, [
561
+ n[4] ||= O("div", { class: "image-overlay__border" }, null, -1),
562
+ O("div", {
563
+ class: "image-overlay__body",
564
+ style: M({ cursor: c.value ? "grabbing" : "grab" }),
565
+ onMousedown: n[0] ||= G((e) => _e(e), ["prevent", "stop"]),
566
+ onContextmenu: n[1] ||= G((e) => t.$emit("context-menu", e), ["prevent", "stop"])
567
+ }, null, 36),
568
+ (F(!0), D(C, null, L(oe.value, (e) => (F(), D("div", {
569
+ key: e.pos,
570
+ class: "image-overlay__handle",
571
+ style: M(e.style),
572
+ "data-handle": e.pos,
573
+ onMousedown: G((t) => A(t, e.pos), ["prevent", "stop"])
574
+ }, null, 44, ot))), 128)),
575
+ n[5] ||= O("div", { class: "image-overlay__rotate-line" }, null, -1),
576
+ O("div", {
577
+ class: "image-overlay__rotate-handle",
578
+ style: M({ left: `${ie.value / 2 - 7}px` }),
579
+ title: z(r)("imageOverlay.rotate"),
580
+ onMousedown: n[2] ||= G((e) => K(e), ["prevent", "stop"])
581
+ }, null, 44, st),
582
+ s.value ? (F(), D("div", ct, R(Math.round(u.value)) + " × " + R(Math.round(d.value)), 1)) : E("", !0),
583
+ l.value ? (F(), D("div", lt, R(Math.round(f.value)) + "° ", 1)) : E("", !0)
584
+ ], 36)) : E("", !0);
585
+ }
586
+ }), [["__scopeId", "data-v-a6f20ec2"]]), pt = { class: "doc-outline__header" }, mt = { class: "doc-outline__body" }, ht = {
587
+ key: 0,
588
+ class: "doc-outline__empty"
589
+ }, gt = ["onMousedown"], _t = /* @__PURE__ */ b(/* @__PURE__ */ A({
590
+ __name: "DocumentOutline",
591
+ props: {
592
+ isOpen: { type: Boolean },
593
+ headings: {}
594
+ },
595
+ emits: ["close", "navigate"],
596
+ setup(e) {
597
+ return (t, n) => e.isOpen ? (F(), D("nav", {
598
+ key: 0,
599
+ class: "doc-outline",
600
+ role: "navigation",
601
+ "aria-label": "Document outline",
602
+ onMousedown: n[1] ||= G(() => {}, ["stop"])
603
+ }, [O("div", pt, [O("button", {
604
+ class: "doc-outline__back",
605
+ title: "Close outline",
606
+ "aria-label": "Close outline",
607
+ onClick: n[0] ||= (e) => t.$emit("close")
608
+ }, [k(c, {
609
+ name: "arrow_back",
610
+ size: 20
611
+ })]), n[2] ||= O("span", { class: "doc-outline__title" }, "Document Outline", -1)]), O("div", mt, [e.headings.length === 0 ? (F(), D("div", ht, " No headings found ")) : E("", !0), (F(!0), D(C, null, L(e.headings, (e, n) => (F(), D("button", {
612
+ key: n,
613
+ class: "doc-outline__item",
614
+ style: M({ paddingLeft: 12 + (e.level - 1) * 16 + "px" }),
615
+ onMousedown: G((n) => t.$emit("navigate", e.pmPos), ["prevent"])
616
+ }, R(e.text || "(untitled)"), 45, gt))), 128))])], 32)) : E("", !0);
617
+ }
618
+ }), [["__scopeId", "data-v-cb2cdc39"]]), vt = /* @__PURE__ */ b(/* @__PURE__ */ A({
619
+ __name: "PageIndicator",
620
+ props: {
621
+ currentPage: {},
622
+ totalPages: {},
623
+ visible: { type: Boolean }
624
+ },
625
+ setup(e) {
626
+ let { t } = n();
627
+ return (n, r) => (F(), D("div", {
628
+ class: "docx-editor-vue__page-indicator",
629
+ style: M({ opacity: +!!e.visible }),
630
+ "aria-live": "polite",
631
+ role: "status"
632
+ }, R(z(t)("viewer.pageIndicator", {
633
+ current: e.currentPage,
634
+ total: e.totalPages
635
+ })), 5));
636
+ }
637
+ }), [["__scopeId", "data-v-d117bf6e"]]), yt = { class: "hf-editor__toolbar" }, bt = { class: "hf-editor__label" }, xt = { class: "hf-editor__actions" }, St = /* @__PURE__ */ b(/* @__PURE__ */ A({
638
+ __name: "InlineHeaderFooterEditor",
639
+ props: {
640
+ isOpen: { type: Boolean },
641
+ position: {},
642
+ headerFooter: {},
643
+ styles: {},
644
+ theme: {},
645
+ targetRect: {}
646
+ },
647
+ emits: [
648
+ "save",
649
+ "close",
650
+ "remove"
651
+ ],
652
+ setup(e, { emit: t }) {
653
+ let n = e, r = t, i = I(null), a = null, o = I({});
654
+ function s() {
655
+ let e = n.targetRect;
656
+ e && (o.value = {
657
+ position: "absolute",
658
+ top: `${e.top}px`,
659
+ left: `${e.left}px`,
660
+ width: `${e.width}px`,
661
+ minHeight: `${Math.max(e.height, 60)}px`,
662
+ zIndex: "100"
663
+ });
664
+ }
665
+ V(() => n.isOpen, async (e) => {
666
+ e ? (s(), await j(), c()) : l();
667
+ }), V(() => n.targetRect, () => {
668
+ n.isOpen && s();
669
+ }, { deep: !0 });
670
+ function c() {
671
+ let e = i.value;
672
+ if (!e || a) return;
673
+ let t = je, r = Me(n.headerFooter?.content ?? [], {
674
+ styles: n.styles ?? void 0,
675
+ theme: n.theme ?? null
676
+ });
677
+ a = new Ae(e, {
678
+ state: ye.create({
679
+ doc: r,
680
+ schema: t.getSchema(),
681
+ plugins: t.getPlugins() ?? []
682
+ }),
683
+ editable: () => !0
684
+ }), a.focus();
685
+ }
686
+ function l() {
687
+ a &&= (a.destroy(), null);
688
+ }
689
+ function u() {
690
+ a && (r("save", Ne(a.state.doc)), r("close"));
691
+ }
692
+ return N(() => {
693
+ l();
694
+ }), (t, n) => e.isOpen ? (F(), D("div", {
695
+ key: 0,
696
+ class: "hf-editor",
697
+ style: M(o.value),
698
+ onMousedown: n[2] ||= G(() => {}, ["stop"]),
699
+ onContextmenu: n[3] ||= G(() => {}, ["stop"])
700
+ }, [O("div", yt, [O("span", bt, R(e.position === "header" ? "Header" : "Footer"), 1), O("div", xt, [
701
+ O("button", {
702
+ class: "hf-editor__btn",
703
+ title: "Remove",
704
+ onMousedown: n[0] ||= G((e) => t.$emit("remove"), ["prevent"])
705
+ }, " Remove ", 32),
706
+ O("button", {
707
+ class: "hf-editor__btn hf-editor__btn--primary",
708
+ title: "Save",
709
+ onMousedown: G(u, ["prevent"])
710
+ }, " Save ", 32),
711
+ O("button", {
712
+ class: "hf-editor__btn",
713
+ title: "Cancel",
714
+ onMousedown: n[1] ||= G((e) => t.$emit("close"), ["prevent"])
715
+ }, " Cancel ", 32)
716
+ ])]), O("div", {
717
+ ref_key: "editorRef",
718
+ ref: i,
719
+ class: "hf-editor__content"
720
+ }, null, 512)], 36)) : E("", !0);
721
+ }
722
+ }), [["__scopeId", "data-v-343434c4"]]), Ct = {
723
+ key: 0,
724
+ class: "docx-editor-vue__title-bar"
725
+ }, wt = { class: "docx-editor-vue__title-bar-left" }, Tt = { class: "docx-editor-vue__title-bar-center" }, Et = { class: "docx-editor-vue__title-bar-right" }, Dt = /* @__PURE__ */ A({
726
+ __name: "DocxEditorMenuBar",
727
+ props: {
728
+ showMenuBar: { type: Boolean },
729
+ documentName: {},
730
+ documentNameEditable: {
731
+ type: Boolean,
732
+ default: !0
733
+ },
734
+ renderLogo: {},
735
+ renderTitleBarRight: {}
736
+ },
737
+ emits: [
738
+ "rename",
739
+ "menu-action",
740
+ "insert-table"
741
+ ],
742
+ setup(e, { emit: t }) {
743
+ let n = t;
744
+ return (t, r) => e.showMenuBar ? (F(), D("div", Ct, [
745
+ O("div", wt, [e.renderLogo ? (F(), T(de(e.renderLogo), { key: 0 })) : E("", !0), ue(t.$slots, "title-bar-left")]),
746
+ O("div", Tt, [k(g, {
747
+ "model-value": e.documentName,
748
+ editable: e.documentNameEditable,
749
+ "onUpdate:modelValue": r[0] ||= (e) => n("rename", e)
750
+ }, null, 8, ["model-value", "editable"]), k(v, {
751
+ onAction: r[1] ||= (e) => n("menu-action", e),
752
+ onInsertTable: r[2] ||= (e, t) => n("insert-table", e, t)
753
+ })]),
754
+ O("div", Et, [ue(t.$slots, "title-bar-right"), e.renderTitleBarRight ? (F(), T(de(e.renderTitleBarRight), { key: 0 })) : E("", !0)])
755
+ ])) : E("", !0);
756
+ }
757
+ }), Ot = /* @__PURE__ */ A({
758
+ __name: "DocxEditorDialogs",
759
+ props: {
760
+ view: {},
761
+ bookmarks: {},
762
+ selectedImagePmPos: {},
763
+ sectionProperties: {},
764
+ showFindReplace: { type: Boolean },
765
+ showInsertImage: { type: Boolean },
766
+ showHyperlink: { type: Boolean },
767
+ showInsertSymbol: { type: Boolean },
768
+ showImageProperties: { type: Boolean },
769
+ showPageSetup: { type: Boolean },
770
+ showKeyboardShortcuts: { type: Boolean }
771
+ },
772
+ emits: [
773
+ "update:showFindReplace",
774
+ "update:showInsertImage",
775
+ "update:showHyperlink",
776
+ "update:showInsertSymbol",
777
+ "update:showImageProperties",
778
+ "update:showPageSetup",
779
+ "update:showKeyboardShortcuts",
780
+ "insert-image",
781
+ "insert-symbol",
782
+ "hyperlink-submit",
783
+ "hyperlink-remove",
784
+ "page-setup-apply"
785
+ ],
786
+ setup(t, { emit: n }) {
787
+ let r = n;
788
+ return (n, a) => (F(), D(C, null, [
789
+ k(u, {
790
+ "is-open": t.showFindReplace,
791
+ view: t.view,
792
+ onClose: a[0] ||= (e) => r("update:showFindReplace", !1)
793
+ }, null, 8, ["is-open", "view"]),
794
+ k(s, {
795
+ "is-open": t.showInsertImage,
796
+ onClose: a[1] ||= (e) => r("update:showInsertImage", !1),
797
+ onInsert: a[2] ||= (e) => r("insert-image", e)
798
+ }, null, 8, ["is-open"]),
799
+ k(e, {
800
+ "is-open": t.showHyperlink,
801
+ view: t.view,
802
+ bookmarks: t.bookmarks,
803
+ onClose: a[3] ||= (e) => r("update:showHyperlink", !1),
804
+ onSubmit: a[4] ||= (e) => r("hyperlink-submit", e),
805
+ onRemove: a[5] ||= (e) => r("hyperlink-remove")
806
+ }, null, 8, [
807
+ "is-open",
808
+ "view",
809
+ "bookmarks"
810
+ ]),
811
+ k(i, {
812
+ "is-open": t.showInsertSymbol,
813
+ onClose: a[6] ||= (e) => r("update:showInsertSymbol", !1),
814
+ onInsert: a[7] ||= (e) => r("insert-symbol", e)
815
+ }, null, 8, ["is-open"]),
816
+ k(l, {
817
+ "is-open": t.showImageProperties,
818
+ view: t.view,
819
+ "pm-pos": t.selectedImagePmPos,
820
+ onClose: a[8] ||= (e) => r("update:showImageProperties", !1)
821
+ }, null, 8, [
822
+ "is-open",
823
+ "view",
824
+ "pm-pos"
825
+ ]),
826
+ k(o, {
827
+ "is-open": t.showPageSetup,
828
+ "section-properties": t.sectionProperties,
829
+ onClose: a[9] ||= (e) => r("update:showPageSetup", !1),
830
+ onApply: a[10] ||= (e) => r("page-setup-apply", e)
831
+ }, null, 8, ["is-open", "section-properties"]),
832
+ k(d, {
833
+ "is-open": t.showKeyboardShortcuts,
834
+ onClose: a[11] ||= (e) => r("update:showKeyboardShortcuts", !1)
835
+ }, null, 8, ["is-open"])
836
+ ], 64));
837
+ }
838
+ }), kt = ["disabled", "onMousedown"], At = { class: "ctx-menu__label" }, jt = {
839
+ key: 0,
840
+ class: "ctx-menu__shortcut"
841
+ }, Mt = 220, Nt = 32, Pt = 10, Ft = /* @__PURE__ */ b(/* @__PURE__ */ A({
842
+ __name: "TextContextMenu",
843
+ props: {
844
+ isOpen: { type: Boolean },
845
+ position: {},
846
+ hasSelection: { type: Boolean },
847
+ isEditable: { type: Boolean },
848
+ inTable: { type: Boolean },
849
+ onImage: { type: Boolean },
850
+ canMergeCells: { type: Boolean },
851
+ canSplitCell: { type: Boolean }
852
+ },
853
+ emits: ["close", "action"],
854
+ setup(e, { emit: t }) {
855
+ let n = e, r = t, i = I(null), a = w(() => {
856
+ let e = [
857
+ {
858
+ id: "cut",
859
+ label: "Cut",
860
+ action: "cut",
861
+ shortcut: "Ctrl+X",
862
+ disabled: !n.hasSelection || !n.isEditable
863
+ },
864
+ {
865
+ id: "copy",
866
+ label: "Copy",
867
+ action: "copy",
868
+ shortcut: "Ctrl+C",
869
+ disabled: !n.hasSelection
870
+ },
871
+ {
872
+ id: "paste",
873
+ label: "Paste",
874
+ action: "paste",
875
+ shortcut: "Ctrl+V",
876
+ disabled: !n.isEditable
877
+ },
878
+ {
879
+ id: "pasteAsPlainText",
880
+ label: "Paste as Plain Text",
881
+ action: "pasteAsPlainText",
882
+ shortcut: "Ctrl+Shift+V",
883
+ disabled: !n.isEditable
884
+ },
885
+ {
886
+ id: "div1",
887
+ label: "",
888
+ action: "",
889
+ divider: !0
890
+ },
891
+ {
892
+ id: "delete",
893
+ label: "Delete",
894
+ action: "delete",
895
+ shortcut: "Del",
896
+ disabled: !n.hasSelection || !n.isEditable
897
+ },
898
+ {
899
+ id: "selectAll",
900
+ label: "Select All",
901
+ action: "selectAll",
902
+ shortcut: "Ctrl+A"
903
+ }
904
+ ];
905
+ return n.onImage && n.isEditable && e.push({
906
+ id: "div-img",
907
+ label: "",
908
+ action: "",
909
+ divider: !0
910
+ }, {
911
+ id: "replaceImage",
912
+ label: "Replace image…",
913
+ action: "replaceImage"
914
+ }, {
915
+ id: "imageProperties",
916
+ label: "Image properties…",
917
+ action: "imageProperties"
918
+ }, {
919
+ id: "deleteImage",
920
+ label: "Delete image",
921
+ action: "deleteImage",
922
+ shortcut: "Del"
923
+ }), n.inTable && n.isEditable && e.push({
924
+ id: "div2",
925
+ label: "",
926
+ action: "",
927
+ divider: !0
928
+ }, {
929
+ id: "addRowAbove",
930
+ label: "Insert row above",
931
+ action: "addRowAbove"
932
+ }, {
933
+ id: "addRowBelow",
934
+ label: "Insert row below",
935
+ action: "addRowBelow"
936
+ }, {
937
+ id: "deleteRow",
938
+ label: "Delete row",
939
+ action: "deleteRow"
940
+ }, {
941
+ id: "div3",
942
+ label: "",
943
+ action: "",
944
+ divider: !0
945
+ }, {
946
+ id: "addColLeft",
947
+ label: "Insert column left",
948
+ action: "addColumnLeft"
949
+ }, {
950
+ id: "addColRight",
951
+ label: "Insert column right",
952
+ action: "addColumnRight"
953
+ }, {
954
+ id: "deleteCol",
955
+ label: "Delete column",
956
+ action: "deleteColumn"
957
+ }, {
958
+ id: "div4",
959
+ label: "",
960
+ action: "",
961
+ divider: !0
962
+ }, {
963
+ id: "mergeCells",
964
+ label: "Merge cells",
965
+ action: "mergeCells",
966
+ disabled: !n.canMergeCells
967
+ }, {
968
+ id: "splitCell",
969
+ label: "Split cell",
970
+ action: "splitCell",
971
+ disabled: !n.canSplitCell
972
+ }), e;
973
+ }), o = w(() => {
974
+ let e = n.position.x, t = n.position.y, r = a.value.filter((e) => !e.divider).length, i = a.value.filter((e) => e.divider).length, o = r * Nt + i * 9;
975
+ return typeof window < "u" && (e + Mt + Pt > window.innerWidth && (e = window.innerWidth - Mt - Pt), t + o + Pt > window.innerHeight && (t = window.innerHeight - o - Pt)), {
976
+ position: "fixed",
977
+ left: `${e}px`,
978
+ top: `${t}px`,
979
+ zIndex: 400
980
+ };
981
+ });
982
+ function s(e) {
983
+ e && (r("action", e), r("close"));
984
+ }
985
+ function c(e) {
986
+ e.key === "Escape" && r("close");
987
+ }
988
+ return V(() => n.isOpen, (e) => {
989
+ e && j(() => i.value?.focus());
990
+ }), (t, n) => (F(), T(ie, { to: "body" }, [e.isOpen ? (F(), D("div", {
991
+ key: 0,
992
+ class: "ctx-menu-backdrop",
993
+ onMousedown: n[0] ||= (e) => t.$emit("close"),
994
+ onContextmenu: n[1] ||= G((e) => t.$emit("close"), ["prevent"])
995
+ }, null, 32)) : E("", !0), e.isOpen ? (F(), D("div", {
996
+ key: 1,
997
+ ref_key: "menuRef",
998
+ ref: i,
999
+ class: "ctx-menu",
1000
+ style: M(o.value),
1001
+ onContextmenu: n[2] ||= G(() => {}, ["prevent"]),
1002
+ onKeydown: c
1003
+ }, [(F(!0), D(C, null, L(a.value, (e, t) => (F(), D("button", {
1004
+ key: e.id || t,
1005
+ class: le(["ctx-menu__item", {
1006
+ "ctx-menu__item--disabled": e.disabled,
1007
+ "ctx-menu__item--divider": e.divider
1008
+ }]),
1009
+ disabled: e.disabled,
1010
+ onMousedown: G((t) => s(e.action), ["prevent"])
1011
+ }, [O("span", At, R(e.label), 1), e.shortcut ? (F(), D("span", jt, R(e.shortcut), 1)) : E("", !0)], 42, kt))), 128))], 36)) : E("", !0)]));
1012
+ }
1013
+ }), [["__scopeId", "data-v-741c4f71"]]), It = ["aria-label"], Lt = { class: "image-ctx-menu__icon" }, Rt = { class: "image-ctx-menu__label" }, zt = {
1014
+ key: 1,
1015
+ class: "image-ctx-menu__divider",
1016
+ role: "separator"
1017
+ }, Bt = [
1018
+ "data-wrap-type",
1019
+ "data-current",
1020
+ "data-disabled",
1021
+ "disabled",
1022
+ "title",
1023
+ "onClick"
1024
+ ], Vt = { class: "image-ctx-menu__icon" }, Ht = { class: "image-ctx-menu__label" }, Ut = ["aria-label"], Wt = ["disabled", "onClick"], Gt = { class: "image-ctx-menu__label" }, Kt = {
1025
+ key: 0,
1026
+ class: "image-ctx-menu__shortcut"
1027
+ }, qt = {
1028
+ key: 0,
1029
+ class: "image-ctx-menu__divider",
1030
+ role: "separator"
1031
+ }, Jt = 18, Yt = 260, Q = 10, Xt = /* @__PURE__ */ b(/* @__PURE__ */ A({
1032
+ __name: "ImageContextMenu",
1033
+ props: {
1034
+ state: {},
1035
+ textActions: {},
1036
+ canOpenProperties: {
1037
+ type: Boolean,
1038
+ default: !1
1039
+ }
1040
+ },
1041
+ emits: [
1042
+ "close",
1043
+ "select",
1044
+ "text-action",
1045
+ "open-properties"
1046
+ ],
1047
+ setup(e, { emit: t }) {
1048
+ let r = e, i = t;
1049
+ function a() {
1050
+ i("open-properties"), i("close");
1051
+ }
1052
+ let { t: o } = n(), s = I(null), l = Te, u = w(() => r.state ? J(r.state.currentWrapType, r.state.currentCssFloat ?? null) : null), d = {
1053
+ inline: "wrap_text",
1054
+ squareLeft: "format_image_left",
1055
+ squareRight: "format_image_right",
1056
+ behind: "flip_to_back",
1057
+ inFront: "flip_to_front"
1058
+ };
1059
+ function f(e) {
1060
+ return d[e];
1061
+ }
1062
+ let p = w(() => {
1063
+ if (!r.state) return {};
1064
+ let e = Te.length * 36 + 16, t = r.state.position.x, n = r.state.position.y;
1065
+ return typeof window < "u" && (t + Yt > window.innerWidth && (t = window.innerWidth - Yt - Q), n + e > window.innerHeight && (n = window.innerHeight - e - Q), t < Q && (t = Q), n < Q && (n = Q)), {
1066
+ position: "fixed",
1067
+ left: `${t}px`,
1068
+ top: `${n}px`,
1069
+ minWidth: `${Yt}px`,
1070
+ zIndex: 400
1071
+ };
1072
+ });
1073
+ function m(e) {
1074
+ return r.state ? Oe(e, r.state.currentWrapType) : !1;
1075
+ }
1076
+ function h(e) {
1077
+ m(e) && (i("select", e.choice), i("close"));
1078
+ }
1079
+ function g(e) {
1080
+ e.disabled || (i("text-action", e.action), i("close"));
1081
+ }
1082
+ function _(e) {
1083
+ e.preventDefault(), i("close");
1084
+ }
1085
+ function ee(e) {
1086
+ e.key === "Escape" && (e.preventDefault(), i("close"));
1087
+ }
1088
+ return (t, n) => (F(), T(ie, { to: "body" }, [e.state && e.state.open ? (F(), D("div", {
1089
+ key: 0,
1090
+ class: "image-ctx-menu-backdrop",
1091
+ onMousedown: _,
1092
+ onContextmenu: n[0] ||= G((e) => t.$emit("close"), ["prevent"])
1093
+ }, null, 32)) : E("", !0), e.state && e.state.open ? (F(), D("div", {
1094
+ key: 1,
1095
+ ref_key: "menuRef",
1096
+ ref: s,
1097
+ class: "image-ctx-menu",
1098
+ role: "menu",
1099
+ "aria-label": z(o)("imageWrap.menu.ariaLabel"),
1100
+ "data-testid": "image-context-menu",
1101
+ style: M(p.value),
1102
+ onContextmenu: n[4] ||= G(() => {}, ["prevent"]),
1103
+ onKeydown: ee
1104
+ }, [
1105
+ e.canOpenProperties ? (F(), D("button", {
1106
+ key: 0,
1107
+ type: "button",
1108
+ role: "menuitem",
1109
+ class: "image-ctx-menu__item",
1110
+ "data-action": "open-properties",
1111
+ onMousedown: n[1] ||= G(() => {}, ["prevent"]),
1112
+ onClick: a
1113
+ }, [O("span", Lt, [k(c, {
1114
+ name: "settings",
1115
+ size: Jt
1116
+ })]), O("span", Rt, R(z(o)("imageWrap.menu.imageProperties")), 1)], 32)) : E("", !0),
1117
+ e.canOpenProperties ? (F(), D("div", zt)) : E("", !0),
1118
+ (F(!0), D(C, null, L(z(l), (e) => (F(), D("button", {
1119
+ key: e.choice,
1120
+ type: "button",
1121
+ role: "menuitem",
1122
+ class: le(["image-ctx-menu__item", { "image-ctx-menu__item--current": e.choice === u.value }]),
1123
+ "data-wrap-type": e.choice,
1124
+ "data-current": e.choice === u.value ? "true" : "false",
1125
+ "data-disabled": m(e) ? "false" : "true",
1126
+ disabled: !m(e),
1127
+ title: z(o)(`imageWrap.menuDesc.${e.i18nDescKey}`),
1128
+ onMousedown: n[2] ||= G(() => {}, ["prevent"]),
1129
+ onClick: (t) => h(e)
1130
+ }, [
1131
+ O("span", Vt, [k(c, {
1132
+ name: f(e.iconHint),
1133
+ size: Jt
1134
+ }, null, 8, ["name"])]),
1135
+ O("span", Ht, R(z(o)(`imageWrap.menu.${e.i18nLabelKey}`)), 1),
1136
+ e.choice === u.value ? (F(), D("span", {
1137
+ key: 0,
1138
+ class: "image-ctx-menu__current-dot",
1139
+ "aria-label": z(o)("imageWrap.menu.ariaLabel")
1140
+ }, "●", 8, Ut)) : E("", !0)
1141
+ ], 42, Bt))), 128)),
1142
+ e.textActions && e.textActions.length > 0 ? (F(), D(C, { key: 2 }, [n[5] ||= O("div", {
1143
+ class: "image-ctx-menu__divider",
1144
+ role: "separator"
1145
+ }, null, -1), (F(!0), D(C, null, L(e.textActions, (e, t) => (F(), D(C, { key: `${e.action}-${t}` }, [O("button", {
1146
+ type: "button",
1147
+ role: "menuitem",
1148
+ class: "image-ctx-menu__item image-ctx-menu__item--text",
1149
+ disabled: e.disabled,
1150
+ onMousedown: n[3] ||= G(() => {}, ["prevent"]),
1151
+ onClick: (t) => g(e)
1152
+ }, [O("span", Gt, R(e.label), 1), e.shortcut ? (F(), D("span", Kt, R(e.shortcut), 1)) : E("", !0)], 40, Wt), e.dividerAfter ? (F(), D("div", qt)) : E("", !0)], 64))), 128))], 64)) : E("", !0)
1153
+ ], 44, It)) : E("", !0)]));
1154
+ }
1155
+ }), [["__scopeId", "data-v-5c21ca8c"]]), Zt = /* @__PURE__ */ A({
1156
+ __name: "DocxEditorOverlays",
1157
+ props: {
1158
+ readOnly: { type: Boolean },
1159
+ contextMenu: {},
1160
+ imageContextMenu: {},
1161
+ imageContextMenuTextActions: {},
1162
+ canOpenImageProperties: { type: Boolean }
1163
+ },
1164
+ emits: [
1165
+ "context-menu-action",
1166
+ "close-context-menu",
1167
+ "image-wrap-select",
1168
+ "close-image-context-menu",
1169
+ "open-image-properties"
1170
+ ],
1171
+ setup(e, { emit: t }) {
1172
+ let n = t;
1173
+ return (t, r) => (F(), D(C, null, [k(Ft, {
1174
+ "is-open": e.contextMenu.isOpen,
1175
+ position: e.contextMenu.position,
1176
+ "has-selection": e.contextMenu.hasSelection,
1177
+ "is-editable": !e.readOnly,
1178
+ "in-table": e.contextMenu.inTable,
1179
+ "on-image": e.contextMenu.onImage,
1180
+ "can-merge-cells": e.contextMenu.canMergeCells,
1181
+ "can-split-cell": e.contextMenu.canSplitCell,
1182
+ onAction: r[0] ||= (e) => n("context-menu-action", e),
1183
+ onClose: r[1] ||= (e) => n("close-context-menu")
1184
+ }, null, 8, [
1185
+ "is-open",
1186
+ "position",
1187
+ "has-selection",
1188
+ "is-editable",
1189
+ "in-table",
1190
+ "on-image",
1191
+ "can-merge-cells",
1192
+ "can-split-cell"
1193
+ ]), k(Xt, {
1194
+ state: e.imageContextMenu,
1195
+ "text-actions": e.imageContextMenuTextActions,
1196
+ "can-open-properties": e.canOpenImageProperties,
1197
+ onClose: r[2] ||= (e) => n("close-image-context-menu"),
1198
+ onSelect: r[3] ||= (e) => n("image-wrap-select", e),
1199
+ onTextAction: r[4] ||= (e) => n("context-menu-action", e),
1200
+ onOpenProperties: r[5] ||= (e) => n("open-image-properties")
1201
+ }, null, 8, [
1202
+ "state",
1203
+ "text-actions",
1204
+ "can-open-properties"
1205
+ ])], 64));
1206
+ }
1207
+ }), Qt = ["href", "title"], $t = ["title"], en = ["title"], tn = ["title"], nn = { class: "docx-hyperlink-popup__edit-row" }, rn = ["placeholder", "onKeydown"], an = { class: "docx-hyperlink-popup__edit-row" }, $ = ["onKeydown"], on = ["disabled"], sn = /* @__PURE__ */ b(/* @__PURE__ */ A({
1208
+ __name: "HyperlinkPopup",
1209
+ props: {
1210
+ data: {},
1211
+ readOnly: { type: Boolean }
1212
+ },
1213
+ emits: [
1214
+ "navigate",
1215
+ "copy",
1216
+ "edit",
1217
+ "remove",
1218
+ "close"
1219
+ ],
1220
+ setup(e, { emit: t }) {
1221
+ let { t: r } = n(), i = e, a = t, o = I(!1), s = I(""), c = I(""), l = I(null), u = w(() => ({
1222
+ left: (i.data?.position.left ?? 0) + "px",
1223
+ top: (i.data?.position.top ?? 0) + "px"
1224
+ }));
1225
+ V(() => i.data?.href, () => {
1226
+ o.value = !1;
1227
+ });
1228
+ let d = null, f = null;
1229
+ function p() {
1230
+ f &&= (clearTimeout(f), null), d &&= (document.removeEventListener("mousedown", d), null);
1231
+ }
1232
+ V(() => i.data, (e) => {
1233
+ p(), e && (d = (e) => {
1234
+ let t = l.value;
1235
+ t && !t.contains(e.target) && a("close");
1236
+ }, f = setTimeout(() => {
1237
+ d && document.addEventListener("mousedown", d);
1238
+ }, 0));
1239
+ }, { immediate: !0 }), N(p);
1240
+ function m() {
1241
+ i.data && (s.value = i.data.displayText, c.value = i.data.href, o.value = !0);
1242
+ }
1243
+ function h() {
1244
+ c.value.trim() && (a("edit", s.value, c.value), o.value = !1);
1245
+ }
1246
+ function g() {
1247
+ i.data && (a("copy", i.data.href), typeof navigator < "u" && navigator.clipboard && navigator.clipboard.writeText(i.data.href).catch(() => {}));
1248
+ }
1249
+ return (t, n) => e.data ? (F(), D("div", {
1250
+ key: 0,
1251
+ ref_key: "popupRef",
1252
+ ref: l,
1253
+ class: le(["docx-hyperlink-popup", { "docx-hyperlink-popup--edit": o.value }]),
1254
+ style: M(u.value),
1255
+ onMousedown: n[6] ||= G(() => {}, ["stop"])
1256
+ }, [o.value ? (F(), D(C, { key: 1 }, [O("div", nn, [U(O("input", {
1257
+ class: "docx-hyperlink-popup__input",
1258
+ placeholder: z(r)("hyperlinkPopup.displayTextPlaceholder"),
1259
+ "onUpdate:modelValue": n[2] ||= (e) => s.value = e,
1260
+ onKeydown: [W(G(h, ["prevent"]), ["enter"]), n[3] ||= W((e) => t.$emit("close"), ["esc"])]
1261
+ }, null, 40, rn), [[B, s.value]])]), O("div", an, [U(O("input", {
1262
+ class: "docx-hyperlink-popup__input",
1263
+ placeholder: "https://...",
1264
+ "onUpdate:modelValue": n[4] ||= (e) => c.value = e,
1265
+ onKeydown: [W(G(h, ["prevent"]), ["enter"]), n[5] ||= W((e) => t.$emit("close"), ["esc"])]
1266
+ }, null, 40, $), [[B, c.value]]), O("button", {
1267
+ class: "docx-hyperlink-popup__apply",
1268
+ disabled: !c.value.trim(),
1269
+ onClick: G(h, ["prevent"])
1270
+ }, R(z(r)("common.apply")), 9, on)])], 64)) : (F(), D(C, { key: 0 }, [
1271
+ n[10] ||= se("<span class=\"docx-hyperlink-popup__icon\" aria-hidden data-v-9d23bb12><svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" data-v-9d23bb12><circle cx=\"12\" cy=\"12\" r=\"10\" data-v-9d23bb12></circle><path d=\"M2 12h20\" data-v-9d23bb12></path><path d=\"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z\" data-v-9d23bb12></path></svg></span>", 1),
1272
+ O("a", {
1273
+ class: "docx-hyperlink-popup__url",
1274
+ href: e.data.href,
1275
+ title: e.data.href,
1276
+ onClick: n[0] ||= G((n) => t.$emit("navigate", e.data.href), ["prevent"])
1277
+ }, R(e.data.href), 9, Qt),
1278
+ n[11] ||= O("span", { class: "docx-hyperlink-popup__sep" }, null, -1),
1279
+ O("button", {
1280
+ class: "docx-hyperlink-popup__btn",
1281
+ title: z(r)("hyperlinkPopup.copyLink"),
1282
+ onClick: G(g, ["prevent"])
1283
+ }, [...n[7] ||= [O("svg", {
1284
+ width: "18",
1285
+ height: "18",
1286
+ viewBox: "0 0 24 24",
1287
+ fill: "none",
1288
+ stroke: "currentColor",
1289
+ "stroke-width": "2",
1290
+ "stroke-linecap": "round",
1291
+ "stroke-linejoin": "round"
1292
+ }, [O("rect", {
1293
+ x: "9",
1294
+ y: "9",
1295
+ width: "13",
1296
+ height: "13",
1297
+ rx: "2",
1298
+ ry: "2"
1299
+ }), O("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })], -1)]], 8, $t),
1300
+ e.readOnly ? E("", !0) : (F(), D("button", {
1301
+ key: 0,
1302
+ class: "docx-hyperlink-popup__btn",
1303
+ title: z(r)("hyperlinkPopup.editLink"),
1304
+ onClick: G(m, ["prevent"])
1305
+ }, [...n[8] ||= [O("svg", {
1306
+ width: "18",
1307
+ height: "18",
1308
+ viewBox: "0 0 24 24",
1309
+ fill: "none",
1310
+ stroke: "currentColor",
1311
+ "stroke-width": "2",
1312
+ "stroke-linecap": "round",
1313
+ "stroke-linejoin": "round"
1314
+ }, [O("path", { d: "M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" }), O("path", { d: "M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" })], -1)]], 8, en)),
1315
+ e.readOnly ? E("", !0) : (F(), D("button", {
1316
+ key: 1,
1317
+ class: "docx-hyperlink-popup__btn",
1318
+ title: z(r)("hyperlinkPopup.removeLink"),
1319
+ onClick: n[1] ||= G((e) => t.$emit("remove"), ["prevent"])
1320
+ }, [...n[9] ||= [se("<svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" data-v-9d23bb12><path d=\"M18.84 12.25l1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71\" data-v-9d23bb12></path><path d=\"M5.17 11.75l-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71\" data-v-9d23bb12></path><line x1=\"8\" y1=\"2\" x2=\"8\" y2=\"5\" data-v-9d23bb12></line><line x1=\"2\" y1=\"8\" x2=\"5\" y2=\"8\" data-v-9d23bb12></line><line x1=\"16\" y1=\"19\" x2=\"16\" y2=\"22\" data-v-9d23bb12></line><line x1=\"19\" y1=\"16\" x2=\"22\" y2=\"16\" data-v-9d23bb12></line></svg>", 1)]], 8, tn))
1321
+ ], 64))], 38)) : E("", !0);
1322
+ }
1323
+ }), [["__scopeId", "data-v-9d23bb12"]]);
1324
+ //#endregion
1325
+ //#region src/composables/useFileIO.ts
1326
+ function cn(e) {
1327
+ let t = I(null);
1328
+ async function n() {
1329
+ await e.nextTick(), e.extractCommentsAndChanges(), e.emit("ready");
1330
+ }
1331
+ async function r(t) {
1332
+ try {
1333
+ let r = await q(t);
1334
+ if (!r) return;
1335
+ await e.loadBuffer(r.buffer), e.emit("update:document", e.getDocument()), e.emit("rename", r.name), await n();
1336
+ } catch (t) {
1337
+ e.emit("error", t instanceof Error ? t : /* @__PURE__ */ Error("Failed to open document"));
1338
+ }
1339
+ }
1340
+ function i(t) {
1341
+ e.onDocumentNameChange?.(t), e.emit("rename", t);
1342
+ }
1343
+ async function a() {
1344
+ let t = await e.saveBlob();
1345
+ if (!t) return;
1346
+ let n = (e.documentName() ?? "").trim() || "document", r = URL.createObjectURL(t), i = window.document.createElement("a");
1347
+ i.href = r, i.download = `${n.replace(/\.docx$/i, "")}.docx`, i.click(), setTimeout(() => URL.revokeObjectURL(r), 0);
1348
+ }
1349
+ async function o(t) {
1350
+ await e.loadBuffer(t), e.emit("update:document", e.getDocument()), await n();
1351
+ }
1352
+ function s(t) {
1353
+ e.loadParsedDocument(t), e.emit("update:document", t), n();
1354
+ }
1355
+ async function c() {
1356
+ let t = await e.saveBlob();
1357
+ return t ? t.arrayBuffer() : null;
1358
+ }
1359
+ return {
1360
+ docxInputRef: t,
1361
+ handleDocxFileChange: r,
1362
+ handleDocumentNameChange: i,
1363
+ downloadCurrentDocument: a,
1364
+ emitReadyAfterSidebarStateRefresh: n,
1365
+ loadDocumentBuffer: o,
1366
+ loadDocument: s,
1367
+ save: c
1368
+ };
1369
+ }
1370
+ //#endregion
1371
+ //#region src/composables/useHyperlinkManagement.ts
1372
+ function ln(e) {
1373
+ let t = I(null);
1374
+ function n(t) {
1375
+ let n = e.editorView.value;
1376
+ if (!n) return;
1377
+ let r = e.getCommands(), { empty: i } = n.state.selection, a = t.bookmark ? `#${t.bookmark}` : t.url;
1378
+ if (a) {
1379
+ if (i && t.displayText) {
1380
+ let e = r.insertHyperlink;
1381
+ e && e(t.displayText, a, t.tooltip || void 0)(n.state, (e) => n.dispatch(e), n);
1382
+ } else {
1383
+ let e = r.setHyperlink;
1384
+ e && e(a, t.tooltip || void 0)(n.state, (e) => n.dispatch(e), n);
1385
+ }
1386
+ n.focus();
1387
+ }
1388
+ }
1389
+ function r() {
1390
+ let t = e.editorView.value;
1391
+ if (!t) return;
1392
+ let n = e.getCommands().removeHyperlink;
1393
+ n && n()(t.state, (e) => t.dispatch(e), t), t.focus();
1394
+ }
1395
+ function i(e) {
1396
+ window.open(e, "_blank", "noopener,noreferrer"), t.value = null;
1397
+ }
1398
+ function a(n, r) {
1399
+ let i = e.editorView.value;
1400
+ if (!i) return;
1401
+ let a = K(i.state);
1402
+ if (!a) {
1403
+ t.value = null;
1404
+ return;
1405
+ }
1406
+ let o = i.state.schema.marks.hyperlink, { $from: s } = i.state.selection, c = o.create({
1407
+ href: r,
1408
+ tooltip: a.mark.attrs.tooltip
1409
+ }), l = s.marks().filter((e) => e.type !== o), u = i.state.schema.text(n, [...l, c]), d = i.state.tr.replaceWith(a.start, a.end, u);
1410
+ i.dispatch(d.scrollIntoView()), t.value = null, i.focus();
1411
+ }
1412
+ function o() {
1413
+ let n = e.editorView.value;
1414
+ if (!n) return;
1415
+ let r = K(n.state, t.value?.href);
1416
+ if (!r) {
1417
+ t.value = null;
1418
+ return;
1419
+ }
1420
+ let i = n.state.schema.marks.hyperlink, a = n.state.tr.removeMark(r.start, r.end, i);
1421
+ n.dispatch(a.scrollIntoView()), t.value = null, n.focus();
1422
+ }
1423
+ return {
1424
+ hyperlinkPopupData: t,
1425
+ handleHyperlinkSubmit: n,
1426
+ handleHyperlinkRemove: r,
1427
+ handleHyperlinkPopupNavigate: i,
1428
+ handleHyperlinkPopupEdit: a,
1429
+ handleHyperlinkPopupRemove: o
1430
+ };
1431
+ }
1432
+ //#endregion
1433
+ //#region src/composables/useFormattingActions.ts
1434
+ function un(e) {
1435
+ function t() {
1436
+ let t = e.editorView.value;
1437
+ t && (pe(t.state, t.dispatch, t), t.focus());
1438
+ }
1439
+ function n(t) {
1440
+ let n = e.editorView.value;
1441
+ if (!n) return;
1442
+ let r = e.getDocument()?.package?.styles;
1443
+ if (r) {
1444
+ let e = Ve(r).resolveParagraphStyle(t);
1445
+ Z(t, {
1446
+ paragraphFormatting: e.paragraphFormatting,
1447
+ runFormatting: e.runFormatting
1448
+ })(n.state, (e) => n.dispatch(e));
1449
+ } else Z(t)(n.state, (e) => n.dispatch(e));
1450
+ n.focus();
1451
+ }
1452
+ function r() {
1453
+ let t = e.editorView.value;
1454
+ t && (He(t.state, (e) => t.dispatch(e), t), t.focus());
1455
+ }
1456
+ function i(t) {
1457
+ let n = e.editorView.value;
1458
+ if (!n) return;
1459
+ let { from: r } = n.state.selection, i = n.state.tr.insertText(t, r);
1460
+ n.dispatch(i.scrollIntoView()), n.focus();
1461
+ }
1462
+ function a(t) {
1463
+ let n = e.editorView.value;
1464
+ if (!n) return !1;
1465
+ let r = Qe(n.state.doc, t.paraId);
1466
+ if (!r) return !1;
1467
+ let i = r.from + 1, a = r.to - 1;
1468
+ if (t.search) {
1469
+ let e = tt(n.state.doc, r.from, r.to, t.search);
1470
+ if (!e) return !1;
1471
+ i = e.from, a = e.to;
1472
+ }
1473
+ if (i >= a) return !0;
1474
+ let { schema: o } = n.state, s = t.marks, c = n.state.tr;
1475
+ if (s.bold !== void 0 && o.marks.bold && (c = s.bold ? c.addMark(i, a, o.marks.bold.create()) : c.removeMark(i, a, o.marks.bold)), s.italic !== void 0 && o.marks.italic && (c = s.italic ? c.addMark(i, a, o.marks.italic.create()) : c.removeMark(i, a, o.marks.italic)), s.underline !== void 0 && o.marks.underline) if (s.underline) {
1476
+ let e = typeof s.underline == "object" ? s.underline.style : void 0;
1477
+ c = c.addMark(i, a, o.marks.underline.create({ style: e ?? "single" }));
1478
+ } else c = c.removeMark(i, a, o.marks.underline);
1479
+ return s.strike !== void 0 && o.marks.strike && (c = s.strike ? c.addMark(i, a, o.marks.strike.create()) : c.removeMark(i, a, o.marks.strike)), s.color !== void 0 && o.marks.textColor && (c = s.color && (s.color.rgb || s.color.themeColor) ? c.addMark(i, a, o.marks.textColor.create({
1480
+ rgb: s.color.rgb ?? null,
1481
+ themeColor: s.color.themeColor ?? null
1482
+ })) : c.removeMark(i, a, o.marks.textColor)), s.highlight !== void 0 && o.marks.highlight && (c = s.highlight ? c.addMark(i, a, o.marks.highlight.create({ color: Ue(s.highlight) || s.highlight })) : c.removeMark(i, a, o.marks.highlight)), s.fontSize !== void 0 && o.marks.fontSize && (c = s.fontSize > 0 ? c.addMark(i, a, o.marks.fontSize.create({ size: Pe(s.fontSize) })) : c.removeMark(i, a, o.marks.fontSize)), s.fontFamily !== void 0 && o.marks.fontFamily && (c = s.fontFamily && (s.fontFamily.ascii || s.fontFamily.hAnsi) ? c.addMark(i, a, o.marks.fontFamily.create({
1483
+ ascii: s.fontFamily.ascii ?? null,
1484
+ hAnsi: s.fontFamily.hAnsi ?? s.fontFamily.ascii ?? null
1485
+ })) : c.removeMark(i, a, o.marks.fontFamily)), n.dispatch(c), !0;
1486
+ }
1487
+ function o(t) {
1488
+ let n = e.editorView.value;
1489
+ if (!n) return !1;
1490
+ let r = Qe(n.state.doc, t.paraId);
1491
+ if (!r) return !1;
1492
+ let i = e.getDocument(), a = i?.package?.styles ? Ve(i.package.styles) : null;
1493
+ if (a && !a.hasParagraphStyle(t.styleId)) return !1;
1494
+ let o = n.state.doc.resolve(r.from + 1), s = n.state.doc.resolve(r.to - 1), c = n.state.apply(n.state.tr.setSelection(xe.between(o, s))), l = a ? (() => {
1495
+ let e = a.resolveParagraphStyle(t.styleId);
1496
+ return Z(t.styleId, {
1497
+ paragraphFormatting: e.paragraphFormatting,
1498
+ runFormatting: e.runFormatting
1499
+ });
1500
+ })() : Z(t.styleId), u = !1;
1501
+ return l(c, (e) => {
1502
+ u = !0, e.setSelection(n.state.selection.map(e.doc, e.mapping)), n.dispatch(e);
1503
+ }), u;
1504
+ }
1505
+ return {
1506
+ handleClearFormatting: t,
1507
+ handleApplyStyle: n,
1508
+ handleInsertPageBreak: r,
1509
+ handleInsertSymbol: i,
1510
+ applyFormatting: a,
1511
+ setParagraphStyle: o
1512
+ };
1513
+ }
1514
+ //#endregion
1515
+ //#region src/composables/usePageSetupControls.ts
1516
+ function dn(e) {
1517
+ function t(t) {
1518
+ let n = e.getDocument();
1519
+ if (!n?.package?.document) return;
1520
+ let r = n.package.document.finalSectionProperties ?? {};
1521
+ n.package.document.finalSectionProperties = {
1522
+ ...r,
1523
+ ...t
1524
+ }, e.stateTick.value++, e.reLayout(), e.emit("change", n);
1525
+ }
1526
+ function n(n, r) {
1527
+ e.readOnly.value || t({ [n]: r });
1528
+ }
1529
+ function r(e) {
1530
+ n("marginLeft", e);
1531
+ }
1532
+ function i(e) {
1533
+ n("marginRight", e);
1534
+ }
1535
+ function a(e) {
1536
+ n("marginTop", e);
1537
+ }
1538
+ function o(e) {
1539
+ n("marginBottom", e);
1540
+ }
1541
+ function s(t) {
1542
+ let n = e.editorView.value;
1543
+ n && ze(t)(n.state, n.dispatch);
1544
+ }
1545
+ function c(t) {
1546
+ let n = e.editorView.value;
1547
+ n && Be(t)(n.state, n.dispatch);
1548
+ }
1549
+ function l(t) {
1550
+ let n = e.editorView.value;
1551
+ n && (t < 0 ? Re(-t, !0)(n.state, n.dispatch) : Re(t, !1)(n.state, n.dispatch));
1552
+ }
1553
+ function u(t) {
1554
+ let n = e.editorView.value;
1555
+ n && Le(t)(n.state, n.dispatch);
1556
+ }
1557
+ return {
1558
+ handlePageSetupApply: t,
1559
+ handleLeftMarginChange: r,
1560
+ handleRightMarginChange: i,
1561
+ handleTopMarginChange: a,
1562
+ handleBottomMarginChange: o,
1563
+ handleIndentLeftChange: s,
1564
+ handleIndentRightChange: c,
1565
+ handleFirstLineIndentChange: l,
1566
+ handleTabStopRemove: u
1567
+ };
1568
+ }
1569
+ //#endregion
1570
+ //#region src/composables/useOutlineSidebar.ts
1571
+ function fn(e) {
1572
+ function t() {
1573
+ if (!e.showOutline.value) {
1574
+ let t = e.editorView.value;
1575
+ t && (e.outlineHeadings.value = We(t.state.doc));
1576
+ }
1577
+ e.showOutline.value = !e.showOutline.value;
1578
+ }
1579
+ function n(t) {
1580
+ let n = e.editorView.value;
1581
+ if (!n) return;
1582
+ let r = n.state.doc.resolve(Math.min(t + 1, n.state.doc.content.size)), i = xe.near(r);
1583
+ n.dispatch(n.state.tr.setSelection(i).scrollIntoView()), n.focus();
1584
+ }
1585
+ function r() {
1586
+ e.showSidebar.value || e.extractCommentsAndChanges(), e.showSidebar.value = !e.showSidebar.value;
1587
+ }
1588
+ function i(t) {
1589
+ let n = t.target;
1590
+ n && (n.closest(".paged-editor__pages") || n.closest(".unified-sidebar") || n.closest(".docx-comment-margin-markers") || (e.activeSidebarItem.value = null));
1591
+ }
1592
+ return {
1593
+ handleToggleOutline: t,
1594
+ handleOutlineNavigate: n,
1595
+ handleToggleSidebar: r,
1596
+ handleEditorScrollMouseDown: i
1597
+ };
1598
+ }
1599
+ //#endregion
1600
+ //#region src/composables/useKeyboardShortcuts.ts
1601
+ function pn(e) {
1602
+ function t(t) {
1603
+ if (t.key === "F1") {
1604
+ t.preventDefault(), e.showKeyboardShortcuts.value = !0;
1605
+ return;
1606
+ }
1607
+ e.handleZoomKeyDown(t), (t.ctrlKey || t.metaKey) && (e.disableFindReplaceShortcuts?.() && (t.key === "f" || t.key === "h") || (t.key === "f" || t.key === "h" ? (t.preventDefault(), e.showFindReplace.value = !0) : t.key === "k" ? (t.preventDefault(), e.showHyperlink.value = !0) : t.key === "/" && (t.preventDefault(), e.showKeyboardShortcuts.value = !e.showKeyboardShortcuts.value)));
1608
+ }
1609
+ return P(() => window.addEventListener("keydown", t)), N(() => window.removeEventListener("keydown", t)), { handleKeyDown: t };
1610
+ }
1611
+ //#endregion
1612
+ //#region src/utils/commentFactories.ts
1613
+ function mn(e, t, n, r) {
1614
+ return {
1615
+ id: e.reduce((e, t) => Math.max(e, t.id), 0) + 1,
1616
+ author: n,
1617
+ date: (/* @__PURE__ */ new Date()).toISOString(),
1618
+ content: [{
1619
+ type: "paragraph",
1620
+ properties: {},
1621
+ content: [{
1622
+ type: "run",
1623
+ properties: {},
1624
+ content: [{
1625
+ type: "text",
1626
+ text: t
1627
+ }]
1628
+ }]
1629
+ }],
1630
+ ...r == null ? {} : { parentId: r }
1631
+ };
1632
+ }
1633
+ //#endregion
1634
+ //#region src/composables/useCommentManagement.ts
1635
+ function hn(e) {
1636
+ function t(t, n, r) {
1637
+ return mn(e.getDocument()?.package?.document?.comments ?? [], t, n, r);
1638
+ }
1639
+ function n(n) {
1640
+ let r = e.getDocument(), i = e.editorView.value;
1641
+ if (!r?.package?.document || !i) return null;
1642
+ r.package.document.comments || (r.package.document.comments = []);
1643
+ let a = i.state.schema.marks.comment;
1644
+ if (!a) return null;
1645
+ let o = Qe(i.state.doc, n.paraId);
1646
+ if (!o) return null;
1647
+ let s = o.from + 1, c = o.to - 1;
1648
+ if (n.search) {
1649
+ let e = tt(i.state.doc, o.from, o.to, n.search);
1650
+ if (!e) return null;
1651
+ s = e.from, c = e.to;
1652
+ }
1653
+ if (s >= c) return null;
1654
+ let l = t(n.text, n.author);
1655
+ return r.package.document.comments.push(l), e.comments.value = [...r.package.document.comments], i.dispatch(i.state.tr.addMark(s, c, a.create({ commentId: l.id }))), e.showSidebar.value = !0, e.emit("change", r), e.contentChangeSubscribers.forEach((e) => e(r)), l.id;
1656
+ }
1657
+ function r(n, r, i) {
1658
+ let a = e.getDocument();
1659
+ if (!a?.package?.document?.comments || !a.package.document.comments.some((e) => e.id === n)) return null;
1660
+ let o = t(r, i, n);
1661
+ return a.package.document.comments.push(o), e.comments.value = [...a.package.document.comments], e.emit("change", a), e.contentChangeSubscribers.forEach((e) => e(a)), o.id;
1662
+ }
1663
+ function i(t) {
1664
+ let n = e.getDocument();
1665
+ if (!n?.package?.document?.comments) return;
1666
+ let r = n.package.document.comments.find((e) => e.id === t);
1667
+ r && (r.done = !0, e.comments.value = [...n.package.document.comments], e.emit("change", n), e.contentChangeSubscribers.forEach((e) => e(n)));
1668
+ }
1669
+ function a(t) {
1670
+ let n = e.editorView.value;
1671
+ if (!n) return !1;
1672
+ let { schema: r } = n.state;
1673
+ if (!r.marks.deletion || !r.marks.insertion) return !1;
1674
+ let i = Qe(n.state.doc, t.paraId);
1675
+ if (!i) return !1;
1676
+ let a = t.search === "", o = t.replaceWith === "";
1677
+ if (a && o) return !1;
1678
+ let s, c;
1679
+ if (a) s = i.to - 1, c = i.to - 1;
1680
+ else {
1681
+ let e = tt(n.state.doc, i.from, i.to, t.search);
1682
+ if (!e) return !1;
1683
+ s = e.from, c = e.to;
1684
+ }
1685
+ let l = !1;
1686
+ if (s < c && n.state.doc.nodesBetween(s, c, (e) => {
1687
+ for (let t of e.marks) if (t.type === r.marks.insertion || t.type === r.marks.deletion) return l = !0, !1;
1688
+ return !0;
1689
+ }), l) return !1;
1690
+ let u = Math.max(0, ...e.trackedChanges.value.map((e) => e.revisionId)) + 1, d = (/* @__PURE__ */ new Date()).toISOString(), f = r.marks.deletion.create({
1691
+ revisionId: u,
1692
+ author: t.author,
1693
+ date: d
1694
+ }), p = r.marks.insertion.create({
1695
+ revisionId: u,
1696
+ author: t.author,
1697
+ date: d
1698
+ }), m = n.state.tr;
1699
+ return a || (m = m.addMark(s, c, f)), o || (m = m.insert(c, r.text(t.replaceWith, [p]))), n.dispatch(m), e.extractCommentsAndChanges(), e.showSidebar.value = !0, !0;
1700
+ }
1701
+ function o(e, t) {
1702
+ r(e, t, "User");
1703
+ }
1704
+ function s(t) {
1705
+ let n = e.getDocument();
1706
+ if (!n?.package?.document?.comments) return;
1707
+ let r = n.package.document.comments.find((e) => e.id === t);
1708
+ r && (r.done = !1), e.comments.value = [...n.package.document.comments], e.emit("change", n);
1709
+ }
1710
+ function c(t) {
1711
+ let n = e.getDocument();
1712
+ n?.package?.document?.comments && (n.package.document.comments = n.package.document.comments.filter((e) => e.id !== t && e.parentId !== t), e.comments.value = [...n.package.document.comments], e.emit("change", n));
1713
+ }
1714
+ function l(t, n) {
1715
+ let r = e.editorView.value;
1716
+ r && (Ge(t, n)(r.state, r.dispatch), e.extractCommentsAndChanges(), r.focus());
1717
+ }
1718
+ function u(t, n) {
1719
+ let r = e.editorView.value;
1720
+ r && (Ke(t, n)(r.state, r.dispatch), e.extractCommentsAndChanges(), r.focus());
1721
+ }
1722
+ function d(n, r) {
1723
+ let i = e.getDocument(), a = e.editorView.value;
1724
+ if (!i?.package?.document || !a) return;
1725
+ i.package.document.comments || (i.package.document.comments = []);
1726
+ let o = a.state.schema.marks.comment;
1727
+ if (!o) return;
1728
+ let s = null, c = a.state.schema.marks.insertion, l = a.state.schema.marks.deletion;
1729
+ if (a.state.doc.descendants((e, t) => {
1730
+ if (s !== null) return !1;
1731
+ for (let r of e.marks) if ((r.type === c || r.type === l) && r.attrs.revisionId === n) return s = t, !1;
1732
+ return !0;
1733
+ }), s === null) return;
1734
+ let u = t(r, "User");
1735
+ i.package.document.comments.push(u), e.comments.value = [...i.package.document.comments];
1736
+ let d = s, f = Math.min(d + 1, a.state.doc.content.size);
1737
+ a.dispatch(a.state.tr.addMark(d, f, o.create({ commentId: u.id }))), e.emit("change", i);
1738
+ }
1739
+ return {
1740
+ addComment: n,
1741
+ replyToComment: r,
1742
+ resolveComment: i,
1743
+ proposeChange: a,
1744
+ handleCommentReply: o,
1745
+ handleCommentUnresolve: s,
1746
+ handleCommentDelete: c,
1747
+ handleAcceptChange: l,
1748
+ handleRejectChange: u,
1749
+ handleTrackedChangeReply: d
1750
+ };
1751
+ }
1752
+ //#endregion
1753
+ //#region src/utils/domQueries.ts
1754
+ function gn(e, t) {
1755
+ let n = X(e);
1756
+ for (let e of n) {
1757
+ let n = Number(e.dataset.pmStart), r = Number(e.dataset.pmEnd);
1758
+ if (!isNaN(n) && !isNaN(r) && t >= n && t <= r) return e;
1759
+ }
1760
+ return null;
1761
+ }
1762
+ function _n(e, t, n) {
1763
+ if (!e || !t) return;
1764
+ let r = null;
1765
+ for (let t of X(e)) {
1766
+ let e = Number(t.dataset.pmStart), i = Number(t.dataset.pmEnd);
1767
+ if (Number.isFinite(e) && Number.isFinite(i) && n >= e && n <= i) {
1768
+ r = t;
1769
+ break;
1770
+ }
1771
+ }
1772
+ if (r ||= e.querySelector(`[data-pm-start="${n}"]`), !r) return;
1773
+ let i = t.getBoundingClientRect(), a = r.getBoundingClientRect();
1774
+ t.scrollTo({
1775
+ top: a.top - i.top + t.scrollTop - 48,
1776
+ behavior: "smooth"
1777
+ });
1778
+ }
1779
+ function vn(e, t, n, r) {
1780
+ if (!e || !t) return null;
1781
+ let i = Y(e, n, r, 1);
1782
+ return i === null || i < 0 ? null : Math.min(i, t.state.doc.content.size);
1783
+ }
1784
+ function yn(e, t, n) {
1785
+ if (!e) return;
1786
+ let r = gn(e, t);
1787
+ if (!r) return;
1788
+ let i = r.textContent || "", a = Number(r.dataset.pmStart) || 0, [o, s] = he(i, t - a), c = a + o, l = a + s;
1789
+ c < l && n(c, l);
1790
+ }
1791
+ function bn(e, t, n) {
1792
+ if (!e) return;
1793
+ let r = gn(e, t);
1794
+ if (!r) return;
1795
+ let i = r.closest(".layout-paragraph");
1796
+ if (!i) return;
1797
+ let a = Number(i.dataset.pmStart), o = Number(i.dataset.pmEnd);
1798
+ !isNaN(a) && !isNaN(o) && a < o && n(a, o);
1799
+ }
1800
+ //#endregion
1801
+ //#region src/composables/useCommentLifecycle.ts
1802
+ function xn(e) {
1803
+ let t = I(null), n = I(null), r = I(null), i = I(!1);
1804
+ function a() {
1805
+ let t = e.getDocument(), n = e.editorView.value;
1806
+ !t || !n || (e.comments.value = [...t.package?.document?.comments ?? []], e.trackedChanges.value = qe(n.state).entries, !i.value && (e.comments.value.length > 0 || e.trackedChanges.value.length > 0) && (e.showSidebar.value = !0, i.value = !0));
1807
+ }
1808
+ function o() {
1809
+ e.stateTick.value;
1810
+ let n = e.editorView.value;
1811
+ if (!n || e.isAddingComment.value || e.readOnly.value) {
1812
+ t.value = null;
1813
+ return;
1814
+ }
1815
+ let { from: r, to: i } = n.state.selection;
1816
+ if (r === i) {
1817
+ t.value = null;
1818
+ return;
1819
+ }
1820
+ let a = e.pagesRef.value, o = e.pagesViewportRef.value;
1821
+ if (!a || !o) {
1822
+ t.value = null;
1823
+ return;
1824
+ }
1825
+ let s = o.getBoundingClientRect(), c = gn(a, r);
1826
+ if (!c) {
1827
+ t.value = null;
1828
+ return;
1829
+ }
1830
+ let l = c.getBoundingClientRect().top - s.top + o.scrollTop, u = a.querySelector(".layout-page");
1831
+ if (!u) {
1832
+ t.value = null;
1833
+ return;
1834
+ }
1835
+ t.value = {
1836
+ top: l,
1837
+ left: u.getBoundingClientRect().right - s.left + 8
1838
+ };
1839
+ }
1840
+ function s() {
1841
+ e.stateTick.value;
1842
+ let t = e.editorView.value;
1843
+ if (!t) return;
1844
+ let n = t.state.selection.$from, r = [
1845
+ ...t.state.storedMarks ?? [],
1846
+ ...n.nodeAfter?.marks ?? [],
1847
+ ...n.nodeBefore?.marks ?? [],
1848
+ ...n.marks()
1849
+ ], i = null;
1850
+ for (let t of r) {
1851
+ if (t.type.name === "comment" && t.attrs.commentId != null) {
1852
+ let n = t.attrs.commentId;
1853
+ if (n === -1 || e.resolvedCommentIds.value.has(n)) continue;
1854
+ i = `comment-${n}`;
1855
+ break;
1856
+ }
1857
+ if ((t.type.name === "insertion" || t.type.name === "deletion") && t.attrs.revisionId != null) {
1858
+ let n = String(t.attrs.revisionId), r = e.trackedChanges.value.findIndex((e) => String(e.revisionId) === n || String(e.insertionRevisionId ?? "") === n);
1859
+ if (r >= 0) {
1860
+ i = `tc-${e.trackedChanges.value[r].revisionId}-${r}`;
1861
+ break;
1862
+ }
1863
+ }
1864
+ }
1865
+ i && (e.showSidebar.value = !0), e.activeSidebarItem.value = i;
1866
+ }
1867
+ function c() {
1868
+ let i = e.editorView.value;
1869
+ if (!i) return;
1870
+ let { from: a, to: o } = i.state.selection;
1871
+ if (a === o) return;
1872
+ n.value = {
1873
+ from: a,
1874
+ to: o
1875
+ }, r.value = t.value?.top ?? null;
1876
+ let s = i.state.schema.marks.comment;
1877
+ if (s) {
1878
+ let e = i.state.tr.addMark(a, o, s.create({ commentId: -1 }));
1879
+ i.dispatch(e);
1880
+ }
1881
+ e.showSidebar.value = !0, e.isAddingComment.value = !0, t.value = null;
1882
+ }
1883
+ function l(t) {
1884
+ let i = e.getDocument(), a = e.editorView.value;
1885
+ if (!i?.package) return;
1886
+ i.package.document.comments || (i.package.document.comments = []);
1887
+ let o = mn(i.package.document.comments, t, "User");
1888
+ i.package.document.comments.push(o), e.comments.value = [...i.package.document.comments];
1889
+ let s = n.value;
1890
+ if (a && s && s.from !== s.to) {
1891
+ let e = a.state.schema.marks.comment;
1892
+ if (e) {
1893
+ let t = a.state.tr.removeMark(s.from, s.to, e);
1894
+ t = t.addMark(s.from, s.to, e.create({ commentId: o.id })), a.dispatch(t);
1895
+ }
1896
+ }
1897
+ n.value = null, r.value = null, e.isAddingComment.value = !1, e.emit("change", i);
1898
+ }
1899
+ function u() {
1900
+ let t = e.editorView.value, i = n.value;
1901
+ if (t && i && i.from !== i.to) {
1902
+ let e = t.state.schema.marks.comment;
1903
+ e && t.dispatch(t.state.tr.removeMark(i.from, i.to, e));
1904
+ }
1905
+ n.value = null, r.value = null, e.isAddingComment.value = !1;
1906
+ }
1907
+ function d(t) {
1908
+ e.showSidebar.value = !0;
1909
+ }
1910
+ V([
1911
+ e.stateTick,
1912
+ e.isAddingComment,
1913
+ e.zoom
1914
+ ], () => o()), V(e.stateTick, () => s());
1915
+ let f = null;
1916
+ return P(() => {
1917
+ f = new ResizeObserver(() => o()), e.pagesRef.value && f.observe(e.pagesRef.value), window.addEventListener("resize", o);
1918
+ }), N(() => {
1919
+ f?.disconnect(), window.removeEventListener("resize", o);
1920
+ }), {
1921
+ floatingCommentBtn: t,
1922
+ pendingCommentRange: n,
1923
+ addCommentYPosition: r,
1924
+ sidebarAutoOpenedRef: i,
1925
+ extractCommentsAndChanges: a,
1926
+ handleAddComment: l,
1927
+ handleCancelAddComment: u,
1928
+ handleStartAddComment: c,
1929
+ handleMarkerClick: d,
1930
+ recomputeFloatingCommentBtn: o,
1931
+ recomputeActiveSidebarItem: s
1932
+ };
1933
+ }
1934
+ //#endregion
1935
+ //#region src/composables/useImageActions.ts
1936
+ function Sn(e) {
1937
+ let t = fe(null), n = I(!1), r = w(() => {
1938
+ e.stateTick.value;
1939
+ let n = e.editorView.value, r = t.value;
1940
+ if (!n || !r) return null;
1941
+ let i = n.state.doc.nodeAt(r.pmPos);
1942
+ return !i || i.type.name !== "image" ? null : {
1943
+ wrapType: i.attrs.wrapType ?? "inline",
1944
+ displayMode: i.attrs.displayMode ?? "inline",
1945
+ cssFloat: i.attrs.cssFloat ?? null
1946
+ };
1947
+ });
1948
+ function i(t) {
1949
+ let n = e.editorView.value;
1950
+ if (!n) return;
1951
+ let r = n.state.schema.nodes.image;
1952
+ if (!r) return;
1953
+ let i = r.create({
1954
+ src: t.src,
1955
+ alt: t.alt,
1956
+ width: t.width,
1957
+ height: t.height
1958
+ }), { from: a } = n.state.selection, o = n.state.tr.insert(a, i);
1959
+ n.dispatch(o.scrollIntoView()), n.focus();
1960
+ }
1961
+ function a(n) {
1962
+ let r = e.editorView.value, i = t.value;
1963
+ if (!r || !i) return;
1964
+ let a = ke(n);
1965
+ if (!a) return;
1966
+ let o = r.state.doc.nodeAt(i.pmPos), s = e.getCommands(), c = o?.attrs.wrapType === "inline" && a !== "inline" ? { initialPositionEmu: Ee(i.element, e.zoom.value) } : void 0, l = s.setImageWrapType?.(i.pmPos, a, c);
1967
+ l && (l(r.state, (e) => r.dispatch(e), r), r.focus());
1968
+ }
1969
+ function o(n) {
1970
+ let r = e.editorView.value, i = t.value;
1971
+ if (!r || !i) return;
1972
+ let a = r.state.doc.nodeAt(i.pmPos);
1973
+ if (!a || a.type.name !== "image") return;
1974
+ let o = a.attrs.transform || "", s = o.match(/rotate\((-?\d+(?:\.\d+)?)deg\)/), c = s ? parseFloat(s[1]) : 0, l = /scaleX\(-1\)/.test(o), u = /scaleY\(-1\)/.test(o);
1975
+ n === "rotateCW" ? c = (c + 90) % 360 : n === "rotateCCW" ? c = (c - 90 + 360) % 360 : n === "flipH" ? l = !l : n === "flipV" && (u = !u);
1976
+ let d = [];
1977
+ c !== 0 && d.push(`rotate(${c}deg)`), l && d.push("scaleX(-1)"), u && d.push("scaleY(-1)");
1978
+ let f = d.length > 0 ? d.join(" ") : null, p = r.state.tr.setNodeMarkup(i.pmPos, void 0, {
1979
+ ...a.attrs,
1980
+ transform: f
1981
+ });
1982
+ r.dispatch(p.scrollIntoView()), r.focus();
1983
+ }
1984
+ return {
1985
+ selectedImage: t,
1986
+ imageInteracting: n,
1987
+ imageToolbarContext: r,
1988
+ handleInsertImage: i,
1989
+ handleToolbarImageWrap: a,
1990
+ handleImageTransform: o
1991
+ };
1992
+ }
1993
+ //#endregion
1994
+ //#region src/utils/imageClipboard.ts
1995
+ function Cn(e, t) {
1996
+ return e.getBlob(t);
1997
+ }
1998
+ function wn(e, t) {
1999
+ let n = e.state.doc.nodeAt(t);
2000
+ if (!n || n.type.name !== "image") return;
2001
+ let r = `<img src="${n.attrs.src}" data-pm-image="true" data-width="${n.attrs.width ?? ""}" data-height="${n.attrs.height ?? ""}" data-wrap-type="${n.attrs.wrapType ?? ""}" data-display-mode="${n.attrs.displayMode ?? ""}" data-rid="${n.attrs.rId ?? ""}" />`, i = new ClipboardItem({
2002
+ "text/html": new Blob([r], { type: "text/html" }),
2003
+ "text/plain": new Blob(["[image]"], { type: "text/plain" })
2004
+ });
2005
+ navigator.clipboard.write([i]).catch(() => {
2006
+ let e = document.createElement("textarea");
2007
+ e.value = r, document.body.appendChild(e), e.select(), document.execCommand("copy"), document.body.removeChild(e);
2008
+ });
2009
+ }
2010
+ function Tn(e) {
2011
+ return new Promise((t, n) => {
2012
+ let r = new FileReader();
2013
+ r.onload = () => t(r.result), r.onerror = n, r.readAsDataURL(e);
2014
+ });
2015
+ }
2016
+ function En(e) {
2017
+ return new Promise((t) => {
2018
+ let n = new Image();
2019
+ n.onload = () => t({
2020
+ width: n.naturalWidth,
2021
+ height: n.naturalHeight
2022
+ }), n.onerror = () => t({
2023
+ width: 200,
2024
+ height: 200
2025
+ }), n.src = e;
2026
+ });
2027
+ }
2028
+ async function Dn(e) {
2029
+ try {
2030
+ let t = await navigator.clipboard.read();
2031
+ for (let n of t) {
2032
+ let t = n.types.find((e) => e.startsWith("image/"));
2033
+ if (t) {
2034
+ let r = await Tn(await Cn(n, t)), i = await En(r), a = i.width, o = i.height;
2035
+ a > 612 && (o = Math.round(612 / a * o), a = 612);
2036
+ let s = e.state.schema.nodes.image.create({
2037
+ src: r,
2038
+ width: a,
2039
+ height: o,
2040
+ rId: `rId_img_${Date.now()}`,
2041
+ wrapType: "inline",
2042
+ displayMode: "inline"
2043
+ });
2044
+ e.dispatch(e.state.tr.replaceSelectionWith(s));
2045
+ return;
2046
+ }
2047
+ if (n.types.includes("text/html")) {
2048
+ let t = await (await Cn(n, "text/html")).text(), r = t.match(/<img[^>]+src="([^"]+)"[^>]*>/i);
2049
+ if (r && r[1]) {
2050
+ let n = r[1], i = t.match(/data-width="(\d+)"/), a = t.match(/data-height="(\d+)"/), o = i ? Number(i[1]) : 200, s = a ? Number(a[1]) : 200, c = e.state.schema.nodes.image.create({
2051
+ src: n,
2052
+ width: o || 200,
2053
+ height: s || 200,
2054
+ rId: `rId_img_${Date.now()}`,
2055
+ wrapType: "inline",
2056
+ displayMode: "inline"
2057
+ });
2058
+ e.dispatch(e.state.tr.replaceSelectionWith(c));
2059
+ return;
2060
+ }
2061
+ }
2062
+ if (n.types.includes("text/plain")) {
2063
+ let t = await (await Cn(n, "text/plain")).text();
2064
+ if (t && t !== "[image]") {
2065
+ let { from: n } = e.state.selection;
2066
+ e.dispatch(e.state.tr.insertText(t, n));
2067
+ }
2068
+ return;
2069
+ }
2070
+ }
2071
+ } catch {
2072
+ let t = await navigator.clipboard?.readText();
2073
+ if (t) {
2074
+ let { from: n } = e.state.selection;
2075
+ e.dispatch(e.state.tr.insertText(t, n));
2076
+ }
2077
+ }
2078
+ }
2079
+ function On(e, t) {
2080
+ let n = e.state.doc.nodeAt(t);
2081
+ if (!n || n.type.name !== "image") return;
2082
+ let r = document.createElement("input");
2083
+ r.type = "file", r.accept = "image/*", r.onchange = async () => {
2084
+ let i = r.files?.[0];
2085
+ if (!i) return;
2086
+ let a = await Tn(i), o = await En(a), s = n.attrs.width || o.width, c = n.attrs.height || o.height, l = Math.min(s / o.width, c / o.height), u = Math.round(o.width * l), d = Math.round(o.height * l);
2087
+ try {
2088
+ let r = e.state.tr.setNodeMarkup(t, void 0, {
2089
+ ...n.attrs,
2090
+ src: a,
2091
+ width: u,
2092
+ height: d,
2093
+ rId: `rId_img_${Date.now()}`
2094
+ });
2095
+ e.dispatch(r);
2096
+ } catch {}
2097
+ }, r.click();
2098
+ }
2099
+ //#endregion
2100
+ //#region src/composables/useContextMenus.ts
2101
+ function kn(e) {
2102
+ let { t } = n(), r = I({
2103
+ isOpen: !1,
2104
+ position: {
2105
+ x: 0,
2106
+ y: 0
2107
+ },
2108
+ hasSelection: !1,
2109
+ inTable: !1,
2110
+ onImage: !1,
2111
+ canMergeCells: !1,
2112
+ canSplitCell: !1
2113
+ }), i = I(null), a = w(() => [
2114
+ {
2115
+ action: "cut",
2116
+ label: t("contextMenu.cut"),
2117
+ shortcut: t("contextMenu.cutShortcut")
2118
+ },
2119
+ {
2120
+ action: "copy",
2121
+ label: t("contextMenu.copy"),
2122
+ shortcut: t("contextMenu.copyShortcut")
2123
+ },
2124
+ {
2125
+ action: "paste",
2126
+ label: t("contextMenu.paste"),
2127
+ shortcut: t("contextMenu.pasteShortcut"),
2128
+ dividerAfter: !0
2129
+ },
2130
+ {
2131
+ action: "delete",
2132
+ label: t("contextMenu.delete"),
2133
+ shortcut: t("contextMenu.deleteShortcut")
2134
+ }
2135
+ ]);
2136
+ function o(t) {
2137
+ let n = e.editorView.value;
2138
+ if (!n) return;
2139
+ let a = t.target, o = De(a);
2140
+ if (o) {
2141
+ let a = Number(o.dataset.pmStart);
2142
+ if (!isNaN(a)) {
2143
+ try {
2144
+ let e = be.create(n.state.doc, a);
2145
+ n.dispatch(n.state.tr.setSelection(e));
2146
+ } catch {}
2147
+ e.selectedImage.value = {
2148
+ element: o,
2149
+ pmPos: a,
2150
+ width: o.offsetWidth,
2151
+ height: o.offsetHeight
2152
+ }, e.clearOverlay();
2153
+ let s = n.state.doc.nodeAt(a);
2154
+ if (s && s.type.name === "image") {
2155
+ let n = s.attrs.wrapType ?? "inline", c = s.attrs.cssFloat;
2156
+ i.value = {
2157
+ open: !0,
2158
+ position: {
2159
+ x: t.clientX,
2160
+ y: t.clientY
2161
+ },
2162
+ pmPos: a,
2163
+ currentWrapType: n,
2164
+ currentCssFloat: c ?? null,
2165
+ inlinePositionEmu: n === "inline" ? Ee(o, e.zoom.value) : void 0
2166
+ }, r.value.isOpen = !1;
2167
+ return;
2168
+ }
2169
+ }
2170
+ }
2171
+ {
2172
+ let { from: r, to: i } = n.state.selection, a = e.resolvePos(t.clientX, t.clientY);
2173
+ if (a !== null && (a < r || a > i)) try {
2174
+ e.setPmSelection(a);
2175
+ } catch {}
2176
+ }
2177
+ let s = ve(n.state), { empty: c } = n.state.selection;
2178
+ i.value &&= null, r.value = {
2179
+ isOpen: !0,
2180
+ position: {
2181
+ x: t.clientX,
2182
+ y: t.clientY
2183
+ },
2184
+ hasSelection: !c,
2185
+ inTable: s.isInTable,
2186
+ onImage: !!o,
2187
+ canMergeCells: !!s.hasMultiCellSelection,
2188
+ canSplitCell: !!s.canSplitCell
2189
+ };
2190
+ }
2191
+ function s(t) {
2192
+ let n = e.editorView.value, a = e.selectedImage.value;
2193
+ if (!n || !a) return;
2194
+ let o = n.state.doc.nodeAt(a.pmPos);
2195
+ if (!o || o.type.name !== "image") return;
2196
+ let s = o.attrs.wrapType ?? "inline", c = o.attrs.cssFloat;
2197
+ i.value = {
2198
+ open: !0,
2199
+ position: {
2200
+ x: t.clientX,
2201
+ y: t.clientY
2202
+ },
2203
+ pmPos: a.pmPos,
2204
+ currentWrapType: s,
2205
+ currentCssFloat: c ?? null,
2206
+ inlinePositionEmu: s === "inline" ? Ee(a.element, e.zoom.value) : void 0
2207
+ }, r.value.isOpen = !1;
2208
+ }
2209
+ function c(t) {
2210
+ let n = e.editorView.value, r = i.value;
2211
+ if (!n || !r) return;
2212
+ let a = e.getCommands(), o = r.inlinePositionEmu && t !== "inline" ? { initialPositionEmu: r.inlinePositionEmu } : void 0, s = a.setImageWrapType?.(r.pmPos, t, o);
2213
+ s && (s(n.state, (e) => n.dispatch(e), n), n.focus());
2214
+ }
2215
+ function l(t) {
2216
+ let n = e.editorView.value;
2217
+ if (!n) return;
2218
+ let r = e.getCommands();
2219
+ switch (t) {
2220
+ case "cut":
2221
+ if (e.selectedImage.value) {
2222
+ wn(n, e.selectedImage.value.pmPos);
2223
+ let t = e.selectedImage.value.pmPos, r = n.state.doc.nodeAt(t);
2224
+ r && (n.dispatch(n.state.tr.delete(t, t + r.nodeSize)), e.selectedImage.value = null);
2225
+ } else document.execCommand("cut");
2226
+ break;
2227
+ case "copy":
2228
+ e.selectedImage.value ? wn(n, e.selectedImage.value.pmPos) : document.execCommand("copy");
2229
+ break;
2230
+ case "paste":
2231
+ Dn(n);
2232
+ break;
2233
+ case "pasteAsPlainText":
2234
+ navigator.clipboard.readText().then((e) => {
2235
+ e && n.dispatch(n.state.tr.insertText(e).scrollIntoView());
2236
+ }).catch(() => {});
2237
+ break;
2238
+ case "delete": {
2239
+ let { from: e, to: t } = n.state.selection;
2240
+ e !== t && n.dispatch(n.state.tr.delete(e, t));
2241
+ break;
2242
+ }
2243
+ case "selectAll": {
2244
+ let e = xe.create(n.state.doc, 0, n.state.doc.content.size);
2245
+ n.dispatch(n.state.tr.setSelection(e));
2246
+ break;
2247
+ }
2248
+ case "imageProperties":
2249
+ e.selectedImage.value && (e.showImageProperties.value = !0);
2250
+ break;
2251
+ case "replaceImage":
2252
+ e.selectedImage.value && On(n, e.selectedImage.value.pmPos);
2253
+ break;
2254
+ case "deleteImage":
2255
+ if (e.selectedImage.value) {
2256
+ let t = e.selectedImage.value.pmPos, r = n.state.doc.nodeAt(t);
2257
+ r && (n.dispatch(n.state.tr.delete(t, t + r.nodeSize)), e.selectedImage.value = null);
2258
+ }
2259
+ break;
2260
+ case "addRowAbove":
2261
+ case "addRowBelow":
2262
+ case "deleteRow":
2263
+ case "addColumnLeft":
2264
+ case "addColumnRight":
2265
+ case "deleteColumn":
2266
+ case "mergeCells":
2267
+ case "splitCell": {
2268
+ let e = r[t];
2269
+ e && e()(n.state, (e) => n.dispatch(e), n);
2270
+ break;
2271
+ }
2272
+ }
2273
+ n.focus();
2274
+ }
2275
+ return {
2276
+ contextMenu: r,
2277
+ imageContextMenu: i,
2278
+ imageContextMenuTextActions: a,
2279
+ handleContextMenu: o,
2280
+ handleSelectedImageContextMenu: s,
2281
+ handleImageWrapSelect: c,
2282
+ handleContextMenuAction: l
2283
+ };
2284
+ }
2285
+ //#endregion
2286
+ //#region src/composables/usePagesPointer.ts
2287
+ var An = 500;
2288
+ function jn(e) {
2289
+ let t = I(null), n = null;
2290
+ function r() {
2291
+ n !== null && (clearTimeout(n), n = null);
2292
+ }
2293
+ let i = I(null), a = 0, o = null, s = 0, c = !1, l = null, u = I({
2294
+ currentPage: 1,
2295
+ totalPages: 1,
2296
+ visible: !1
2297
+ }), d = null;
2298
+ function f(t, n) {
2299
+ return vn(e.pagesRef.value, e.editorView.value, t, n);
2300
+ }
2301
+ function p(t, n) {
2302
+ let r = e.editorView.value;
2303
+ if (!r) return;
2304
+ let i = r.state.doc.resolve(t), a = n === void 0 ? i : r.state.doc.resolve(n), o = xe.between(i, a);
2305
+ r.dispatch(r.state.tr.setSelection(o));
2306
+ }
2307
+ function m(t) {
2308
+ _n(e.pagesRef.value, e.pagesViewportRef.value, t);
2309
+ }
2310
+ function h(t) {
2311
+ yn(e.pagesRef.value, t, p);
2312
+ }
2313
+ function g(t) {
2314
+ bn(e.pagesRef.value, t, p);
2315
+ }
2316
+ function _(t) {
2317
+ let n = e.editorView.value;
2318
+ if (!n) return;
2319
+ let r = null;
2320
+ if (n.state.doc.descendants((e, n) => r === null ? (e.attrs?.bookmarks)?.some((e) => e.name === t) ? (r = n, !1) : !0 : !1), r !== null) {
2321
+ m(r);
2322
+ try {
2323
+ p(Math.min(r + 1, n.state.doc.content.size));
2324
+ } catch {
2325
+ p(r);
2326
+ }
2327
+ }
2328
+ }
2329
+ function ee(a) {
2330
+ if (e.readOnly.value || c) return;
2331
+ let o = e.pagesRef.value;
2332
+ if (!o) return;
2333
+ let s = e.pagesViewportRef.value;
2334
+ if (!s) return;
2335
+ let l = Ye({
2336
+ mouseX: a.clientX,
2337
+ mouseY: a.clientY,
2338
+ pagesContainer: o,
2339
+ target: a.target,
2340
+ hfEditMode: i.value?.position ?? null
2341
+ });
2342
+ if (!l) {
2343
+ n === null && (n = setTimeout(() => {
2344
+ t.value = null, n = null;
2345
+ }, Je));
2346
+ return;
2347
+ }
2348
+ let u = s.getBoundingClientRect();
2349
+ t.value = {
2350
+ type: l.type,
2351
+ x: l.clientX - u.left,
2352
+ y: l.clientY - u.top,
2353
+ cellPmPos: l.cellPmPos
2354
+ }, r();
2355
+ }
2356
+ function v(n) {
2357
+ n.preventDefault(), n.stopPropagation();
2358
+ let r = t.value, i = e.editorView.value;
2359
+ if (!r || !i) return;
2360
+ let a = i.state.tr.setSelection(xe.create(i.state.doc, r.cellPmPos + 1));
2361
+ i.dispatch(a);
2362
+ let o = e.getCommands(), s = r.type === "row" ? o.addRowBelow?.() : o.addColumnRight?.();
2363
+ s && (s(i.state, (e) => i.dispatch(e), i), t.value = null, i.focus());
2364
+ }
2365
+ function y(t) {
2366
+ let n = t.target?.closest("a[href]");
2367
+ if (!n) return;
2368
+ t.preventDefault();
2369
+ let r = n.getAttribute("href") || "";
2370
+ if (!r) return;
2371
+ if (r.startsWith("#")) {
2372
+ let e = r.slice(1);
2373
+ e && _(e);
2374
+ return;
2375
+ }
2376
+ let i = e.editorView.value;
2377
+ if (i && i.state.selection.from !== i.state.selection.to) return;
2378
+ let a = e.pagesViewportRef.value;
2379
+ if (!a) return;
2380
+ let o = a.getBoundingClientRect(), s = n.getBoundingClientRect();
2381
+ e.hyperlinkPopupData.value = {
2382
+ href: r,
2383
+ displayText: n.textContent || "",
2384
+ tooltip: n.getAttribute("title") || void 0,
2385
+ position: {
2386
+ top: s.bottom - o.top + a.scrollTop + 4,
2387
+ left: s.left - o.left + a.scrollLeft
2388
+ }
2389
+ };
2390
+ }
2391
+ function b(t) {
2392
+ let n = t.target, r = n.closest(".layout-page-header"), a = n.closest(".layout-page-footer"), o = r ?? a;
2393
+ if (!o) return;
2394
+ let s = r ? "header" : "footer", c = e.getDocument();
2395
+ if (!c?.package) return;
2396
+ let l = c.package.document?.sections?.[0]?.properties ?? c.package.document?.finalSectionProperties ?? null, u = s === "header" ? l?.headerReferences : l?.footerReferences, d = s === "header" ? c.package.headers : c.package.footers;
2397
+ if (!u || !d) return;
2398
+ let f = (u.find((e) => e.type === "default") ?? u.find((e) => e.type === "first"))?.rId ?? null, p = f ? d.get(f) ?? null : null, m = e.pagesViewportRef.value;
2399
+ if (!m) return;
2400
+ let h = o.getBoundingClientRect(), g = m.getBoundingClientRect(), _ = e.zoom.value || 1;
2401
+ i.value = {
2402
+ position: s,
2403
+ rId: f,
2404
+ headerFooter: p,
2405
+ targetRect: {
2406
+ top: (h.top - g.top + m.scrollTop) / _,
2407
+ left: (h.left - g.left + m.scrollLeft) / _,
2408
+ width: h.width / _,
2409
+ height: h.height / _
2410
+ }
2411
+ };
2412
+ }
2413
+ function x(t) {
2414
+ let n = e.getDocument(), r = i.value;
2415
+ if (!n?.package || !r) return;
2416
+ let a = r.position === "header" ? n.package.headers : n.package.footers;
2417
+ if (!a || !r.rId) return;
2418
+ let o = a.get(r.rId);
2419
+ o && (o.content = t), e.reLayout(), e.emit("change", n);
2420
+ }
2421
+ function te() {
2422
+ let t = e.getDocument(), n = i.value;
2423
+ if (!t?.package || !n || !n.rId) return;
2424
+ let r = (n.position === "header" ? t.package.headers : t.package.footers)?.get(n.rId);
2425
+ r && (r.content = []), i.value = null, e.reLayout(), e.emit("change", t);
2426
+ }
2427
+ function ne(t) {
2428
+ if (t.button !== 0 || e.imageInteracting.value) return;
2429
+ let n = e.editorView.value;
2430
+ if (!n || !e.readOnly.value && e.tableResize.tryStartResize(t, n)) return;
2431
+ let r = t.target, i = De(r);
2432
+ if (i) {
2433
+ t.preventDefault(), t.stopPropagation();
2434
+ let r = Number(i.dataset.pmStart);
2435
+ if (!isNaN(r)) {
2436
+ try {
2437
+ let e = be.create(n.state.doc, r);
2438
+ n.dispatch(n.state.tr.setSelection(e));
2439
+ } catch {}
2440
+ e.selectedImage.value = {
2441
+ element: i,
2442
+ pmPos: r,
2443
+ width: i.offsetWidth,
2444
+ height: i.offsetHeight
2445
+ }, e.clearOverlay();
2446
+ }
2447
+ n.focus();
2448
+ return;
2449
+ }
2450
+ e.selectedImage.value = null, t.preventDefault();
2451
+ let u = f(t.clientX, t.clientY);
2452
+ if (u === null) {
2453
+ n.focus();
2454
+ return;
2455
+ }
2456
+ let d = Date.now();
2457
+ if (d - a < An && o === u ? s++ : s = 1, a = d, o = u, s === 2) h(u);
2458
+ else if (s >= 3) g(u), s = 0;
2459
+ else {
2460
+ if (t.shiftKey) {
2461
+ let { from: e } = n.state.selection;
2462
+ p(e, u);
2463
+ } else p(u);
2464
+ l = u, c = !0;
2465
+ }
2466
+ n.focus();
2467
+ }
2468
+ function re(e) {
2469
+ if (!c || l === null) return;
2470
+ let t = f(e.clientX, e.clientY);
2471
+ t !== null && t !== l && p(l, t);
2472
+ }
2473
+ function S() {
2474
+ c = !1;
2475
+ }
2476
+ function C() {
2477
+ let t = e.pagesViewportRef.value, n = e.layout.value;
2478
+ if (!t || !n || n.pages.length === 0) return;
2479
+ let r = t.scrollTop, i = n.pages.length, a = r + t.clientHeight / 2, o = 24, s = 1;
2480
+ for (let e = 0; e < n.pages.length; e++) {
2481
+ let t = n.pages[e].size.h, r = o + t;
2482
+ if (a < r) {
2483
+ s = e + 1;
2484
+ break;
2485
+ }
2486
+ o = r + 24, s = e + 2;
2487
+ }
2488
+ s = Math.min(s, i), u.value = {
2489
+ currentPage: s,
2490
+ totalPages: i,
2491
+ visible: !0
2492
+ }, d && clearTimeout(d), d = setTimeout(() => {
2493
+ u.value = {
2494
+ ...u.value,
2495
+ visible: !1
2496
+ };
2497
+ }, 600);
2498
+ }
2499
+ return P(() => {
2500
+ window.addEventListener("mousemove", re), window.addEventListener("mouseup", S), e.pagesViewportRef.value?.addEventListener("scroll", C, { passive: !0 });
2501
+ }), N(() => {
2502
+ r(), window.removeEventListener("mousemove", re), window.removeEventListener("mouseup", S), e.pagesViewportRef.value?.removeEventListener("scroll", C), d && clearTimeout(d);
2503
+ }), {
2504
+ tableInsertButton: t,
2505
+ hfEdit: i,
2506
+ scrollPageInfo: u,
2507
+ resolvePos: f,
2508
+ setPmSelection: p,
2509
+ scrollVisiblePositionIntoView: m,
2510
+ navigateToBookmark: _,
2511
+ handlePagesMouseDown: ne,
2512
+ handlePagesMouseMove: ee,
2513
+ handlePagesClick: y,
2514
+ handlePagesDoubleClick: b,
2515
+ handleTableInsertClick: v,
2516
+ clearTableInsertTimer: r,
2517
+ handleHfSave: x,
2518
+ handleHfRemove: te
2519
+ };
2520
+ }
2521
+ //#endregion
2522
+ //#region src/composables/useSelectionSync.ts
2523
+ function Mn(e) {
2524
+ let t = null, n = null;
2525
+ function r() {
2526
+ let r = e.pagesRef.value;
2527
+ r && (r.querySelectorAll(".vue-sel-rect, .vue-caret").forEach((e) => e.remove()), t !== null && (clearInterval(t), t = null), n = null);
2528
+ }
2529
+ function i() {
2530
+ let i = e.pagesRef.value, a = e.editorView.value;
2531
+ if (!i || !a) return;
2532
+ r();
2533
+ let o = a.state.selection;
2534
+ if (o instanceof be && o.node.type.name === "image") {
2535
+ let t = null;
2536
+ for (let e of i.querySelectorAll(`[data-pm-start="${o.from}"]`)) {
2537
+ let n = De(e);
2538
+ if (n) {
2539
+ t = n;
2540
+ break;
2541
+ }
2542
+ }
2543
+ if (t) {
2544
+ let n = e.selectedImage.value;
2545
+ (!n || n.element !== t || n.pmPos !== o.from || n.width !== t.offsetWidth || n.height !== t.offsetHeight) && (e.selectedImage.value = {
2546
+ element: t,
2547
+ pmPos: o.from,
2548
+ width: t.offsetWidth,
2549
+ height: t.offsetHeight
2550
+ });
2551
+ return;
2552
+ }
2553
+ }
2554
+ if (e.selectedImage.value) return;
2555
+ let { from: s, to: c, empty: l } = a.state.selection, u = i.scrollTop, d = i.scrollLeft;
2556
+ if (l) {
2557
+ let e = Ce(i, s, i.getBoundingClientRect());
2558
+ if (e) {
2559
+ let r = document.createElement("div");
2560
+ r.className = "vue-caret", r.style.cssText = `
2561
+ position: absolute;
2562
+ left: ${e.x + d}px;
2563
+ top: ${e.y + u}px;
2564
+ width: 2px;
2565
+ height: ${e.height}px;
2566
+ background: #000;
2567
+ pointer-events: none;
2568
+ z-index: ${te.selectionOverlay};
2569
+ `, i.appendChild(r), n = r;
2570
+ let a = !0;
2571
+ t = setInterval(() => {
2572
+ a = !a, n && (n.style.opacity = a ? "1" : "0");
2573
+ }, 530);
2574
+ }
2575
+ return;
2576
+ }
2577
+ let f = we(i, s, c, i.getBoundingClientRect());
2578
+ for (let e of f) {
2579
+ let t = document.createElement("div");
2580
+ t.className = "vue-sel-rect", t.style.cssText = `
2581
+ position: absolute;
2582
+ left: ${e.x + d}px;
2583
+ top: ${e.y + u}px;
2584
+ width: ${e.width}px;
2585
+ height: ${e.height}px;
2586
+ background: rgba(66, 133, 244, 0.3);
2587
+ pointer-events: none;
2588
+ z-index: ${te.selectionOverlay};
2589
+ `, i.appendChild(t);
2590
+ }
2591
+ }
2592
+ return N(() => {
2593
+ r();
2594
+ }), {
2595
+ clearOverlay: r,
2596
+ updateSelectionOverlay: i
2597
+ };
2598
+ }
2599
+ //#endregion
2600
+ //#region src/composables/useMenuActions.ts
2601
+ function Nn(e) {
2602
+ function t(t) {
2603
+ let n = e.editorView.value;
2604
+ if (!n) return;
2605
+ let r = e.getCommands()[t];
2606
+ r && (r()(n.state, (e) => n.dispatch(e), n), n.focus());
2607
+ }
2608
+ function n(t, n) {
2609
+ let r = e.editorView.value;
2610
+ if (!r) return;
2611
+ let i = e.getCommands().insertTable;
2612
+ i && (i(t, n)(r.state, (e) => r.dispatch(e), r), r.focus());
2613
+ }
2614
+ function r(n) {
2615
+ switch (n) {
2616
+ case "open":
2617
+ e.docxInputRef.value?.click(), e.emit("menu-action", "open");
2618
+ break;
2619
+ case "save":
2620
+ e.emit("menu-action", "save"), e.downloadCurrentDocument();
2621
+ break;
2622
+ case "pageSetup":
2623
+ e.showPageSetup.value = !0;
2624
+ break;
2625
+ case "clearFormatting":
2626
+ e.handleClearFormatting();
2627
+ break;
2628
+ case "insertImage":
2629
+ e.showInsertImage.value = !0;
2630
+ break;
2631
+ case "insertLink":
2632
+ e.showHyperlink.value = !0;
2633
+ break;
2634
+ case "insertSymbol":
2635
+ e.showInsertSymbol.value = !0;
2636
+ break;
2637
+ case "insertPageBreak":
2638
+ e.handleInsertPageBreak();
2639
+ break;
2640
+ case "insertTOC":
2641
+ t("generateTOC");
2642
+ break;
2643
+ case "outline":
2644
+ e.handleToggleOutline();
2645
+ break;
2646
+ case "sidebar":
2647
+ e.handleToggleSidebar();
2648
+ break;
2649
+ case "shortcuts":
2650
+ e.showKeyboardShortcuts.value = !0;
2651
+ break;
2652
+ case "reportIssue":
2653
+ Xe();
2654
+ break;
2655
+ case "dirLTR":
2656
+ t("setLtr");
2657
+ break;
2658
+ case "dirRTL":
2659
+ t("setRtl");
2660
+ break;
2661
+ }
2662
+ }
2663
+ return {
2664
+ handleMenuAction: r,
2665
+ handleMenuTableInsert: n,
2666
+ execSimpleCommand: t
2667
+ };
2668
+ }
2669
+ //#endregion
2670
+ //#region src/composables/useDocumentLifecycle.ts
2671
+ function Pn(e) {
2672
+ async function t(t) {
2673
+ e.sidebarAutoOpenedRef.value = !1, await e.loadDocumentBuffer(t);
2674
+ }
2675
+ function n(t) {
2676
+ e.sidebarAutoOpenedRef.value = !1, e.loadDocument(t);
2677
+ }
2678
+ V(e.documentBuffer, (e) => {
2679
+ e && t(e);
2680
+ }), V(e.document, (e) => {
2681
+ e && n(e);
2682
+ }), P(async () => {
2683
+ await j();
2684
+ let r = e.documentBuffer(), i = e.document();
2685
+ r ? await t(r) : i && n(i);
2686
+ });
2687
+ }
2688
+ //#endregion
2689
+ //#region src/composables/useDocxEditorRefApi.ts
2690
+ function Fn(e) {
2691
+ function t() {
2692
+ e.onPrint?.(), window.print();
2693
+ }
2694
+ function n() {
2695
+ t();
2696
+ }
2697
+ function r() {
2698
+ return e.zoom.value;
2699
+ }
2700
+ function i(t) {
2701
+ if (!Number.isInteger(t) || t < 1) return;
2702
+ let n = e.pagesViewportRef.value, r = e.pagesRef.value?.querySelector(`[data-page-number="${t}"]`);
2703
+ if (!n || !r) return;
2704
+ let i = n.getBoundingClientRect(), a = r.getBoundingClientRect();
2705
+ n.scrollTo({
2706
+ top: a.top - i.top + n.scrollTop - 24,
2707
+ behavior: "smooth"
2708
+ });
2709
+ }
2710
+ function a(t) {
2711
+ Number.isFinite(t) && e.scrollVisiblePositionIntoView(t);
2712
+ }
2713
+ function o() {
2714
+ return e.editorView.value ? {
2715
+ getDocument: e.getDocument,
2716
+ getView: () => e.editorView.value,
2717
+ getState: () => e.editorView.value?.state ?? null
2718
+ } : null;
2719
+ }
2720
+ function s() {
2721
+ return e.layout.value?.pages.length ?? 0;
2722
+ }
2723
+ function c() {
2724
+ let t = e.layout.value, n = e.editorView.value;
2725
+ if (!t || !n) return 0;
2726
+ let r = Ie(t, n.state.selection.from);
2727
+ return r == null ? 0 : r + 1;
2728
+ }
2729
+ function l(t) {
2730
+ let n = e.editorView.value;
2731
+ if (!n) return !1;
2732
+ let r = Qe(n.state.doc, t);
2733
+ return r ? (e.scrollVisiblePositionIntoView(r.from + 1), !0) : !1;
2734
+ }
2735
+ function u(t, n) {
2736
+ return nt(e.editorView.value, t, n);
2737
+ }
2738
+ function d() {
2739
+ return rt(e.editorView.value);
2740
+ }
2741
+ function f() {
2742
+ return e.comments.value;
2743
+ }
2744
+ function p(t) {
2745
+ return it(e.editorView.value, e.layout.value, t);
2746
+ }
2747
+ function m(t) {
2748
+ return e.contentChangeSubscribers.add(t), () => e.contentChangeSubscribers.delete(t);
2749
+ }
2750
+ function h(t) {
2751
+ return e.selectionChangeSubscribers.add(t), () => e.selectionChangeSubscribers.delete(t);
2752
+ }
2753
+ return { exposed: {
2754
+ getAgent: () => null,
2755
+ save: e.save,
2756
+ setZoom: e.setZoom,
2757
+ getZoom: r,
2758
+ focus: e.focus,
2759
+ scrollToPage: i,
2760
+ scrollToPosition: a,
2761
+ openPrintPreview: n,
2762
+ print: t,
2763
+ loadDocument: e.loadDocument,
2764
+ loadDocumentBuffer: e.loadDocumentBuffer,
2765
+ destroy: e.destroy,
2766
+ getDocument: e.getDocument,
2767
+ getEditorRef: o,
2768
+ addComment: e.addComment,
2769
+ replyToComment: e.replyToComment,
2770
+ resolveComment: e.resolveComment,
2771
+ proposeChange: e.proposeChange,
2772
+ scrollToParaId: l,
2773
+ findInDocument: u,
2774
+ getSelectionInfo: d,
2775
+ getComments: f,
2776
+ applyFormatting: e.applyFormatting,
2777
+ setParagraphStyle: e.setParagraphStyle,
2778
+ getPageContent: p,
2779
+ getTotalPages: s,
2780
+ getCurrentPage: c,
2781
+ onContentChange: m,
2782
+ onSelectionChange: h
2783
+ } };
2784
+ }
2785
+ //#endregion
2786
+ //#region src/components/DocxEditor.vue?vue&type=script&setup=true&lang.ts
2787
+ var In = { class: "docx-editor-vue__toolbar-shell" }, Ln = {
2788
+ key: 0,
2789
+ class: "docx-editor-vue__error"
2790
+ }, Rn = {
2791
+ key: 1,
2792
+ class: "docx-editor-vue__loading"
2793
+ }, zn = { class: "docx-editor-vue__editor-area" }, Bn = {
2794
+ key: 0,
2795
+ class: "docx-editor-vue__vertical-ruler"
2796
+ }, Vn = ["title"], Hn = ["title", "aria-label"], Un = /* @__PURE__ */ A({
2797
+ __name: "DocxEditor",
2798
+ props: {
2799
+ documentBuffer: { default: null },
2800
+ document: { default: null },
2801
+ showToolbar: {
2802
+ type: Boolean,
2803
+ default: !0
2804
+ },
2805
+ showMenuBar: {
2806
+ type: Boolean,
2807
+ default: !0
2808
+ },
2809
+ showRuler: {
2810
+ type: Boolean,
2811
+ default: !0
2812
+ },
2813
+ documentName: { default: "" },
2814
+ readOnly: {
2815
+ type: Boolean,
2816
+ default: !1
2817
+ },
2818
+ mode: { default: "editing" },
2819
+ onModeChange: {},
2820
+ i18n: { default: void 0 },
2821
+ theme: { default: null },
2822
+ externalPlugins: { default: () => [] },
2823
+ showZoomControl: {
2824
+ type: Boolean,
2825
+ default: !0
2826
+ },
2827
+ initialZoom: { default: 1 },
2828
+ toolbarExtra: {
2829
+ type: Function,
2830
+ default: void 0
2831
+ },
2832
+ className: { default: "" },
2833
+ style: {
2834
+ type: [
2835
+ Boolean,
2836
+ null,
2837
+ String,
2838
+ Object,
2839
+ Array
2840
+ ],
2841
+ default: void 0
2842
+ },
2843
+ showOutline: {
2844
+ type: Boolean,
2845
+ default: !1
2846
+ },
2847
+ showOutlineButton: {
2848
+ type: Boolean,
2849
+ default: !0
2850
+ },
2851
+ fontFamilies: { default: void 0 },
2852
+ onPrint: {
2853
+ type: Function,
2854
+ default: void 0
2855
+ },
2856
+ disableFindReplaceShortcuts: {
2857
+ type: Boolean,
2858
+ default: !1
2859
+ },
2860
+ renderLogo: {
2861
+ type: Function,
2862
+ default: void 0
2863
+ },
2864
+ onDocumentNameChange: {
2865
+ type: Function,
2866
+ default: void 0
2867
+ },
2868
+ documentNameEditable: {
2869
+ type: Boolean,
2870
+ default: !0
2871
+ },
2872
+ renderTitleBarRight: {
2873
+ type: Function,
2874
+ default: void 0
2875
+ }
2876
+ },
2877
+ emits: [
2878
+ "change",
2879
+ "update:document",
2880
+ "error",
2881
+ "ready",
2882
+ "rename",
2883
+ "menu-action",
2884
+ "mode-change"
2885
+ ],
2886
+ setup(e, { expose: n, emit: r }) {
2887
+ let i = e, a = r, o = I(i.mode), s = w(() => i.readOnly || o.value === "viewing");
2888
+ f(w(() => i.i18n));
2889
+ let { t: l } = t(w(() => i.i18n)), u = I(null), d = I(null), g = I(null), v = I(0), b = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Set(), te = new Ze(), C = I(!1), ie = I(!1), ae = I(!1), se = I(!1), A = I(!1), ce = I(!1), L = I(i.showOutline), B = I(!1), U = I(!1), W = I(!1), pe = I(null), K = fe([]), he = fe([]), ge = fe([]), { zoom: q, zoomPercent: _e, isMinZoom: ve, isMaxZoom: ye, setZoom: be, zoomIn: xe, zoomOut: Se, handleWheel: Ce, handleKeyDown: we, installShortcuts: Te, ZOOM_PRESETS: Ee } = ne(i.initialZoom);
2890
+ Te();
2891
+ let { editorView: J, isReady: De, parseError: Oe, layout: ke, loadBuffer: Ae, loadDocument: je, save: Me, focus: Ne, destroy: Pe, getDocument: Y, getCommands: X, reLayout: Ie } = re({
2892
+ hiddenContainer: u,
2893
+ pagesContainer: d,
2894
+ readOnly: s,
2895
+ externalPlugins: i.externalPlugins,
2896
+ syncCoordinator: te,
2897
+ onChange: (e) => {
2898
+ a("change", e), a("update:document", e), b.forEach((t) => t(e));
2899
+ },
2900
+ onError: (e) => a("error", e),
2901
+ onSelectionUpdate: () => {
2902
+ v.value++, er();
2903
+ let e = rt(J.value);
2904
+ x.forEach((t) => t(e));
2905
+ }
2906
+ }), Z = w(() => {
2907
+ v.value;
2908
+ let e = Y();
2909
+ if (!e?.package?.document) return null;
2910
+ let t = e.package.document;
2911
+ return t.finalSectionProperties ?? t.sections?.[0]?.properties ?? null;
2912
+ }), Le = w(() => (v.value, Y()?.package?.theme ?? i.theme ?? null)), Re = w(() => {
2913
+ let e = [];
2914
+ return U.value && e.push(`translateX(-${me}px)`), q.value !== 1 && e.push(`scale(${q.value})`), {
2915
+ transform: e.length > 0 ? e.join(" ") : void 0,
2916
+ transformOrigin: "top center",
2917
+ transition: "transform 0.2s ease"
2918
+ };
2919
+ }), ze = w(() => ({
2920
+ paddingLeft: "20px",
2921
+ paddingRight: 20 + (U.value ? me * 2 : 0) + "px",
2922
+ transition: "padding 0.2s ease"
2923
+ })), Be = w(() => {
2924
+ let e = Z.value;
2925
+ return Fe(e?.pageWidth ?? 12240) * q.value;
2926
+ }), Ve = w(() => {
2927
+ let e = /* @__PURE__ */ new Set();
2928
+ for (let t of K.value) t.parentId == null && t.done && e.add(t.id);
2929
+ return e;
2930
+ }), He = w(() => {
2931
+ v.value;
2932
+ let e = J.value;
2933
+ if (!e) return [];
2934
+ let t = /* @__PURE__ */ new Set(), n = [];
2935
+ return e.state.doc.descendants((e) => {
2936
+ let r = e.attrs?.bookmarks;
2937
+ if (!r) return !0;
2938
+ for (let e of r) {
2939
+ let r = e.name;
2940
+ !r || r.startsWith("_") || t.has(r) || (t.add(r), n.push({
2941
+ name: r,
2942
+ label: r
2943
+ }));
2944
+ }
2945
+ return !0;
2946
+ }), n.sort((e, t) => e.name.localeCompare(t.name));
2947
+ }), { floatingCommentBtn: Ue, pendingCommentRange: We, addCommentYPosition: Ge, sidebarAutoOpenedRef: Ke, extractCommentsAndChanges: qe, handleAddComment: Je, handleCancelAddComment: Ye, handleStartAddComment: Xe, handleMarkerClick: Qe } = xn({
2948
+ editorView: J,
2949
+ getDocument: Y,
2950
+ comments: K,
2951
+ trackedChanges: he,
2952
+ resolvedCommentIds: Ve,
2953
+ activeSidebarItem: pe,
2954
+ showSidebar: U,
2955
+ isAddingComment: W,
2956
+ readOnly: s,
2957
+ zoom: q,
2958
+ stateTick: v,
2959
+ pagesRef: d,
2960
+ pagesViewportRef: g,
2961
+ emit: a
2962
+ }), { docxInputRef: $e, handleDocxFileChange: et, handleDocumentNameChange: tt, downloadCurrentDocument: nt, emitReadyAfterSidebarStateRefresh: it, loadDocumentBuffer: ot, loadDocument: st, save: ct } = cn({
2963
+ loadBuffer: Ae,
2964
+ loadParsedDocument: je,
2965
+ getDocument: Y,
2966
+ saveBlob: Me,
2967
+ extractCommentsAndChanges: qe,
2968
+ emit: a,
2969
+ documentName: () => i.documentName,
2970
+ onDocumentNameChange: i.onDocumentNameChange,
2971
+ nextTick: j
2972
+ }), { hyperlinkPopupData: lt, handleHyperlinkSubmit: ut, handleHyperlinkRemove: dt, handleHyperlinkPopupNavigate: pt, handleHyperlinkPopupEdit: mt, handleHyperlinkPopupRemove: ht } = ln({
2973
+ editorView: J,
2974
+ getCommands: X
2975
+ }), { handleClearFormatting: gt, handleApplyStyle: yt, handleInsertPageBreak: bt, handleInsertSymbol: xt, applyFormatting: Ct, setParagraphStyle: wt } = un({
2976
+ editorView: J,
2977
+ getDocument: Y
2978
+ }), { handlePageSetupApply: Tt, handleLeftMarginChange: Et, handleRightMarginChange: kt, handleTopMarginChange: At, handleBottomMarginChange: jt, handleIndentLeftChange: Mt, handleIndentRightChange: Nt, handleFirstLineIndentChange: Pt, handleTabStopRemove: Ft } = dn({
2979
+ editorView: J,
2980
+ getDocument: Y,
2981
+ readOnly: s,
2982
+ stateTick: v,
2983
+ reLayout: Ie,
2984
+ emit: a
2985
+ }), { handleToggleOutline: It, handleOutlineNavigate: Lt, handleToggleSidebar: Rt, handleEditorScrollMouseDown: zt } = fn({
2986
+ editorView: J,
2987
+ showOutline: L,
2988
+ showSidebar: U,
2989
+ outlineHeadings: ge,
2990
+ activeSidebarItem: pe,
2991
+ extractCommentsAndChanges: qe
2992
+ });
2993
+ pn({
2994
+ showKeyboardShortcuts: B,
2995
+ showFindReplace: C,
2996
+ showHyperlink: ae,
2997
+ handleZoomKeyDown: we,
2998
+ disableFindReplaceShortcuts: () => i.disableFindReplaceShortcuts
2999
+ });
3000
+ let { addComment: Bt, replyToComment: Vt, resolveComment: Ht, proposeChange: Ut, handleCommentReply: Wt, handleCommentUnresolve: Gt, handleCommentDelete: Kt, handleAcceptChange: qt, handleRejectChange: Jt, handleTrackedChangeReply: Yt } = hn({
3001
+ editorView: J,
3002
+ getDocument: Y,
3003
+ comments: K,
3004
+ trackedChanges: he,
3005
+ showSidebar: U,
3006
+ isAddingComment: W,
3007
+ pendingCommentRange: We,
3008
+ contentChangeSubscribers: b,
3009
+ extractCommentsAndChanges: qe,
3010
+ emit: a
3011
+ }), { selectedImage: Q, imageInteracting: Xt, imageToolbarContext: Qt, handleInsertImage: $t, handleToolbarImageWrap: en, handleImageTransform: tn } = Sn({
3012
+ editorView: J,
3013
+ zoom: q,
3014
+ stateTick: v,
3015
+ getCommands: X
3016
+ }), nn = S(), rn = null, { tableInsertButton: an, hfEdit: $, scrollPageInfo: on, resolvePos: mn, setPmSelection: gn, scrollVisiblePositionIntoView: _n, handlePagesMouseDown: vn, handlePagesMouseMove: yn, handlePagesClick: bn, handlePagesDoubleClick: Cn, handleTableInsertClick: wn, clearTableInsertTimer: Tn, handleHfSave: En, handleHfRemove: Dn } = jn({
3017
+ editorView: J,
3018
+ pagesRef: d,
3019
+ pagesViewportRef: g,
3020
+ selectedImage: Q,
3021
+ imageInteracting: Xt,
3022
+ hyperlinkPopupData: lt,
3023
+ readOnly: s,
3024
+ zoom: q,
3025
+ layout: ke,
3026
+ tableResize: nn,
3027
+ getCommands: X,
3028
+ getDocument: Y,
3029
+ reLayout: Ie,
3030
+ emit: a,
3031
+ clearOverlay: $n
3032
+ }), { contextMenu: On, imageContextMenu: An, imageContextMenuTextActions: Un, handleContextMenu: Wn, handleSelectedImageContextMenu: Gn, handleImageWrapSelect: Kn, handleContextMenuAction: qn } = kn({
3033
+ editorView: J,
3034
+ selectedImage: Q,
3035
+ zoom: q,
3036
+ showImageProperties: A,
3037
+ getCommands: X,
3038
+ clearOverlay: $n,
3039
+ setPmSelection: gn,
3040
+ resolvePos: mn
3041
+ }), { handleMenuAction: Jn, handleMenuTableInsert: Yn } = Nn({
3042
+ editorView: J,
3043
+ getCommands: X,
3044
+ docxInputRef: $e,
3045
+ showPageSetup: ce,
3046
+ showInsertImage: ie,
3047
+ showHyperlink: ae,
3048
+ showInsertSymbol: se,
3049
+ showKeyboardShortcuts: B,
3050
+ handleClearFormatting: gt,
3051
+ handleInsertPageBreak: bt,
3052
+ handleToggleOutline: It,
3053
+ handleToggleSidebar: Rt,
3054
+ downloadCurrentDocument: nt,
3055
+ emit: a
3056
+ });
3057
+ Pn({
3058
+ documentBuffer: () => i.documentBuffer,
3059
+ document: () => i.document,
3060
+ loadDocumentBuffer: ot,
3061
+ loadDocument: st,
3062
+ sidebarAutoOpenedRef: Ke
3063
+ });
3064
+ let Xn = () => J.value, Zn = () => d.value;
3065
+ V(() => i.mode, (e) => {
3066
+ e && e !== o.value && (o.value = e);
3067
+ }), V(() => i.showOutline, (e) => {
3068
+ L.value = !!e;
3069
+ });
3070
+ function Qn(e) {
3071
+ o.value !== e && (o.value = e, a("mode-change", e));
3072
+ }
3073
+ P(() => {
3074
+ rn = nn.install();
3075
+ }), N(() => {
3076
+ rn?.();
3077
+ });
3078
+ function $n() {
3079
+ tr.clearOverlay();
3080
+ }
3081
+ function er() {
3082
+ tr.updateSelectionOverlay();
3083
+ }
3084
+ let tr = Mn({
3085
+ editorView: J,
3086
+ pagesRef: d,
3087
+ selectedImage: Q
3088
+ });
3089
+ N(() => {
3090
+ $n();
3091
+ });
3092
+ let { exposed: nr } = Fn({
3093
+ editorView: J,
3094
+ layout: ke,
3095
+ pagesRef: d,
3096
+ pagesViewportRef: g,
3097
+ zoom: q,
3098
+ comments: K,
3099
+ focus: Ne,
3100
+ destroy: Pe,
3101
+ getDocument: Y,
3102
+ setZoom: be,
3103
+ save: ct,
3104
+ loadDocument: st,
3105
+ loadDocumentBuffer: ot,
3106
+ addComment: Bt,
3107
+ replyToComment: Vt,
3108
+ resolveComment: Ht,
3109
+ proposeChange: Ut,
3110
+ applyFormatting: Ct,
3111
+ setParagraphStyle: wt,
3112
+ scrollVisiblePositionIntoView: _n,
3113
+ contentChangeSubscribers: b,
3114
+ selectionChangeSubscribers: x,
3115
+ onPrint: i.onPrint
3116
+ });
3117
+ return n(nr), (t, n) => (F(), D("div", {
3118
+ class: le([
3119
+ "docx-editor-vue ep-root paged-editor",
3120
+ e.className,
3121
+ {
3122
+ "paged-editor--readonly": s.value,
3123
+ "paged-editor--hf-editing": z($) !== null,
3124
+ "paged-editor--editing-header": z($)?.position === "header",
3125
+ "paged-editor--editing-footer": z($)?.position === "footer"
3126
+ }
3127
+ ]),
3128
+ style: M(e.style)
3129
+ }, [
3130
+ O("div", In, [k(Dt, {
3131
+ "show-menu-bar": e.showMenuBar,
3132
+ "document-name": e.documentName,
3133
+ "document-name-editable": e.documentNameEditable,
3134
+ "render-logo": e.renderLogo,
3135
+ "render-title-bar-right": e.renderTitleBarRight,
3136
+ onRename: z(tt),
3137
+ onMenuAction: z(Jn),
3138
+ onInsertTable: z(Yn)
3139
+ }, {
3140
+ "title-bar-left": H(() => [ue(t.$slots, "title-bar-left")]),
3141
+ "title-bar-right": H(() => [ue(t.$slots, "title-bar-right")]),
3142
+ _: 3
3143
+ }, 8, [
3144
+ "show-menu-bar",
3145
+ "document-name",
3146
+ "document-name-editable",
3147
+ "render-logo",
3148
+ "render-title-bar-right",
3149
+ "onRename",
3150
+ "onMenuAction",
3151
+ "onInsertTable"
3152
+ ]), e.showToolbar ? (F(), T(y, {
3153
+ key: 0,
3154
+ view: z(J),
3155
+ "get-commands": z(X),
3156
+ "state-tick": v.value,
3157
+ "zoom-percent": z(_e),
3158
+ "is-min-zoom": z(ve),
3159
+ "is-max-zoom": z(ye),
3160
+ "zoom-presets": z(Ee),
3161
+ "show-zoom-control": e.showZoomControl,
3162
+ "editor-mode": o.value,
3163
+ "comments-sidebar-open": U.value,
3164
+ "image-context": z(Qt),
3165
+ theme: Le.value,
3166
+ "font-families": e.fontFamilies,
3167
+ onInsertLink: n[0] ||= (e) => ae.value = !0,
3168
+ onApplyStyle: z(yt),
3169
+ onZoomIn: z(xe),
3170
+ onZoomOut: z(Se),
3171
+ onZoomSet: z(be),
3172
+ onToggleSidebar: z(Rt),
3173
+ onModeChange: Qn,
3174
+ onImageWrapType: z(en),
3175
+ onImageProperties: n[1] ||= (e) => A.value = !0,
3176
+ onImageTransform: z(tn)
3177
+ }, oe({
3178
+ "table-context": H(() => [k(h, {
3179
+ view: z(J),
3180
+ "get-commands": z(X),
3181
+ "state-tick": v.value,
3182
+ theme: Le.value
3183
+ }, null, 8, [
3184
+ "view",
3185
+ "get-commands",
3186
+ "state-tick",
3187
+ "theme"
3188
+ ])]),
3189
+ _: 2
3190
+ }, [e.toolbarExtra ? {
3191
+ name: "toolbar-extra",
3192
+ fn: H(() => [(F(), T(de(e.toolbarExtra)))]),
3193
+ key: "0"
3194
+ } : {
3195
+ name: "toolbar-extra",
3196
+ fn: H(() => [ue(t.$slots, "toolbar-extra")]),
3197
+ key: "1"
3198
+ }]), 1032, [
3199
+ "view",
3200
+ "get-commands",
3201
+ "state-tick",
3202
+ "zoom-percent",
3203
+ "is-min-zoom",
3204
+ "is-max-zoom",
3205
+ "zoom-presets",
3206
+ "show-zoom-control",
3207
+ "editor-mode",
3208
+ "comments-sidebar-open",
3209
+ "image-context",
3210
+ "theme",
3211
+ "font-families",
3212
+ "onApplyStyle",
3213
+ "onZoomIn",
3214
+ "onZoomOut",
3215
+ "onZoomSet",
3216
+ "onToggleSidebar",
3217
+ "onImageWrapType",
3218
+ "onImageTransform"
3219
+ ])) : E("", !0)]),
3220
+ k(Ot, {
3221
+ "show-find-replace": C.value,
3222
+ "onUpdate:showFindReplace": n[2] ||= (e) => C.value = e,
3223
+ "show-insert-image": ie.value,
3224
+ "onUpdate:showInsertImage": n[3] ||= (e) => ie.value = e,
3225
+ "show-hyperlink": ae.value,
3226
+ "onUpdate:showHyperlink": n[4] ||= (e) => ae.value = e,
3227
+ "show-insert-symbol": se.value,
3228
+ "onUpdate:showInsertSymbol": n[5] ||= (e) => se.value = e,
3229
+ "show-image-properties": A.value,
3230
+ "onUpdate:showImageProperties": n[6] ||= (e) => A.value = e,
3231
+ "show-page-setup": ce.value,
3232
+ "onUpdate:showPageSetup": n[7] ||= (e) => ce.value = e,
3233
+ "show-keyboard-shortcuts": B.value,
3234
+ "onUpdate:showKeyboardShortcuts": n[8] ||= (e) => B.value = e,
3235
+ view: z(J),
3236
+ bookmarks: He.value,
3237
+ "selected-image-pm-pos": z(Q)?.pmPos ?? null,
3238
+ "section-properties": Z.value,
3239
+ onInsertImage: z($t),
3240
+ onInsertSymbol: z(xt),
3241
+ onHyperlinkSubmit: z(ut),
3242
+ onHyperlinkRemove: z(dt),
3243
+ onPageSetupApply: z(Tt)
3244
+ }, null, 8, [
3245
+ "show-find-replace",
3246
+ "show-insert-image",
3247
+ "show-hyperlink",
3248
+ "show-insert-symbol",
3249
+ "show-image-properties",
3250
+ "show-page-setup",
3251
+ "show-keyboard-shortcuts",
3252
+ "view",
3253
+ "bookmarks",
3254
+ "selected-image-pm-pos",
3255
+ "section-properties",
3256
+ "onInsertImage",
3257
+ "onInsertSymbol",
3258
+ "onHyperlinkSubmit",
3259
+ "onHyperlinkRemove",
3260
+ "onPageSetupApply"
3261
+ ]),
3262
+ z(Oe) ? (F(), D("div", Ln, R(z(Oe)), 1)) : E("", !0),
3263
+ !z(De) && !z(Oe) ? (F(), D("div", Rn, "Loading...")) : E("", !0),
3264
+ O("div", {
3265
+ ref_key: "hiddenPmRef",
3266
+ ref: u,
3267
+ class: "docx-editor-vue__hidden-pm paged-editor__hidden-pm"
3268
+ }, null, 512),
3269
+ O("div", {
3270
+ class: "docx-editor-vue__editor-scroll",
3271
+ onMousedown: n[31] ||= (...e) => z(zt) && z(zt)(...e)
3272
+ }, [e.showRuler && Z.value ? (F(), D("div", {
3273
+ key: 0,
3274
+ class: "docx-editor-vue__ruler-row",
3275
+ style: M(ze.value)
3276
+ }, [k(_, {
3277
+ "section-props": Z.value,
3278
+ zoom: z(q),
3279
+ editable: !s.value,
3280
+ onLeftMarginChange: z(Et),
3281
+ onRightMarginChange: z(kt),
3282
+ onIndentLeftChange: z(Mt),
3283
+ onIndentRightChange: z(Nt),
3284
+ onFirstLineIndentChange: z(Pt),
3285
+ onTabStopRemove: z(Ft)
3286
+ }, null, 8, [
3287
+ "section-props",
3288
+ "zoom",
3289
+ "editable",
3290
+ "onLeftMarginChange",
3291
+ "onRightMarginChange",
3292
+ "onIndentLeftChange",
3293
+ "onIndentRightChange",
3294
+ "onFirstLineIndentChange",
3295
+ "onTabStopRemove"
3296
+ ])], 4)) : E("", !0), O("div", zn, [
3297
+ O("div", {
3298
+ ref_key: "pagesViewportRef",
3299
+ ref: g,
3300
+ class: "docx-editor-vue__pages-viewport",
3301
+ onMousedown: n[22] ||= (...e) => z(vn) && z(vn)(...e),
3302
+ onMousemove: n[23] ||= (...e) => z(yn) && z(yn)(...e),
3303
+ onClick: n[24] ||= (...e) => z(bn) && z(bn)(...e),
3304
+ onDblclick: n[25] ||= (...e) => z(Cn) && z(Cn)(...e),
3305
+ onContextmenu: n[26] ||= G((...e) => z(Wn) && z(Wn)(...e), ["prevent"]),
3306
+ onWheel: n[27] ||= (...e) => z(Ce) && z(Ce)(...e)
3307
+ }, [
3308
+ e.showRuler && Z.value ? (F(), D("div", Bn, [k(p, {
3309
+ "section-props": Z.value,
3310
+ zoom: z(q),
3311
+ editable: !s.value,
3312
+ onTopMarginChange: z(At),
3313
+ onBottomMarginChange: z(jt)
3314
+ }, null, 8, [
3315
+ "section-props",
3316
+ "zoom",
3317
+ "editable",
3318
+ "onTopMarginChange",
3319
+ "onBottomMarginChange"
3320
+ ])])) : E("", !0),
3321
+ O("div", {
3322
+ ref_key: "pagesRef",
3323
+ ref: d,
3324
+ class: "docx-editor-vue__pages paged-editor__pages",
3325
+ style: M(Re.value)
3326
+ }, null, 4),
3327
+ k(St, {
3328
+ "is-open": z($) !== null,
3329
+ position: z($)?.position ?? "header",
3330
+ "header-footer": z($)?.headerFooter ?? null,
3331
+ styles: z(Y)()?.package?.styles ?? null,
3332
+ theme: z(Y)()?.package?.theme ?? null,
3333
+ "target-rect": z($)?.targetRect ?? null,
3334
+ onSave: z(En),
3335
+ onClose: n[9] ||= (e) => $.value = null,
3336
+ onRemove: z(Dn)
3337
+ }, null, 8, [
3338
+ "is-open",
3339
+ "position",
3340
+ "header-footer",
3341
+ "styles",
3342
+ "theme",
3343
+ "target-rect",
3344
+ "onSave",
3345
+ "onRemove"
3346
+ ]),
3347
+ k(ft, {
3348
+ "image-info": z(Q),
3349
+ zoom: z(q),
3350
+ view: z(J),
3351
+ onOpenProperties: n[10] ||= (e) => A.value = !0,
3352
+ onDeselect: n[11] ||= (e) => Q.value = null,
3353
+ onInteractStart: n[12] ||= (e) => Xt.value = !0,
3354
+ onInteractEnd: n[13] ||= (e) => Xt.value = !1,
3355
+ onContextMenu: z(Gn)
3356
+ }, null, 8, [
3357
+ "image-info",
3358
+ "zoom",
3359
+ "view",
3360
+ "onContextMenu"
3361
+ ]),
3362
+ k(at, {
3363
+ "get-view": Xn,
3364
+ "get-pages-container": Zn,
3365
+ zoom: z(q),
3366
+ "transaction-version": v.value,
3367
+ "sync-coordinator": z(te)
3368
+ }, null, 8, [
3369
+ "zoom",
3370
+ "transaction-version",
3371
+ "sync-coordinator"
3372
+ ]),
3373
+ z(Ue) && !W.value && !s.value ? (F(), D("button", {
3374
+ key: 1,
3375
+ type: "button",
3376
+ class: "docx-editor-vue__floating-comment",
3377
+ style: M({
3378
+ top: z(Ue).top + "px",
3379
+ left: z(Ue).left + "px"
3380
+ }),
3381
+ title: z(l)("comments.addComment"),
3382
+ onMousedown: n[14] ||= G((...e) => z(Xe) && z(Xe)(...e), ["prevent", "stop"])
3383
+ }, [k(c, {
3384
+ name: "add_comment",
3385
+ size: 16
3386
+ })], 44, Vn)) : E("", !0),
3387
+ z(an) && !s.value ? (F(), D("button", {
3388
+ key: 2,
3389
+ type: "button",
3390
+ class: "docx-editor-vue__table-insert-btn",
3391
+ style: M({
3392
+ left: z(an).x + "px",
3393
+ top: z(an).y + "px"
3394
+ }),
3395
+ title: z(an).type === "row" ? "Insert row below" : "Insert column to the right",
3396
+ "aria-label": z(an).type === "row" ? "Insert row below" : "Insert column to the right",
3397
+ onMousedown: n[15] ||= (...e) => z(wn) && z(wn)(...e),
3398
+ onMouseenter: n[16] ||= (...e) => z(Tn) && z(Tn)(...e),
3399
+ onMouseleave: n[17] ||= (e) => an.value = null
3400
+ }, [...n[36] ||= [O("svg", {
3401
+ width: "12",
3402
+ height: "12",
3403
+ viewBox: "0 0 12 12",
3404
+ fill: "none"
3405
+ }, [O("path", {
3406
+ d: "M6 1v10M1 6h10",
3407
+ stroke: "currentColor",
3408
+ "stroke-width": "1.5",
3409
+ "stroke-linecap": "round"
3410
+ })], -1)]], 44, Hn)) : E("", !0),
3411
+ k(ee, {
3412
+ comments: K.value,
3413
+ "pages-container": d.value,
3414
+ zoom: z(q),
3415
+ "page-width-px": Be.value,
3416
+ "sidebar-open": U.value,
3417
+ "resolved-comment-ids": Ve.value,
3418
+ onMarkerClick: z(Qe)
3419
+ }, null, 8, [
3420
+ "comments",
3421
+ "pages-container",
3422
+ "zoom",
3423
+ "page-width-px",
3424
+ "sidebar-open",
3425
+ "resolved-comment-ids",
3426
+ "onMarkerClick"
3427
+ ]),
3428
+ k(m, {
3429
+ "is-open": U.value,
3430
+ comments: K.value,
3431
+ "tracked-changes": he.value,
3432
+ "is-adding-comment": W.value,
3433
+ "add-comment-y-position": z(Ge),
3434
+ "show-resolved": !0,
3435
+ "pages-container": d.value,
3436
+ "page-width-px": Be.value,
3437
+ zoom: z(q),
3438
+ "active-item-id": pe.value,
3439
+ onClose: n[18] ||= (e) => U.value = !1,
3440
+ onAddComment: z(Je),
3441
+ onCancelAddComment: z(Ye),
3442
+ onCommentReply: z(Wt),
3443
+ onCommentResolve: z(Ht),
3444
+ onCommentUnresolve: z(Gt),
3445
+ onCommentDelete: z(Kt),
3446
+ onAcceptChange: z(qt),
3447
+ onRejectChange: z(Jt),
3448
+ onTrackedChangeReply: z(Yt),
3449
+ "onUpdate:activeItemId": n[19] ||= (e) => pe.value = e
3450
+ }, null, 8, [
3451
+ "is-open",
3452
+ "comments",
3453
+ "tracked-changes",
3454
+ "is-adding-comment",
3455
+ "add-comment-y-position",
3456
+ "pages-container",
3457
+ "page-width-px",
3458
+ "zoom",
3459
+ "active-item-id",
3460
+ "onAddComment",
3461
+ "onCancelAddComment",
3462
+ "onCommentReply",
3463
+ "onCommentResolve",
3464
+ "onCommentUnresolve",
3465
+ "onCommentDelete",
3466
+ "onAcceptChange",
3467
+ "onRejectChange",
3468
+ "onTrackedChangeReply"
3469
+ ]),
3470
+ k(sn, {
3471
+ data: z(lt),
3472
+ "read-only": s.value,
3473
+ onNavigate: z(pt),
3474
+ onCopy: n[20] ||= (e) => lt.value = null,
3475
+ onEdit: z(mt),
3476
+ onRemove: z(ht),
3477
+ onClose: n[21] ||= (e) => lt.value = null
3478
+ }, null, 8, [
3479
+ "data",
3480
+ "read-only",
3481
+ "onNavigate",
3482
+ "onEdit",
3483
+ "onRemove"
3484
+ ])
3485
+ ], 544),
3486
+ !L.value && e.showOutlineButton ? (F(), D("button", {
3487
+ key: 0,
3488
+ type: "button",
3489
+ class: "docx-editor-vue__outline-toggle",
3490
+ title: "Show document outline",
3491
+ onClick: n[28] ||= (...e) => z(It) && z(It)(...e),
3492
+ onMousedown: n[29] ||= G(() => {}, ["stop"])
3493
+ }, [k(c, {
3494
+ name: "format_list_bulleted",
3495
+ size: 20
3496
+ })], 32)) : E("", !0),
3497
+ z(on).totalPages > 1 ? (F(), T(vt, {
3498
+ key: 1,
3499
+ "current-page": z(on).currentPage,
3500
+ "total-pages": z(on).totalPages,
3501
+ visible: z(on).visible
3502
+ }, null, 8, [
3503
+ "current-page",
3504
+ "total-pages",
3505
+ "visible"
3506
+ ])) : E("", !0),
3507
+ k(_t, {
3508
+ "is-open": L.value,
3509
+ headings: ge.value,
3510
+ onClose: n[30] ||= (e) => L.value = !1,
3511
+ onNavigate: z(Lt)
3512
+ }, null, 8, [
3513
+ "is-open",
3514
+ "headings",
3515
+ "onNavigate"
3516
+ ])
3517
+ ])], 32),
3518
+ O("input", {
3519
+ ref_key: "docxInputRef",
3520
+ ref: $e,
3521
+ type: "file",
3522
+ accept: ".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",
3523
+ style: { display: "none" },
3524
+ onChange: n[32] ||= (...e) => z(et) && z(et)(...e)
3525
+ }, null, 544),
3526
+ k(Zt, {
3527
+ "read-only": s.value,
3528
+ "context-menu": z(On),
3529
+ "image-context-menu": z(An),
3530
+ "image-context-menu-text-actions": z(Un),
3531
+ "can-open-image-properties": !!z(Q),
3532
+ onContextMenuAction: z(qn),
3533
+ onCloseContextMenu: n[33] ||= (e) => z(On).isOpen = !1,
3534
+ onImageWrapSelect: z(Kn),
3535
+ onCloseImageContextMenu: n[34] ||= (e) => An.value = null,
3536
+ onOpenImageProperties: n[35] ||= (e) => A.value = !0
3537
+ }, null, 8, [
3538
+ "read-only",
3539
+ "context-menu",
3540
+ "image-context-menu",
3541
+ "image-context-menu-text-actions",
3542
+ "can-open-image-properties",
3543
+ "onContextMenuAction",
3544
+ "onImageWrapSelect"
3545
+ ])
3546
+ ], 6));
3547
+ }
3548
+ });
3549
+ //#endregion
3550
+ //#region src/renderAsync.ts
3551
+ async function Wn(e, t, n = {}) {
3552
+ let r = e instanceof ArrayBuffer ? e : await _e(e), i = null, a = null, o = !1, s = {
3553
+ save: async () => {
3554
+ let e = await (i?.save() ?? Promise.resolve(null));
3555
+ return e ? new Blob([e], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }) : null;
3556
+ },
3557
+ getDocument: () => i?.getDocument() ?? null,
3558
+ focus: () => {
3559
+ i?.focus();
3560
+ },
3561
+ setZoom: (e) => {
3562
+ i?.setZoom(e);
3563
+ },
3564
+ scrollToParaId: (e) => i?.scrollToParaId(e) ?? !1,
3565
+ scrollToPosition: (e) => {
3566
+ i?.scrollToPosition(e);
3567
+ },
3568
+ destroy: () => {
3569
+ i?.destroy(), a?.unmount(), a = null;
3570
+ }
3571
+ };
3572
+ return new Promise((e, c) => {
3573
+ a = ae({ setup() {
3574
+ return () => ce(Un, {
3575
+ ...n,
3576
+ documentBuffer: r,
3577
+ showToolbar: n.showToolbar ?? !0,
3578
+ readOnly: n.readOnly ?? !1,
3579
+ ref: (e) => {
3580
+ i = e ?? null;
3581
+ },
3582
+ onReady: () => {
3583
+ n.onReady?.(), o || (o = !0, e(s));
3584
+ },
3585
+ onError: (e) => {
3586
+ n.onError?.(e), o || (o = !0, c(e));
3587
+ },
3588
+ onChange: n.onChange,
3589
+ onRename: n.onRename,
3590
+ onMenuAction: n.onMenuAction,
3591
+ onModeChange: n.onModeChange
3592
+ });
3593
+ } }), a.mount(t);
3594
+ });
3595
+ }
3596
+ //#endregion
3597
+ //#region src/index.ts
3598
+ var Gn = "0.0.2";
3599
+ //#endregion
3600
+ export { Un as DocxEditor, Gn as VERSION, r as defaultLocale, a as i18nPlugin, f as provideLocale, Wn as renderAsync, n as useTranslation };