@stll/folio-vue 0.20.0 → 0.21.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.
@@ -1,780 +0,0 @@
1
- import { computed as e, inject as t, onBeforeUnmount as n, onMounted as r, onScopeDispose as i, provide as a, ref as o, shallowRef as s, toValue as c, watch as l, watchEffect as u } from "vue";
2
- import { getMargins as d, getPageSize as f, twipsToPixels as p } from "@stll/folio-core/paged-layout/sectionGeometry";
3
- import { createAnonymizationDecorationsPlugin as m } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations";
4
- import { autocompleteSuggestionPlugin as h } from "@stll/folio-core/prosemirror/plugins/autocompleteSuggestion";
5
- import { createTemplateDirectivesPlugin as g } from "@stll/folio-core/prosemirror/plugins/templateDirectives";
6
- import { createSuggestionModePlugin as ee, setSuggestionMode as te } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
7
- import { FOLIO_DOCX_SERIALIZATION_MODE as _, createFolioEditor as v } from "@stll/folio-core/controller/folioEditor";
8
- import { createFolioEditorEmitter as ne } from "@stll/folio-core/controller/folioEditorEvents";
9
- import { loadCollaborationModules as re } from "@stll/folio-core/controller/collaborationModules";
10
- import { createHeaderFooterEditorManager as ie } from "@stll/folio-core/controller/headerFooterEditorManager";
11
- import { createNoteEditorManager as ae } from "@stll/folio-core/controller/noteEditorManager";
12
- import { collectRemoteSelections as oe, createHiddenEditorManager as se, createHiddenEditorState as ce } from "@stll/folio-core/controller/hiddenEditorManager";
13
- import { runLayoutPipeline as le } from "@stll/folio-core/controller/layoutPipeline";
14
- import { createHyphenationReadiness as ue } from "@stll/folio-core/controller/hyphenationReadiness";
15
- import { browserClock as de, createLayoutScheduler as fe } from "@stll/folio-core/controller/layoutScheduler";
16
- import { createLayoutSession as pe } from "@stll/folio-core/controller/layoutSession";
17
- import { parseDocx as me } from "@stll/folio-core/docx/parser";
18
- import { getFootnoteText as he } from "@stll/folio-core/docx/footnoteParser";
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
- //#region src/utils/colorMode.ts
36
- var Le = "(prefers-color-scheme: dark)";
37
- function Re() {
38
- return typeof window < "u" && typeof window.matchMedia == "function";
39
- }
40
- function ze(e, t) {
41
- return e === "dark" || e === "system" && t;
42
- }
43
- function Be(e) {
44
- if (!Re()) return () => {};
45
- let t = window.matchMedia(Le);
46
- e(t.matches);
47
- let n = (t) => e(t.matches);
48
- return t.addEventListener("change", n), () => t.removeEventListener("change", n);
49
- }
50
- //#endregion
51
- //#region src/composables/useColorMode.ts
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
- } };
57
- function j() {
58
- let n = t(O, e(() => D)), i = o(!1), a = o(!1);
59
- return r(() => {
60
- i.value = !0;
61
- }), u((e) => {
62
- !i.value || n.value !== "system" || e(Be((e) => {
63
- a.value = e;
64
- }));
65
- }), e(() => ze(n.value, i.value && a.value));
66
- }
67
- //#endregion
68
- //#region src/composables/useDocxEditor.ts
69
- var Ve = 24, He = 32, Ue = 96, We = 250, Ge = [], Ke = [];
70
- function qe(e) {
71
- let t = e?.columnCount ?? 1;
72
- if (t <= 1) return;
73
- let n = {
74
- count: t,
75
- gap: p(e?.columnSpace ?? 720),
76
- equalWidth: e?.equalWidth ?? !0
77
- };
78
- return e?.separator !== void 0 && (n.separator = e.separator), n;
79
- }
80
- function Je(e, t, n, r, i, a) {
81
- if (!e) return;
82
- let o = t ? {
83
- ...a,
84
- rId: t
85
- } : a, s = t ? n?.getView(t) : null;
86
- return s ? ge(s.state.doc, r, i, o) : _e(e, r, i, o);
87
- }
88
- function Ye(e, t, n, r, i) {
89
- if (!e || e.size === 0) return;
90
- let a = /* @__PURE__ */ new Map();
91
- for (let [o, s] of e) {
92
- let e = Je(s, o, t, n, r, i);
93
- e && a.set(o, e);
94
- }
95
- return a.size > 0 ? a : void 0;
96
- }
97
- function Xe(e, t, n) {
98
- let r = /* @__PURE__ */ new Map();
99
- if (!n || !n.package.footnotes) return r;
100
- let i = /* @__PURE__ */ new Map();
101
- for (let e of n.package.footnotes) e.noteType && e.noteType !== "normal" || i.set(e.id, e);
102
- for (let [n, a] of e) {
103
- let e = [];
104
- for (let n of a) {
105
- let r = i.get(n);
106
- if (!r) continue;
107
- let a = t.get(n), o = a?.displayNumber ?? 0;
108
- e.push({
109
- displayNumber: String(o),
110
- noteId: n,
111
- text: he(r),
112
- ...a ? { content: {
113
- blocks: a.blocks,
114
- measures: a.measures,
115
- height: a.height
116
- } } : {}
117
- });
118
- }
119
- e.length > 0 && r.set(n, e);
120
- }
121
- return r;
122
- }
123
- var M = /* @__PURE__ */ new Set([
124
- "black",
125
- "blue",
126
- "cyan",
127
- "darkBlue",
128
- "darkCyan",
129
- "darkGray",
130
- "darkGreen",
131
- "darkMagenta",
132
- "darkRed",
133
- "darkYellow",
134
- "green",
135
- "lightGray",
136
- "magenta",
137
- "none",
138
- "red",
139
- "white",
140
- "yellow"
141
- ]);
142
- function Ze(e) {
143
- let t = [], n = (e, r) => {
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
- e.forEach((e, t, i) => {
146
- n(e, `${r}.content[${i}]`);
147
- });
148
- };
149
- return n(e, "doc"), t.join("; ");
150
- }
151
- function Qe() {
152
- return typeof document > "u" || !("fonts" in document) || document.fonts.status === "loaded";
153
- }
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
- return [
163
- rt,
164
- tt,
165
- ...x,
166
- ...c(S)?.plugins ?? [],
167
- it,
168
- ...st() ? [U, at] : [],
169
- ot
170
- ];
171
- }
172
- let W = ne(), G = new be(), lt = pe(), ut = ue({
173
- relayout: () => {
174
- let e = M.value?.state ?? lt.lastEditorState;
175
- e && J(e, { reason: "hyphenation-ready" });
176
- },
177
- onError: (e) => w?.(e)
178
- });
179
- i(ut.cancel);
180
- let dt = new ye({
181
- pageGap: p,
182
- showShadow: !0
183
- }), K = ie({
184
- getHost: () => k.value,
185
- getDocument: () => A.value,
186
- getStyles: () => A.value?.package.styles ?? null,
187
- getTheme: () => A.value?.package.theme ?? null,
188
- onTransaction: ({ rId: e, kind: t, view: n, docChanged: r, selectionChanged: i }) => {
189
- if (r) {
190
- V.value = !0;
191
- let e = M.value;
192
- e && Y.schedule(e.state, null);
193
- }
194
- if (r || i) {
195
- let { from: r, to: i } = n.state.selection;
196
- I.value = {
197
- from: r,
198
- kind: t,
199
- rId: e,
200
- to: i
201
- }, T?.(n.state), W.emit("selectionChange", {
202
- from: r,
203
- to: i
204
- });
205
- }
206
- G.requestRender();
207
- }
208
- }), ft = { current: null }, q = ae({
209
- getHost: () => r?.value ?? null,
210
- getPlugins: () => nt,
211
- getDocument: () => A.value,
212
- getStyles: () => A.value?.package.styles ?? null,
213
- getTheme: () => A.value?.package.theme ?? null,
214
- onTransaction: ({ docChanged: e, selectionChanged: t, view: n }) => {
215
- if (e) {
216
- V.value = !0;
217
- let e = A.value;
218
- if (e) {
219
- let t = ft.current?.snapshotDocument(e) ?? e;
220
- A.value = t, C?.(t), W.emit("docChange", t);
221
- }
222
- let t = M.value;
223
- t && Y.schedule(t.state, null);
224
- }
225
- if (e || t) {
226
- T?.(n.state);
227
- let { from: e, to: t } = n.state.selection;
228
- W.emit("selectionChange", {
229
- from: e,
230
- to: t
231
- });
232
- }
233
- }
234
- });
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
- }
239
- function J(e, t = {}) {
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
- try {
242
- pt(le({
243
- contentWidth: h,
244
- columns: m,
245
- pageSize: l,
246
- margins: u,
247
- pageGap: p,
248
- showMarginGuides: c(ge) === !0,
249
- marginGuideColor: c(_e),
250
- ...(() => {
251
- let e = c(he);
252
- return e === void 0 ? {} : { pageRenderer: e };
253
- })(),
254
- syncCoordinator: G,
255
- headerContent: v.headerContent,
256
- footerContent: v.footerContent,
257
- firstPageHeaderContent: v.firstPageHeaderContent,
258
- firstPageFooterContent: v.firstPageFooterContent,
259
- headerContentRId: v.activeHeaderRId,
260
- footerContentRId: v.activeFooterRId,
261
- firstPageHeaderContentRId: v.activeFirstHeaderRId,
262
- firstPageFooterContentRId: v.activeFirstFooterRId,
263
- sectionHeaderFooterRefs: ve(i),
264
- theme: ee,
265
- sectionProperties: s,
266
- document: i,
267
- defaultTabStop: te,
268
- mirrorMargins: _,
269
- styles: g,
270
- layout: R.value,
271
- hfPMs: K,
272
- painter: dt,
273
- pagesContainer: r,
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
- }, e, t));
284
- } catch (e) {
285
- let t = e instanceof Error ? e : Error(String(e));
286
- w?.(t);
287
- }
288
- }
289
- let Y = fe({
290
- runLayout: (e, t) => J(e, t),
291
- debounceMs: He,
292
- maxDelayMs: Ue,
293
- clock: de
294
- }), X = null;
295
- function mt() {
296
- X !== null && (window.clearTimeout(X), X = null);
297
- let e = M.value, t = A.value;
298
- if (!(!e || !t)) try {
299
- let n = Se(e.state.doc, t);
300
- A.value = n, K.sync(), q.sync(), C?.(n), W.emit("docChange", n);
301
- } catch (e) {
302
- w?.(e instanceof Error ? e : Error(String(e)));
303
- }
304
- }
305
- function ht() {
306
- X !== null && window.clearTimeout(X), X = window.setTimeout(() => {
307
- X = null, mt();
308
- }, We);
309
- }
310
- let Z = se({
311
- getHost: () => t.value,
312
- getDocument: () => A.value,
313
- getStyles: () => A.value?.package.styles ?? null,
314
- getExtensionManager: () => H,
315
- getExternalPlugins: ct,
316
- getCollaboration: () => c(S),
317
- getCollaborationModules: () => P.value,
318
- getPrecomputedInitialState: () => null,
319
- getReadOnly: () => c(u),
320
- getDocumentIdentity: () => String(j),
321
- getDocumentContext: () => A.value,
322
- onTransaction: gt,
323
- onSelectionChange: (e) => {
324
- N.value = e, T?.(e), W.emit("selectionChange", {
325
- from: e.selection.from,
326
- to: e.selection.to
327
- });
328
- },
329
- onKeyDown: () => !1,
330
- onCopy: () => Le?.(),
331
- onCut: () => Re?.(),
332
- onPaste: () => ze?.(),
333
- onReadOnlyEditAttempt: () => Be?.(),
334
- onEditorViewReady: _t,
335
- onEditorViewDestroy: () => {
336
- M.value = null, z.value = !1, E?.(null);
337
- },
338
- onRemoteSelectionsChange: (e) => {
339
- F.value = e;
340
- }
341
- }), Q = () => {
342
- let e = c(S)?.awareness, t = P.value, n = Z.getView();
343
- F.value = e && t && n ? oe(n.state, e, t) : [];
344
- };
345
- l(() => c(S), (e, t, n) => {
346
- if (F.value = [], !e) {
347
- P.value = null, Z.retryViewCreation(), Z.syncExternalDocument();
348
- return;
349
- }
350
- let r = !1;
351
- n(() => {
352
- r = !0;
353
- }), P.value = null, re().then((e) => {
354
- r || (P.value = e, Z.retryViewCreation(), Z.syncExternalDocument(), Q());
355
- }, (e) => {
356
- r || (P.value = null, w?.(e instanceof Error ? e : Error(String(e))));
357
- });
358
- }, { immediate: !0 }), l(() => ({
359
- awareness: c(S)?.awareness,
360
- modules: P.value,
361
- view: M.value
362
- }), ({ awareness: e, modules: t, view: n }, r, i) => {
363
- if (!e || !t || !n) {
364
- F.value = [];
365
- return;
366
- }
367
- e.on("change", Q), Q(), i(() => {
368
- e.off("change", Q), F.value = [];
369
- });
370
- }, { flush: "post" });
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
- }
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
- });
378
- }
379
- let vt = {
380
- getDocx: async (e) => (await Et(e))?.buffer ?? null,
381
- loadDocument: Tt,
382
- loadDocx: wt
383
- }, yt = v({
384
- getEditorApi: () => Z.api,
385
- getLayout: () => R.value,
386
- runLayout: (e, t) => J(e, t),
387
- getDocumentIO: () => vt,
388
- emitter: W
389
- });
390
- function $(e) {
391
- te(c(y) === "suggesting", e.state, e.dispatch, c(b));
392
- }
393
- l([() => c(y), () => c(b)], () => {
394
- let e = M.value;
395
- e && $(e);
396
- for (let e of q.listStories()) {
397
- let t = q.getView(e);
398
- t && $(t);
399
- }
400
- }), l(() => c(u), (e) => {
401
- Z.syncEditable(), e && Nt();
402
- });
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
- if (t) {
408
- let e = n.indexOf(ot), t = e === -1 ? n.length : e;
409
- n.splice(t, 0, U, at);
410
- }
411
- e.updateState(e.state.reconfigure({ plugins: n }));
412
- }
413
- l(() => st(), () => {
414
- let e = M.value;
415
- e && bt(e);
416
- });
417
- function xt() {
418
- Z.ensureView();
419
- }
420
- function St() {
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
- if (!(!e || c(S))) try {
426
- let t = ce({
427
- document: e,
428
- styles: e.package.styles ?? null,
429
- manager: H,
430
- externalPlugins: ct(),
431
- collaborationModules: null,
432
- reason: "mount"
433
- });
434
- N.value = t, J(t, { reason: "initial" });
435
- } catch (e) {
436
- w?.(e instanceof Error ? e : Error(String(e)));
437
- }
438
- }
439
- l([
440
- t,
441
- a,
442
- k,
443
- ...r ? [r] : []
444
- ], () => {
445
- t.value && A.value && !Z.getView() && xt(), K.sync(), q.sync();
446
- }, { flush: "post" });
447
- async function wt(e) {
448
- B.value = null, z.value = !1;
449
- try {
450
- let t = await me(e, { password: c(je) });
451
- A.value = t, St();
452
- } catch (e) {
453
- let t = e instanceof Error ? e : Error(String(e));
454
- B.value = t.message, w?.(t);
455
- }
456
- }
457
- function Tt(e) {
458
- B.value = null, A.value = e, St();
459
- }
460
- async function Et(e) {
461
- let t = M.value, n = A.value;
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(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
- if (d && l) {
465
- let { attemptSelectiveSave: e } = await import("@stll/folio-core/docx/selectiveSave");
466
- m = await e(s, l, {
467
- changedParaIds: we(i),
468
- structuralChange: Te(i),
469
- hasUntrackedChanges: Ee(i),
470
- maxBytes: o.selectiveSaveMaxBytes
471
- });
472
- }
473
- let h = u ? m : null, g = null;
474
- if (!h) g = l ? await f(s) : await p(s), h = g;
475
- else if (o.selectiveSaveTripwire) try {
476
- g = await f(s);
477
- } catch {}
478
- if (o.selectiveSaveTripwire && g && O) try {
479
- let { compareSelectiveVsFull: e } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
480
- O(await e(m, g));
481
- } catch {}
482
- return {
483
- buffer: h,
484
- document: s
485
- };
486
- }
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
- }
491
- function Ot() {
492
- let e = A.value;
493
- return e ? q.snapshotDocument(K.snapshotDocument(e)) : null;
494
- }
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
- return K.getView(e);
500
- }
501
- function jt() {
502
- K.sync();
503
- }
504
- function Mt(e) {
505
- let t = q.activate(e);
506
- t && ($(t), L.value = e, requestAnimationFrame(() => t.focus()));
507
- }
508
- function Nt() {
509
- q.activate(null), L.value = null;
510
- }
511
- function Pt() {
512
- let e = L.value;
513
- return e ? q.getView(e) : null;
514
- }
515
- function Ft() {
516
- return H.getCommands();
517
- }
518
- function It() {
519
- let e = Pt();
520
- e ? e.focus() : M.value?.focus();
521
- }
522
- function Lt() {
523
- let e = M.value;
524
- e && J(e.state, { reason: "manual" });
525
- }
526
- l([
527
- () => c(ge),
528
- () => c(_e),
529
- () => c(he)
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
- syncCoordinator: G,
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
- };
563
- }
564
- function P(e, t) {
565
- if (t < e.top + 40) {
566
- let n = Math.max(0, e.top + 40 - t);
567
- return -Math.min(12, n / 40 * 12);
568
- }
569
- if (t > e.bottom - 40) {
570
- let n = Math.max(0, t - (e.bottom - 40));
571
- return Math.min(12, n / 40 * 12);
572
- }
573
- return 0;
574
- }
575
- //#endregion
576
- //#region src/composables/useDragAutoScroll.ts
577
- function F({ pagesContainer: e, onScrollExtendSelection: t }) {
578
- let n = null, r = 0, a = 0, o = !1, s = null;
579
- function c() {
580
- if (s) return s;
581
- let t = e.value;
582
- return t ? (s = je(t), s) : null;
583
- }
584
- function l() {
585
- o = !1, n !== null && (cancelAnimationFrame(n), n = null);
586
- }
587
- function u() {
588
- if (!o) return;
589
- let e = c();
590
- if (!e) return;
591
- let i = P(e.getBoundingClientRect(), a);
592
- i !== 0 && (e.scrollTop += i, t(r, a)), n = requestAnimationFrame(u);
593
- }
594
- function d() {
595
- o || (o = !0, n = requestAnimationFrame(u));
596
- }
597
- function f(e, t) {
598
- if (r = e, a = t, !o) {
599
- let e = c();
600
- if (!e) return;
601
- let n = e.getBoundingClientRect();
602
- (t < n.top + 40 || t > n.bottom - 40) && d();
603
- }
604
- }
605
- return i(() => l()), {
606
- updateMousePosition: f,
607
- stopAutoScroll: l
608
- };
609
- }
610
- //#endregion
611
- //#region src/composables/useTableResize.ts
612
- function I() {
613
- let e = {
614
- active: !1,
615
- startX: 0,
616
- handle: null,
617
- columnIndex: 0,
618
- tablePmStart: 0,
619
- origWidths: {
620
- left: 0,
621
- right: 0
622
- }
623
- }, t = {
624
- active: !1,
625
- startY: 0,
626
- handle: null,
627
- rowIndex: 0,
628
- isEdge: !1,
629
- tablePmStart: 0,
630
- origHeight: 0
631
- }, n = {
632
- active: !1,
633
- startX: 0,
634
- handle: null,
635
- columnIndex: 0,
636
- tablePmStart: 0,
637
- origWidth: 0
638
- }, r = null;
639
- function i() {
640
- return e.active || t.active || n.active;
641
- }
642
- function a(i, a) {
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), 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
- }
646
- function o(r) {
647
- if (e.active && e.handle) {
648
- r.preventDefault();
649
- let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
650
- e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
651
- let i = Math.round(t * x), a = e.origWidths.left + i, o = e.origWidths.right - i;
652
- a >= y && o >= y && (e.origWidths = {
653
- left: a,
654
- right: o
655
- });
656
- return;
657
- }
658
- if (t.active && t.handle) {
659
- r.preventDefault();
660
- let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
661
- t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
662
- let i = Math.round(e * x), a = t.origHeight + i;
663
- a >= b && (t.origHeight = a);
664
- return;
665
- }
666
- if (n.active && n.handle) {
667
- r.preventDefault();
668
- let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
669
- n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
670
- let i = Math.round(e * x), a = n.origWidth + i;
671
- a >= y && (n.origWidth = a);
672
- }
673
- }
674
- function s(i) {
675
- if (e.active) {
676
- e.active = !1, e.handle?.classList.remove("dragging"), r && Me(r, {
677
- pmStart: e.tablePmStart,
678
- colIdx: e.columnIndex,
679
- newLeft: e.origWidths.left,
680
- newRight: e.origWidths.right
681
- }), e.handle = null;
682
- return;
683
- }
684
- if (t.active) {
685
- t.active = !1, t.handle?.classList.remove("dragging"), r && Ne(r, {
686
- pmStart: t.tablePmStart,
687
- rowIdx: t.rowIndex,
688
- newHeight: t.origHeight
689
- }), t.handle = null;
690
- return;
691
- }
692
- n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && S(r, {
693
- pmStart: n.tablePmStart,
694
- colIdx: n.columnIndex,
695
- newWidth: n.origWidth
696
- }), n.handle = null);
697
- }
698
- function c() {
699
- return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
700
- document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", s);
701
- };
702
- }
703
- return {
704
- tryStartResize: a,
705
- install: c,
706
- isResizing: i
707
- };
708
- }
709
- function L(e, t) {
710
- let n = Fe(e, t.tablePmStart, t.columnIndex);
711
- n && (t.origWidths = n);
712
- }
713
- function R(e, t, n) {
714
- let r = Ie(e, t.tablePmStart, t.rowIndex);
715
- if (r != null) {
716
- t.origHeight = r;
717
- return;
718
- }
719
- let i = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), a = i ? i.getBoundingClientRect().height : 30;
720
- t.origHeight = Math.round(a * x);
721
- }
722
- function $e(e, t) {
723
- let n = Pe(e, t.tablePmStart, t.columnIndex);
724
- n != null && (t.origWidth = n);
725
- }
726
- //#endregion
727
- //#region src/composables/useTrackedChanges.ts
728
- function et(t, n) {
729
- return e(() => (n.value, C(t.value?.state ?? null)));
730
- }
731
- //#endregion
732
- //#region src/composables/useZoom.ts
733
- var z = T, B = w, V = [
734
- .5,
735
- .75,
736
- 1,
737
- 1.25,
738
- 1.5,
739
- 2
740
- ];
741
- function H(t = 1) {
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
- function l(e) {
744
- i.value = Math.max(z, Math.min(B, Math.round(e * 100) / 100));
745
- }
746
- function u() {
747
- l(i.value + E);
748
- }
749
- function d() {
750
- l(i.value - E);
751
- }
752
- function f() {
753
- l(1);
754
- }
755
- function p(e) {
756
- (e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d());
757
- }
758
- function m(e) {
759
- (e.ctrlKey || e.metaKey) && (e.shiftKey || e.altKey || (e.key === "=" || e.key === "+" ? (e.preventDefault(), u()) : e.key === "-" ? (e.preventDefault(), d()) : e.key === "0" && (e.preventDefault(), f())));
760
- }
761
- function h() {
762
- r(() => document.addEventListener("keydown", m)), n(() => document.removeEventListener("keydown", m));
763
- }
764
- return {
765
- zoom: i,
766
- zoomPercent: a,
767
- isMinZoom: s,
768
- isMaxZoom: c,
769
- setZoom: l,
770
- zoomIn: u,
771
- zoomOut: d,
772
- resetZoom: f,
773
- handleWheel: p,
774
- handleKeyDown: m,
775
- installShortcuts: h,
776
- ZOOM_PRESETS: V
777
- };
778
- }
779
- //#endregion
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 };