@stll/folio-vue 0.19.1 → 0.20.1

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.
@@ -16,58 +16,58 @@ import { browserClock as de, createLayoutScheduler as fe } from "@stll/folio-cor
16
16
  import { createLayoutSession as pe } from "@stll/folio-core/controller/layoutSession";
17
17
  import { parseDocx as me } from "@stll/folio-core/docx/parser";
18
18
  import { getFootnoteText as he } from "@stll/folio-core/docx/footnoteParser";
19
- import { convertHeaderFooterPmDocToContent as y, convertHeaderFooterToContent as ge } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
20
- import { resolveSectionHeaderFooterRefs as _e } from "@stll/folio-core/layout-engine";
21
- import { LayoutPainter as ve } from "@stll/folio-core/layout-painter";
22
- import { LayoutSelectionGate as ye } from "@stll/folio-core/paged-layout/LayoutSelectionGate";
23
- import { getTransactionsDirtyRange as be } from "@stll/folio-core/paged-layout/transactionDirtyRange";
24
- import { fromProseDoc as xe } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
25
- import { ExtensionManager as Se } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
26
- import { getChangedParagraphIds as Ce, hasStructuralChanges as we, hasUntrackedChanges as Te } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
27
- import { createStarterKit as Ee } from "@stll/folio-core/prosemirror/extensions/StarterKit";
28
- import { createTemplatePreviewValuesPlugin as De } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
29
- import { templateSlashMenuPlugin as Oe } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
30
- import { resolveHeaderFooterContent as ke } from "@stll/folio-core/utils/headerFooter";
31
- import { findVerticalScrollParent as Ae } from "@stll/folio-core/utils/findVerticalScrollParent";
32
- import { MIN_CELL_WIDTH_TWIPS as b, MIN_ROW_HEIGHT_TWIPS as je, TWIPS_PER_PIXEL as x, commitColumnResize as S, commitRightEdgeResize as Me, commitRowResize as Ne, readColumnWidthAt as Pe, readColumnWidths as Fe, readRowHeight as C } from "@stll/folio-core/prosemirror/tableResize";
33
- import { extractTrackedChanges as w } from "@stll/folio-core/prosemirror/utils/extractTrackedChanges";
34
- import { ZOOM_MAX as T, ZOOM_MIN as Ie, ZOOM_STEP as Le } from "@stll/folio-core/utils/zoom";
19
+ import { convertHeaderFooterPmDocToContent as ge, convertHeaderFooterToContent as _e } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
20
+ import { resolveSectionHeaderFooterRefs as ve } from "@stll/folio-core/layout-engine";
21
+ import { LayoutPainter as ye } from "@stll/folio-core/layout-painter";
22
+ import { LayoutSelectionGate as be } from "@stll/folio-core/paged-layout/LayoutSelectionGate";
23
+ import { getTransactionsDirtyRange as xe } from "@stll/folio-core/paged-layout/transactionDirtyRange";
24
+ import { fromProseDoc as Se } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
25
+ import { ExtensionManager as Ce } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
26
+ import { getChangedParagraphIds as we, hasStructuralChanges as Te, hasUntrackedChanges as Ee } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
27
+ import { createStarterKit as De } from "@stll/folio-core/prosemirror/extensions/StarterKit";
28
+ import { createTemplatePreviewValuesPlugin as Oe } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
29
+ import { templateSlashMenuPlugin as ke } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
30
+ import { resolveHeaderFooterContent as Ae } from "@stll/folio-core/utils/headerFooter";
31
+ import { findVerticalScrollParent as je } from "@stll/folio-core/utils/findVerticalScrollParent";
32
+ import { MIN_CELL_WIDTH_TWIPS as y, MIN_ROW_HEIGHT_TWIPS as b, TWIPS_PER_PIXEL as x, commitColumnResize as Me, commitRightEdgeResize as S, commitRowResize as Ne, readColumnWidthAt as Pe, readColumnWidths as Fe, readRowHeight as Ie } from "@stll/folio-core/prosemirror/tableResize";
33
+ import { extractTrackedChanges as C } from "@stll/folio-core/prosemirror/utils/extractTrackedChanges";
34
+ import { ZOOM_MAX as w, ZOOM_MIN as T, ZOOM_STEP as E } from "@stll/folio-core/utils/zoom";
35
35
  //#region src/utils/colorMode.ts
