@stll/folio-vue 0.8.1 → 0.10.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 (52) hide show
  1. package/dist/ListButtons-BcB7qvzQ.cjs +4 -0
  2. package/dist/{ListButtons-DXqMvba3.js → ListButtons-rpVlLZJ8.js} +689 -710
  3. package/dist/SplitCellDialog-B_TOoiMw.cjs +15 -0
  4. package/dist/{WatermarkDialog-r4wmldt4.js → SplitCellDialog-DRQuZsA3.js} +1537 -1604
  5. package/dist/components/AutocompleteCaretOverlay.types.d.ts +18 -0
  6. package/dist/components/DocxEditor/pagedEditorRef.d.ts +16 -3
  7. package/dist/components/DocxEditor/types.d.ts +27 -0
  8. package/dist/composables/index.d.ts +2 -2
  9. package/dist/composables/useColorMode.d.ts +17 -4
  10. package/dist/composables/useContextMenus.d.ts +3 -0
  11. package/dist/composables/useDocxEditor.d.ts +47 -0
  12. package/dist/composables/useDocxEditorRefApi.d.ts +14 -0
  13. package/dist/composables/useFindReplace.d.ts +24 -22
  14. package/dist/composables/useFontLifecycle.d.ts +21 -0
  15. package/dist/composables/useKeyboardShortcuts.d.ts +0 -1
  16. package/dist/composables/usePagesPointer.d.ts +14 -13
  17. package/dist/composables/useRemoteSelectionSync.d.ts +10 -0
  18. package/dist/composables/useSelectionSync.d.ts +17 -30
  19. package/dist/composables.cjs +2 -2
  20. package/dist/composables.js +93 -81
  21. package/dist/dialogs.cjs +1 -1
  22. package/dist/dialogs.js +2 -2
  23. package/dist/folio-vue.css +1 -1
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.d.ts +4 -1
  26. package/dist/index.js +2249 -1401
  27. package/dist/renderAsync.d.ts +4 -0
  28. package/dist/styles/zIndex.d.ts +1 -0
  29. package/dist/styles.cjs +1 -1
  30. package/dist/styles.js +1 -1
  31. package/dist/ui/folio-ui.d.ts +1 -1
  32. package/dist/ui.cjs +1 -1
  33. package/dist/ui.js +10 -10
  34. package/dist/useFindReplace-CL8Rbc3y.js +59 -0
  35. package/dist/useFindReplace-ZCrdvwEk.cjs +1 -0
  36. package/dist/useZoom-DBbzwfMG.cjs +1 -0
  37. package/dist/useZoom-DwDDS7hq.js +749 -0
  38. package/dist/utils/colorMode.d.ts +3 -4
  39. package/dist/utils/embeddedFonts.d.ts +7 -0
  40. package/dist/utils/fontFaces.d.ts +10 -0
  41. package/dist/utils/hostFonts.d.ts +1 -5
  42. package/dist/zIndex-CYoLNG_N.cjs +1 -0
  43. package/dist/{zIndex-BY0qa8Au.js → zIndex-Ei9BbHSW.js} +1 -0
  44. package/package.json +1 -1
  45. package/dist/ListButtons-BvsV1yti.cjs +0 -4
  46. package/dist/WatermarkDialog-DHfk8jrg.cjs +0 -15
  47. package/dist/components/sidebar/resolveItemPositions.d.ts +0 -22
  48. package/dist/composables/useHostCallbacks.d.ts +0 -24
  49. package/dist/composables/useMenuActions.d.ts +0 -36
  50. package/dist/useZoom-C7jhL696.cjs +0 -1
  51. package/dist/useZoom-zJvuJlUd.js +0 -615
  52. package/dist/zIndex-dFsQbASx.cjs +0 -1
