@stll/folio-vue 0.6.1 → 0.7.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.
@@ -11,23 +11,24 @@ import { browserClock as v, createLayoutScheduler as ne } from "@stll/folio-core
11
11
  import { createLayoutSession as re } from "@stll/folio-core/controller/layoutSession";
12
12
  import { parseDocx as ie } from "@stll/folio-core/docx/parser";
13
13
  import { getFootnoteText as y } from "@stll/folio-core/docx/footnoteParser";
14
- import { convertHeaderFooterPmDocToContent as ae, convertHeaderFooterToContent as b } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
14
+ import { convertHeaderFooterPmDocToContent as b, convertHeaderFooterToContent as x } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
15
+ import { resolveSectionHeaderFooterRefs as ae } from "@stll/folio-core/layout-engine";
15
16
  import { LayoutPainter as oe } from "@stll/folio-core/layout-painter";
16
17
  import { LayoutSelectionGate as se } from "@stll/folio-core/paged-layout/LayoutSelectionGate";
17
18
  import { getTransactionDirtyRange as ce } from "@stll/folio-core/paged-layout/transactionDirtyRange";
18
- import { fromProseDoc as x } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
19
- import { ExtensionManager as le } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
20
- import { getChangedParagraphIds as ue, hasStructuralChanges as de, hasUntrackedChanges as fe } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
21
- import { createStarterKit as pe } from "@stll/folio-core/prosemirror/extensions/StarterKit";
22
- import { createTemplatePreviewValuesPlugin as me } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
23
- import { templateSlashMenuPlugin as he } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
19
+ import { fromProseDoc as le } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
20
+ import { ExtensionManager as ue } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
21
+ import { getChangedParagraphIds as de, hasStructuralChanges as fe, hasUntrackedChanges as pe } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
22
+ import { createStarterKit as me } from "@stll/folio-core/prosemirror/extensions/StarterKit";
23
+ import { createTemplatePreviewValuesPlugin as he } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
24
+ import { templateSlashMenuPlugin as ge } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
24
25
  import { findVerticalScrollParent as S } from "@stll/folio-core/utils/findVerticalScrollParent";
25
- import { MIN_CELL_WIDTH_TWIPS as C, MIN_ROW_HEIGHT_TWIPS as w, TWIPS_PER_PIXEL as T, commitColumnResize as E, commitRightEdgeResize as ge, commitRowResize as _e, readColumnWidthAt as ve, readColumnWidths as D, readRowHeight as ye } from "@stll/folio-core/prosemirror/tableResize";
26
- import { extractTrackedChanges as O } from "@stll/folio-core/prosemirror/utils/extractTrackedChanges";
27
- import { ZOOM_MAX as k, ZOOM_MIN as A, ZOOM_STEP as j } from "@stll/folio-core/utils/zoom";
26
+ import { MIN_CELL_WIDTH_TWIPS as C, MIN_ROW_HEIGHT_TWIPS as _e, TWIPS_PER_PIXEL as w, commitColumnResize as T, commitRightEdgeResize as E, commitRowResize as D, readColumnWidthAt as ve, readColumnWidths as O, readRowHeight as ye } from "@stll/folio-core/prosemirror/tableResize";
27
+ import { extractTrackedChanges as k } from "@stll/folio-core/prosemirror/utils/extractTrackedChanges";
28
+ import { ZOOM_MAX as be, ZOOM_MIN as xe, ZOOM_STEP as A } from "@stll/folio-core/utils/zoom";
28
29
  //#region src/composables/useDocxEditor.ts