36
- var Re = "(prefers-color-scheme: dark)";
37
- function ze() {
36
+ var Le = "(prefers-color-scheme: dark)";
37
+ function Re() {
38
38
  return typeof window < "u" && typeof window.matchMedia == "function";
39
39
  }
40
- function Be(e, t) {
40
+ function ze(e, t) {
41
41
  return e === "dark" || e === "system" && t;
42
42
  }
43
- function Ve(e) {
44
- if (!ze()) return () => {};
45
- let t = window.matchMedia(Re);
43
+ function Be(e) {
44
+ if (!Re()) return () => {};
45
+ let t = window.matchMedia(Le);
46
46
  e(t.matches);
47
47
  let n = (t) => e(t.matches);
48
48
  return t.addEventListener("change", n), () => t.removeEventListener("change", n);
49
49
  }
50
50
  //#endregion
51
51
  //#region src/composables/useColorMode.ts
52
- var E = "light", D = Symbol("folioColorMode"), O = (t = E) => {
53
- a(D, e(() => c(t)));
54
- }, He = { install(t, n = E) {
55
- t.provide(D, e(() => c(n)));
52
+ var D = "light", O = Symbol("folioColorMode"), k = (t = D) => {
53
+ a(O, e(() => c(t)));
54
+ }, A = { install(t, n = D) {
55
+ t.provide(O, e(() => c(n)));
56
56
  } };
57
- function k() {
58
- let n = t(D, e(() => E)), i = o(!1), a = o(!1);
57
+ function j() {
58
+ let n = t(O, e(() => D)), i = o(!1), a = o(!1);
59
59
  return r(() => {
60
60
  i.value = !0;
61
61
  }), u((e) => {
62
- !i.value || n.value !== "system" || e(Ve((e) => {
62
+ !i.value || n.value !== "system" || e(Be((e) => {
63
63
  a.value = e;
64
64
  }));
65
- }), e(() => Be(n.value, i.value && a.value));
65
+ }), e(() => ze(n.value, i.value && a.value));
66
66
  }
67
67
  //#endregion
68
68
  //#region src/composables/useDocxEditor.ts
69
- var Ue = 24, We = 32, Ge = 96, Ke = 250, qe = [], Je = [];
70
- function Ye(e) {
69
+ var Ve = 24, He = 32, Ue = 96, We = 250, Ge = [], Ke = [];
70
+ function qe(e) {
71
71
  let t = e?.columnCount ?? 1;
72
72
  if (t <= 1) return;
73
73
  let n = {
@@ -77,24 +77,24 @@ function Ye(e) {
77
77
  };
78
78
  return e?.separator !== void 0 && (n.separator = e.separator), n;
79
79
  }
80
- function Xe(e, t, n, r, i, a) {
80
+ function Je(e, t, n, r, i, a) {
81
81
  if (!e) return;
82
82
  let o = t ? {
83
83
  ...a,
84
84
  rId: t
85
85
  } : a, s = t ? n?.getView(t) : null;
86
- return s ? y(s.state.doc, r, i, o) : ge(e, r, i, o);
86
+ return s ? ge(s.state.doc, r, i, o) : _e(e, r, i, o);
87
87
  }
88
- function Ze(e, t, n, r, i) {
88
+ function Ye(e, t, n, r, i) {
89
89
  if (!e || e.size === 0) return;
90
90
  let a = /* @__PURE__ */ new Map();
91
91
  for (let [o, s] of e) {
92
- let e = Xe(s, o, t, n, r, i);
92
+ let e = Je(s, o, t, n, r, i);
93
93
  e && a.set(o, e);
94
94
  }
95
95
  return a.size > 0 ? a : void 0;
96
96
  }
97
- function Qe(e, t, n) {
97
+ function Xe(e, t, n) {
98
98
  let r = /* @__PURE__ */ new Map();
99
99
  if (!n || !n.package.footnotes) return r;
100
100
  let i = /* @__PURE__ */ new Map();
@@ -120,7 +120,7 @@ function Qe(e, t, n) {
120
120
  }
121
121
  return r;
122
122
  }
123
- var A = /* @__PURE__ */ new Set([
123
+ var M = /* @__PURE__ */ new Set([
124
124
  "black",
125
125
  "blue",
126
126
  "cyan",
@@ -139,61 +139,61 @@ var A = /* @__PURE__ */ new Set([
139
139
  "white",
140
140
  "yellow"
141
141
  ]);
142
- function $e(e) {
142
+ function Ze(e) {
143
143
  let t = [], n = (e, r) => {
144
- for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !A.has(String(i.attrs.color)) && t.push(`${r}.marks[${n}]=${JSON.stringify(i.attrs)}`);
144
+ 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)}`);
145
145
  e.forEach((e, t, i) => {
146
146
  n(e, `${r}.content[${i}]`);
147
147
  });
148
148
  };
149
149
  return n(e, "doc"), t.join("; ");
150
150
  }
151
- function et() {
151
+ function Qe() {
152
152
  return typeof document > "u" || !("fonts" in document) || document.fonts.status === "loaded";
153
153
  }
154
- function j(e) {
155
- let { hiddenContainer: t, hiddenHeaderFooterContainer: n, noteEditorContainer: r, pagesContainer: a, readOnly: u = !1, pageGap: p = Ue, pageRenderer: he, showMarginGuides: y, marginGuideColor: ge, password: Ae, editorMode: b, author: je, externalPlugins: x = [], collaboration: S, onAnonymizationMatchesChange: Me, showTemplateDirectives: Ne, onSlashMenuChange: Pe, onSlashMenuKeyAction: Fe, onChange: C, onError: w, onSelectionUpdate: T, onEditorViewReady: Ie, onCopy: Le, onCut: Re, onPaste: ze, onReadOnlyEditAttempt: Be, featureFlags: Ve, onSelectiveSaveTripwire: E } = e, D = n ?? t, O = s(null), He = 0, k = s(null), A = s(null), j = s(null), M = s([]), N = s(null), P = s(null), F = s(null), I = s([]), L = s([]), R = o(!1), z = o(null), B = o(!1), V = new Se(Ee());
156
- V.buildSchema(), V.initializeRuntime();
157
- let tt = ee(!1), nt = [tt], rt = h({ keymap: !0 }), it = m({ onMatchesChange: (e) => Me?.(e) }), H = g(), U = Oe({
158
- onChange: (e) => Pe?.(e),
159
- onKeyAction: (e) => Fe?.(e) ?? !1
160
- }), at = De(), ot = () => c(Ne) === !0;
161
- function st() {
154
+ function N(e) {
155
+ let { hiddenContainer: t, hiddenHeaderFooterContainer: n, noteEditorContainer: r, pagesContainer: a, readOnly: u = !1, pageGap: p = Ve, pageRenderer: he, showMarginGuides: ge, marginGuideColor: _e, password: je, editorMode: y, author: b, externalPlugins: x = [], historyShortcuts: Me = "editor", collaboration: S, onAnonymizationMatchesChange: Ne, showTemplateDirectives: Pe, onSlashMenuChange: Fe, onSlashMenuKeyAction: Ie, onChange: C, onError: w, onSelectionUpdate: T, onEditorViewReady: E, onCopy: Le, onCut: Re, onPaste: ze, onReadOnlyEditAttempt: Be, featureFlags: D, onSelectiveSaveTripwire: O } = e, k = n ?? t, A = s(null), j = 0, M = s(null), N = s(null), P = s(null), F = s([]), I = s(null), L = s(null), R = s(null), $e = s([]), et = s([]), z = o(!1), B = o(null), V = o(!1), H = new Ce(De({ historyShortcuts: Me }));
156
+ H.buildSchema(), H.initializeRuntime();
157
+ let tt = ee(!1), nt = [tt], rt = h({ keymap: !0 }), it = m({ onMatchesChange: (e) => Ne?.(e) }), U = g(), at = ke({
158
+ onChange: (e) => Fe?.(e),
159
+ onKeyAction: (e) => Ie?.(e) ?? !1
160
+ }), ot = Oe(), st = () => c(Pe) === !0;
161
+ function ct() {
162
162
  return [
163
163
  rt,
164
164
  tt,
165
165
  ...x,
166
166
  ...c(S)?.plugins ?? [],
167
167
  it,
168
- ...ot() ? [H, U] : [],
169
- at
168
+ ...st() ? [U, at] : [],
169
+ ot
170
170
  ];
171
171
  }
172
- let W = ne(), G = new ye(), ct = pe(), lt = ue({
172
+ let W = ne(), G = new be(), lt = pe(), ut = ue({
173
173
  relayout: () => {
174
- let e = k.value?.state ?? ct.lastEditorState;
174
+ let e = M.value?.state ?? lt.lastEditorState;
175
175
  e && J(e, { reason: "hyphenation-ready" });
176
176
  },
177
177
  onError: (e) => w?.(e)
178
178
  });
179
- i(lt.cancel);
180
- let ut = new ve({
179
+ i(ut.cancel);
180
+ let dt = new ye({
181
181
  pageGap: p,
182
182
  showShadow: !0
183
183
  }), K = ie({
184
- getHost: () => D.value,
185
- getDocument: () => O.value,
186
- getStyles: () => O.value?.package.styles ?? null,
187
- getTheme: () => O.value?.package.theme ?? null,
184
+ getHost: () => k.value,
185
+ getDocument: () => A.value,
186
+ getStyles: () => A.value?.package.styles ?? null,
187
+ getTheme: () => A.value?.package.theme ?? null,
188
188
  onTransaction: ({ rId: e, kind: t, view: n, docChanged: r, selectionChanged: i }) => {
189
189
  if (r) {
190
- B.value = !0;
191
- let e = k.value;
190
+ V.value = !0;
191
+ let e = M.value;
192
192
  e && Y.schedule(e.state, null);
193
193
  }
194
194
  if (r || i) {
195
195
  let { from: r, to: i } = n.state.selection;
196
- N.value = {
196
+ I.value = {
197
197
  from: r,
198
198
  kind: t,
199
199
  rId: e,
@@ -205,21 +205,21 @@ function j(e) {
205
205
  }
206
206
  G.requestRender();
207
207
  }
208
- }), dt = { current: null }, q = ae({
208
+ }), ft = { current: null }, q = ae({
209
209
  getHost: () => r?.value ?? null,
210
210
  getPlugins: () => nt,
211
- getDocument: () => O.value,
212
- getStyles: () => O.value?.package.styles ?? null,
213
- getTheme: () => O.value?.package.theme ?? null,
211
+ getDocument: () => A.value,
212
+ getStyles: () => A.value?.package.styles ?? null,
213
+ getTheme: () => A.value?.package.theme ?? null,
214
214
  onTransaction: ({ docChanged: e, selectionChanged: t, view: n }) => {
215
215
  if (e) {
216
- B.value = !0;
217
- let e = O.value;
216
+ V.value = !0;
217
+ let e = A.value;
218
218
  if (e) {
219
- let t = dt.current?.snapshotDocument(e) ?? e;
220
- O.value = t, C?.(t), W.emit("docChange", t);
219
+ let t = ft.current?.snapshotDocument(e) ?? e;
220
+ A.value = t, C?.(t), W.emit("docChange", t);
221
221
  }
222
- let t = k.value;
222
+ let t = M.value;
223
223
  t && Y.schedule(t.state, null);
224
224
  }
225
225
  if (e || t) {
@@ -232,21 +232,21 @@ function j(e) {
232
232
  }
233
233
  }
234
234
  });
235
- dt.current = q;
236
- function ft(e) {
237
- e.layout && (F.value = e.layout), e.blocks && (I.value = e.blocks), e.measures && (L.value = e.measures), e.blockLookup && ut.setBlockLookup(e.blockLookup), e.layout && W.emit("layoutComplete", e.layout);
235
+ ft.current = q;
236
+ function pt(e) {
237
+ e.layout && (R.value = e.layout), e.blocks && ($e.value = e.blocks), e.measures && (et.value = e.measures), e.blockLookup && dt.setBlockLookup(e.blockLookup), e.layout && W.emit("layoutComplete", e.layout);
238
238
  }
239
239
  function J(e, t = {}) {
240
- let n = a.value, r = n instanceof HTMLDivElement ? n : null, i = O.value, o = i?.package.document, s = o?.sections?.[0]?.properties ?? o?.finalSectionProperties ?? null, l = f(s), u = d(s), m = Ye(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?.mirrorMargins === !0, v = ke(i?.package);
240
+ let n = a.value, r = n instanceof HTMLDivElement ? n : null, i = A.value, o = i?.package.document, s = o?.sections?.[0]?.properties ?? o?.finalSectionProperties ?? null, l = f(s), u = d(s), m = qe(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?.mirrorMargins === !0, v = Ae(i?.package);
241
241
  try {
242
- ft(le({
242
+ pt(le({
243
243
  contentWidth: h,
244
244
  columns: m,
245
245
  pageSize: l,
246
246
  margins: u,
247
247
  pageGap: p,
248
- showMarginGuides: c(y) === !0,
249
- marginGuideColor: c(ge),
248
+ showMarginGuides: c(ge) === !0,
249
+ marginGuideColor: c(_e),
250
250
  ...(() => {
251
251
  let e = c(he);
252
252
  return e === void 0 ? {} : { pageRenderer: e };
@@ -260,26 +260,26 @@ function j(e) {
260
260
  footerContentRId: v.activeFooterRId,
261
261
  firstPageHeaderContentRId: v.activeFirstHeaderRId,
262
262
  firstPageFooterContentRId: v.activeFirstFooterRId,
263
- sectionHeaderFooterRefs: _e(i),
263
+ sectionHeaderFooterRefs: ve(i),
264
264
  theme: ee,
265
265
  sectionProperties: s,
266
266
  document: i,
267
267
  defaultTabStop: te,
268
268
  mirrorMargins: _,
269
269
  styles: g,
270
- layout: F.value,
270
+ layout: R.value,
271
271
  hfPMs: K,
272
- painter: ut,
272
+ painter: dt,
273
273
  pagesContainer: r,
274
- session: ct,
275
- renderHfFromContentOrPm: Xe,
276
- renderHeaderFooterContentByRId: Ze,
277
- documentFontsAreLoaded: et,
278
- buildFootnoteRenderItems: Qe,
279
- describeInvalidHighlightMarks: $e,
280
- emptyTemplatePreviewEntries: qe,
281
- emptyTemplatePreviewHidden: Je,
282
- hyphenationReadiness: lt
274
+ session: lt,
275
+ renderHfFromContentOrPm: Je,
276
+ renderHeaderFooterContentByRId: Ye,
277
+ documentFontsAreLoaded: Qe,
278
+ buildFootnoteRenderItems: Xe,
279
+ describeInvalidHighlightMarks: Ze,
280
+ emptyTemplatePreviewEntries: Ge,
281
+ emptyTemplatePreviewHidden: Ke,
282
+ hyphenationReadiness: ut
283
283
  }, e, t));
284
284
  } catch (e) {
285
285
  let t = e instanceof Error ? e : Error(String(e));
@@ -288,40 +288,40 @@ function j(e) {
288
288
  }
289
289
  let Y = fe({
290
290
  runLayout: (e, t) => J(e, t),
291
- debounceMs: We,
292
- maxDelayMs: Ge,
291
+ debounceMs: He,
292
+ maxDelayMs: Ue,
293
293
  clock: de
294
294
  }), X = null;
295
- function pt() {
295
+ function mt() {
296
296
  X !== null && (window.clearTimeout(X), X = null);
297
- let e = k.value, t = O.value;
297
+ let e = M.value, t = A.value;
298
298
  if (!(!e || !t)) try {
299
- let n = xe(e.state.doc, t);
300
- O.value = n, K.sync(), q.sync(), C?.(n), W.emit("docChange", n);
299
+ let n = Se(e.state.doc, t);
300
+ A.value = n, K.sync(), q.sync(), C?.(n), W.emit("docChange", n);
301
301
  } catch (e) {
302
302
  w?.(e instanceof Error ? e : Error(String(e)));
303
303
  }
304
304
  }
305
- function mt() {
305
+ function ht() {
306
306
  X !== null && window.clearTimeout(X), X = window.setTimeout(() => {
307
- X = null, pt();
308
- }, Ke);
307
+ X = null, mt();
308
+ }, We);
309
309
  }
310
310
  let Z = se({
311
311
  getHost: () => t.value,
312
- getDocument: () => O.value,
313
- getStyles: () => O.value?.package.styles ?? null,
314
- getExtensionManager: () => V,
315
- getExternalPlugins: st,
312
+ getDocument: () => A.value,
313
+ getStyles: () => A.value?.package.styles ?? null,
314
+ getExtensionManager: () => H,
315
+ getExternalPlugins: ct,
316
316
  getCollaboration: () => c(S),
317
- getCollaborationModules: () => j.value,
317
+ getCollaborationModules: () => P.value,
318
318
  getPrecomputedInitialState: () => null,
319
319
  getReadOnly: () => c(u),
320
- getDocumentIdentity: () => String(He),
321
- getDocumentContext: () => O.value,
322
- onTransaction: ht,
320
+ getDocumentIdentity: () => String(j),
321
+ getDocumentContext: () => A.value,
322
+ onTransaction: gt,
323
323
  onSelectionChange: (e) => {
324
- A.value = e, T?.(e), W.emit("selectionChange", {
324
+ N.value = e, T?.(e), W.emit("selectionChange", {
325
325
  from: e.selection.from,
326
326
  to: e.selection.to
327
327
  });
@@ -331,107 +331,107 @@ function j(e) {
331
331
  onCut: () => Re?.(),
332
332
  onPaste: () => ze?.(),
333
333
  onReadOnlyEditAttempt: () => Be?.(),
334
- onEditorViewReady: gt,
334
+ onEditorViewReady: _t,
335
335
  onEditorViewDestroy: () => {
336
- k.value = null, R.value = !1, Ie?.(null);
336
+ M.value = null, z.value = !1, E?.(null);
337
337
  },
338
338
  onRemoteSelectionsChange: (e) => {
339
- M.value = e;
339
+ F.value = e;
340
340
  }
341
341
  }), Q = () => {
342
- let e = c(S)?.awareness, t = j.value, n = Z.getView();
343
- M.value = e && t && n ? oe(n.state, e, t) : [];
342
+ let e = c(S)?.awareness, t = P.value, n = Z.getView();
343
+ F.value = e && t && n ? oe(n.state, e, t) : [];
344
344
  };
345
345
  l(() => c(S), (e, t, n) => {
346
- if (M.value = [], !e) {
347
- j.value = null, Z.retryViewCreation(), Z.syncExternalDocument();
346
+ if (F.value = [], !e) {
347
+ P.value = null, Z.retryViewCreation(), Z.syncExternalDocument();
348
348
  return;
349
349
  }
350
350
  let r = !1;
351
351
  n(() => {
352
352
  r = !0;
353
- }), j.value = null, re().then((e) => {
354
- r || (j.value = e, Z.retryViewCreation(), Z.syncExternalDocument(), Q());
353
+ }), P.value = null, re().then((e) => {
354
+ r || (P.value = e, Z.retryViewCreation(), Z.syncExternalDocument(), Q());
355
355
  }, (e) => {
356
- r || (j.value = null, w?.(e instanceof Error ? e : Error(String(e))));
356
+ r || (P.value = null, w?.(e instanceof Error ? e : Error(String(e))));
357
357
  });
358
358
  }, { immediate: !0 }), l(() => ({
359
359
  awareness: c(S)?.awareness,
360
- modules: j.value,
361
- view: k.value
360
+ modules: P.value,
361
+ view: M.value
362
362
  }), ({ awareness: e, modules: t, view: n }, r, i) => {
363
363
  if (!e || !t || !n) {
364
- M.value = [];
364
+ F.value = [];
365
365
  return;
366
366
  }
367
367
  e.on("change", Q), Q(), i(() => {
368
- e.off("change", Q), M.value = [];
368
+ e.off("change", Q), F.value = [];
369
369
  });
370
370
  }, { flush: "post" });
371
- function ht({ transactions: e, newState: t, docChanged: n }) {
372
- A.value = t, n && (B.value = !0, G.incrementStateSeq(), Y.schedule(t, be(e)), mt()), G.requestRender();
371
+ function gt({ transactions: e, newState: t, docChanged: n }) {
372
+ N.value = t, n && (V.value = !0, G.incrementStateSeq(), Y.schedule(t, xe(e)), ht()), G.requestRender();
373
373
  }
374
- function gt(e) {
375
- k.value = e, A.value = e.state, R.value = !0, J(e.state, { reason: "initial" }), G.requestRender(), $(e), Ie?.(e), c(u) || requestAnimationFrame(() => {
376
- k.value === e && e.focus();
374
+ function _t(e) {
375
+ M.value = e, N.value = e.state, z.value = !0, J(e.state, { reason: "initial" }), G.requestRender(), $(e), E?.(e), c(u) || requestAnimationFrame(() => {
376
+ M.value === e && e.focus();
377
377
  });
378
378
  }
379
- let _t = {
380
- getDocx: async (e) => (await Tt(e))?.buffer ?? null,
381
- loadDocument: wt,
382
- loadDocx: Ct
383
- }, vt = v({
379
+ let vt = {
380
+ getDocx: async (e) => (await Et(e))?.buffer ?? null,
381
+ loadDocument: Tt,
382
+ loadDocx: wt
383
+ }, yt = v({
384
384
  getEditorApi: () => Z.api,
385
- getLayout: () => F.value,
385
+ getLayout: () => R.value,
386
386
  runLayout: (e, t) => J(e, t),
387
- getDocumentIO: () => _t,
387
+ getDocumentIO: () => vt,
388
388
  emitter: W
389
389
  });
390
390
  function $(e) {
391
- te(c(b) === "suggesting", e.state, e.dispatch, c(je));
391
+ te(c(y) === "suggesting", e.state, e.dispatch, c(b));
392
392
  }
393
- l([() => c(b), () => c(je)], () => {
394
- let e = k.value;
393
+ l([() => c(y), () => c(b)], () => {
394
+ let e = M.value;
395
395
  e && $(e);
396
396
  for (let e of q.listStories()) {
397
397
  let t = q.getView(e);
398
398
  t && $(t);
399
399
  }
400
400
  }), l(() => c(u), (e) => {
401
- Z.syncEditable(), e && Mt();
401
+ Z.syncEditable(), e && Nt();
402
402
  });
403
- function yt(e) {
404
- let t = ot();
405
- if (t === e.state.plugins.includes(H)) return;
406
- let n = e.state.plugins.filter((e) => e !== H && e !== U);
403
+ function bt(e) {
404
+ let t = st();
405
+ if (t === e.state.plugins.includes(U)) return;
406
+ let n = e.state.plugins.filter((e) => e !== U && e !== at);
407
407
  if (t) {
408
- let e = n.indexOf(at), t = e === -1 ? n.length : e;
409
- n.splice(t, 0, H, U);
408
+ let e = n.indexOf(ot), t = e === -1 ? n.length : e;
409
+ n.splice(t, 0, U, at);
410
410
  }
411
411
  e.updateState(e.state.reconfigure({ plugins: n }));
412
412
  }
413
- l(() => ot(), () => {
414
- let e = k.value;
415
- e && yt(e);
413
+ l(() => st(), () => {
414
+ let e = M.value;
415
+ e && bt(e);
416
416
  });
417
- function bt() {
418
- Z.ensureView();
419
- }
420
417
  function xt() {
421
- He += 1, B.value = !1, N.value = null, P.value = null, q.activate(null), Y.dispose(), Z.destroyView(), K.sync(), q.sync(), Z.ensureView(), Z.getView() || St();
418
+ Z.ensureView();
422
419
  }
423
420
  function St() {
424
- let e = O.value;
421
+ j += 1, V.value = !1, I.value = null, L.value = null, q.activate(null), Y.dispose(), Z.destroyView(), K.sync(), q.sync(), Z.ensureView(), Z.getView() || Ct();
422
+ }
423
+ function Ct() {
424
+ let e = A.value;
425
425
  if (!(!e || c(S))) try {
426
426
  let t = ce({
427
427
  document: e,
428
428
  styles: e.package.styles ?? null,
429
- manager: V,
430
- externalPlugins: st(),
429
+ manager: H,
430
+ externalPlugins: ct(),
431
431
  collaborationModules: null,
432
432
  reason: "mount"
433
433
  });
434
- A.value = t, J(t, { reason: "initial" });
434
+ N.value = t, J(t, { reason: "initial" });
435
435
  } catch (e) {
436
436
  w?.(e instanceof Error ? e : Error(String(e)));
437
437
  }
@@ -439,34 +439,34 @@ function j(e) {
439
439
  l([
440
440
  t,
441
441
  a,
442
- D,
442
+ k,
443
443
  ...r ? [r] : []
444
444
  ], () => {
445
- t.value && O.value && !Z.getView() && bt(), K.sync(), q.sync();
445
+ t.value && A.value && !Z.getView() && xt(), K.sync(), q.sync();
446
446
  }, { flush: "post" });
447
- async function Ct(e) {
448
- z.value = null, R.value = !1;
447
+ async function wt(e) {
448
+ B.value = null, z.value = !1;
449
449
  try {
450
- let t = await me(e, { password: c(Ae) });
451
- O.value = t, xt();
450
+ let t = await me(e, { password: c(je) });
451
+ A.value = t, St();
452
452
  } catch (e) {
453
453
  let t = e instanceof Error ? e : Error(String(e));
454
- z.value = t.message, w?.(t);
454
+ B.value = t.message, w?.(t);
455
455
  }
456
456
  }
457
- function wt(e) {
458
- z.value = null, O.value = e, xt();
457
+ function Tt(e) {
458
+ B.value = null, A.value = e, St();
459
459
  }
460
- async function Tt(e) {
461
- let t = k.value, n = O.value;
460
+ async function Et(e) {
461
+ let t = M.value, n = A.value;
462
462
  if (!t || !n) return null;
463
- let r = q.snapshotDocument(K.snapshotDocument(n)), i = t.state, { resolveSelectiveSaveFlags: a } = await import("@stll/folio-core/docx/selectiveSaveFlags"), o = a(c(Ve)), s = xe(i.doc, r), l = s.originalBuffer ?? null, u = o.selectiveSave && e?.mode !== _.full, d = u || o.selectiveSaveTripwire, { repackDocx: f, createDocx: p } = await import("@stll/folio-core/docx/rezip"), m = null;
463
+ let r = q.snapshotDocument(K.snapshotDocument(n)), i = t.state, { resolveSelectiveSaveFlags: a } = await import("@stll/folio-core/docx/selectiveSaveFlags"), o = a(c(D)), s = Se(i.doc, r), l = s.originalBuffer ?? null, u = o.selectiveSave && e?.mode !== _.full, d = u || o.selectiveSaveTripwire, { repackDocx: f, createDocx: p } = await import("@stll/folio-core/docx/rezip"), m = null;
464
464
  if (d && l) {
465
465
  let { attemptSelectiveSave: e } = await import("@stll/folio-core/docx/selectiveSave");
466
466
  m = await e(s, l, {
467
- changedParaIds: Ce(i),
468
- structuralChange: we(i),
469
- hasUntrackedChanges: Te(i),
467
+ changedParaIds: we(i),
468
+ structuralChange: Te(i),
469
+ hasUntrackedChanges: Ee(i),
470
470
  maxBytes: o.selectiveSaveMaxBytes
471
471
  });
472
472
  }
@@ -475,93 +475,93 @@ function j(e) {
475
475
  else if (o.selectiveSaveTripwire) try {
476
476
  g = await f(s);
477
477
  } catch {}
478
- if (o.selectiveSaveTripwire && g && E) try {
478
+ if (o.selectiveSaveTripwire && g && O) try {
479
479
  let { compareSelectiveVsFull: e } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
480
- E(await e(m, g));
480
+ O(await e(m, g));
481
481
  } catch {}
482
482
  return {
483
483
  buffer: h,
484
484
  document: s
485
485
  };
486
486
  }
487
- async function Et(e) {
488
- let t = await Tt({ mode: e?.selective === !1 ? _.full : _.preferSelective });
489
- return t ? (O.value = t.document, K.sync(), q.sync(), B.value = !1, new Blob([t.buffer], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" })) : null;
487
+ async function Dt(e) {
488
+ let t = await Et({ mode: e?.selective === !1 ? _.full : _.preferSelective });
489
+ return t ? (A.value = t.document, K.sync(), q.sync(), V.value = !1, new Blob([t.buffer], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" })) : null;
490
490
  }
491
- function Dt() {
492
- let e = O.value;
491
+ function Ot() {
492
+ let e = A.value;
493
493
  return e ? q.snapshotDocument(K.snapshotDocument(e)) : null;
494
494
  }
495
- function Ot(e) {
496
- O.value = e, K.sync(), q.sync(), P.value && !q.getView(P.value) && (P.value = null);
497
- }
498
495
  function kt(e) {
496
+ A.value = e, K.sync(), q.sync(), L.value && !q.getView(L.value) && (L.value = null);
497
+ }
498
+ function At(e) {
499
499
  return K.getView(e);
500
500
  }
501
- function At() {
501
+ function jt() {
502
502
  K.sync();
503
503
  }
504
- function jt(e) {
504
+ function Mt(e) {
505
505
  let t = q.activate(e);
506
- t && ($(t), P.value = e, requestAnimationFrame(() => t.focus()));
507
- }
508
- function Mt() {
509
- q.activate(null), P.value = null;
506
+ t && ($(t), L.value = e, requestAnimationFrame(() => t.focus()));
510
507
  }
511
508
  function Nt() {
512
- let e = P.value;
513
- return e ? q.getView(e) : null;
509
+ q.activate(null), L.value = null;
514
510
  }
515
511
  function Pt() {
516
- return V.getCommands();
512
+ let e = L.value;
513
+ return e ? q.getView(e) : null;
517
514
  }
518
515
  function Ft() {
519
- let e = Nt();
520
- e ? e.focus() : k.value?.focus();
516
+ return H.getCommands();
521
517
  }
522
518
  function It() {
523
- let e = k.value;
519
+ let e = Pt();
520
+ e ? e.focus() : M.value?.focus();
521
+ }
522
+ function Lt() {
523
+ let e = M.value;
524
524
  e && J(e.state, { reason: "manual" });
525
525
  }
526
526
  l([
527
- () => c(y),
528
527
  () => c(ge),
528
+ () => c(_e),
529
529
  () => c(he)
530
- ], () => It());
531
- function Lt() {
532
- Y.dispose(), X !== null && (window.clearTimeout(X), X = null), Z.destroyView(), M.value = [], K.destroy(), q.destroy(), V.destroy(), A.value = null, F.value = null, O.value = null, R.value = !1;
533
- }
534
- return i(Lt), {
535
- editor: vt,
536
- editorView: k,
537
- editorState: A,
538
- remoteSelections: M,
539
- headerFooterSelection: N,
540
- activeNoteStory: P,
541
- isReady: R,
542
- isDirty: B,
543
- parseError: z,
544
- layout: F,
545
- blocks: I,
546
- measures: L,
530
+ ], () => Lt());
531
+ function Rt() {
532
+ Y.dispose(), X !== null && (window.clearTimeout(X), X = null), Z.destroyView(), F.value = [], K.destroy(), q.destroy(), H.destroy(), N.value = null, R.value = null, A.value = null, z.value = !1;
533
+ }
534
+ return i(Rt), {
535
+ editor: yt,
536
+ editorView: M,
537
+ editorState: N,
538
+ remoteSelections: F,
539
+ headerFooterSelection: I,
540
+ activeNoteStory: L,
541
+ isReady: z,
542
+ isDirty: V,
543
+ parseError: B,
544
+ layout: R,
545
+ blocks: $e,
546
+ measures: et,
547
547
  syncCoordinator: G,
548
- loadBuffer: Ct,
549
- loadDocument: wt,
550
- save: Et,
551
- getDocument: Dt,
552
- setDocument: Ot,
553
- getHeaderFooterView: kt,
554
- syncHeaderFooterViews: At,
555
- openNoteStory: jt,
556
- closeNoteStory: Mt,
557
- getActiveNoteView: Nt,
558
- getCommands: Pt,
559
- focus: Ft,
560
- reLayout: It,
561
- destroy: Lt
548
+ loadBuffer: wt,
549
+ loadDocument: Tt,
550
+ save: Dt,
551
+ getDocument: Ot,
552
+ setDocument: kt,
553
+ getHeaderFooterView: At,
554
+ syncHeaderFooterViews: jt,
555
+ openNoteStory: Mt,
556
+ closeNoteStory: Nt,
557
+ getActiveNoteView: Pt,
558
+ getCommands: Ft,
559
+ focus: It,
560
+ reLayout: Lt,
561
+ destroy: Rt
562
562
  };
563
563
  }
564
- function M(e, t) {
564
+ function P(e, t) {
565
565
  if (t < e.top + 40) {
566
566
  let n = Math.max(0, e.top + 40 - t);
567
567
  return -Math.min(12, n / 40 * 12);
@@ -574,12 +574,12 @@ function M(e, t) {
574
574
  }
575
575
  //#endregion
576
576
  //#region src/composables/useDragAutoScroll.ts
577
- function N({ pagesContainer: e, onScrollExtendSelection: t }) {
577
+ function F({ pagesContainer: e, onScrollExtendSelection: t }) {
578
578
  let n = null, r = 0, a = 0, o = !1, s = null;
579
579
  function c() {
580
580
  if (s) return s;
581
581
  let t = e.value;
582
- return t ? (s = Ae(t), s) : null;
582
+ return t ? (s = je(t), s) : null;
583
583
  }
584
584
  function l() {
585
585
  o = !1, n !== null && (cancelAnimationFrame(n), n = null);
@@ -588,7 +588,7 @@ function N({ pagesContainer: e, onScrollExtendSelection: t }) {
588
588
  if (!o) return;
589
589
  let e = c();
590
590
  if (!e) return;
591
- let i = M(e.getBoundingClientRect(), a);
591
+ let i = P(e.getBoundingClientRect(), a);
592
592
  i !== 0 && (e.scrollTop += i, t(r, a)), n = requestAnimationFrame(u);
593
593
  }
594
594
  function d() {
@@ -609,7 +609,7 @@ function N({ pagesContainer: e, onScrollExtendSelection: t }) {
609
609
  }
610
610
  //#endregion
611
611
  //#region src/composables/useTableResize.ts
612
- function P() {
612
+ function I() {
613
613
  let e = {
614
614
  active: !1,
615
615
  startX: 0,
@@ -641,7 +641,7 @@ function P() {
641
641
  }
642
642
  function a(i, a) {
643
643
  let o = i.target;
644
- 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), F(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), I(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), L(a, n), !0) : !1 : !1;
644
+ 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), $e(a, n), !0) : !1 : !1;
645
645
  }
646
646
  function o(r) {
647
647
  if (e.active && e.handle) {
@@ -649,7 +649,7 @@ function P() {
649
649
  let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
650
650
  e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
651
651
  let i = Math.round(t * x), a = e.origWidths.left + i, o = e.origWidths.right - i;
652
- a >= b && o >= b && (e.origWidths = {
652
+ a >= y && o >= y && (e.origWidths = {
653
653
  left: a,
654
654
  right: o
655
655
  });
@@ -660,7 +660,7 @@ function P() {
660
660
  let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
661
661
  t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
662
662
  let i = Math.round(e * x), a = t.origHeight + i;
663
- a >= je && (t.origHeight = a);
663
+ a >= b && (t.origHeight = a);
664
664
  return;
665
665
  }
666
666
  if (n.active && n.handle) {
@@ -668,12 +668,12 @@ function P() {
668
668
  let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
669
669
  n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
670
670
  let i = Math.round(e * x), a = n.origWidth + i;
671
- a >= b && (n.origWidth = a);
671
+ a >= y && (n.origWidth = a);
672
672
  }
673
673
  }
674
674
  function s(i) {
675
675
  if (e.active) {
676
- e.active = !1, e.handle?.classList.remove("dragging"), r && S(r, {
676
+ e.active = !1, e.handle?.classList.remove("dragging"), r && Me(r, {
677
677
  pmStart: e.tablePmStart,
678
678
  colIdx: e.columnIndex,
679
679
  newLeft: e.origWidths.left,
@@ -689,7 +689,7 @@ function P() {
689
689
  }), t.handle = null;
690
690
  return;
691
691
  }
692
- n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && Me(r, {
692
+ n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && S(r, {
693
693
  pmStart: n.tablePmStart,
694
694
  colIdx: n.columnIndex,
695
695
  newWidth: n.origWidth
@@ -706,12 +706,12 @@ function P() {
706
706
  isResizing: i
707
707
  };
708
708
  }
709
- function F(e, t) {
709
+ function L(e, t) {
710
710
  let n = Fe(e, t.tablePmStart, t.columnIndex);
711
711
  n && (t.origWidths = n);
712
712
  }
713
- function I(e, t, n) {
714
- let r = C(e, t.tablePmStart, t.rowIndex);
713
+ function R(e, t, n) {
714
+ let r = Ie(e, t.tablePmStart, t.rowIndex);
715
715
  if (r != null) {
716
716
  t.origHeight = r;
717
717
  return;
@@ -719,18 +719,18 @@ function I(e, t, n) {
719
719
  let i = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), a = i ? i.getBoundingClientRect().height : 30;
720
720
  t.origHeight = Math.round(a * x);
721
721
  }
722
- function L(e, t) {
722
+ function $e(e, t) {
723
723
  let n = Pe(e, t.tablePmStart, t.columnIndex);
724
724
  n != null && (t.origWidth = n);
725
725
  }
726
726
  //#endregion
727
727
  //#region src/composables/useTrackedChanges.ts
728
- function R(t, n) {
729
- return e(() => (n.value, w(t.value?.state ?? null)));
728
+ function et(t, n) {
729
+ return e(() => (n.value, C(t.value?.state ?? null)));
730
730
  }
731
731
  //#endregion
732
732
  //#region src/composables/useZoom.ts
733
- var z = Ie, B = T, V = [
733
+ var z = T, B = w, V = [
734
734
  .5,
735
735
  .75,
736
736
  1,
@@ -738,16 +738,16 @@ var z = Ie, B = T, V = [
738
738
  1.5,
739
739
  2
740
740
  ];
741
- function tt(t = 1) {
741
+ function H(t = 1) {
742
742
  let i = o(Math.max(z, Math.min(B, t))), a = e(() => Math.round(i.value * 100)), s = e(() => i.value <= z), c = e(() => i.value >= B);
743
743
  function l(e) {
744
744
  i.value = Math.max(z, Math.min(B, Math.round(e * 100) / 100));
745
745
  }
746
746
  function u() {
747
- l(i.value + Le);
747
+ l(i.value + E);
748
748
  }
749
749
  function d() {
750
- l(i.value - Le);
750
+ l(i.value - E);
751
751
  }
752
752
  function f() {
753
753
  l(1);
@@ -777,4 +777,4 @@ function tt(t = 1) {
777
777
  };
778
778
  }
779
779
  //#endregion
780
- export { N as a, E as c, P as i, O as l, w as n, j as o, R as r, He as s, tt as t, k as u };
780
+ export { F as a, D as c, I as i, k as l, C as n, N as o, et as r, A as s, H as t, j as u };