@@ -0,0 +1,749 @@
1
+ import { computed as e, inject as t, onBeforeUnmount as n, onMounted as r, onScopeDispose as i, provide as a, ref as o, shallowRef as s, toValue as c, watch as l, watchEffect as u } from "vue";
2
+ import { getMargins as d, getPageSize as f, twipsToPixels as p } from "@stll/folio-core/paged-layout/sectionGeometry";
3
+ import { createAnonymizationDecorationsPlugin as m } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations";
4
+ import { autocompleteSuggestionPlugin as h } from "@stll/folio-core/prosemirror/plugins/autocompleteSuggestion";
5
+ import { createTemplateDirectivesPlugin as g } from "@stll/folio-core/prosemirror/plugins/templateDirectives";
6
+ import { createSuggestionModePlugin as ee, setSuggestionMode as te } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
7
+ import { createFolioEditor as _ } from "@stll/folio-core/controller/folioEditor";
8
+ import { createFolioEditorEmitter as ne } from "@stll/folio-core/controller/folioEditorEvents";
9
+ import { loadCollaborationModules as v } from "@stll/folio-core/controller/collaborationModules";
10
+ import { createHeaderFooterEditorManager as re } from "@stll/folio-core/controller/headerFooterEditorManager";
11
+ import { createNoteEditorManager as ie } from "@stll/folio-core/controller/noteEditorManager";
12
+ import { collectRemoteSelections as ae, createHiddenEditorManager as oe, createHiddenEditorState as se } from "@stll/folio-core/controller/hiddenEditorManager";
13
+ import { runLayoutPipeline as ce } from "@stll/folio-core/controller/layoutPipeline";
14
+ import { browserClock as le, createLayoutScheduler as ue } from "@stll/folio-core/controller/layoutScheduler";
15
+ import { createLayoutSession as de } from "@stll/folio-core/controller/layoutSession";
16
+ import { parseDocx as fe } from "@stll/folio-core/docx/parser";
17
+ import { getFootnoteText as y } from "@stll/folio-core/docx/footnoteParser";
18
+ import { convertHeaderFooterPmDocToContent as b, convertHeaderFooterToContent as pe } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
19
+ import { resolveSectionHeaderFooterRefs as me } from "@stll/folio-core/layout-engine";
20
+ import { LayoutPainter as he } from "@stll/folio-core/layout-painter";
21
+ import { LayoutSelectionGate as ge } from "@stll/folio-core/paged-layout/LayoutSelectionGate";
22
+ import { getTransactionDirtyRange as _e } from "@stll/folio-core/paged-layout/transactionDirtyRange";
23
+ import { fromProseDoc as ve } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
24
+ import { ExtensionManager as ye } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
25
+ import { getChangedParagraphIds as be, hasStructuralChanges as xe, hasUntrackedChanges as Se } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
26
+ import { createStarterKit as Ce } from "@stll/folio-core/prosemirror/extensions/StarterKit";
27
+ import { createTemplatePreviewValuesPlugin as we } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
28
+ import { templateSlashMenuPlugin as Te } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
29
+ import { resolveHeaderFooterContent as Ee } from "@stll/folio-core/utils/headerFooter";
30
+ import { findVerticalScrollParent as De } from "@stll/folio-core/utils/findVerticalScrollParent";
31
+ import { MIN_CELL_WIDTH_TWIPS as x, MIN_ROW_HEIGHT_TWIPS as Oe, TWIPS_PER_PIXEL as S, commitColumnResize as C, commitRightEdgeResize as ke, commitRowResize as Ae, readColumnWidthAt as je, readColumnWidths as Me, readRowHeight as Ne } from "@stll/folio-core/prosemirror/tableResize";
32
+ import { extractTrackedChanges as w } from "@stll/folio-core/prosemirror/utils/extractTrackedChanges";
33
+ import { ZOOM_MAX as T, ZOOM_MIN as Pe, ZOOM_STEP as E } from "@stll/folio-core/utils/zoom";
34
+ //#region src/utils/colorMode.ts
35
+ var Fe = "(prefers-color-scheme: dark)";
36
+ function Ie() {
37
+ return typeof window < "u" && typeof window.matchMedia == "function";
38
+ }
39
+ function Le(e, t) {
40
+ return e === "dark" || e === "system" && t;
41
+ }
42
+ function Re(e) {
43
+ if (!Ie()) return () => {};
44
+ let t = window.matchMedia(Fe);
45
+ e(t.matches);
46
+ let n = (t) => e(t.matches);
47
+ return t.addEventListener("change", n), () => t.removeEventListener("change", n);
48
+ }
49
+ //#endregion
50
+ //#region src/composables/useColorMode.ts
51
+ var D = "light", O = Symbol("folioColorMode"), k = (t = D) => {
52
+ a(O, e(() => c(t)));
53
+ }, A = { install(t, n = D) {
54
+ t.provide(O, e(() => c(n)));
55
+ } };
56
+ function j() {
57
+ let n = t(O, e(() => D)), i = o(!1), a = o(!1);
58
+ return r(() => {
59
+ i.value = !0;
60
+ }), u((e) => {
61
+ !i.value || n.value !== "system" || e(Re((e) => {
62
+ a.value = e;
63
+ }));
64
+ }), e(() => Le(n.value, i.value && a.value));
65
+ }
66
+ //#endregion
67
+ //#region src/composables/useDocxEditor.ts
68
+ var ze = 24, Be = 32, Ve = 96, He = 250, Ue = [];
69
+ function We(e) {
70
+ let t = e?.columnCount ?? 1;
71
+ if (t <= 1) return;
72
+ let n = {
73
+ count: t,
74
+ gap: p(e?.columnSpace ?? 720),
75
+ equalWidth: e?.equalWidth ?? !0
76
+ };
77
+ return e?.separator !== void 0 && (n.separator = e.separator), n;
78
+ }
79
+ function Ge(e, t, n, r, i, a) {
80
+ if (!e) return;
81
+ let o = t ? {
82
+ ...a,
83
+ rId: t
84
+ } : a, s = t ? n?.getView(t) : null;
85
+ return s ? b(s.state.doc, r, i, o) : pe(e, r, i, o);
86
+ }
87
+ function Ke(e, t, n, r, i) {
88
+ if (!e || e.size === 0) return;
89
+ let a = /* @__PURE__ */ new Map();
90
+ for (let [o, s] of e) {
91
+ let e = Ge(s, o, t, n, r, i);
92
+ e && a.set(o, e);
93
+ }
94
+ return a.size > 0 ? a : void 0;
95
+ }
96
+ function qe(e, t, n) {
97
+ let r = /* @__PURE__ */ new Map();
98
+ if (!n || !n.package.footnotes) return r;
99
+ let i = /* @__PURE__ */ new Map();
100
+ for (let e of n.package.footnotes) e.noteType && e.noteType !== "normal" || i.set(e.id, e);
101
+ for (let [n, a] of e) {
102
+ let e = [];
103
+ for (let n of a) {
104
+ let r = i.get(n);
105
+ if (!r) continue;
106
+ let a = t.get(n), o = a?.displayNumber ?? 0;
107
+ e.push({
108
+ displayNumber: String(o),
109
+ noteId: n,
110
+ text: y(r),
111
+ ...a ? { content: {
112
+ blocks: a.blocks,
113
+ measures: a.measures,
114
+ height: a.height
115
+ } } : {}
116
+ });
117
+ }
118
+ e.length > 0 && r.set(n, e);
119
+ }
120
+ return r;
121
+ }
122
+ var M = /* @__PURE__ */ new Set([
123
+ "black",
124
+ "blue",
125
+ "cyan",
126
+ "darkBlue",
127
+ "darkCyan",
128
+ "darkGray",
129
+ "darkGreen",
130
+ "darkMagenta",
131
+ "darkRed",
132
+ "darkYellow",
133
+ "green",
134
+ "lightGray",
135
+ "magenta",
136
+ "none",
137
+ "red",
138
+ "white",
139
+ "yellow"
140
+ ]);
141
+ function Je(e) {
142
+ let t = [], n = (e, r) => {
143
+ for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !M.has(String(i.attrs.color)) && t.push(`${r}.marks[${n}]=${JSON.stringify(i.attrs)}`);
144
+ e.forEach((e, t, i) => {
145
+ n(e, `${r}.content[${i}]`);
146
+ });
147
+ };
148
+ return n(e, "doc"), t.join("; ");
149
+ }
150
+ function Ye() {
151
+ return typeof document > "u" || !("fonts" in document) || document.fonts.status === "loaded";
152
+ }
153
+ function N(e) {
154
+ let { hiddenContainer: t, hiddenHeaderFooterContainer: n, noteEditorContainer: r, pagesContainer: a, readOnly: u = !1, pageGap: p = ze, showMarginGuides: y, marginGuideColor: b, documentKey: pe, password: De, editorMode: x, author: Oe, externalPlugins: S = [], collaboration: C, onAnonymizationMatchesChange: ke, showTemplateDirectives: Ae, onSlashMenuChange: je, onSlashMenuKeyAction: Me, onChange: Ne, onError: w, onSelectionUpdate: T, onEditorViewReady: Pe, onCopy: E, onCut: Fe, onPaste: Ie, onReadOnlyEditAttempt: Le, featureFlags: Re, onSelectiveSaveTripwire: D } = e, O = n ?? t, k = s(null), A = s(null), j = s(null), M = s(null), N = s([]), P = s(null), F = s(null), I = s(null), L = s([]), R = s([]), z = o(!1), B = o(null), V = o(!1), H = new ye(Ce());
155
+ H.buildSchema(), H.initializeRuntime();
156
+ let Xe = ee(!1), Ze = [Xe], Qe = h({ keymap: !0 }), $e = m({ onMatchesChange: (e) => ke?.(e) }), U = g(), et = Te({
157
+ onChange: (e) => je?.(e),
158
+ onKeyAction: (e) => Me?.(e) ?? !1
159
+ }), tt = we(), nt = () => c(Ae) === !0;
160
+ function rt() {
161
+ return [
162
+ Qe,
163
+ Xe,
164
+ ...S,
165
+ ...c(C)?.plugins ?? [],
166
+ $e,
167
+ ...nt() ? [U, et] : [],
168
+ tt
169
+ ];
170
+ }
171
+ let W = ne(), G = new ge(), it = de(), at = new he({
172
+ pageGap: p,
173
+ showShadow: !0
174
+ }), K = re({
175
+ getHost: () => O.value,
176
+ getDocument: () => k.value,
177
+ getStyles: () => k.value?.package.styles ?? null,
178
+ getTheme: () => k.value?.package.theme ?? null,
179
+ onTransaction: ({ rId: e, kind: t, view: n, docChanged: r, selectionChanged: i }) => {
180
+ if (r) {
181
+ V.value = !0;
182
+ let e = A.value;
183
+ e && Y.schedule(e.state, null);
184
+ }
185
+ if (r || i) {
186
+ let { from: r, to: i } = n.state.selection;
187
+ P.value = {
188
+ from: r,
189
+ kind: t,
190
+ rId: e,
191
+ to: i
192
+ }, T?.(n.state), W.emit("selectionChange", {
193
+ from: r,
194
+ to: i
195
+ });
196
+ }
197
+ G.requestRender();
198
+ }
199
+ }), ot = { current: null }, q = ie({
200
+ getHost: () => r?.value ?? null,
201
+ getPlugins: () => Ze,
202
+ getDocument: () => k.value,
203
+ getStyles: () => k.value?.package.styles ?? null,
204
+ getTheme: () => k.value?.package.theme ?? null,
205
+ onTransaction: ({ docChanged: e, selectionChanged: t, view: n }) => {
206
+ if (e) {
207
+ V.value = !0;
208
+ let e = k.value;
209
+ if (e) {
210
+ let t = ot.current?.snapshotDocument(e) ?? e;
211
+ k.value = t, Ne?.(t), W.emit("docChange", t);
212
+ }
213
+ let t = A.value;
214
+ t && Y.schedule(t.state, null);
215
+ }
216
+ if (e || t) {
217
+ T?.(n.state);
218
+ let { from: e, to: t } = n.state.selection;
219
+ W.emit("selectionChange", {
220
+ from: e,
221
+ to: t
222
+ });
223
+ }
224
+ }
225
+ });
226
+ ot.current = q;
227
+ function st(e) {
228
+ e.layout && (I.value = e.layout), e.blocks && (L.value = e.blocks), e.measures && (R.value = e.measures), e.blockLookup && at.setBlockLookup(e.blockLookup), e.layout && W.emit("layoutComplete", e.layout);
229
+ }
230
+ function J(e, t = {}) {
231
+ let n = a.value, r = n instanceof HTMLDivElement ? n : null, i = k.value, o = i?.package.document, s = o?.sections?.[0]?.properties ?? o?.finalSectionProperties ?? null, l = f(s), u = d(s), m = We(s), h = l.w - u.left - u.right, g = i?.package.styles ?? null, ee = i?.package.theme ?? null, te = i?.package.settings?.defaultTabStop, _ = i?.package.settings, ne = _ !== void 0 && "mirrorMargins" in _ && _.mirrorMargins === !0, v = Ee(i?.package);
232
+ try {
233
+ st(ce({
234
+ contentWidth: h,
235
+ columns: m,
236
+ pageSize: l,
237
+ margins: u,
238
+ pageGap: p,
239
+ showMarginGuides: c(y) === !0,
240
+ marginGuideColor: c(b),
241
+ syncCoordinator: G,
242
+ headerContent: v.headerContent,
243
+ footerContent: v.footerContent,
244
+ firstPageHeaderContent: v.firstPageHeaderContent,
245
+ firstPageFooterContent: v.firstPageFooterContent,
246
+ headerContentRId: v.activeHeaderRId,
247
+ footerContentRId: v.activeFooterRId,
248
+ firstPageHeaderContentRId: v.activeFirstHeaderRId,
249
+ firstPageFooterContentRId: v.activeFirstFooterRId,
250
+ sectionHeaderFooterRefs: me(i),
251
+ theme: ee,
252
+ sectionProperties: s,
253
+ document: i,
254
+ defaultTabStop: te,
255
+ mirrorMargins: ne,
256
+ styles: g,
257
+ layout: I.value,
258
+ hfPMs: K,
259
+ painter: at,
260
+ pagesContainer: r,
261
+ session: it,
262
+ renderHfFromContentOrPm: Ge,
263
+ renderHeaderFooterContentByRId: Ke,
264
+ documentFontsAreLoaded: Ye,
265
+ buildFootnoteRenderItems: qe,
266
+ describeInvalidHighlightMarks: Je,
267
+ emptyTemplatePreviewEntries: Ue
268
+ }, e, t));
269
+ } catch (e) {
270
+ let t = e instanceof Error ? e : Error(String(e));
271
+ w?.(t);
272
+ }
273
+ }
274
+ let Y = ue({
275
+ runLayout: (e, t) => J(e, t),
276
+ debounceMs: Be,
277
+ maxDelayMs: Ve,
278
+ clock: le
279
+ }), X = null;
280
+ function ct() {
281
+ X !== null && (window.clearTimeout(X), X = null);
282
+ let e = A.value, t = k.value;
283
+ if (!(!e || !t)) try {
284
+ let n = ve(e.state.doc, t);
285
+ k.value = n, K.sync(), q.sync(), Ne?.(n), W.emit("docChange", n);
286
+ } catch (e) {
287
+ w?.(e instanceof Error ? e : Error(String(e)));
288
+ }
289
+ }
290
+ function lt() {
291
+ X !== null && window.clearTimeout(X), X = window.setTimeout(() => {
292
+ X = null, ct();
293
+ }, He);
294
+ }
295
+ let Z = oe({
296
+ getHost: () => t.value,
297
+ getDocument: () => k.value,
298
+ getStyles: () => k.value?.package.styles ?? null,
299
+ getExtensionManager: () => H,
300
+ getExternalPlugins: rt,
301
+ getCollaboration: () => c(C),
302
+ getCollaborationModules: () => M.value,
303
+ getPrecomputedInitialState: () => null,
304
+ getReadOnly: () => c(u),
305
+ getDocumentKey: () => c(pe),
306
+ getDocumentContext: () => k.value,
307
+ onTransaction: ut,
308
+ onSelectionChange: (e) => {
309
+ j.value = e, T?.(e), W.emit("selectionChange", {
310
+ from: e.selection.from,
311
+ to: e.selection.to
312
+ });
313
+ },
314
+ onKeyDown: () => !1,
315
+ onCopy: () => E?.(),
316
+ onCut: () => Fe?.(),
317
+ onPaste: () => Ie?.(),
318
+ onReadOnlyEditAttempt: () => Le?.(),
319
+ onEditorViewReady: dt,
320
+ onEditorViewDestroy: () => {
321
+ A.value = null, z.value = !1, Pe?.(null);
322
+ },
323
+ onRemoteSelectionsChange: (e) => {
324
+ N.value = e;
325
+ }
326
+ }), Q = () => {
327
+ let e = c(C)?.awareness, t = M.value, n = Z.getView();
328
+ N.value = e && t && n ? ae(n.state, e, t) : [];
329
+ };
330
+ l(() => c(C), (e, t, n) => {
331
+ if (N.value = [], !e) {
332
+ M.value = null, Z.retryViewCreation(), Z.syncExternalDocument();
333
+ return;
334
+ }
335
+ let r = !1;
336
+ n(() => {
337
+ r = !0;
338
+ }), M.value = null, v().then((e) => {
339
+ r || (M.value = e, Z.retryViewCreation(), Z.syncExternalDocument(), Q());
340
+ }, (e) => {
341
+ r || (M.value = null, w?.(e instanceof Error ? e : Error(String(e))));
342
+ });
343
+ }, { immediate: !0 }), l(() => ({
344
+ awareness: c(C)?.awareness,
345
+ modules: M.value,
346
+ view: A.value
347
+ }), ({ awareness: e, modules: t, view: n }, r, i) => {
348
+ if (!e || !t || !n) {
349
+ N.value = [];
350
+ return;
351
+ }
352
+ e.on("change", Q), Q(), i(() => {
353
+ e.off("change", Q), N.value = [];
354
+ });
355
+ }, { flush: "post" });
356
+ function ut(e, t) {
357
+ j.value = t, e.docChanged && (V.value = !0, G.incrementStateSeq(), Y.schedule(t, _e(e)), lt()), G.requestRender();
358
+ }
359
+ function dt(e) {
360
+ A.value = e, j.value = e.state, z.value = !0, J(e.state, { reason: "initial" }), G.requestRender(), $(e), Pe?.(e), c(u) || requestAnimationFrame(() => {
361
+ A.value === e && e.focus();
362
+ });
363
+ }
364
+ let ft = _({
365
+ getEditorApi: () => Z.api,
366
+ getLayout: () => I.value,
367
+ runLayout: (e, t) => J(e, t),
368
+ emitter: W
369
+ });
370
+ function $(e) {
371
+ te(c(x) === "suggesting", e.state, e.dispatch, c(Oe));
372
+ }
373
+ l([() => c(x), () => c(Oe)], () => {
374
+ let e = A.value;
375
+ e && $(e);
376
+ for (let e of q.listStories()) {
377
+ let t = q.getView(e);
378
+ t && $(t);
379
+ }
380
+ }), l(() => c(u), (e) => {
381
+ Z.syncEditable(), e && Tt();
382
+ });
383
+ function pt(e) {
384
+ let t = nt();
385
+ if (t === e.state.plugins.includes(U)) return;
386
+ let n = e.state.plugins.filter((e) => e !== U && e !== et);
387
+ if (t) {
388
+ let e = n.indexOf(tt), t = e === -1 ? n.length : e;
389
+ n.splice(t, 0, U, et);
390
+ }
391
+ e.updateState(e.state.reconfigure({ plugins: n }));
392
+ }
393
+ l(() => nt(), () => {
394
+ let e = A.value;
395
+ e && pt(e);
396
+ });
397
+ function mt() {
398
+ Z.ensureView();
399
+ }
400
+ function ht() {
401
+ V.value = !1, P.value = null, F.value = null, q.activate(null), Y.dispose(), Z.destroyView(), K.sync(), q.sync(), Z.ensureView(), Z.getView() || gt();
402
+ }
403
+ function gt() {
404
+ let e = k.value;
405
+ if (!(!e || c(C))) try {
406
+ let t = se({
407
+ document: e,
408
+ styles: e.package.styles ?? null,
409
+ manager: H,
410
+ externalPlugins: rt(),
411
+ collaborationModules: null,
412
+ reason: "mount"
413
+ });
414
+ j.value = t, J(t, { reason: "initial" });
415
+ } catch (e) {
416
+ w?.(e instanceof Error ? e : Error(String(e)));
417
+ }
418
+ }
419
+ l([
420
+ t,
421
+ a,
422
+ O,
423
+ ...r ? [r] : []
424
+ ], () => {
425
+ t.value && k.value && !Z.getView() && mt(), K.sync(), q.sync();
426
+ }, { flush: "post" });
427
+ async function _t(e) {
428
+ B.value = null, z.value = !1;
429
+ try {
430
+ let t = await fe(e, { password: c(De) });
431
+ k.value = t, ht();
432
+ } catch (e) {
433
+ let t = e instanceof Error ? e : Error(String(e));
434
+ B.value = t.message, w?.(t);
435
+ }
436
+ }
437
+ function vt(e) {
438
+ B.value = null, k.value = e, ht();
439
+ }
440
+ async function yt(e) {
441
+ let t = A.value, n = k.value;
442
+ if (!t || !n) return null;
443
+ let r = q.snapshotDocument(K.snapshotDocument(n)), i = t.state, { resolveSelectiveSaveFlags: a } = await import("@stll/folio-core/docx/selectiveSaveFlags"), o = a(c(Re)), s = ve(i.doc, r), l = s.originalBuffer ?? null, u = o.selectiveSave && e?.selective !== !1, d = u || o.selectiveSaveTripwire, { repackDocx: f, createDocx: p } = await import("@stll/folio-core/docx/rezip"), m = null;
444
+ if (d && l) {
445
+ let { attemptSelectiveSave: e } = await import("@stll/folio-core/docx/selectiveSave");
446
+ m = await e(s, l, {
447
+ changedParaIds: be(i),
448
+ structuralChange: xe(i),
449
+ hasUntrackedChanges: Se(i),
450
+ maxBytes: o.selectiveSaveMaxBytes
451
+ });
452
+ }
453
+ let h = u ? m : null, g = null;
454
+ if (!h) g = l ? await f(s) : await p(s), h = g;
455
+ else if (o.selectiveSaveTripwire) try {
456
+ g = await f(s);
457
+ } catch {}
458
+ if (o.selectiveSaveTripwire && g && D) try {
459
+ let { compareSelectiveVsFull: e } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
460
+ D(await e(m, g));
461
+ } catch {}
462
+ return k.value = s, K.sync(), q.sync(), V.value = !1, new Blob([h], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
463
+ }
464
+ function bt() {
465
+ let e = k.value;
466
+ return e ? q.snapshotDocument(K.snapshotDocument(e)) : null;
467
+ }
468
+ function xt(e) {
469
+ k.value = e, K.sync(), q.sync(), F.value && !q.getView(F.value) && (F.value = null);
470
+ }
471
+ function St(e) {
472
+ return K.getView(e);
473
+ }
474
+ function Ct() {
475
+ K.sync();
476
+ }
477
+ function wt(e) {
478
+ let t = q.activate(e);
479
+ t && ($(t), F.value = e, requestAnimationFrame(() => t.focus()));
480
+ }
481
+ function Tt() {
482
+ q.activate(null), F.value = null;
483
+ }
484
+ function Et() {
485
+ let e = F.value;
486
+ return e ? q.getView(e) : null;
487
+ }
488
+ function Dt() {
489
+ return H.getCommands();
490
+ }
491
+ function Ot() {
492
+ let e = Et();
493
+ e ? e.focus() : A.value?.focus();
494
+ }
495
+ function kt() {
496
+ let e = A.value;
497
+ e && J(e.state, { reason: "manual" });
498
+ }
499
+ l([() => c(y), () => c(b)], () => kt());
500
+ function At() {
501
+ Y.dispose(), X !== null && (window.clearTimeout(X), X = null), Z.destroyView(), N.value = [], K.destroy(), q.destroy(), H.destroy(), j.value = null, I.value = null, k.value = null, z.value = !1;
502
+ }
503
+ return i(At), {
504
+ editor: ft,
505
+ editorView: A,
506
+ editorState: j,
507
+ remoteSelections: N,
508
+ headerFooterSelection: P,
509
+ activeNoteStory: F,
510
+ isReady: z,
511
+ isDirty: V,
512
+ parseError: B,
513
+ layout: I,
514
+ blocks: L,
515
+ measures: R,
516
+ syncCoordinator: G,
517
+ loadBuffer: _t,
518
+ loadDocument: vt,
519
+ save: yt,
520
+ getDocument: bt,
521
+ setDocument: xt,
522
+ getHeaderFooterView: St,
523
+ syncHeaderFooterViews: Ct,
524
+ openNoteStory: wt,
525
+ closeNoteStory: Tt,
526
+ getActiveNoteView: Et,
527
+ getCommands: Dt,
528
+ focus: Ot,
529
+ reLayout: kt,
530
+ destroy: At
531
+ };
532
+ }
533
+ function P(e, t) {
534
+ if (t < e.top + 40) {
535
+ let n = Math.max(0, e.top + 40 - t);
536
+ return -Math.min(12, n / 40 * 12);
537
+ }
538
+ if (t > e.bottom - 40) {
539
+ let n = Math.max(0, t - (e.bottom - 40));
540
+ return Math.min(12, n / 40 * 12);
541
+ }
542
+ return 0;
543
+ }
544
+ //#endregion
545
+ //#region src/composables/useDragAutoScroll.ts
546
+ function F({ pagesContainer: e, onScrollExtendSelection: t }) {
547
+ let n = null, r = 0, a = 0, o = !1, s = null;
548
+ function c() {
549
+ if (s) return s;
550
+ let t = e.value;
551
+ return t ? (s = De(t), s) : null;
552
+ }
553
+ function l() {
554
+ o = !1, n !== null && (cancelAnimationFrame(n), n = null);
555
+ }
556
+ function u() {
557
+ if (!o) return;
558
+ let e = c();
559
+ if (!e) return;
560
+ let i = P(e.getBoundingClientRect(), a);
561
+ i !== 0 && (e.scrollTop += i, t(r, a)), n = requestAnimationFrame(u);
562
+ }
563
+ function d() {
564
+ o || (o = !0, n = requestAnimationFrame(u));
565
+ }
566
+ function f(e, t) {
567
+ if (r = e, a = t, !o) {
568
+ let e = c();
569
+ if (!e) return;
570
+ let n = e.getBoundingClientRect();
571
+ (t < n.top + 40 || t > n.bottom - 40) && d();
572
+ }
573
+ }
574
+ return i(() => l()), {
575
+ updateMousePosition: f,
576
+ stopAutoScroll: l
577
+ };
578
+ }
579
+ //#endregion
580
+ //#region src/composables/useTableResize.ts
581
+ function I() {
582
+ let e = {
583
+ active: !1,
584
+ startX: 0,
585
+ handle: null,
586
+ columnIndex: 0,
587
+ tablePmStart: 0,
588
+ origWidths: {
589
+ left: 0,
590
+ right: 0
591
+ }
592
+ }, t = {
593
+ active: !1,
594
+ startY: 0,
595
+ handle: null,
596
+ rowIndex: 0,
597
+ isEdge: !1,
598
+ tablePmStart: 0,
599
+ origHeight: 0
600
+ }, n = {
601
+ active: !1,
602
+ startX: 0,
603
+ handle: null,
604
+ columnIndex: 0,
605
+ tablePmStart: 0,
606
+ origWidth: 0
607
+ }, r = null;
608
+ function i() {
609
+ return e.active || t.active || n.active;
610
+ }
611
+ function a(i, a) {
612
+ let o = i.target;
613
+ return o instanceof HTMLElement ? o.classList.contains("layout-table-resize-handle") ? (i.preventDefault(), i.stopPropagation(), r = a, e.active = !0, e.startX = i.clientX, e.handle = o, o.classList.add("dragging"), e.columnIndex = parseInt(o.dataset.columnIndex ?? "0", 10), e.tablePmStart = parseInt(o.dataset.tablePmStart ?? "0", 10), L(a, e), !0) : o.classList.contains("layout-table-row-resize-handle") || o.classList.contains("layout-table-edge-handle-bottom") ? (i.preventDefault(), i.stopPropagation(), r = a, t.active = !0, t.startY = i.clientY, t.handle = o, t.isEdge = o.dataset.isEdge === "bottom", o.classList.add("dragging"), t.rowIndex = parseInt(o.dataset.rowIndex ?? "0", 10), t.tablePmStart = parseInt(o.dataset.tablePmStart ?? "0", 10), R(a, t, o), !0) : o.classList.contains("layout-table-edge-handle-right") ? (i.preventDefault(), i.stopPropagation(), r = a, n.active = !0, n.startX = i.clientX, n.handle = o, o.classList.add("dragging"), n.columnIndex = parseInt(o.dataset.columnIndex ?? "0", 10), n.tablePmStart = parseInt(o.dataset.tablePmStart ?? "0", 10), z(a, n), !0) : !1 : !1;
614
+ }
615
+ function o(r) {
616
+ if (e.active && e.handle) {
617
+ r.preventDefault();
618
+ let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
619
+ e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
620
+ let i = Math.round(t * S), a = e.origWidths.left + i, o = e.origWidths.right - i;
621
+ a >= x && o >= x && (e.origWidths = {
622
+ left: a,
623
+ right: o
624
+ });
625
+ return;
626
+ }
627
+ if (t.active && t.handle) {
628
+ r.preventDefault();
629
+ let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
630
+ t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
631
+ let i = Math.round(e * S), a = t.origHeight + i;
632
+ a >= Oe && (t.origHeight = a);
633
+ return;
634
+ }
635
+ if (n.active && n.handle) {
636
+ r.preventDefault();
637
+ let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
638
+ n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
639
+ let i = Math.round(e * S), a = n.origWidth + i;
640
+ a >= x && (n.origWidth = a);
641
+ }
642
+ }
643
+ function s(i) {
644
+ if (e.active) {
645
+ e.active = !1, e.handle?.classList.remove("dragging"), r && C(r, {
646
+ pmStart: e.tablePmStart,
647
+ colIdx: e.columnIndex,
648
+ newLeft: e.origWidths.left,
649
+ newRight: e.origWidths.right
650
+ }), e.handle = null;
651
+ return;
652
+ }
653
+ if (t.active) {
654
+ t.active = !1, t.handle?.classList.remove("dragging"), r && Ae(r, {
655
+ pmStart: t.tablePmStart,
656
+ rowIdx: t.rowIndex,
657
+ newHeight: t.origHeight
658
+ }), t.handle = null;
659
+ return;
660
+ }
661
+ n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && ke(r, {
662
+ pmStart: n.tablePmStart,
663
+ colIdx: n.columnIndex,
664
+ newWidth: n.origWidth
665
+ }), n.handle = null);
666
+ }
667
+ function c() {
668
+ return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
669
+ document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", s);
670
+ };
671
+ }
672
+ return {
673
+ tryStartResize: a,
674
+ install: c,
675
+ isResizing: i
676
+ };
677
+ }
678
+ function L(e, t) {
679
+ let n = Me(e, t.tablePmStart, t.columnIndex);
680
+ n && (t.origWidths = n);
681
+ }
682
+ function R(e, t, n) {
683
+ let r = Ne(e, t.tablePmStart, t.rowIndex);
684
+ if (r != null) {
685
+ t.origHeight = r;
686
+ return;
687
+ }
688
+ let i = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), a = i ? i.getBoundingClientRect().height : 30;
689
+ t.origHeight = Math.round(a * S);
690
+ }
691
+ function z(e, t) {
692
+ let n = je(e, t.tablePmStart, t.columnIndex);
693
+ n != null && (t.origWidth = n);
694
+ }
695
+ //#endregion
696
+ //#region src/composables/useTrackedChanges.ts
697
+ function B(t, n) {
698
+ return e(() => (n.value, w(t.value?.state ?? null)));
699
+ }
700
+ //#endregion
701
+ //#region src/composables/useZoom.ts
702
+ var V = Pe, H = T, Xe = [
703
+ .5,
704
+ .75,
705
+ 1,
706
+ 1.25,
707
+ 1.5,
708
+ 2
709
+ ];
710
+ function Ze(t = 1) {
711
+ let i = o(Math.max(V, Math.min(H, t))), a = e(() => Math.round(i.value * 100)), s = e(() => i.value <= V), c = e(() => i.value >= H);
712
+ function l(e) {
713
+ i.value = Math.max(V, Math.min(H, Math.round(e * 100) / 100));
714
+ }
715
+ function u() {
716
+ l(i.value + E);
717
+ }
718
+ function d() {
719
+ l(i.value - E);
720
+ }
721
+ function f() {
722
+ l(1);
723
+ }
724
+ function p(e) {
725
+ (e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d());
726
+ }
727
+ function m(e) {
728
+ (e.ctrlKey || e.metaKey) && (e.shiftKey || e.altKey || (e.key === "=" || e.key === "+" ? (e.preventDefault(), u()) : e.key === "-" ? (e.preventDefault(), d()) : e.key === "0" && (e.preventDefault(), f())));
729
+ }
730
+ function h() {
731
+ r(() => document.addEventListener("keydown", m)), n(() => document.removeEventListener("keydown", m));
732
+ }
733
+ return {
734
+ zoom: i,
735
+ zoomPercent: a,
736
+ isMinZoom: s,
737
+ isMaxZoom: c,
738
+ setZoom: l,
739
+ zoomIn: u,
740
+ zoomOut: d,
741
+ resetZoom: f,
742
+ handleWheel: p,
743
+ handleKeyDown: m,
744
+ installShortcuts: h,
745
+ ZOOM_PRESETS: Xe
746
+ };
747
+ }
748
+ //#endregion
749
+ export { F as a, D as c, I as i, k as l, w as n, N as o, B as r, A as s, Ze as t, j as u };