@stll/folio-vue 0.22.1 → 0.22.2

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.
@@ -54,12 +54,12 @@ function it(e) {
54
54
  }
55
55
  //#endregion
56
56
  //#region src/composables/useColorMode.ts
57
- var w = "light", T = Symbol("folioColorMode"), E = (t = w) => {
57
+ var w = "light", T = Symbol("folioColorMode"), at = (t = w) => {
58
58
  a(T, e(() => c(t)));
59
- }, at = { install(t, n = w) {
59
+ }, ot = { install(t, n = w) {
60
60
  t.provide(T, e(() => c(n)));
61
61
  } };
62
- function D() {
62
+ function E() {
63
63
  let n = t(T, e(() => w)), i = o(!1), a = o(!1);
64
64
  return r(() => {
65
65
  i.value = !0;
@@ -71,8 +71,8 @@ function D() {
71
71
  }
72
72
  //#endregion
73
73
  //#region src/composables/useDocxEditor.ts
74
- var ot = 24, st = 250, ct = [], lt = [];
75
- function ut(e) {
74
+ var st = 24, ct = "User", lt = 250, ut = [], dt = [];
75
+ function ft(e) {
76
76
  let t = e?.columnCount ?? 1;
77
77
  if (t <= 1) return;
78
78
  let n = {
@@ -82,7 +82,7 @@ function ut(e) {
82
82
  };
83
83
  return e?.separator !== void 0 && (n.separator = e.separator), n;
84
84
  }
85
- function dt(e, t, n, r, i, a) {
85
+ function pt(e, t, n, r, i, a) {
86
86
  if (!e) return;
87
87
  let o = t ? {
88
88
  ...a,
@@ -90,16 +90,16 @@ function dt(e, t, n, r, i, a) {
90
90
  } : a, s = t ? n?.getView(t) : null;
91
91
  return s ? je(s.state.doc, r, i, o) : Me(e, r, i, o);
92
92
  }
93
- function ft(e, t, n, r, i) {
93
+ function mt(e, t, n, r, i) {
94
94
  if (!e || e.size === 0) return;
95
95
  let a = /* @__PURE__ */ new Map();
96
96
  for (let [o, s] of e) {
97
- let e = dt(s, o, t, n, r, i);
97
+ let e = pt(s, o, t, n, r, i);
98
98
  e && a.set(o, e);
99
99
  }
100
100
  return a.size > 0 ? a : void 0;
101
101
  }
102
- function pt(e, t, n) {
102
+ function ht(e, t, n) {
103
103
  let r = /* @__PURE__ */ new Map();
104
104
  if (!n || !n.package.footnotes) return r;
105
105
  let i = /* @__PURE__ */ new Map();
@@ -125,7 +125,7 @@ function pt(e, t, n) {
125
125
  }
126
126
  return r;
127
127
  }
128
- var O = /* @__PURE__ */ new Set([
128
+ var D = /* @__PURE__ */ new Set([
129
129
  "black",
130
130
  "blue",
131
131
  "cyan",
@@ -144,17 +144,17 @@ var O = /* @__PURE__ */ new Set([
144
144
  "white",
145
145
  "yellow"
146
146
  ]);
147
- function mt(e) {
147
+ function gt(e) {
148
148
  let t = [], n = (e, r) => {
149
- for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !O.has(String(i.attrs.color)) && t.push(`${r}.marks[${n}]=${JSON.stringify(i.attrs)}`);
149
+ for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !D.has(String(i.attrs.color)) && t.push(`${r}.marks[${n}]=${JSON.stringify(i.attrs)}`);
150
150
  e.forEach((e, t, i) => {
151
151
  n(e, `${r}.content[${i}]`);
152
152
  });
153
153
  };
154
154
  return n(e, "doc"), t.join("; ");
155
155
  }
156
- function k(e) {
157
- let { hiddenContainer: t, hiddenHeaderFooterContainer: n, noteEditorContainer: r, pagesContainer: a, readOnly: u = !1, experimentalSession: _, pageGap: se = ot, pageRenderer: ce, markupView: me = "all-markup", showMarginGuides: je, marginGuideColor: Me, password: v, editorMode: y, author: b, externalPlugins: Je = [], historyShortcuts: Ye = "editor", collaboration: x, onAnonymizationMatchesChange: Xe, showTemplateDirectives: Ze, onSlashMenuChange: Qe, onSlashMenuKeyAction: $e, onChange: et, onError: S, onSelectionUpdate: C, onEditorViewReady: tt, onCopy: nt, onCut: rt, onPaste: it, onReadOnlyEditAttempt: w, featureFlags: T, onSelectiveSaveTripwire: E } = e, at = n ?? t, D = s(null), O = 0, k = !1, A = 0, j = !1, M = s(null), N = s(null), P = s(null), F = s([]), ht = s(null), I = s(null), L = s(null), gt = s([]), _t = s([]), R = o(!1), z = o(null), B = o(!1), V = () => ee(c(_), d.authorityRouting), H = (e) => V() ? ie(e) : e, vt = (e, t) => {
156
+ function O(e) {
157
+ let { hiddenContainer: t, hiddenHeaderFooterContainer: n, noteEditorContainer: r, pagesContainer: a, readOnly: u = !1, experimentalSession: _, pageGap: se = st, pageRenderer: ce, markupView: me = "all-markup", showMarginGuides: je, marginGuideColor: Me, password: v, editorMode: y, author: b, externalPlugins: Je = [], historyShortcuts: Ye = "editor", collaboration: x, onAnonymizationMatchesChange: Xe, showTemplateDirectives: Ze, onSlashMenuChange: Qe, onSlashMenuKeyAction: $e, onChange: et, onError: S, onSelectionUpdate: C, onEditorViewReady: tt, onCopy: nt, onCut: rt, onPaste: it, onReadOnlyEditAttempt: w, featureFlags: T, onSelectiveSaveTripwire: at } = e, ot = n ?? t, E = () => c(b) ?? ct, D = s(null), O = 0, _t = !1, k = 0, A = !1, j = s(null), M = s(null), N = s(null), P = s([]), F = s(null), I = s(null), L = s(null), vt = s([]), yt = s([]), R = o(!1), z = o(null), B = o(!1), V = () => ee(c(_), d.authorityRouting), H = (e) => V() ? ie(e) : e, bt = (e, t) => {
158
158
  if (!V()) return !1;
159
159
  let n = new g({
160
160
  gap: e,
@@ -163,46 +163,46 @@ function k(e) {
163
163
  return S?.(n), !0;
164
164
  }, U = new ze(We({ historyShortcuts: Ye }));
165
165
  U.buildSchema(), U.initializeRuntime();
166
- let yt = fe(!1), bt = [yt], xt = ue({ keymap: !0 }), St = le({ onMatchesChange: (e) => Xe?.(e) }), Ct = de(), wt = Ke({
166
+ let xt = fe(!1), St = [xt], Ct = ue({ keymap: !0 }), wt = le({ onMatchesChange: (e) => Xe?.(e) }), Tt = de(), Et = Ke({
167
167
  onChange: (e) => Qe?.(e),
168
168
  onKeyAction: (e) => $e?.(e) ?? !1
169
- }), Tt = Ge(), Et = () => c(Ze) === !0;
170
- function Dt() {
169
+ }), Dt = Ge(), Ot = () => c(Ze) === !0;
170
+ function kt() {
171
171
  return [
172
+ Ct,
172
173
  xt,
173
- yt,
174
174
  ...Je,
175
175
  ...c(x)?.plugins ?? [],
176
- St,
177
- ...Et() ? [Ct, wt] : [],
178
- Tt
176
+ wt,
177
+ ...Ot() ? [Tt, Et] : [],
178
+ Dt
179
179
  ];
180
180
  }
181
- let W = _e(), G = new Fe(), Ot = ke(), kt = Te({
181
+ let W = _e(), G = new Fe(), At = ke(), jt = Te({
182
182
  relayout: () => {
183
- let e = M.value?.state ?? Ot.lastEditorState;
183
+ let e = j.value?.state ?? At.lastEditorState;
184
184
  e && Y(e, { reason: "hyphenation-ready" });
185
185
  },
186
186
  onError: (e) => S?.(e)
187
187
  });
188
- i(kt.cancel), i(Oe({
189
- measuredFontSet: () => Ot.lastMeasureInputs?.fontSet ?? null,
188
+ i(jt.cancel), i(Oe({
189
+ measuredFontSet: () => At.lastMeasureInputs?.fontSet ?? null,
190
190
  relayout: () => {
191
- if (j) return;
192
- let e = M.value?.state ?? Ot.lastEditorState;
191
+ if (A) return;
192
+ let e = j.value?.state ?? At.lastEditorState;
193
193
  e && Y(e, { reason: "font-ready" });
194
194
  }
195
195
  }));
196
- let At = new Pe({
196
+ let Mt = new Pe({
197
197
  pageGap: se,
198
198
  showShadow: !0
199
199
  }), K = Se({
200
- getHost: () => at.value,
200
+ getHost: () => ot.value,
201
201
  getDocument: () => Q.api.getCanonicalDocument() ?? D.value,
202
202
  getCanonicalApi: () => Q.api,
203
203
  getExperimentalSession: () => c(_),
204
- onSessionRefusal: (e, t) => {
205
- z.value = e, S?.(new g({
204
+ onSessionRefusal: (e, t, n) => {
205
+ z.value = e, S?.(n ?? new g({
206
206
  gap: t,
207
207
  message: e
208
208
  }));
@@ -212,7 +212,7 @@ function k(e) {
212
212
  onTransaction: ({ rId: e, kind: t, view: n, docChanged: r, selectionChanged: i }) => {
213
213
  if (r && (B.value = !0, X.schedule()), r || i) {
214
214
  let { from: r, to: i } = n.state.selection;
215
- ht.value = {
215
+ F.value = {
216
216
  from: r,
217
217
  kind: t,
218
218
  rId: e,
@@ -224,14 +224,14 @@ function k(e) {
224
224
  }
225
225
  G.requestRender();
226
226
  }
227
- }), jt = { current: null }, q = Ce({
227
+ }), Nt = { current: null }, q = Ce({
228
228
  getHost: () => r?.value ?? null,
229
- getPlugins: () => bt,
229
+ getPlugins: () => St,
230
230
  getDocument: () => Q.api.getCanonicalDocument() ?? D.value,
231
231
  getCanonicalApi: () => Q.api,
232
232
  getExperimentalSession: () => c(_),
233
- onSessionRefusal: (e, t) => {
234
- z.value = e, S?.(new g({
233
+ onSessionRefusal: (e, t, n) => {
234
+ z.value = e, S?.(n ?? new g({
235
235
  gap: t,
236
236
  message: e
237
237
  }));
@@ -243,7 +243,7 @@ function k(e) {
243
243
  B.value = !0;
244
244
  let e = D.value;
245
245
  if (e) {
246
- let t = Q.api.getCanonicalDocument() ?? jt.current?.snapshotDocument(e) ?? e;
246
+ let t = Q.api.getCanonicalDocument() ?? Nt.current?.snapshotDocument(e) ?? e;
247
247
  D.value = t, et?.(H(t)), W.emit("docChange", H(t));
248
248
  }
249
249
  X.schedule();
@@ -258,19 +258,19 @@ function k(e) {
258
258
  }
259
259
  }
260
260
  });
261
- jt.current = q;
261
+ Nt.current = q;
262
262
  let J = () => {
263
263
  K.sync(), q.sync();
264
264
  };
265
265
  l(() => c(_), J);
266
- function Mt(e) {
267
- e.layout && (L.value = e.layout), e.blocks && (gt.value = e.blocks), e.measures && (_t.value = e.measures), e.blockLookup && At.setBlockLookup(e.blockLookup), e.layout && W.emit("layoutComplete", e.layout);
266
+ function Pt(e) {
267
+ e.layout && (L.value = e.layout), e.blocks && (vt.value = e.blocks), e.measures && (yt.value = e.measures), e.blockLookup && Mt.setBlockLookup(e.blockLookup), e.layout && W.emit("layoutComplete", e.layout);
268
268
  }
269
269
  function Y(e, t = {}) {
270
- if (j) return;
271
- let n = a.value, r = n instanceof HTMLDivElement ? n : null, i = D.value, o = i?.package.document, s = o?.sections?.[0]?.properties ?? o?.finalSectionProperties ?? null, l = oe(s), u = ae(s), d = ut(s), f = l.w - u.left - u.right, ee = i?.package.styles ?? null, p = i?.package.theme ?? null, m = i?.package.settings?.defaultTabStop, h = i?.package.settings?.mirrorMargins === !0, g = qe(i?.package);
270
+ if (A) return;
271
+ let n = a.value, r = n instanceof HTMLDivElement ? n : null, i = D.value, o = i?.package.document, s = o?.sections?.[0]?.properties ?? o?.finalSectionProperties ?? null, l = oe(s), u = ae(s), d = ft(s), f = l.w - u.left - u.right, ee = i?.package.styles ?? null, p = i?.package.theme ?? null, m = i?.package.settings?.defaultTabStop, h = i?.package.settings?.mirrorMargins === !0, g = qe(i?.package);
272
272
  try {
273
- Mt(we({
273
+ Pt(we({
274
274
  contentWidth: f,
275
275
  columns: d,
276
276
  pageSize: l,
@@ -300,17 +300,17 @@ function k(e) {
300
300
  styles: ee,
301
301
  layout: L.value,
302
302
  hfPMs: K,
303
- painter: At,
303
+ painter: Mt,
304
304
  pagesContainer: r,
305
- session: Ot,
306
- renderHfFromContentOrPm: dt,
307
- renderHeaderFooterContentByRId: ft,
305
+ session: At,
306
+ renderHfFromContentOrPm: pt,
307
+ renderHeaderFooterContentByRId: mt,
308
308
  readFontSetSignature: Ee,
309
- buildFootnoteRenderItems: pt,
310
- describeInvalidHighlightMarks: mt,
311
- emptyTemplatePreviewEntries: ct,
312
- emptyTemplatePreviewHidden: lt,
313
- hyphenationReadiness: kt,
309
+ buildFootnoteRenderItems: ht,
310
+ describeInvalidHighlightMarks: gt,
311
+ emptyTemplatePreviewEntries: ut,
312
+ emptyTemplatePreviewHidden: dt,
313
+ hyphenationReadiness: jt,
314
314
  markupView: c(me)
315
315
  }, e, t));
316
316
  } catch (e) {
@@ -319,52 +319,52 @@ function k(e) {
319
319
  }
320
320
  }
321
321
  let X = h({
322
- readState: () => M.value?.state ?? null,
322
+ readState: () => j.value?.state ?? null,
323
323
  runLayout: (e, t) => Y(e, t),
324
324
  ...p,
325
325
  clock: m
326
- }), Z = null, Nt = Le();
327
- function Pt() {
326
+ }), Z = null, Ft = Le();
327
+ function It() {
328
328
  Z !== null && (window.clearTimeout(Z), Z = null);
329
- let e = M.value, t = D.value;
329
+ let e = j.value, t = D.value;
330
330
  if (!(!e || !t)) try {
331
331
  let n = Q.api.getCanonicalDocument();
332
332
  if (!n && V()) return;
333
- let r = n ?? Nt.reconcile(Ie(e.state.doc, t), e.state.doc);
333
+ let r = n ?? Ft.reconcile(Ie(e.state.doc, t), e.state.doc);
334
334
  D.value = r, J(), et?.(H(r)), W.emit("docChange", H(r));
335
335
  } catch (e) {
336
336
  S?.(e instanceof Error ? e : Error(String(e)));
337
337
  }
338
338
  }
339
- function Ft() {
339
+ function Lt() {
340
340
  Z !== null && window.clearTimeout(Z), Z = window.setTimeout(() => {
341
- Z = null, Pt();
342
- }, st);
341
+ Z = null, It();
342
+ }, lt);
343
343
  }
344
344
  let Q = ne({
345
345
  getHost: () => t.value,
346
346
  getDocument: () => D.value,
347
347
  getStyles: () => D.value?.package.styles ?? null,
348
348
  getExtensionManager: () => U,
349
- getExternalPlugins: Dt,
349
+ getExternalPlugins: kt,
350
350
  getCollaboration: () => c(x),
351
- getCollaborationModules: () => P.value,
351
+ getCollaborationModules: () => N.value,
352
352
  getPrecomputedInitialState: () => null,
353
353
  getReadOnly: () => c(u),
354
354
  getExperimentalSession: () => c(_),
355
355
  getEditingMode: () => c(y) ?? "editing",
356
- getSuggestionAuthor: () => c(b) ?? "User",
357
- onSessionRefusal: (e, t) => {
358
- S?.(new g({
356
+ getSuggestionAuthor: E,
357
+ onSessionRefusal: (e, t, n) => {
358
+ S?.(n ?? new g({
359
359
  gap: t,
360
360
  message: e
361
361
  }));
362
362
  },
363
363
  getDocumentIdentity: () => String(O),
364
364
  getDocumentContext: () => D.value,
365
- onTransaction: Lt,
365
+ onTransaction: zt,
366
366
  onSelectionChange: (e) => {
367
- N.value = e, C?.(e), W.emit("selectionChange", {
367
+ M.value = e, C?.(e), W.emit("selectionChange", {
368
368
  from: e.selection.from,
369
369
  to: e.selection.to
370
370
  });
@@ -374,123 +374,127 @@ function k(e) {
374
374
  onCut: () => rt?.(),
375
375
  onPaste: () => it?.(),
376
376
  onReadOnlyEditAttempt: () => w?.(),
377
- onEditorViewReady: Rt,
377
+ onEditorViewReady: Bt,
378
378
  onEditorViewDestroy: () => {
379
- M.value = null, R.value = !1, tt?.(null);
379
+ j.value = null, R.value = !1, tt?.(null);
380
380
  },
381
381
  onRemoteSelectionsChange: (e) => {
382
- F.value = e;
382
+ P.value = e;
383
383
  }
384
- }), It = () => {
385
- let e = c(x)?.awareness, t = P.value, n = Q.getView();
386
- F.value = e && t && n ? te(n.state, e, t) : [];
384
+ }), Rt = () => {
385
+ let e = c(x)?.awareness, t = N.value, n = Q.getView();
386
+ P.value = e && t && n ? te(n.state, e, t) : [];
387
387
  };
388
388
  l(() => c(x), (e, t, n) => {
389
- if (F.value = [], !e) {
390
- P.value = null, Q.retryViewCreation(), Q.syncExternalDocument();
389
+ if (P.value = [], !e) {
390
+ N.value = null, Q.retryViewCreation(), Q.syncExternalDocument();
391
391
  return;
392
392
  }
393
393
  let r = !1;
394
394
  n(() => {
395
395
  r = !0;
396
- }), P.value = null, xe().then((e) => {
397
- r || (P.value = e, Q.retryViewCreation(), Q.syncExternalDocument(), It());
396
+ }), N.value = null, xe().then((e) => {
397
+ r || (N.value = e, Q.retryViewCreation(), Q.syncExternalDocument(), Rt());
398
398
  }, (e) => {
399
- r || (P.value = null, S?.(e instanceof Error ? e : Error(String(e))));
399
+ r || (N.value = null, S?.(e instanceof Error ? e : Error(String(e))));
400
400
  });
401
401
  }, { immediate: !0 }), l(() => ({
402
402
  awareness: c(x)?.awareness,
403
- modules: P.value,
404
- view: M.value
403
+ modules: N.value,
404
+ view: j.value
405
405
  }), ({ awareness: e, modules: t, view: n }, r, i) => {
406
406
  if (!e || !t || !n) {
407
- F.value = [];
407
+ P.value = [];
408
408
  return;
409
409
  }
410
- e.on("change", It), It(), i(() => {
411
- e.off("change", It), F.value = [];
410
+ e.on("change", Rt), Rt(), i(() => {
411
+ e.off("change", Rt), P.value = [];
412
412
  });
413
413
  }, { flush: "post" });
414
- function Lt({ newState: e, docChanged: t, transactions: n }) {
415
- N.value = e;
414
+ function zt({ newState: e, docChanged: t, transactions: n }) {
415
+ M.value = e;
416
416
  let r = n[0]?.before;
417
- if (t && r && Nt.noteBase(r), t) {
417
+ if (t && r && Ft.noteBase(r), t) {
418
418
  let e = Q.api.getCanonicalDocument();
419
- e && (D.value = e, J()), B.value = !0, G.incrementStateSeq(), X.schedule(), Ft();
419
+ e && (D.value = e, J()), B.value = !0, G.incrementStateSeq(), X.schedule(), Lt();
420
420
  }
421
421
  G.requestRender();
422
422
  }
423
- function Rt(e) {
424
- M.value = e, N.value = e.state, R.value = !0;
425
- let t = D.value, n = O, r = ++A;
426
- j = !0;
423
+ function Bt(e) {
424
+ j.value = e, M.value = e.state, R.value = !0;
425
+ let t = D.value, n = O, r = ++k;
426
+ A = !0;
427
427
  let i = () => {
428
- A === r && (j = !1, !(k || O !== n || Q.getView() !== e) && (Y(e.state, { reason: "initial" }), G.requestRender()));
428
+ k === r && (A = !1, !(_t || O !== n || Q.getView() !== e) && (Y(e.state, { reason: "initial" }), G.requestRender()));
429
429
  };
430
430
  De(t, e.state.doc).then(i, i), $(e), tt?.(e), c(u) || requestAnimationFrame(() => {
431
- M.value === e && e.focus();
431
+ j.value === e && e.focus();
432
432
  });
433
433
  }
434
- let zt = {
435
- getDocx: async (e) => (await qt(e))?.buffer ?? null,
436
- loadDocument: Kt,
437
- loadDocx: Gt
438
- }, Bt = ge({
434
+ let Vt = {
435
+ getDocx: async (e) => (await Yt(e))?.buffer ?? null,
436
+ loadDocument: Jt,
437
+ loadDocx: qt
438
+ }, Ht = ge({
439
439
  getEditorApi: () => Q.api,
440
440
  getLayout: () => L.value,
441
441
  runLayout: (e, t) => Y(e, t),
442
- getDocumentIO: () => zt,
442
+ getDocumentIO: () => Vt,
443
443
  emitter: W
444
444
  });
445
445
  function $(e) {
446
- pe(c(y) === "suggesting", e.state, e.dispatch, c(b));
447
- }
448
- l([() => c(y), () => c(b)], () => {
449
- let e = M.value;
446
+ pe(c(y) === "suggesting", e.state, e.dispatch, E());
447
+ }
448
+ l([() => c(y), E], () => {
449
+ Ht.setCanonicalMode(c(y) === "suggesting" ? {
450
+ type: "suggesting",
451
+ author: E()
452
+ } : { type: "editing" });
453
+ let e = j.value;
450
454
  e && $(e);
451
455
  for (let e of q.listStories()) {
452
456
  let t = q.getView(e);
453
457
  t && $(t);
454
458
  }
455
459
  }), l(() => c(u), (e) => {
456
- Q.syncEditable(), e && en();
460
+ Q.syncEditable(), e && nn();
457
461
  });
458
- function Vt(e) {
459
- let t = Et();
460
- if (t === e.state.plugins.includes(Ct)) return;
461
- let n = e.state.plugins.filter((e) => e !== Ct && e !== wt);
462
+ function Ut(e) {
463
+ let t = Ot();
464
+ if (t === e.state.plugins.includes(Tt)) return;
465
+ let n = e.state.plugins.filter((e) => e !== Tt && e !== Et);
462
466
  if (t) {
463
- let e = n.indexOf(Tt), t = e === -1 ? n.length : e;
464
- n.splice(t, 0, Ct, wt);
467
+ let e = n.indexOf(Dt), t = e === -1 ? n.length : e;
468
+ n.splice(t, 0, Tt, Et);
465
469
  }
466
470
  e.updateState(e.state.reconfigure({ plugins: n }));
467
471
  }
468
- l(() => Et(), () => {
469
- let e = M.value;
470
- e && Vt(e);
472
+ l(() => Ot(), () => {
473
+ let e = j.value;
474
+ e && Ut(e);
471
475
  });
472
- function Ht() {
476
+ function Wt() {
473
477
  Q.ensureView();
474
478
  }
475
- function Ut() {
476
- O += 1, B.value = !1, ht.value = null, I.value = null, q.activate(null), X.dispose(), Q.destroyView(), V() && Q.ensureView(), J(), Q.ensureView(), Q.getView() || Wt();
479
+ function Gt() {
480
+ O += 1, B.value = !1, F.value = null, I.value = null, q.activate(null), X.dispose(), Q.destroyView(), V() && Q.ensureView(), J(), Q.ensureView(), Q.getView() || Kt();
477
481
  }
478
- function Wt() {
482
+ function Kt() {
479
483
  let e = D.value;
480
484
  if (!(!e || c(x))) try {
481
485
  let t = re({
482
486
  document: e,
483
487
  styles: e.package.styles ?? null,
484
488
  manager: U,
485
- externalPlugins: Dt(),
489
+ externalPlugins: kt(),
486
490
  collaborationModules: null,
487
491
  reason: "mount"
488
492
  });
489
- N.value = t;
490
- let n = O, r = ++A;
491
- j = !0;
493
+ M.value = t;
494
+ let n = O, r = ++k;
495
+ A = !0;
492
496
  let i = () => {
493
- A === r && (j = !1, !(k || O !== n || D.value !== e || Q.getView()) && Y(t, { reason: "initial" }));
497
+ k === r && (A = !1, !(_t || O !== n || D.value !== e || Q.getView()) && Y(t, { reason: "initial" }));
494
498
  };
495
499
  De(e, t.doc).then(i, i);
496
500
  } catch (e) {
@@ -500,12 +504,12 @@ function k(e) {
500
504
  l([
501
505
  t,
502
506
  a,
503
- at,
507
+ ot,
504
508
  ...r ? [r] : []
505
509
  ], () => {
506
- t.value && D.value && !Q.getView() && Ht(), J();
510
+ t.value && D.value && !Q.getView() && Wt(), J();
507
511
  }, { flush: "post" });
508
- async function Gt(e) {
512
+ async function qt(e) {
509
513
  z.value = null, R.value = !1;
510
514
  try {
511
515
  let t = e;
@@ -515,17 +519,17 @@ function k(e) {
515
519
  t = n.value;
516
520
  }
517
521
  let n = await Ae(t, { password: c(v) });
518
- D.value = n, Ut();
522
+ D.value = n, Gt();
519
523
  } catch (e) {
520
524
  let t = e instanceof Error ? e : Error(String(e));
521
525
  z.value = t.message, S?.(t);
522
526
  }
523
527
  }
524
- function Kt(e) {
525
- z.value = null, D.value = e, Nt.reset(), Ut();
528
+ function Jt(e) {
529
+ z.value = null, D.value = e, Ft.reset(), Gt();
526
530
  }
527
- async function qt(e) {
528
- let t = M.value, n = D.value;
531
+ async function Yt(e) {
532
+ let t = j.value, n = D.value;
529
533
  if (!t || !n) return null;
530
534
  try {
531
535
  let t = Q.api.captureCanonicalSave();
@@ -540,13 +544,13 @@ function k(e) {
540
544
  diagnostic: t,
541
545
  message: `Canonical save used a fidelity fallback: ${t.type} (${t.part}).`
542
546
  }));
543
- return n.tripwireResult && E?.(n.tripwireResult), n;
547
+ return n.tripwireResult && at?.(n.tripwireResult), n;
544
548
  }
545
549
  } catch (e) {
546
550
  return S?.(e instanceof Error ? e : Error(String(e))), null;
547
551
  }
548
552
  if (V()) return null;
549
- Z !== null && Pt();
553
+ Z !== null && It();
550
554
  let r = q.snapshotDocument(K.snapshotDocument(n)), i = t.state, a = Re(Ie(i.doc, r)), { resolveSelectiveSaveFlags: o } = await import("@stll/folio-core/docx/selectiveSaveFlags"), s = o(c(T)), l = a.originalBuffer ?? null, u = s.selectiveSave && e?.mode !== he.full, f = u || s.selectiveSaveTripwire, { repackDocx: ee, createDocx: p } = await import("@stll/folio-core/docx/rezip"), m = null;
551
555
  if (f && l) {
552
556
  let { attemptSelectiveSave: e } = await import("@stll/folio-core/docx/selectiveSave");
@@ -566,55 +570,55 @@ function k(e) {
566
570
  else if (s.selectiveSaveTripwire) try {
567
571
  g = await te();
568
572
  } catch {}
569
- if (s.selectiveSaveTripwire && g && E) try {
573
+ if (s.selectiveSaveTripwire && g && at) try {
570
574
  let { compareSelectiveVsFull: e } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
571
- E(await e(m, g));
575
+ at(await e(m, g));
572
576
  } catch {}
573
577
  return {
574
578
  buffer: h,
575
579
  document: a
576
580
  };
577
581
  }
578
- async function Jt(e) {
579
- let t = M.value, n = t?.state, r = await qt({ mode: e?.selective === !1 ? he.full : he.preferSelective });
580
- return r ? (M.value === t && t?.state.doc === n?.doc && (r.version === void 0 || Q.api.isCanonicalSaveCurrent(r.version)) && (D.value = r.document, J(), B.value = !1), new Blob([r.buffer], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" })) : null;
582
+ async function Xt(e) {
583
+ let t = j.value, n = t?.state, r = await Yt({ mode: e?.selective === !1 ? he.full : he.preferSelective });
584
+ return r ? (j.value === t && t?.state.doc === n?.doc && (r.version === void 0 || Q.api.isCanonicalSaveCurrent(r.version)) && (D.value = r.document, J(), B.value = !1), new Blob([r.buffer], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" })) : null;
581
585
  }
582
- function Yt() {
586
+ function Zt() {
583
587
  let e = Q.api.getCanonicalDocument();
584
588
  if (e) return e;
585
589
  if (V()) return null;
586
590
  let t = D.value;
587
591
  return t ? H(q.snapshotDocument(K.snapshotDocument(t))) : null;
588
592
  }
589
- function Xt(e) {
590
- vt(d.modelEdits, "Direct document model changes are unavailable in this session.") || (D.value = e, J(), I.value && !q.getView(I.value) && (I.value = null));
593
+ function Qt(e) {
594
+ bt(d.modelEdits, "Direct document model changes are unavailable in this session.") || (D.value = e, J(), I.value && !q.getView(I.value) && (I.value = null));
591
595
  }
592
- function Zt(e) {
596
+ function $t(e) {
593
597
  return K.getView(e);
594
598
  }
595
- function Qt() {
599
+ function en() {
596
600
  J();
597
601
  }
598
- function $t(e) {
602
+ function tn(e) {
599
603
  let t = q.activate(e);
600
604
  t && ($(t), I.value = e, requestAnimationFrame(() => t.focus()));
601
605
  }
602
- function en() {
606
+ function nn() {
603
607
  q.activate(null), I.value = null;
604
608
  }
605
- function tn() {
609
+ function rn() {
606
610
  let e = I.value;
607
611
  return e ? q.getView(e) : null;
608
612
  }
609
- function nn() {
613
+ function an() {
610
614
  return U.getCommands();
611
615
  }
612
- function rn() {
613
- let e = tn();
614
- e ? e.focus() : M.value?.focus();
616
+ function on() {
617
+ let e = rn();
618
+ e ? e.focus() : j.value?.focus();
615
619
  }
616
- function an() {
617
- let e = M.value;
620
+ function sn() {
621
+ let e = j.value;
618
622
  e && Y(e.state, { reason: "manual" });
619
623
  }
620
624
  l([
@@ -622,41 +626,41 @@ function k(e) {
622
626
  () => c(Me),
623
627
  () => c(ce),
624
628
  () => c(me)
625
- ], () => an());
626
- function on() {
627
- k = !0, A += 1, j = !1, X.dispose(), Z !== null && (window.clearTimeout(Z), Z = null), Q.destroyView(), F.value = [], K.destroy(), q.destroy(), U.destroy(), N.value = null, L.value = null, D.value = null, R.value = !1;
628
- }
629
- return i(on), {
630
- editor: Bt,
631
- editorView: M,
632
- editorState: N,
633
- remoteSelections: F,
634
- headerFooterSelection: ht,
629
+ ], () => sn());
630
+ function cn() {
631
+ _t = !0, k += 1, A = !1, X.dispose(), Z !== null && (window.clearTimeout(Z), Z = null), Q.destroyView(), P.value = [], K.destroy(), q.destroy(), U.destroy(), M.value = null, L.value = null, D.value = null, R.value = !1;
632
+ }
633
+ return i(cn), {
634
+ editor: Ht,
635
+ editorView: j,
636
+ editorState: M,
637
+ remoteSelections: P,
638
+ headerFooterSelection: F,
635
639
  activeNoteStory: I,
636
640
  isReady: R,
637
641
  isDirty: B,
638
642
  parseError: z,
639
643
  layout: L,
640
- blocks: gt,
641
- measures: _t,
644
+ blocks: vt,
645
+ measures: yt,
642
646
  syncCoordinator: G,
643
- loadBuffer: Gt,
644
- loadDocument: Kt,
645
- save: Jt,
646
- getDocument: Yt,
647
- setDocument: Xt,
648
- getHeaderFooterView: Zt,
649
- syncHeaderFooterViews: Qt,
650
- openNoteStory: $t,
651
- closeNoteStory: en,
652
- getActiveNoteView: tn,
653
- getCommands: nn,
654
- focus: rn,
655
- reLayout: an,
656
- destroy: on
647
+ loadBuffer: qt,
648
+ loadDocument: Jt,
649
+ save: Xt,
650
+ getDocument: Zt,
651
+ setDocument: Qt,
652
+ getHeaderFooterView: $t,
653
+ syncHeaderFooterViews: en,
654
+ openNoteStory: tn,
655
+ closeNoteStory: nn,
656
+ getActiveNoteView: rn,
657
+ getCommands: an,
658
+ focus: on,
659
+ reLayout: sn,
660
+ destroy: cn
657
661
  };
658
662
  }
659
- function A(e, t) {
663
+ function _t(e, t) {
660
664
  if (t < e.top + 40) {
661
665
  let n = Math.max(0, e.top + 40 - t);
662
666
  return -Math.min(12, n / 40 * 12);
@@ -669,7 +673,7 @@ function A(e, t) {
669
673
  }
670
674
  //#endregion
671
675
  //#region src/composables/useDragAutoScroll.ts
672
- function j({ pagesContainer: e, onScrollExtendSelection: t }) {
676
+ function k({ pagesContainer: e, onScrollExtendSelection: t }) {
673
677
  let n = null, r = 0, a = 0, o = !1;
674
678
  function s() {
675
679
  return se(e.value);
@@ -681,7 +685,7 @@ function j({ pagesContainer: e, onScrollExtendSelection: t }) {
681
685
  if (!o) return;
682
686
  let e = s();
683
687
  if (!e) return;
684
- let i = A(e.getBoundingClientRect(), a);
688
+ let i = _t(e.getBoundingClientRect(), a);
685
689
  i !== 0 && (ce(e, i), t(r, a)), n = requestAnimationFrame(l);
686
690
  }
687
691
  function u() {
@@ -702,7 +706,7 @@ function j({ pagesContainer: e, onScrollExtendSelection: t }) {
702
706
  }
703
707
  //#endregion
704
708
  //#region src/composables/useTableResize.ts
705
- function M() {
709
+ function A() {
706
710
  let e = {
707
711
  active: !1,
708
712
  startX: 0,
@@ -734,7 +738,7 @@ function M() {
734
738
  }
735
739
  function a(i, a) {
736
740
  let o = i.target;
737
- 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), N(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), P(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), F(a, n), !0) : !1 : !1;
741
+ 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), j(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), M(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), N(a, n), !0) : !1 : !1;
738
742
  }
739
743
  function o(r) {
740
744
  if (e.active && e.handle) {
@@ -799,11 +803,11 @@ function M() {
799
803
  isResizing: i
800
804
  };
801
805
  }
802
- function N(e, t) {
806
+ function j(e, t) {
803
807
  let n = Ze(e, t.tablePmStart, t.columnIndex);
804
808
  n && (t.origWidths = n);
805
809
  }
806
- function P(e, t, n) {
810
+ function M(e, t, n) {
807
811
  let r = Qe(e, t.tablePmStart, t.rowIndex);
808
812
  if (r != null) {
809
813
  t.origHeight = r;
@@ -812,18 +816,18 @@ function P(e, t, n) {
812
816
  let i = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), a = i ? i.getBoundingClientRect().height : 30;
813
817
  t.origHeight = Math.round(a * b);
814
818
  }
815
- function F(e, t) {
819
+ function N(e, t) {
816
820
  let n = Xe(e, t.tablePmStart, t.columnIndex);
817
821
  n != null && (t.origWidth = n);
818
822
  }
819
823
  //#endregion
820
824
  //#region src/composables/useTrackedChanges.ts
821
- function ht(t, n) {
825
+ function P(t, n) {
822
826
  return e(() => (n.value, $e(t.value?.state ?? null)));
823
827
  }
824
828
  //#endregion
825
829
  //#region src/composables/useZoom.ts
826
- var I = S, L = et, gt = [
830
+ var F = S, I = et, L = [
827
831
  .5,
828
832
  .75,
829
833
  1,
@@ -831,10 +835,10 @@ var I = S, L = et, gt = [
831
835
  1.5,
832
836
  2
833
837
  ];
834
- function _t(t = 1) {
835
- let i = o(Math.max(I, Math.min(L, t))), a = e(() => Math.round(i.value * 100)), s = e(() => i.value <= I), c = e(() => i.value >= L);
838
+ function vt(t = 1) {
839
+ let i = o(Math.max(F, Math.min(I, t))), a = e(() => Math.round(i.value * 100)), s = e(() => i.value <= F), c = e(() => i.value >= I);
836
840
  function l(e) {
837
- i.value = Math.max(I, Math.min(L, Math.round(e * 100) / 100));
841
+ i.value = Math.max(F, Math.min(I, Math.round(e * 100) / 100));
838
842
  }
839
843
  function u() {
840
844
  l(i.value + C);
@@ -866,8 +870,8 @@ function _t(t = 1) {
866
870
  handleWheel: ee,
867
871
  handleKeyDown: p,
868
872
  installShortcuts: m,
869
- ZOOM_PRESETS: gt
873
+ ZOOM_PRESETS: L
870
874
  };
871
875
  }
872
876
  //#endregion
873
- export { j as a, w as c, M as i, E as l, $e as n, k as o, ht as r, at as s, _t as t, D as u };
877
+ export { k as a, w as c, A as i, at as l, $e as n, O as o, P as r, ot as s, vt as t, E as u };