29
- var be = 24, xe = 32, Se = 96, Ce = 250, we = [];
30
- function Te(e) {
30
+ var Se = 24, Ce = 32, we = 96, Te = 250, Ee = [];
31
+ function De(e) {
31
32
  let t = e?.columnCount ?? 1;
32
33
  if (t <= 1) return;
33
34
  let n = {
@@ -37,32 +38,17 @@ function Te(e) {
37
38
  };
38
39
  return e?.separator !== void 0 && (n.separator = e.separator), n;
39
40
  }
40
- function M(e) {
41
- let t = {};
42
- e.titlePg !== void 0 && (t.titlePg = e.titlePg);
43
- for (let n of e.headerReferences ?? []) n.type === "default" ? t.headerDefault = n.rId : n.type === "first" ? t.headerFirst = n.rId : t.headerEven = n.rId;
44
- for (let n of e.footerReferences ?? []) n.type === "default" ? t.footerDefault = n.rId : n.type === "first" ? t.footerFirst = n.rId : t.footerEven = n.rId;
45
- return t;
46
- }
47
- function Ee(e) {
48
- let t = e?.package.document;
49
- if (!t) return;
50
- let n = t.sections;
51
- if (n && n.length > 0) return n.map((e) => M(e.properties));
52
- let r = t.finalSectionProperties;
53
- if (r) return [M(r)];
54
- }
55
- var N = {
41
+ var j = {
56
42
  hf: null,
57
43
  rId: null
58
44
  };
59
- function De(e, t) {
45
+ function Oe(e, t) {
60
46
  let n = e?.package;
61
47
  if (!n || !t) return {
62
- header: N,
63
- footer: N,
64
- firstHeader: N,
65
- firstFooter: N
48
+ header: j,
49
+ footer: j,
50
+ firstHeader: j,
51
+ firstFooter: j
66
52
  };
67
53
  let r = n.headers, i = n.footers, a = (e) => e ? r?.get(e) ?? null : null, o = (e) => e ? i?.get(e) ?? null : null, s = null, c = null;
68
54
  for (let e of t.headerReferences ?? []) e.type === "default" ? s = e.rId : e.type === "first" && (c = e.rId);
@@ -87,19 +73,19 @@ function De(e, t) {
87
73
  }
88
74
  };
89
75
  }
90
- function Oe(e, t, n, r, i, a) {
76
+ function M(e, t, n, r, i, a) {
91
77
  if (!e) return;
92
78
  let o = t ? {
93
79
  ...a,
94
80
  rId: t
95
81
  } : a, s = t ? n?.getView(t) : null;
96
- return s ? ae(s.state.doc, r, i, o) : b(e, r, i, o);
82
+ return s ? b(s.state.doc, r, i, o) : x(e, r, i, o);
97
83
  }
98
84
  function ke(e, t, n, r, i) {
99
85
  if (!e || e.size === 0) return;
100
86
  let a = /* @__PURE__ */ new Map();
101
87
  for (let [o, s] of e) {
102
- let e = Oe(s, o, t, n, r, i);
88
+ let e = M(s, o, t, n, r, i);
103
89
  e && a.set(o, e);
104
90
  }
105
91
  return a.size > 0 ? a : void 0;
@@ -129,7 +115,7 @@ function Ae(e, t, n) {
129
115
  }
130
116
  return r;
131
117
  }
132
- var P = /* @__PURE__ */ new Set([
118
+ var N = /* @__PURE__ */ new Set([
133
119
  "black",
134
120
  "blue",
135
121
  "cyan",
@@ -150,7 +136,7 @@ var P = /* @__PURE__ */ new Set([
150
136
  ]);
151
137
  function je(e) {
152
138
  let t = [], n = (e, r) => {
153
- for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !P.has(String(i.attrs.color)) && t.push(`${r}.marks[${n}]=${JSON.stringify(i.attrs)}`);
139
+ for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !N.has(String(i.attrs.color)) && t.push(`${r}.marks[${n}]=${JSON.stringify(i.attrs)}`);
154
140
  e.forEach((e, t, i) => {
155
141
  n(e, `${r}.content[${i}]`);
156
142
  });
@@ -160,31 +146,31 @@ function je(e) {
160
146
  function Me() {
161
147
  return typeof document > "u" || !("fonts" in document) || document.fonts.status === "loaded";
162
148
  }
163
- function F(e) {
164
- let { hiddenContainer: t, pagesContainer: n, readOnly: u = !1, pageGap: y = be, documentKey: ae, password: b, editorMode: S, author: C, externalPlugins: w = [], onAnonymizationMatchesChange: T, showTemplateDirectives: E, onSlashMenuChange: ge, onSlashMenuKeyAction: _e, onChange: ve, onError: D, onSelectionUpdate: ye, onEditorViewReady: O, onReadOnlyEditAttempt: k, featureFlags: A, onSelectiveSaveTripwire: j } = e, M = a(null), N = a(null), P = a(null), F = a(null), I = a([]), L = a([]), R = i(!1), z = i(null), B = i(!1), V = new le(pe());
149
+ function P(e) {
150
+ let { hiddenContainer: t, pagesContainer: n, readOnly: u = !1, pageGap: y = Se, documentKey: b, password: x, editorMode: S, author: C, externalPlugins: _e = [], onAnonymizationMatchesChange: w, showTemplateDirectives: T, onSlashMenuChange: E, onSlashMenuKeyAction: D, onChange: ve, onError: O, onSelectionUpdate: ye, onEditorViewReady: k, onReadOnlyEditAttempt: be, featureFlags: xe, onSelectiveSaveTripwire: A } = e, j = a(null), N = a(null), P = a(null), F = a(null), I = a([]), L = a([]), R = i(!1), z = i(null), B = i(!1), V = new ue(me());
165
151
  V.buildSchema(), V.initializeRuntime();
166
- let H = p(!1), U = d({ onMatchesChange: (e) => T?.(e) }), W = f(), G = he({
167
- onChange: (e) => ge?.(e),
168
- onKeyAction: (e) => _e?.(e) ?? !1
169
- }), K = me(), q = () => o(E) === !0;
170
- function Ne() {
152
+ let H = p(!1), U = d({ onMatchesChange: (e) => w?.(e) }), W = f(), G = ge({
153
+ onChange: (e) => E?.(e),
154
+ onKeyAction: (e) => D?.(e) ?? !1
155
+ }), Ne = he(), K = () => o(T) === !0;
156
+ function Pe() {
171
157
  return [
172
158
  H,
173
- ...w,
159
+ ..._e,
174
160
  U,
175
- ...q() ? [W, G] : [],
176
- K
161
+ ...K() ? [W, G] : [],
162
+ Ne
177
163
  ];
178
164
  }
179
- let J = ee(), Y = new se(), Pe = re(), Fe = new oe({
165
+ let q = ee(), J = new se(), Fe = re(), Y = new oe({
180
166
  pageGap: y,
181
167
  showShadow: !0
182
168
  });
183
169
  function Ie(e) {
184
- e.layout && (F.value = e.layout), e.blocks && (I.value = e.blocks), e.measures && (L.value = e.measures), e.blockLookup && Fe.setBlockLookup(e.blockLookup), e.layout && J.emit("layoutComplete", e.layout);
170
+ e.layout && (F.value = e.layout), e.blocks && (I.value = e.blocks), e.measures && (L.value = e.measures), e.blockLookup && Y.setBlockLookup(e.blockLookup), e.layout && q.emit("layoutComplete", e.layout);
185
171
  }
186
172
  function X(e, t = {}) {
187
- let r = n.value, i = r instanceof HTMLDivElement ? r : null, a = M.value, o = a?.package.document, s = o?.sections?.[0]?.properties ?? o?.finalSectionProperties ?? null, u = l(s), d = c(s), f = Te(s), p = u.w - d.left - d.right, m = a?.package.styles ?? null, h = a?.package.theme ?? null, ee = a?.package.settings?.defaultTabStop, g = a?.package.settings, _ = g !== void 0 && "mirrorMargins" in g && g.mirrorMargins === !0, v = De(a, s);
173
+ let r = n.value, i = r instanceof HTMLDivElement ? r : null, a = j.value, o = a?.package.document, s = o?.sections?.[0]?.properties ?? o?.finalSectionProperties ?? null, u = l(s), d = c(s), f = De(s), p = u.w - d.left - d.right, m = a?.package.styles ?? null, h = a?.package.theme ?? null, ee = a?.package.settings?.defaultTabStop, g = a?.package.settings, _ = g !== void 0 && "mirrorMargins" in g && g.mirrorMargins === !0, v = Oe(a, s);
188
174
  try {
189
175
  Ie(te({
190
176
  contentWidth: p,
@@ -192,7 +178,7 @@ function F(e) {
192
178
  pageSize: u,
193
179
  margins: d,
194
180
  pageGap: y,
195
- syncCoordinator: Y,
181
+ syncCoordinator: J,
196
182
  headerContent: v.header.hf,
197
183
  footerContent: v.footer.hf,
198
184
  firstPageHeaderContent: v.firstHeader.hf,
@@ -201,7 +187,7 @@ function F(e) {
201
187
  footerContentRId: v.footer.rId,
202
188
  firstPageHeaderContentRId: v.firstHeader.rId,
203
189
  firstPageFooterContentRId: v.firstFooter.rId,
204
- sectionHeaderFooterRefs: Ee(a),
190
+ sectionHeaderFooterRefs: ae(a),
205
191
  theme: h,
206
192
  sectionProperties: s,
207
193
  document: a,
@@ -210,74 +196,74 @@ function F(e) {
210
196
  styles: m,
211
197
  layout: F.value,
212
198
  hfPMs: null,
213
- painter: Fe,
199
+ painter: Y,
214
200
  pagesContainer: i,
215
- session: Pe,
216
- renderHfFromContentOrPm: Oe,
201
+ session: Fe,
202
+ renderHfFromContentOrPm: M,
217
203
  renderHeaderFooterContentByRId: ke,
218
204
  documentFontsAreLoaded: Me,
219
205
  buildFootnoteRenderItems: Ae,
220
206
  describeInvalidHighlightMarks: je,
221
- emptyTemplatePreviewEntries: we
207
+ emptyTemplatePreviewEntries: Ee
222
208
  }, e, t));
223
209
  } catch (e) {
224
210
  let t = e instanceof Error ? e : Error(String(e));
225
- D?.(t);
211
+ O?.(t);
226
212
  }
227
213
  }
228
214
  let Z = ne({
229
215
  runLayout: (e, t) => X(e, t),
230
- debounceMs: xe,
231
- maxDelayMs: Se,
216
+ debounceMs: Ce,
217
+ maxDelayMs: we,
232
218
  clock: v
233
219
  }), Q = null;
234
220
  function Le() {
235
221
  Q !== null && (window.clearTimeout(Q), Q = null);
236
- let e = N.value, t = M.value;
222
+ let e = N.value, t = j.value;
237
223
  if (!(!e || !t)) try {
238
- let n = x(e.state.doc, t);
239
- M.value = n, ve?.(n), J.emit("docChange", n);
224
+ let n = le(e.state.doc, t);
225
+ j.value = n, ve?.(n), q.emit("docChange", n);
240
226
  } catch (e) {
241
- D?.(e instanceof Error ? e : Error(String(e)));
227
+ O?.(e instanceof Error ? e : Error(String(e)));
242
228
  }
243
229
  }
244
230
  function Re() {
245
231
  Q !== null && window.clearTimeout(Q), Q = window.setTimeout(() => {
246
232
  Q = null, Le();
247
- }, Ce);
233
+ }, Te);
248
234
  }
249
235
  let $ = g({
250
236
  getHost: () => t.value,
251
- getDocument: () => M.value,
252
- getStyles: () => M.value?.package.styles ?? null,
237
+ getDocument: () => j.value,
238
+ getStyles: () => j.value?.package.styles ?? null,
253
239
  getExtensionManager: () => V,
254
- getExternalPlugins: Ne,
240
+ getExternalPlugins: Pe,
255
241
  getCollaboration: () => void 0,
256
242
  getCollaborationModules: () => null,
257
243
  getPrecomputedInitialState: () => null,
258
244
  getReadOnly: () => o(u),
259
- getDocumentKey: () => o(ae),
260
- getDocumentContext: () => M.value,
245
+ getDocumentKey: () => o(b),
246
+ getDocumentContext: () => j.value,
261
247
  onTransaction: ze,
262
248
  onSelectionChange: (e) => {
263
- P.value = e, ye?.(e), J.emit("selectionChange", {
249
+ P.value = e, ye?.(e), q.emit("selectionChange", {
264
250
  from: e.selection.from,
265
251
  to: e.selection.to
266
252
  });
267
253
  },
268
254
  onKeyDown: () => !1,
269
- onReadOnlyEditAttempt: () => k?.(),
255
+ onReadOnlyEditAttempt: () => be?.(),
270
256
  onEditorViewReady: Be,
271
257
  onEditorViewDestroy: () => {
272
- N.value = null, R.value = !1, O?.(null);
258
+ N.value = null, R.value = !1, k?.(null);
273
259
  },
274
260
  onRemoteSelectionsChange: () => {}
275
261
  });
276
262
  function ze(e, t) {
277
- P.value = t, e.docChanged && (B.value = !0, Y.incrementStateSeq(), Z.schedule(t, ce(e)), Re()), Y.requestRender();
263
+ P.value = t, e.docChanged && (B.value = !0, J.incrementStateSeq(), Z.schedule(t, ce(e)), Re()), J.requestRender();
278
264
  }
279
265
  function Be(e) {
280
- N.value = e, P.value = e.state, R.value = !0, X(e.state, { reason: "initial" }), Y.requestRender(), He(e), O?.(e), o(u) || requestAnimationFrame(() => {
266
+ N.value = e, P.value = e.state, R.value = !0, X(e.state, { reason: "initial" }), J.requestRender(), He(e), k?.(e), o(u) || requestAnimationFrame(() => {
281
267
  N.value === e && e.focus();
282
268
  });
283
269
  }
@@ -285,7 +271,7 @@ function F(e) {
285
271
  getEditorApi: () => $.api,
286
272
  getLayout: () => F.value,
287
273
  runLayout: (e, t) => X(e, t),
288
- emitter: J
274
+ emitter: q
289
275
  });
290
276
  function He(e) {
291
277
  m(o(S) === "suggesting", e.state, e.dispatch, o(C));
@@ -295,16 +281,16 @@ function F(e) {
295
281
  e && He(e);
296
282
  }), s(() => o(u), () => $.syncEditable());
297
283
  function Ue(e) {
298
- let t = q();
284
+ let t = K();
299
285
  if (t === e.state.plugins.includes(W)) return;
300
286
  let n = e.state.plugins.filter((e) => e !== W && e !== G);
301
287
  if (t) {
302
- let e = n.indexOf(K), t = e === -1 ? n.length : e;
288
+ let e = n.indexOf(Ne), t = e === -1 ? n.length : e;
303
289
  n.splice(t, 0, W, G);
304
290
  }
305
291
  e.updateState(e.state.reconfigure({ plugins: n }));
306
292
  }
307
- s(() => q(), () => {
293
+ s(() => K(), () => {
308
294
  let e = N.value;
309
295
  e && Ue(e);
310
296
  });
@@ -315,47 +301,47 @@ function F(e) {
315
301
  B.value = !1, Z.dispose(), $.destroyView(), $.ensureView(), $.getView() || Ke();
316
302
  }
317
303
  function Ke() {
318
- let e = M.value;
304
+ let e = j.value;
319
305
  if (e) try {
320
306
  let t = _({
321
307
  document: e,
322
308
  styles: e.package.styles ?? null,
323
309
  manager: V,
324
- externalPlugins: Ne(),
310
+ externalPlugins: Pe(),
325
311
  collaborationModules: null,
326
312
  reason: "mount"
327
313
  });
328
314
  P.value = t, X(t, { reason: "initial" });
329
315
  } catch (e) {
330
- D?.(e instanceof Error ? e : Error(String(e)));
316
+ O?.(e instanceof Error ? e : Error(String(e)));
331
317
  }
332
318
  }
333
319
  s([t, n], () => {
334
- t.value && M.value && !$.getView() && We();
320
+ t.value && j.value && !$.getView() && We();
335
321
  }, { flush: "post" });
336
322
  async function qe(e) {
337
323
  z.value = null, R.value = !1;
338
324
  try {
339
- let t = await ie(e, { password: o(b) });
340
- M.value = t, Ge();
325
+ let t = await ie(e, { password: o(x) });
326
+ j.value = t, Ge();
341
327
  } catch (e) {
342
328
  let t = e instanceof Error ? e : Error(String(e));
343
- z.value = t.message, D?.(t);
329
+ z.value = t.message, O?.(t);
344
330
  }
345
331
  }
346
332
  function Je(e) {
347
- z.value = null, M.value = e, Ge();
333
+ z.value = null, j.value = e, Ge();
348
334
  }
349
335
  async function Ye(e) {
350
- let t = N.value, n = M.value;
336
+ let t = N.value, n = j.value;
351
337
  if (!t || !n) return null;
352
- let r = t.state, { resolveSelectiveSaveFlags: i } = await import("@stll/folio-core/docx/selectiveSaveFlags"), a = i(o(A)), s = x(r.doc, n), c = s.originalBuffer ?? null, l = a.selectiveSave && e?.selective !== !1, u = l || a.selectiveSaveTripwire, { repackDocx: d, createDocx: f } = await import("@stll/folio-core/docx/rezip"), p = null;
338
+ let r = t.state, { resolveSelectiveSaveFlags: i } = await import("@stll/folio-core/docx/selectiveSaveFlags"), a = i(o(xe)), s = le(r.doc, n), c = s.originalBuffer ?? null, l = a.selectiveSave && e?.selective !== !1, u = l || a.selectiveSaveTripwire, { repackDocx: d, createDocx: f } = await import("@stll/folio-core/docx/rezip"), p = null;
353
339
  if (u && c) {
354
340
  let { attemptSelectiveSave: e } = await import("@stll/folio-core/docx/selectiveSave");
355
341
  p = await e(s, c, {
356
- changedParaIds: ue(r),
357
- structuralChange: de(r),
358
- hasUntrackedChanges: fe(r),
342
+ changedParaIds: de(r),
343
+ structuralChange: fe(r),
344
+ hasUntrackedChanges: pe(r),
359
345
  maxBytes: a.selectiveSaveMaxBytes
360
346
  });
361
347
  }
@@ -364,17 +350,17 @@ function F(e) {
364
350
  else if (a.selectiveSaveTripwire) try {
365
351
  h = await d(s);
366
352
  } catch {}
367
- if (a.selectiveSaveTripwire && h && j) try {
353
+ if (a.selectiveSaveTripwire && h && A) try {
368
354
  let { compareSelectiveVsFull: e } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
369
- j(await e(p, h));
355
+ A(await e(p, h));
370
356
  } catch {}
371
357
  return B.value = !1, new Blob([m], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
372
358
  }
373
359
  function Xe() {
374
- return M.value;
360
+ return j.value;
375
361
  }
376
362
  function Ze(e) {
377
- M.value = e;
363
+ j.value = e;
378
364
  }
379
365
  function Qe() {
380
366
  return V.getCommands();
@@ -387,7 +373,7 @@ function F(e) {
387
373
  e && X(e.state, { reason: "manual" });
388
374
  }
389
375
  function tt() {
390
- Z.dispose(), Q !== null && (window.clearTimeout(Q), Q = null), $.destroyView(), V.destroy(), P.value = null, F.value = null, M.value = null, R.value = !1;
376
+ Z.dispose(), Q !== null && (window.clearTimeout(Q), Q = null), $.destroyView(), V.destroy(), P.value = null, F.value = null, j.value = null, R.value = !1;
391
377
  }
392
378
  return r(tt), {
393
379
  editor: Ve,
@@ -410,7 +396,7 @@ function F(e) {
410
396
  destroy: tt
411
397
  };
412
398
  }
413
- function I(e, t) {
399
+ function F(e, t) {
414
400
  if (t < e.top + 40) {
415
401
  let n = Math.max(0, e.top + 40 - t);
416
402
  return -Math.min(12, n / 40 * 12);
@@ -423,7 +409,7 @@ function I(e, t) {
423
409
  }
424
410
  //#endregion
425
411
  //#region src/composables/useDragAutoScroll.ts
426
- function L({ pagesContainer: e, onScrollExtendSelection: t }) {
412
+ function I({ pagesContainer: e, onScrollExtendSelection: t }) {
427
413
  let n = null, i = 0, a = 0, o = !1, s = null;
428
414
  function c() {
429
415
  if (s) return s;
@@ -437,7 +423,7 @@ function L({ pagesContainer: e, onScrollExtendSelection: t }) {
437
423
  if (!o) return;
438
424
  let e = c();
439
425
  if (!e) return;
440
- let r = I(e.getBoundingClientRect(), a);
426
+ let r = F(e.getBoundingClientRect(), a);
441
427
  r !== 0 && (e.scrollTop += r, t(i, a)), n = requestAnimationFrame(u);
442
428
  }
443
429
  function d() {
@@ -458,7 +444,7 @@ function L({ pagesContainer: e, onScrollExtendSelection: t }) {
458
444
  }
459
445
  //#endregion
460
446
  //#region src/composables/useTableResize.ts
461
- function R() {
447
+ function L() {
462
448
  let e = {
463
449
  active: !1,
464
450
  startX: 0,
@@ -490,14 +476,14 @@ function R() {
490
476
  }
491
477
  function a(i, a) {
492
478
  let o = i.target;
493
- 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), z(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), B(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), V(a, n), !0) : !1 : !1;
479
+ 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), R(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), z(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), B(a, n), !0) : !1 : !1;
494
480
  }
495
481
  function o(r) {
496
482
  if (e.active && e.handle) {
497
483
  r.preventDefault();
498
484
  let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
499
485
  e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
500
- let i = Math.round(t * T), a = e.origWidths.left + i, o = e.origWidths.right - i;
486
+ let i = Math.round(t * w), a = e.origWidths.left + i, o = e.origWidths.right - i;
501
487
  a >= C && o >= C && (e.origWidths = {
502
488
  left: a,
503
489
  right: o
@@ -508,21 +494,21 @@ function R() {
508
494
  r.preventDefault();
509
495
  let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
510
496
  t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
511
- let i = Math.round(e * T), a = t.origHeight + i;
512
- a >= w && (t.origHeight = a);
497
+ let i = Math.round(e * w), a = t.origHeight + i;
498
+ a >= _e && (t.origHeight = a);
513
499
  return;
514
500
  }
515
501
  if (n.active && n.handle) {
516
502
  r.preventDefault();
517
503
  let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
518
504
  n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
519
- let i = Math.round(e * T), a = n.origWidth + i;
505
+ let i = Math.round(e * w), a = n.origWidth + i;
520
506
  a >= C && (n.origWidth = a);
521
507
  }
522
508
  }
523
509
  function s(i) {
524
510
  if (e.active) {
525
- e.active = !1, e.handle?.classList.remove("dragging"), r && E(r, {
511
+ e.active = !1, e.handle?.classList.remove("dragging"), r && T(r, {
526
512
  pmStart: e.tablePmStart,
527
513
  colIdx: e.columnIndex,
528
514
  newLeft: e.origWidths.left,
@@ -531,14 +517,14 @@ function R() {
531
517
  return;
532
518
  }
533
519
  if (t.active) {
534
- t.active = !1, t.handle?.classList.remove("dragging"), r && _e(r, {
520
+ t.active = !1, t.handle?.classList.remove("dragging"), r && D(r, {
535
521
  pmStart: t.tablePmStart,
536
522
  rowIdx: t.rowIndex,
537
523
  newHeight: t.origHeight
538
524
  }), t.handle = null;
539
525
  return;
540
526
  }
541
- n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && ge(r, {
527
+ n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && E(r, {
542
528
  pmStart: n.tablePmStart,
543
529
  colIdx: n.columnIndex,
544
530
  newWidth: n.origWidth
@@ -555,31 +541,31 @@ function R() {
555
541
  isResizing: i
556
542
  };
557
543
  }
558
- function z(e, t) {
559
- let n = D(e, t.tablePmStart, t.columnIndex);
544
+ function R(e, t) {
545
+ let n = O(e, t.tablePmStart, t.columnIndex);
560
546
  n && (t.origWidths = n);
561
547
  }
562
- function B(e, t, n) {
548
+ function z(e, t, n) {
563
549
  let r = ye(e, t.tablePmStart, t.rowIndex);
564
550
  if (r != null) {
565
551
  t.origHeight = r;
566
552
  return;
567
553
  }
568
554
  let i = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), a = i ? i.getBoundingClientRect().height : 30;
569
- t.origHeight = Math.round(a * T);
555
+ t.origHeight = Math.round(a * w);
570
556
  }
571
- function V(e, t) {
557
+ function B(e, t) {
572
558
  let n = ve(e, t.tablePmStart, t.columnIndex);
573
559
  n != null && (t.origWidth = n);
574
560
  }
575
561
  //#endregion
576
562
  //#region src/composables/useTrackedChanges.ts
577
- function H(t, n) {
578
- return e(() => (n.value, O(t.value?.state ?? null)));
563
+ function V(t, n) {
564
+ return e(() => (n.value, k(t.value?.state ?? null)));
579
565
  }
580
566
  //#endregion
581
567
  //#region src/composables/useZoom.ts
582
- var U = A, W = k, G = [
568
+ var H = xe, U = be, W = [
583
569
  .5,
584
570
  .75,
585
571
  1,
@@ -587,16 +573,16 @@ var U = A, W = k, G = [
587
573
  1.5,
588
574
  2
589
575
  ];
590
- function K(r = 1) {
591
- let a = i(Math.max(U, Math.min(W, r))), o = e(() => Math.round(a.value * 100)), s = e(() => a.value <= U), c = e(() => a.value >= W);
576
+ function G(r = 1) {
577
+ let a = i(Math.max(H, Math.min(U, r))), o = e(() => Math.round(a.value * 100)), s = e(() => a.value <= H), c = e(() => a.value >= U);
592
578
  function l(e) {
593
- a.value = Math.max(U, Math.min(W, Math.round(e * 100) / 100));
579
+ a.value = Math.max(H, Math.min(U, Math.round(e * 100) / 100));
594
580
  }
595
581
  function u() {
596
- l(a.value + j);
582
+ l(a.value + A);
597
583
  }
598
584
  function d() {
599
- l(a.value - j);
585
+ l(a.value - A);
600
586
  }
601
587
  function f() {
602
588
  l(1);
@@ -622,8 +608,8 @@ function K(r = 1) {
622
608
  handleWheel: p,
623
609
  handleKeyDown: m,
624
610
  installShortcuts: h,
625
- ZOOM_PRESETS: G
611
+ ZOOM_PRESETS: W
626
612
  };
627
613
  }
628
614
  //#endregion
629
- export { L as a, R as i, O as n, F as o, H as r, K as t };
615
+ export { I as a, L as i, k as n, P as o, V as r, G as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/folio-vue",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Vue 3 editor for folio: a Word-document (.docx) editor for the browser, built on @stll/folio-core and ProseMirror.",
5
5
  "keywords": [
6
6
  "document-editor",
@@ -1 +0,0 @@
1
- let e=require("vue"),t=require("@stll/folio-core/paged-layout/sectionGeometry"),n=require("@stll/folio-core/prosemirror/plugins/anonymizationDecorations"),r=require("@stll/folio-core/prosemirror/plugins/templateDirectives"),i=require("@stll/folio-core/prosemirror/plugins/suggestionMode"),a=require("@stll/folio-core/controller/folioEditor"),o=require("@stll/folio-core/controller/folioEditorEvents"),s=require("@stll/folio-core/controller/hiddenEditorManager"),c=require("@stll/folio-core/controller/layoutPipeline"),l=require("@stll/folio-core/controller/layoutScheduler"),u=require("@stll/folio-core/controller/layoutSession"),d=require("@stll/folio-core/docx/parser"),f=require("@stll/folio-core/docx/footnoteParser"),p=require("@stll/folio-core/layout-bridge/convert/headerFooterLayout"),m=require("@stll/folio-core/layout-painter"),h=require("@stll/folio-core/paged-layout/LayoutSelectionGate"),g=require("@stll/folio-core/paged-layout/transactionDirtyRange"),_=require("@stll/folio-core/prosemirror/conversion/fromProseDoc"),v=require("@stll/folio-core/prosemirror/extensions/ExtensionManager"),y=require("@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension"),ee=require("@stll/folio-core/prosemirror/extensions/StarterKit"),te=require("@stll/folio-core/prosemirror/plugins/templatePreviewValues"),ne=require("@stll/folio-core/prosemirror/plugins/templateSlashMenu"),b=require("@stll/folio-core/utils/findVerticalScrollParent"),x=require("@stll/folio-core/prosemirror/tableResize"),S=require("@stll/folio-core/prosemirror/utils/extractTrackedChanges"),C=require("@stll/folio-core/utils/zoom");var re=24,ie=32,ae=96,oe=250,se=[];function ce(e){let n=e?.columnCount??1;if(n<=1)return;let r={count:n,gap:(0,t.twipsToPixels)(e?.columnSpace??720),equalWidth:e?.equalWidth??!0};return e?.separator!==void 0&&(r.separator=e.separator),r}function w(e){let t={};e.titlePg!==void 0&&(t.titlePg=e.titlePg);for(let n of e.headerReferences??[])n.type==="default"?t.headerDefault=n.rId:n.type===`first`?t.headerFirst=n.rId:t.headerEven=n.rId;for(let n of e.footerReferences??[])n.type==="default"?t.footerDefault=n.rId:n.type===`first`?t.footerFirst=n.rId:t.footerEven=n.rId;return t}function le(e){let t=e?.package.document;if(!t)return;let n=t.sections;if(n&&n.length>0)return n.map(e=>w(e.properties));let r=t.finalSectionProperties;if(r)return[w(r)]}var T={hf:null,rId:null};function ue(e,t){let n=e?.package;if(!n||!t)return{header:T,footer:T,firstHeader:T,firstFooter:T};let r=n.headers,i=n.footers,a=e=>e?r?.get(e)??null:null,o=e=>e?i?.get(e)??null:null,s=null,c=null;for(let e of t.headerReferences??[])e.type==="default"?s=e.rId:e.type===`first`&&(c=e.rId);let l=null,u=null;for(let e of t.footerReferences??[])e.type==="default"?l=e.rId:e.type===`first`&&(u=e.rId);return{header:{hf:a(s),rId:s},footer:{hf:o(l),rId:l},firstHeader:{hf:a(c),rId:c},firstFooter:{hf:o(u),rId:u}}}function E(e,t,n,r,i,a){if(!e)return;let o=t?{...a,rId:t}:a,s=t?n?.getView(t):null;return s?(0,p.convertHeaderFooterPmDocToContent)(s.state.doc,r,i,o):(0,p.convertHeaderFooterToContent)(e,r,i,o)}function de(e,t,n,r,i){if(!e||e.size===0)return;let a=new Map;for(let[o,s]of e){let e=E(s,o,t,n,r,i);e&&a.set(o,e)}return a.size>0?a:void 0}function fe(e,t,n){let r=new Map;if(!n||!n.package.footnotes)return r;let i=new Map;for(let e of n.package.footnotes)e.noteType&&e.noteType!==`normal`||i.set(e.id,e);for(let[n,a]of e){let e=[];for(let n of a){let r=i.get(n);if(!r)continue;let a=t.get(n),o=a?.displayNumber??0;e.push({displayNumber:String(o),text:(0,f.getFootnoteText)(r),...a?{content:{blocks:a.blocks,measures:a.measures,height:a.height}}:{}})}e.length>0&&r.set(n,e)}return r}var D=new Set([`black`,`blue`,`cyan`,`darkBlue`,`darkCyan`,`darkGray`,`darkGreen`,`darkMagenta`,`darkRed`,`darkYellow`,`green`,`lightGray`,`magenta`,`none`,`red`,`white`,`yellow`]);function pe(e){let t=[],n=(e,r)=>{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)}`);e.forEach((e,t,i)=>{n(e,`${r}.content[${i}]`)})};return n(e,`doc`),t.join(`; `)}function me(){return typeof document>`u`||!(`fonts`in document)||document.fonts.status===`loaded`}function he(f){let{hiddenContainer:p,pagesContainer:b,readOnly:x=!1,pageGap:S=re,documentKey:C,password:w,editorMode:T,author:D,externalPlugins:he=[],onAnonymizationMatchesChange:ge,showTemplateDirectives:_e,onSlashMenuChange:ve,onSlashMenuKeyAction:O,onChange:k,onError:A,onSelectionUpdate:j,onEditorViewReady:M,onReadOnlyEditAttempt:N,featureFlags:P,onSelectiveSaveTripwire:F}=f,I=(0,e.shallowRef)(null),L=(0,e.shallowRef)(null),R=(0,e.shallowRef)(null),z=(0,e.shallowRef)(null),B=(0,e.shallowRef)([]),ye=(0,e.shallowRef)([]),V=(0,e.ref)(!1),H=(0,e.ref)(null),U=(0,e.ref)(!1),W=new v.ExtensionManager((0,ee.createStarterKit)());W.buildSchema(),W.initializeRuntime();let be=(0,i.createSuggestionModePlugin)(!1),xe=(0,n.createAnonymizationDecorationsPlugin)({onMatchesChange:e=>ge?.(e)}),G=(0,r.createTemplateDirectivesPlugin)(),K=(0,ne.templateSlashMenuPlugin)({onChange:e=>ve?.(e),onKeyAction:e=>O?.(e)??!1}),Se=(0,te.createTemplatePreviewValuesPlugin)(),q=()=>(0,e.toValue)(_e)===!0;function Ce(){return[be,...he,xe,...q()?[G,K]:[],Se]}let J=(0,o.createFolioEditorEmitter)(),Y=new h.LayoutSelectionGate,we=(0,u.createLayoutSession)(),Te=new m.LayoutPainter({pageGap:S,showShadow:!0});function Ee(e){e.layout&&(z.value=e.layout),e.blocks&&(B.value=e.blocks),e.measures&&(ye.value=e.measures),e.blockLookup&&Te.setBlockLookup(e.blockLookup),e.layout&&J.emit(`layoutComplete`,e.layout)}function X(e,n={}){let r=b.value,i=r instanceof HTMLDivElement?r:null,a=I.value,o=a?.package.document,s=o?.sections?.[0]?.properties??o?.finalSectionProperties??null,l=(0,t.getPageSize)(s),u=(0,t.getMargins)(s),d=ce(s),f=l.w-u.left-u.right,p=a?.package.styles??null,m=a?.package.theme??null,h=a?.package.settings?.defaultTabStop,g=a?.package.settings,_=g!==void 0&&`mirrorMargins`in g&&g.mirrorMargins===!0,v=ue(a,s);try{Ee((0,c.runLayoutPipeline)({contentWidth:f,columns:d,pageSize:l,margins:u,pageGap:S,syncCoordinator:Y,headerContent:v.header.hf,footerContent:v.footer.hf,firstPageHeaderContent:v.firstHeader.hf,firstPageFooterContent:v.firstFooter.hf,headerContentRId:v.header.rId,footerContentRId:v.footer.rId,firstPageHeaderContentRId:v.firstHeader.rId,firstPageFooterContentRId:v.firstFooter.rId,sectionHeaderFooterRefs:le(a),theme:m,sectionProperties:s,document:a,defaultTabStop:h,mirrorMargins:_,styles:p,layout:z.value,hfPMs:null,painter:Te,pagesContainer:i,session:we,renderHfFromContentOrPm:E,renderHeaderFooterContentByRId:de,documentFontsAreLoaded:me,buildFootnoteRenderItems:fe,describeInvalidHighlightMarks:pe,emptyTemplatePreviewEntries:se},e,n))}catch(e){let t=e instanceof Error?e:Error(String(e));A?.(t)}}let Z=(0,l.createLayoutScheduler)({runLayout:(e,t)=>X(e,t),debounceMs:ie,maxDelayMs:ae,clock:l.browserClock}),Q=null;function De(){Q!==null&&(window.clearTimeout(Q),Q=null);let e=L.value,t=I.value;if(!(!e||!t))try{let n=(0,_.fromProseDoc)(e.state.doc,t);I.value=n,k?.(n),J.emit(`docChange`,n)}catch(e){A?.(e instanceof Error?e:Error(String(e)))}}function Oe(){Q!==null&&window.clearTimeout(Q),Q=window.setTimeout(()=>{Q=null,De()},oe)}let $=(0,s.createHiddenEditorManager)({getHost:()=>p.value,getDocument:()=>I.value,getStyles:()=>I.value?.package.styles??null,getExtensionManager:()=>W,getExternalPlugins:Ce,getCollaboration:()=>void 0,getCollaborationModules:()=>null,getPrecomputedInitialState:()=>null,getReadOnly:()=>(0,e.toValue)(x),getDocumentKey:()=>(0,e.toValue)(C),getDocumentContext:()=>I.value,onTransaction:ke,onSelectionChange:e=>{R.value=e,j?.(e),J.emit(`selectionChange`,{from:e.selection.from,to:e.selection.to})},onKeyDown:()=>!1,onReadOnlyEditAttempt:()=>N?.(),onEditorViewReady:Ae,onEditorViewDestroy:()=>{L.value=null,V.value=!1,M?.(null)},onRemoteSelectionsChange:()=>{}});function ke(e,t){R.value=t,e.docChanged&&(U.value=!0,Y.incrementStateSeq(),Z.schedule(t,(0,g.getTransactionDirtyRange)(e)),Oe()),Y.requestRender()}function Ae(t){L.value=t,R.value=t.state,V.value=!0,X(t.state,{reason:`initial`}),Y.requestRender(),Me(t),M?.(t),(0,e.toValue)(x)||requestAnimationFrame(()=>{L.value===t&&t.focus()})}let je=(0,a.createFolioEditor)({getEditorApi:()=>$.api,getLayout:()=>z.value,runLayout:(e,t)=>X(e,t),emitter:J});function Me(t){(0,i.setSuggestionMode)((0,e.toValue)(T)===`suggesting`,t.state,t.dispatch,(0,e.toValue)(D))}(0,e.watch)([()=>(0,e.toValue)(T),()=>(0,e.toValue)(D)],()=>{let e=L.value;e&&Me(e)}),(0,e.watch)(()=>(0,e.toValue)(x),()=>$.syncEditable());function Ne(e){let t=q();if(t===e.state.plugins.includes(G))return;let n=e.state.plugins.filter(e=>e!==G&&e!==K);if(t){let e=n.indexOf(Se),t=e===-1?n.length:e;n.splice(t,0,G,K)}e.updateState(e.state.reconfigure({plugins:n}))}(0,e.watch)(()=>q(),()=>{let e=L.value;e&&Ne(e)});function Pe(){$.ensureView()}function Fe(){U.value=!1,Z.dispose(),$.destroyView(),$.ensureView(),$.getView()||Ie()}function Ie(){let e=I.value;if(e)try{let t=(0,s.createHiddenEditorState)({document:e,styles:e.package.styles??null,manager:W,externalPlugins:Ce(),collaborationModules:null,reason:`mount`});R.value=t,X(t,{reason:`initial`})}catch(e){A?.(e instanceof Error?e:Error(String(e)))}}(0,e.watch)([p,b],()=>{p.value&&I.value&&!$.getView()&&Pe()},{flush:`post`});async function Le(t){H.value=null,V.value=!1;try{let n=await(0,d.parseDocx)(t,{password:(0,e.toValue)(w)});I.value=n,Fe()}catch(e){let t=e instanceof Error?e:Error(String(e));H.value=t.message,A?.(t)}}function Re(e){H.value=null,I.value=e,Fe()}async function ze(t){let n=L.value,r=I.value;if(!n||!r)return null;let i=n.state,{resolveSelectiveSaveFlags:a}=await import(`@stll/folio-core/docx/selectiveSaveFlags`),o=a((0,e.toValue)(P)),s=(0,_.fromProseDoc)(i.doc,r),c=s.originalBuffer??null,l=o.selectiveSave&&t?.selective!==!1,u=l||o.selectiveSaveTripwire,{repackDocx:d,createDocx:f}=await import(`@stll/folio-core/docx/rezip`),p=null;if(u&&c){let{attemptSelectiveSave:e}=await import(`@stll/folio-core/docx/selectiveSave`);p=await e(s,c,{changedParaIds:(0,y.getChangedParagraphIds)(i),structuralChange:(0,y.hasStructuralChanges)(i),hasUntrackedChanges:(0,y.hasUntrackedChanges)(i),maxBytes:o.selectiveSaveMaxBytes})}let m=l?p:null,h=null;if(!m)h=c?await d(s):await f(s),m=h;else if(o.selectiveSaveTripwire)try{h=await d(s)}catch{}if(o.selectiveSaveTripwire&&h&&F)try{let{compareSelectiveVsFull:e}=await import(`@stll/folio-core/docx/selectiveSaveTripwire`);F(await e(p,h))}catch{}return U.value=!1,new Blob([m],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})}function Be(){return I.value}function Ve(e){I.value=e}function He(){return W.getCommands()}function Ue(){L.value?.focus()}function We(){let e=L.value;e&&X(e.state,{reason:`manual`})}function Ge(){Z.dispose(),Q!==null&&(window.clearTimeout(Q),Q=null),$.destroyView(),W.destroy(),R.value=null,z.value=null,I.value=null,V.value=!1}return(0,e.onScopeDispose)(Ge),{editor:je,editorView:L,editorState:R,isReady:V,isDirty:U,parseError:H,layout:z,blocks:B,measures:ye,loadBuffer:Le,loadDocument:Re,save:ze,getDocument:Be,setDocument:Ve,getCommands:He,focus:Ue,reLayout:We,destroy:Ge}}function ge(e,t){if(t<e.top+40){let n=Math.max(0,e.top+40-t);return-Math.min(12,n/40*12)}if(t>e.bottom-40){let n=Math.max(0,t-(e.bottom-40));return Math.min(12,n/40*12)}return 0}function _e({pagesContainer:t,onScrollExtendSelection:n}){let r=null,i=0,a=0,o=!1,s=null;function c(){if(s)return s;let e=t.value;return e?(s=(0,b.findVerticalScrollParent)(e),s):null}function l(){o=!1,r!==null&&(cancelAnimationFrame(r),r=null)}function u(){if(!o)return;let e=c();if(!e)return;let t=ge(e.getBoundingClientRect(),a);t!==0&&(e.scrollTop+=t,n(i,a)),r=requestAnimationFrame(u)}function d(){o||(o=!0,r=requestAnimationFrame(u))}function f(e,t){if(i=e,a=t,!o){let e=c();if(!e)return;let n=e.getBoundingClientRect();(t<n.top+40||t>n.bottom-40)&&d()}}return(0,e.onScopeDispose)(()=>l()),{updateMousePosition:f,stopAutoScroll:l}}function ve(){let e={active:!1,startX:0,handle:null,columnIndex:0,tablePmStart:0,origWidths:{left:0,right:0}},t={active:!1,startY:0,handle:null,rowIndex:0,isEdge:!1,tablePmStart:0,origHeight:0},n={active:!1,startX:0,handle:null,columnIndex:0,tablePmStart:0,origWidth:0},r=null;function i(){return e.active||t.active||n.active}function a(i,a){let o=i.target;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),O(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),k(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),A(a,n),!0):!1:!1}function o(r){if(e.active&&e.handle){r.preventDefault();let t=r.clientX-e.startX,n=parseFloat(e.handle.style.left);e.handle.style.left=`${n+t}px`,e.startX=r.clientX;let i=Math.round(t*x.TWIPS_PER_PIXEL),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=x.MIN_CELL_WIDTH_TWIPS&&o>=x.MIN_CELL_WIDTH_TWIPS&&(e.origWidths={left:a,right:o});return}if(t.active&&t.handle){r.preventDefault();let e=r.clientY-t.startY,n=parseFloat(t.handle.style.top);t.handle.style.top=`${n+e}px`,t.startY=r.clientY;let i=Math.round(e*x.TWIPS_PER_PIXEL),a=t.origHeight+i;a>=x.MIN_ROW_HEIGHT_TWIPS&&(t.origHeight=a);return}if(n.active&&n.handle){r.preventDefault();let e=r.clientX-n.startX,t=parseFloat(n.handle.style.left);n.handle.style.left=`${t+e}px`,n.startX=r.clientX;let i=Math.round(e*x.TWIPS_PER_PIXEL),a=n.origWidth+i;a>=x.MIN_CELL_WIDTH_TWIPS&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&(0,x.commitColumnResize)(r,{pmStart:e.tablePmStart,colIdx:e.columnIndex,newLeft:e.origWidths.left,newRight:e.origWidths.right}),e.handle=null;return}if(t.active){t.active=!1,t.handle?.classList.remove(`dragging`),r&&(0,x.commitRowResize)(r,{pmStart:t.tablePmStart,rowIdx:t.rowIndex,newHeight:t.origHeight}),t.handle=null;return}n.active&&(n.active=!1,n.handle?.classList.remove(`dragging`),r&&(0,x.commitRightEdgeResize)(r,{pmStart:n.tablePmStart,colIdx:n.columnIndex,newWidth:n.origWidth}),n.handle=null)}function c(){return document.addEventListener(`mousemove`,o),document.addEventListener(`mouseup`,s),()=>{document.removeEventListener(`mousemove`,o),document.removeEventListener(`mouseup`,s)}}return{tryStartResize:a,install:c,isResizing:i}}function O(e,t){let n=(0,x.readColumnWidths)(e,t.tablePmStart,t.columnIndex);n&&(t.origWidths=n)}function k(e,t,n){let r=(0,x.readRowHeight)(e,t.tablePmStart,t.rowIndex);if(r!=null){t.origHeight=r;return}let i=n.closest(`.layout-table`)?.querySelector(`[data-row-index="${t.rowIndex}"]`),a=i?i.getBoundingClientRect().height:30;t.origHeight=Math.round(a*x.TWIPS_PER_PIXEL)}function A(e,t){let n=(0,x.readColumnWidthAt)(e,t.tablePmStart,t.columnIndex);n!=null&&(t.origWidth=n)}function j(t,n){return(0,e.computed)(()=>(n.value,(0,S.extractTrackedChanges)(t.value?.state??null)))}var M=C.ZOOM_MIN,N=C.ZOOM_MAX,P=[.5,.75,1,1.25,1.5,2];function F(t=1){let n=(0,e.ref)(Math.max(M,Math.min(N,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=M),a=(0,e.computed)(()=>n.value>=N);function o(e){n.value=Math.max(M,Math.min(N,Math.round(e*100)/100))}function s(){o(n.value+C.ZOOM_STEP)}function c(){o(n.value-C.ZOOM_STEP)}function l(){o(1)}function u(e){(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.deltaY<0?s():c())}function d(e){(e.ctrlKey||e.metaKey)&&(e.shiftKey||e.altKey||(e.key===`=`||e.key===`+`?(e.preventDefault(),s()):e.key===`-`?(e.preventDefault(),c()):e.key===`0`&&(e.preventDefault(),l())))}function f(){(0,e.onMounted)(()=>document.addEventListener(`keydown`,d)),(0,e.onBeforeUnmount)(()=>document.removeEventListener(`keydown`,d))}return{zoom:n,zoomPercent:r,isMinZoom:i,isMaxZoom:a,setZoom:o,zoomIn:s,zoomOut:c,resetZoom:l,handleWheel:u,handleKeyDown:d,installShortcuts:f,ZOOM_PRESETS:P}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return F}});