@stll/folio-vue 0.29.0 → 0.31.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,1119 +0,0 @@
1
- import { computed as e, inject as t, onBeforeUnmount as n, onMounted as r, onScopeDispose as i, provide as a, reactive as o, ref as s, shallowRef as c, toRaw as l, toValue as u, watch as d, watchEffect as f } from "vue";
2
- import { isCanonicalRoomCollaboration as p } from "@stll/folio-core/controller/canonicalRoomEditor";
3
- import { CanonicalSessionRefusalError as m, collectRemoteSelections as ee, createHiddenEditorManager as h, createHiddenEditorState as g } from "@stll/folio-core/controller/hiddenEditorManager";
4
- import { carryParseFacts as _, cloneDocumentWithParagraphPropertySources as v } from "@stll/folio-core/docx/document-clone";
5
- import { withHostCommentThreads as y } from "@stll/folio-core/docx/hostCommentThreads";
6
- import { getEditorReadOnlyReason as te } from "@stll/folio-core/managers/EditorModeManager";
7
- import { getEditorScrollRoot as b, scrollEditorBy as x } from "@stll/folio-core/paged-layout/editorScrollRoot";
8
- import { getMargins as S, getPageSize as ne, twipsToPixels as re } from "@stll/folio-core/paged-layout/sectionGeometry";
9
- import { commentIdsNamedIn as C } from "@stll/folio-core/prosemirror/commentRecords";
10
- import { CANONICAL_GAP as ie, canonicalRefusalMessage as ae, usesCanonicalSession as oe } from "@stll/folio-core/types/canonicalCapabilities";
11
- import { readModel as w } from "@stll/folio-core/types/documentModel";
12
- import { readPaintedTableStart as T } from "@stll/folio-core/utils/paintedPositions";
13
- import { lockHeldRevisions as E, trackedChangeEntryRevisionIds as D } from "@stll/folio-core/prosemirror/commands/comments";
14
- import { createSuggestionModePlugin as se, setSuggestionMode as ce } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
15
- import { NO_ANONYMIZATION_TERMS as le } from "@stll/folio-core/controller/anonymizationHighlights";
16
- import { loadCollaborationModules as O } from "@stll/folio-core/controller/collaborationModules";
17
- import { DOCUMENT_CHANGE_NOTIFY_DELAY_MS as ue } from "@stll/folio-core/controller/documentChangeNotification";
18
- import { FOLIO_DOCX_SERIALIZATION_MODE as de, createFolioEditor as fe } from "@stll/folio-core/controller/folioEditor";
19
- import { createFolioEditorEmitter as pe } from "@stll/folio-core/controller/folioEditorEvents";
20
- import { readFontSetSignature as me, waitForInitialLayoutFonts as he, watchLayoutFontLoads as ge } from "@stll/folio-core/controller/fontReadiness";
21
- import { createHeaderFooterEditorManager as _e } from "@stll/folio-core/controller/headerFooterEditorManager";
22
- import { createHyphenationReadiness as ve } from "@stll/folio-core/controller/hyphenationReadiness";
23
- import { runLayoutPipeline as ye } from "@stll/folio-core/controller/layoutPipeline";
24
- import { TRANSACTION_LAYOUT_TIMING as be, browserClock as xe, createLayoutScheduler as Se } from "@stll/folio-core/controller/layoutScheduler";
25
- import { createLayoutSession as Ce } from "@stll/folio-core/controller/layoutSession";
26
- import { createNoteEditorManager as we } from "@stll/folio-core/controller/noteEditorManager";
27
- import { canonicalSaveDiagnosticError as Te, serializeCanonicalSave as Ee } from "@stll/folio-core/docx/canonicalSave";
28
- import { holdsUniqueParagraphIds as De, openCanonicalDocx as Oe, prepareCanonicalDocumentInput as ke } from "@stll/folio-core/docx/canonicalSessionInput";
29
- import { parseDocx as Ae } from "@stll/folio-core/docx/parser";
30
- import { getFootnoteText as je } from "@stll/folio-core/docx/storyPlainText";
31
- import { convertHeaderFooterPmDocToContent as Me, convertHeaderFooterToContent as Ne } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
32
- import { resolveSectionHeaderFooterRefs as Pe } from "@stll/folio-core/layout-engine";
33
- import { LayoutPainter as Fe, releaseDisplayPageResources as Ie } from "@stll/folio-core/layout-painter";
34
- import { LayoutSelectionGate as Le } from "@stll/folio-core/paged-layout/LayoutSelectionGate";
35
- import { fromProseDoc as Re } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
36
- import { ExtensionManager as ze } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
37
- import { getChangedParagraphIds as Be, hasStructuralChanges as Ve, hasUntrackedChanges as He, repackWithEditorSectionRemovals as Ue } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
38
- import { createStarterKit as We } from "@stll/folio-core/prosemirror/extensions/StarterKit";
39
- import { createNoteReferenceFollower as Ge, heldUnreferencedNotes as Ke, withoutUnreferencedNotes as qe } from "@stll/folio-core/prosemirror/noteReferenceReview";
40
- import { createTemplateDirectivesPlugin as Je } from "@stll/folio-core/prosemirror/plugins/templateDirectives";
41
- import { createTemplatePreviewValuesPlugin as Ye } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
42
- import { templateSlashMenuPlugin as Xe } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
43
- import { resolveHeaderFooterContent as Ze } from "@stll/folio-core/utils/headerFooter";
44
- import { FindReplaceManager as Qe } from "@stll/folio-core/managers/FindReplaceManager";
45
- import { findInDisplayedDocument as $e } from "@stll/folio-core/prosemirror/findReplaceSelection";
46
- import { replaceFindMatch as et, replaceFindMatches as tt } from "@stll/folio-core/prosemirror/replaceFindMatches";
47
- import { createFindMatchView as nt, getRenderedSearchStories as rt } from "@stll/folio-core/utils/findMatchView";
48
- import { createDefaultFindOptions as it, replaceEligibility as at } from "@stll/folio-core/utils/findReplace";
49
- import { createFindSearchKey as ot, sameFindSearchKey as k } from "@stll/folio-core/utils/findSearchKey";
50
- import { MIN_CELL_WIDTH_TWIPS as st, MIN_ROW_HEIGHT_TWIPS as ct, TWIPS_PER_PIXEL as lt, clampRowResizeDelta as ut, columnResizeCommand as dt, readColumnWidthAt as ft, readColumnWidths as pt, readRowHeight as mt, rightEdgeResizeCommand as ht, rowResizeCommand as gt } from "@stll/folio-core/prosemirror/tableResize";
51
- import { extractTrackedChanges as _t } from "@stll/folio-core/prosemirror/utils/extractTrackedChanges";
52
- import { ZOOM_MAX as A, ZOOM_MIN as vt, ZOOM_STEP as yt } from "@stll/folio-core/utils/zoom";
53
- // src/utils/colorMode.ts
54
- var bt = "(prefers-color-scheme: dark)";
55
- function j() {
56
- return typeof window < "u" && typeof window.matchMedia == "function";
57
- }
58
- function xt(e, t) {
59
- return e === "dark" || e === "system" && t;
60
- }
61
- function M(e) {
62
- if (!j()) return () => {};
63
- let t = window.matchMedia(bt);
64
- e(t.matches);
65
- let n = (t) => e(t.matches);
66
- return t.addEventListener("change", n), () => t.removeEventListener("change", n);
67
- }
68
- // src/composables/useColorMode.ts
69
- var N = "light", P = Symbol("folioColorMode"), F = (t = N) => {
70
- a(P, e(() => u(t)));
71
- }, I = { install(t, n = N) {
72
- t.provide(P, e(() => u(n)));
73
- } };
74
- function L() {
75
- let n = t(P, e(() => N)), i = s(!1), a = s(!1);
76
- return r(() => {
77
- i.value = !0;
78
- }), f((e) => {
79
- i.value && n.value === "system" && e(M((e) => {
80
- a.value = e;
81
- }));
82
- }), e(() => xt(n.value, i.value && a.value));
83
- }
84
- // src/utils/rawDocument.ts
85
- var St = (e) => R(e, /* @__PURE__ */ new Map()), R = (e, t) => {
86
- if (typeof e != "object" || !e) return e;
87
- let n = l(e), r = t.get(n);
88
- if (r !== void 0) return r;
89
- t.set(n, n);
90
- let i = z(n, t);
91
- return t.set(n, i), i;
92
- }, z = (e, t) => {
93
- if (ArrayBuffer.isView(e) || e instanceof ArrayBuffer) return e;
94
- if (e instanceof Map) {
95
- let n = !1, r = [];
96
- for (let [i, a] of e) {
97
- let e = R(i, t), o = R(a, t);
98
- (e !== i || o !== a) && (n = !0), r.push([e, o]);
99
- }
100
- return n ? new Map(r) : e;
101
- }
102
- if (e instanceof Set) {
103
- let n = !1, r = [];
104
- for (let i of e) {
105
- let e = R(i, t);
106
- e !== i && (n = !0), r.push(e);
107
- }
108
- return n ? new Set(r) : e;
109
- }
110
- if (Array.isArray(e)) {
111
- let n = !1, r = e.map((e) => {
112
- let r = R(e, t);
113
- return r !== e && (n = !0), r;
114
- });
115
- return n ? r : e;
116
- }
117
- let n = Object.getOwnPropertyDescriptors(e), r = !1;
118
- for (let e of Reflect.ownKeys(n)) {
119
- let i = Reflect.get(n, e);
120
- if (!Ct(i)) continue;
121
- let a = R(i.value, t);
122
- a !== i.value && (r = !0, i.value = a);
123
- }
124
- if (!r) return e;
125
- let i = Object.create(Reflect.getPrototypeOf(e), n);
126
- return _(i, e), i;
127
- }, Ct = (e) => typeof e == "object" && !!e && "value" in e, wt = 24, Tt = "User", Et = [], Dt = [];
128
- function Ot(e) {
129
- let t = e?.columnCount ?? 1;
130
- if (t <= 1) return;
131
- let n = {
132
- count: t,
133
- gap: re(e?.columnSpace ?? 720),
134
- equalWidth: e?.equalWidth ?? !0
135
- };
136
- return e?.separator !== void 0 && (n.separator = e.separator), n;
137
- }
138
- function kt(e, t, n, r, i, a) {
139
- if (!e) return;
140
- let o = t ? {
141
- ...a,
142
- rId: t
143
- } : a, s = t ? n?.getView(t) : null;
144
- return s ? Me(s.state.doc, r, i, o) : Ne(e, r, i, o);
145
- }
146
- function At(e, t, n, r, i) {
147
- if (!e || e.size === 0) return;
148
- let a = /* @__PURE__ */ new Map();
149
- for (let [o, s] of e) {
150
- let e = kt(s, o, t, n, r, i);
151
- e && a.set(o, e);
152
- }
153
- return a.size > 0 ? a : void 0;
154
- }
155
- function jt(e, t, n) {
156
- let r = /* @__PURE__ */ new Map();
157
- if (!n || !n.package.footnotes) return r;
158
- let i = /* @__PURE__ */ new Map();
159
- for (let e of n.package.footnotes) e.noteType && e.noteType !== "normal" || i.set(e.id, e);
160
- for (let [n, a] of e) {
161
- let e = [];
162
- for (let n of a) {
163
- let r = i.get(n);
164
- if (!r) continue;
165
- let a = t.get(n), o = a?.displayNumber ?? 0;
166
- e.push({
167
- displayNumber: String(o),
168
- noteId: n,
169
- text: je(r),
170
- ...a ? { content: {
171
- blocks: a.blocks,
172
- measures: a.measures,
173
- height: a.height
174
- } } : {}
175
- });
176
- }
177
- e.length > 0 && r.set(n, e);
178
- }
179
- return r;
180
- }
181
- var B = /* @__PURE__ */ new Set([
182
- "black",
183
- "blue",
184
- "cyan",
185
- "darkBlue",
186
- "darkCyan",
187
- "darkGray",
188
- "darkGreen",
189
- "darkMagenta",
190
- "darkRed",
191
- "darkYellow",
192
- "green",
193
- "lightGray",
194
- "magenta",
195
- "none",
196
- "red",
197
- "white",
198
- "yellow"
199
- ]);
200
- function Mt(e) {
201
- let t = [], n = (e, r) => {
202
- for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !B.has(String(i.attrs.color)) && t.push(`${r}.marks[${n}]=${JSON.stringify(i.attrs)}`);
203
- e.forEach((e, t, i) => {
204
- n(e, `${r}.content[${i}]`);
205
- });
206
- };
207
- return n(e, "doc"), t.join("; ");
208
- }
209
- function V(e) {
210
- let { comments: t, hiddenContainer: n, hiddenHeaderFooterContainer: r, noteEditorContainer: a, pagesContainer: o, readOnly: l = !1, experimentalSession: f, pageGap: _ = wt, pageRenderer: te, markupView: b = "all-markup", showCommentHighlights: x = !0, altChunkMarkerText: re, showMarginGuides: T, marginGuideColor: E, password: D, editorMode: je, author: Me, externalPlugins: Ne = [], historyShortcuts: Qe = "editor", onCanonicalHistory: $e, onCanonicalHistoryDrop: et, collaboration: tt, getAnonymizationTerms: nt, showTemplateDirectives: rt, onSlashMenuChange: it, onSlashMenuKeyAction: at, onChange: ot, onError: k, onSelectionUpdate: st, onEditorViewReady: ct, onCopy: lt, onCut: ut, onPaste: dt, onReadOnlyEditAttempt: ft, featureFlags: pt, onSelectiveSaveTripwire: mt } = e, ht = () => u(f) ?? (u(tt)?.yXmlFragment === void 0 ? void 0 : "legacy"), gt = r ?? n, _t = () => u(Me) ?? Tt, A = c(null), vt = /* @__PURE__ */ new Set(), yt = () => {
211
- let e = A.value;
212
- return (e && w(e).package.styles) ?? null;
213
- }, bt = c(null), j = 0, xt = !1, M = 0, N = !1, P = c(null), F = c(null), I = c(null), L = () => {
214
- let e = u(tt);
215
- return e === void 0 || p(e) ? void 0 : e;
216
- }, R = () => {
217
- let e = u(tt);
218
- return e !== void 0 && p(e) ? e : void 0;
219
- }, z = c([]), Ct = c(null), B = c(null), V = c(null), Nt = s(0), Pt = c([]), Ft = c([]), It = s(!1), H = s(null), U = s(!1), W = () => oe(u(ht), ie.authorityRouting), Lt = (e) => v(e), Rt = (e) => {
220
- let t = Lt(e);
221
- ot?.(t), qt.emit("docChange", t);
222
- }, zt = (e, t) => {
223
- if (!W()) return !1;
224
- let n = new m({
225
- ground: { gap: e },
226
- message: ae(e, t)
227
- });
228
- return k?.(n), !0;
229
- }, G = new ze(We({ historyShortcuts: Qe }));
230
- G.buildSchema(), G.initializeRuntime();
231
- let Bt = se(!1), Vt = [Bt], Ht = Je(), Ut = Xe({
232
- onChange: (e) => it?.(e),
233
- onKeyAction: (e) => at?.(e) ?? !1
234
- }), Wt = Ye(), Gt = () => u(rt) === !0;
235
- function Kt() {
236
- return [
237
- Bt,
238
- ...Ne,
239
- ...L()?.plugins ?? [],
240
- ...Gt() ? [Ht, Ut] : [],
241
- Wt
242
- ];
243
- }
244
- let qt = pe(), K = new Le(), q = Ce(), Jt = ve({
245
- relayout: () => {
246
- let e = P.value?.state ?? q.lastEditorState;
247
- e && Z(e, { reason: "hyphenation-ready" });
248
- },
249
- onError: (e) => k?.(e)
250
- });
251
- i(Jt.cancel), i(ge({
252
- measuredFontSet: () => q.lastMeasureInputs?.fontSet ?? null,
253
- relayout: () => {
254
- if (N) return;
255
- let e = P.value?.state ?? q.lastEditorState;
256
- e && Z(e, { reason: "font-ready" });
257
- }
258
- }));
259
- let Yt = new Fe({
260
- pageGap: _,
261
- showShadow: !0
262
- }), J = _e({
263
- getHost: () => gt.value,
264
- getReadOnly: () => u(l),
265
- getDocument: () => A.value,
266
- getCanonicalApi: () => $.api,
267
- readCanonicalDocument: () => $.readCanonicalDocument(),
268
- getExperimentalSession: () => u(ht),
269
- onSessionRefusal: (e, t, n) => {
270
- H.value = e, k?.(n ?? new m({
271
- ground: t,
272
- message: e
273
- }));
274
- },
275
- getStyles: yt,
276
- getTheme: () => A.value?.package.theme ?? null,
277
- onTransaction: ({ rId: e, kind: t, view: n, docChanged: r, selectionChanged: i }) => {
278
- if (r && (U.value = !0, Qt.schedule()), r || i) {
279
- let { from: r, to: i } = n.state.selection;
280
- Ct.value = {
281
- from: r,
282
- kind: t,
283
- rId: e,
284
- to: i
285
- }, st?.(n.state), qt.emit("selectionChange", {
286
- from: r,
287
- to: i
288
- });
289
- }
290
- K.requestRender();
291
- }
292
- }), Xt = { current: null }, Y = we({
293
- getHost: () => a?.value ?? null,
294
- getPlugins: () => Vt,
295
- getDocument: () => A.value,
296
- getCanonicalApi: () => $.api,
297
- readCanonicalDocument: () => $.readCanonicalDocument(),
298
- getExperimentalSession: () => u(ht),
299
- onSessionRefusal: (e, t, n) => {
300
- H.value = e, k?.(n ?? new m({
301
- ground: t,
302
- message: e
303
- }));
304
- },
305
- getStyles: yt,
306
- getTheme: () => A.value?.package.theme ?? null,
307
- onTransaction: ({ docChanged: e, selectionChanged: t, view: n }) => {
308
- if (e) {
309
- U.value = !0;
310
- let e = A.value;
311
- e && (A.value = $.readCanonicalDocument() ?? Xt.current?.snapshotDocument(e) ?? e, rn()), Qt.schedule();
312
- }
313
- if (e || t) {
314
- st?.(n.state);
315
- let { from: e, to: t } = n.state.selection;
316
- qt.emit("selectionChange", {
317
- from: e,
318
- to: t
319
- });
320
- }
321
- }
322
- });
323
- Xt.current = Y;
324
- let X = () => {
325
- J.sync(), Y.sync();
326
- };
327
- d(() => u(ht), X);
328
- function Zt(e) {
329
- e.layout && (V.value = e.layout), e.blocks && (Pt.value = e.blocks), e.measures && (Ft.value = e.measures), e.blockLookup && Yt.setBlockLookup(e.blockLookup), e.layout && qt.emit("layoutComplete", e.layout);
330
- }
331
- function Z(e, t = {}) {
332
- if (N) return;
333
- let n = o.value, r = n instanceof HTMLDivElement ? n : null, i = A.value, a = i && w(i), s = a?.package.document, c = s?.sections?.[0]?.properties ?? s?.finalSectionProperties ?? null, l = ne(c), d = S(c), f = Ot(c), p = l.w - d.left - d.right;
334
- Nt.value = p;
335
- let m = a?.package.styles ?? null, ee = i?.package.theme ?? null, h = i?.package.settings?.defaultTabStop, g = i?.package.settings?.mirrorMargins === !0, v = Ze(a?.package);
336
- try {
337
- Zt(ye({
338
- contentWidth: p,
339
- columns: f,
340
- pageSize: l,
341
- margins: d,
342
- pageGap: _,
343
- showMarginGuides: u(T) === !0,
344
- marginGuideColor: u(E),
345
- ...(() => {
346
- let e = u(te);
347
- return e === void 0 ? {} : { pageRenderer: e };
348
- })(),
349
- syncCoordinator: K,
350
- headerContent: v.headerContent,
351
- footerContent: v.footerContent,
352
- firstPageHeaderContent: v.firstPageHeaderContent,
353
- firstPageFooterContent: v.firstPageFooterContent,
354
- headerContentRId: v.activeHeaderRId,
355
- footerContentRId: v.activeFooterRId,
356
- firstPageHeaderContentRId: v.activeFirstHeaderRId,
357
- firstPageFooterContentRId: v.activeFirstFooterRId,
358
- sectionHeaderFooterRefs: Pe(a),
359
- theme: ee,
360
- sectionProperties: c,
361
- document: i,
362
- defaultTabStop: h,
363
- mirrorMargins: g,
364
- styles: m,
365
- layout: V.value,
366
- hfPMs: J,
367
- painter: Yt,
368
- pagesContainer: r,
369
- session: q,
370
- renderHfFromContentOrPm: kt,
371
- renderHeaderFooterContentByRId: At,
372
- readFontSetSignature: me,
373
- buildFootnoteRenderItems: jt,
374
- describeInvalidHighlightMarks: Mt,
375
- emptyTemplatePreviewEntries: Et,
376
- emptyTemplatePreviewHidden: Dt,
377
- hyphenationReadiness: Jt,
378
- markupView: u(b),
379
- showCommentHighlights: u(x),
380
- ...re === void 0 ? {} : { altChunkMarkerText: u(re) }
381
- }, e, t));
382
- } catch (e) {
383
- let t = e instanceof Error ? e : Error(String(e));
384
- k?.(t);
385
- }
386
- }
387
- let Qt = Se({
388
- readState: () => P.value?.state ?? null,
389
- runLayout: (e, t) => Z(e, t),
390
- ...be,
391
- clock: xe
392
- }), Q = null, $t = Ge();
393
- function en() {
394
- Q !== null && (window.clearTimeout(Q), Q = null);
395
- let e = P.value, t = A.value;
396
- if (e && t) try {
397
- let n = $.readCanonicalDocument();
398
- if (!n && W()) return;
399
- let r = n ?? $t.reconcile(Re(e.state.doc, w(t), { stylesheetSource: { type: "package" } }), e.state.doc);
400
- A.value = r, X(), nn(), Rt(r);
401
- } catch (e) {
402
- k?.(e instanceof Error ? e : Error(String(e)));
403
- }
404
- }
405
- let tn = null;
406
- function nn() {
407
- tn !== null && (window.clearTimeout(tn), tn = null);
408
- }
409
- function rn() {
410
- nn(), tn = window.setTimeout(() => {
411
- if (tn = null, Q !== null) return;
412
- let e = A.value;
413
- e && Rt(e);
414
- }, ue);
415
- }
416
- function an() {
417
- Q !== null && window.clearTimeout(Q), Q = window.setTimeout(() => {
418
- Q = null, en();
419
- }, ue);
420
- }
421
- let $ = h({
422
- getHost: () => n.value,
423
- getDocument: () => A.value,
424
- getStyles: yt,
425
- getExtensionManager: () => G,
426
- getExternalPlugins: Kt,
427
- getAnonymizationTerms: () => nt?.() ?? le,
428
- getCollaboration: L,
429
- getCollaborationModules: () => I.value,
430
- getCanonicalRoom: R,
431
- getPrecomputedInitialState: () => null,
432
- getReadOnly: () => u(l),
433
- getExperimentalSession: () => u(ht),
434
- getHistoryShortcuts: () => Qe,
435
- onCanonicalHistory: (e) => $e?.(e),
436
- onCanonicalHistoryDrop: (e) => et?.(e),
437
- getEditingMode: () => u(je) ?? "editing",
438
- getSuggestionAuthor: _t,
439
- onSessionRefusal: (e, t, n) => {
440
- k?.(n ?? new m({
441
- ground: t,
442
- message: e
443
- }));
444
- },
445
- getDocumentIdentity: () => String(j),
446
- getDocumentContext: () => A.value,
447
- onTransaction: cn,
448
- onCanonicalCompositionLayout: ln,
449
- getEmbeddedFontFamilyMap: () => q.embeddedFontFamilyMap,
450
- onSelectionChange: (e) => {
451
- F.value = e, st?.(e), qt.emit("selectionChange", {
452
- from: e.selection.from,
453
- to: e.selection.to
454
- });
455
- },
456
- onKeyDown: () => !1,
457
- onCopy: () => lt?.(),
458
- onCut: () => ut?.(),
459
- onPaste: () => dt?.(),
460
- onReadOnlyEditAttempt: () => ft?.(),
461
- onEditorViewReady: un,
462
- onEditorViewDestroy: () => {
463
- P.value = null, It.value = !1, ct?.(null);
464
- },
465
- onRemoteSelectionsChange: (e) => {
466
- z.value = e;
467
- }
468
- }), on = $.api.autocomplete.subscribe((t) => e.onAutocompleteChange?.(t)), sn = () => {
469
- let e = L()?.awareness, t = I.value, n = $.getView();
470
- z.value = e && t && n ? ee(n.state, e, t) : [];
471
- };
472
- d(() => u(tt), (e, t, n) => {
473
- if (z.value = [], !e || p(e)) {
474
- I.value = null, $.retryViewCreation(), $.syncExternalDocument();
475
- return;
476
- }
477
- let r = !1;
478
- n(() => {
479
- r = !0;
480
- }), I.value = null, O().then((e) => {
481
- r || (I.value = e, $.retryViewCreation(), $.syncExternalDocument(), sn());
482
- }, (e) => {
483
- r || (I.value = null, k?.(e instanceof Error ? e : Error(String(e))));
484
- });
485
- }, { immediate: !0 }), d(() => ({
486
- awareness: L()?.awareness,
487
- modules: I.value,
488
- view: P.value
489
- }), ({ awareness: e, modules: t, view: n }, r, i) => {
490
- R() === void 0 && (!e || !t || !n ? z.value = [] : (e.on("change", sn), sn(), i(() => {
491
- e.off("change", sn), z.value = [];
492
- })));
493
- }, { flush: "post" });
494
- function cn({ newState: e, docChanged: t, transactions: n }) {
495
- F.value = e;
496
- let r = n[0]?.before;
497
- if (t && r && $t.noteBase(r), t) {
498
- let e = $.readCanonicalDocument();
499
- e && (A.value = e, X()), U.value = !0, K.incrementStateSeq(), Qt.schedule(), an();
500
- }
501
- K.requestRender();
502
- }
503
- function ln() {
504
- let e = P.value;
505
- e && (F.value = e.state), K.incrementStateSeq(), Qt.schedule(), K.requestRender();
506
- }
507
- function un(e) {
508
- P.value = e, F.value = e.state, It.value = !0;
509
- let t = A.value, n = j, r = ++M;
510
- N = !0;
511
- let i = () => {
512
- M === r && (N = !1, xt || j !== n || $.getView() !== e || (Z(e.state, { reason: "initial" }), K.requestRender()));
513
- };
514
- he(t, e.state.doc).then(i, i), pn(e), ct?.(e), u(l) || requestAnimationFrame(() => {
515
- P.value === e && !e.hasFocus() && e.focus();
516
- });
517
- }
518
- let dn = {
519
- getDocx: async (e) => {
520
- let t = await Cn(e);
521
- return t?.tripwireResult && mt?.(t.tripwireResult), t?.buffer ?? null;
522
- },
523
- loadDocument: bn,
524
- loadDocx: yn
525
- }, fn = fe({
526
- getEditorApi: () => $.api,
527
- getLayout: () => V.value,
528
- runLayout: (e, t) => Z(e, t),
529
- getDocumentIO: () => dn,
530
- emitter: qt
531
- });
532
- function pn(e) {
533
- let t = u(je) === "suggesting";
534
- ce(t, e.state, e.dispatch, _t());
535
- }
536
- d([() => u(je), _t], () => {
537
- fn.setCanonicalMode(u(je) === "suggesting" ? {
538
- type: "suggesting",
539
- author: _t()
540
- } : { type: "editing" });
541
- let e = P.value;
542
- e && pn(e);
543
- for (let e of Y.listStories()) {
544
- let t = Y.getView(e);
545
- t && pn(t);
546
- }
547
- }), d(() => u(l), (e) => {
548
- $.syncEditable(), e && Mn(), J.sync();
549
- });
550
- function mn(e) {
551
- let t = Gt();
552
- if (t === e.state.plugins.includes(Ht)) return;
553
- let n = e.state.plugins.filter((e) => e !== Ht && e !== Ut);
554
- if (t) {
555
- let e = n.indexOf(Wt), t = e === -1 ? n.length : e;
556
- n.splice(t, 0, Ht, Ut);
557
- }
558
- e.updateState(e.state.reconfigure({ plugins: n }));
559
- }
560
- d(() => Gt(), () => {
561
- let e = P.value;
562
- e && mn(e);
563
- });
564
- function hn() {
565
- $.ensureView();
566
- }
567
- function gn() {
568
- nn(), j += 1, bt.value = A.value?.originalBuffer ?? null, U.value = !1, Ct.value = null, B.value = null, Y.activate(null), Qt.dispose(), $.destroyView(), W() && $.ensureView(), X(), $.ensureView(), $.getView() || _n();
569
- }
570
- function _n() {
571
- let e = A.value;
572
- if (e && !L()) try {
573
- let t = g({
574
- document: e,
575
- styles: w(e).package.styles ?? null,
576
- manager: G,
577
- externalPlugins: Kt(),
578
- collaborationModules: null,
579
- reason: "mount"
580
- });
581
- F.value = t;
582
- let n = j, r = ++M;
583
- N = !0;
584
- let i = () => {
585
- M === r && (N = !1, xt || j !== n || A.value !== e || $.getView() || Z(t, { reason: "initial" }));
586
- };
587
- he(e, t.doc).then(i, i);
588
- } catch (e) {
589
- k?.(e instanceof Error ? e : Error(String(e)));
590
- }
591
- }
592
- d([
593
- n,
594
- o,
595
- gt,
596
- ...a ? [a] : []
597
- ], () => {
598
- n.value && A.value && !$.getView() && hn(), X();
599
- }, { flush: "post" });
600
- let vn = 0;
601
- async function yn(e) {
602
- vn += 1, H.value = null, It.value = !1;
603
- try {
604
- let t;
605
- if (W()) {
606
- let n = await Oe(e, { password: u(D) });
607
- if (n.isErr()) throw n.error;
608
- t = n.value.document;
609
- } else t = await Ae(e, { password: u(D) });
610
- vt = Ke(t), A.value = t, gn();
611
- } catch (e) {
612
- let t = e instanceof Error ? e : Error(String(e));
613
- H.value = t.message, k?.(t);
614
- }
615
- }
616
- function bn(e) {
617
- let t = vn += 1;
618
- H.value = null;
619
- let n = St(e);
620
- !W() || De(n) ? Sn(n) : xn(n, t);
621
- }
622
- async function xn(e, t) {
623
- let n = await ke(e);
624
- t === vn && (n.isErr() ? (H.value = n.error.message, k?.(n.error)) : Sn(n.value));
625
- }
626
- function Sn(e) {
627
- vt = Ke(e), A.value = e, $t.reset(), gn();
628
- }
629
- async function Cn(e) {
630
- let n = P.value, r = A.value;
631
- if (!n || !r) return null;
632
- try {
633
- let i = $.api.captureCanonicalSave();
634
- if (i) {
635
- let t = await Ee({
636
- snapshot: i,
637
- options: e,
638
- featureFlags: u(pt)
639
- });
640
- for (let n of t.diagnostics) e?.onDiagnostic || k?.(Te(n));
641
- return t;
642
- }
643
- if (W()) return null;
644
- Q !== null && en();
645
- let a = Y.snapshotDocument(J.snapshotDocument(r)), o = n.state, s = Re(o.doc, w(a), { stylesheetSource: { type: "package" } }), c = qe(t ? y(s, t(), { anchoredInEditor: C(o.doc) }) : s, vt), { resolveSelectiveSaveFlags: l } = await import("@stll/folio-core/docx/selectiveSaveFlags"), d = l(u(pt)), f = c.originalBuffer ?? null, p = d.selectiveSave && e?.mode !== de.full, m = p || d.selectiveSaveTripwire, { repackDocx: ee, createDocx: h } = await import("@stll/folio-core/docx/rezip"), g = null;
646
- if (m && f) {
647
- let { attemptSelectiveSave: t } = await import("@stll/folio-core/docx/selectiveSave");
648
- g = await t(c, f, {
649
- changedParaIds: Be(o),
650
- structuralChange: Ve(o),
651
- hasUntrackedChanges: He(o),
652
- maxBytes: d.selectiveSaveMaxBytes,
653
- onSelectiveDecline: e?.onSelectiveDecline,
654
- onDiagnostic: e?.onDiagnostic
655
- });
656
- }
657
- let _ = p ? g : null, v = null, te = "selective", b = [], x = (e) => b.push(e), S = () => Ue({
658
- state: o,
659
- document: c,
660
- repack: () => ee(c, { onDiagnostic: x })
661
- });
662
- if (!_) v = f ? await S() : await h(c, { onDiagnostic: x }), _ = v, te = "full-repack";
663
- else if (d.selectiveSaveTripwire) try {
664
- v = await S();
665
- } catch {}
666
- let ne = null;
667
- if (d.selectiveSaveTripwire && v && mt) try {
668
- let { compareSelectiveVsFull: e } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
669
- ne = await e(g, v);
670
- } catch {}
671
- for (let t of b) e?.onDiagnostic?.(t);
672
- return e?.onSerializationPath?.(te), {
673
- buffer: _,
674
- path: te,
675
- document: c,
676
- tripwireResult: ne
677
- };
678
- } catch (e) {
679
- return k?.(e instanceof Error ? e : Error(String(e))), null;
680
- }
681
- }
682
- async function wn(e) {
683
- let t = P.value, n = t?.state, r = await Cn({
684
- onDiagnostic: e?.onDiagnostic,
685
- onSelectiveDecline: e?.onSelectiveDecline,
686
- onSerializationPath: e?.onSerializationPath,
687
- mode: e?.selective === !1 ? de.full : de.preferSelective
688
- });
689
- return r ? (P.value === t && t?.state.doc === n?.doc && (r.version === void 0 || $.api.isCanonicalSaveCurrent(r.version)) && (r.version !== void 0 && $.api.markCanonicalSaved(r.version, {
690
- buffer: r.buffer,
691
- path: r.path
692
- }), A.value = r.document, X(), U.value = !1), r.tripwireResult && mt?.(r.tripwireResult), new Blob([r.buffer], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" })) : null;
693
- }
694
- function Tn() {
695
- return $.readCanonicalDocument();
696
- }
697
- function En() {
698
- let e = Tn();
699
- if (e) return e;
700
- if (W()) return null;
701
- let t = A.value;
702
- if (!t) return null;
703
- let n = $.api.getDocument() ?? t;
704
- return Y.snapshotDocument(J.snapshotDocument(n));
705
- }
706
- function Dn() {
707
- let e = En();
708
- return e && Lt(e);
709
- }
710
- function On(e) {
711
- zt(ie.modelEdits, "Direct document model changes are unavailable in this session.") || (A.value = St(e), nn(), bt.value = e.originalBuffer ?? null, X(), B.value && !Y.getView(B.value) && (B.value = null));
712
- }
713
- function kn(e) {
714
- return J.getView(e);
715
- }
716
- function An() {
717
- X();
718
- }
719
- function jn(e) {
720
- let t = Y.activate(e);
721
- t && (pn(t), B.value = e, requestAnimationFrame(() => t.focus()));
722
- }
723
- function Mn() {
724
- Y.activate(null), B.value = null;
725
- }
726
- function Nn() {
727
- let e = B.value;
728
- return e ? Y.getView(e) : null;
729
- }
730
- function Pn() {
731
- return G.getCommands();
732
- }
733
- function Fn() {
734
- let e = Nn();
735
- e ? e.focus() : P.value?.focus();
736
- }
737
- function In() {
738
- let e = P.value;
739
- e && Z(e.state, { reason: "manual" });
740
- }
741
- d([
742
- () => u(T),
743
- () => u(E),
744
- () => u(te),
745
- () => u(b),
746
- () => u(x),
747
- () => u(re)
748
- ], () => In());
749
- function Ln() {
750
- xt = !0, o.value && Ie(o.value), M += 1, N = !1, Qt.dispose(), Q !== null && (window.clearTimeout(Q), Q = null), nn(), $.destroyView(), z.value = [], J.destroy(), Y.destroy(), G.destroy(), F.value = null, V.value = null, A.value = null, bt.value = null, It.value = !1;
751
- }
752
- return i(() => {
753
- Ln(), on();
754
- }), {
755
- setEmbeddedFontFamilies: (e) => {
756
- e ? q.embeddedFontFamilyMap = new Map(e) : delete q.embeddedFontFamilyMap, $.refreshFonts();
757
- },
758
- editor: fn,
759
- editorView: P,
760
- editorState: F,
761
- remoteSelections: z,
762
- headerFooterSelection: Ct,
763
- activeNoteStory: B,
764
- isReady: It,
765
- isDirty: U,
766
- parseError: H,
767
- modelDocument: A,
768
- readDocumentModel: Tn,
769
- sourceBuffer: bt,
770
- hiddenEditorWidth: Nt,
771
- layout: V,
772
- blocks: Pt,
773
- measures: Ft,
774
- syncCoordinator: K,
775
- loadBuffer: yn,
776
- loadDocument: bn,
777
- save: wn,
778
- getDocument: Dn,
779
- readDocument: En,
780
- setDocument: On,
781
- getHeaderFooterView: kn,
782
- syncHeaderFooterViews: An,
783
- openNoteStory: jn,
784
- closeNoteStory: Mn,
785
- getActiveNoteView: Nn,
786
- getCommands: Pn,
787
- focus: Fn,
788
- reLayout: In,
789
- destroy: Ln
790
- };
791
- }
792
- // src/composables/useFindReplace.ts
793
- function Nt({ editorView: t, pagesRef: n, getDocument: r, layout: a, commentRoot: l, revealComment: u, displayMode: f, readOnly: p, onReadonlyEditAttempt: m, onResultChange: ee }) {
794
- let h = new Qe(), g = s(""), _ = s(""), v = o(it()), y = c([]), b = s(-1), x = e(() => y.value.at(b.value) ?? null), S = () => te({
795
- editingMode: t.value?.editable === !1 ? "viewing" : "editing",
796
- readOnlyProp: p.value,
797
- displayMode: f.value
798
- }), ne = e(S), re = e(() => {
799
- let e = x.value;
800
- return S() === null && !!t.value && !!e && w() && at(e).status === "allowed";
801
- }), C = null, ie, ae = null, oe = (e) => {
802
- let n = t.value?.state.doc;
803
- return {
804
- query: g.value,
805
- options: {
806
- ...v,
807
- displayMode: f.value,
808
- includeComments: !!l
809
- },
810
- document: e,
811
- ...n ? { bodyVersion: n } : {},
812
- context: { renderedStories: rt(a.value) }
813
- };
814
- }, w = () => {
815
- let e = r();
816
- return !!e && k(ae, ot(oe(e)));
817
- }, T = () => h.getResult(), E = () => ee(T()), D = () => {
818
- clearTimeout(ie), ie = void 0;
819
- }, se = () => {
820
- D(), h.clear(), C?.destroy(), C = null, y.value = [], ae = null, b.value = -1;
821
- }, ce = () => {
822
- se(), g.value = "", E();
823
- }, le = (e) => (b.value = e, C?.navigate(e, u), E(), !0), O = (e = "query") => {
824
- D();
825
- let i = r(), o = n.value, s = t.value?.state.doc;
826
- if (!i || !g.value.trim()) return ce(), [];
827
- let c = oe(i), u = $e({
828
- document: c.document,
829
- state: t.value?.state ?? null,
830
- searchText: c.query,
831
- options: c.options,
832
- context: c.context
833
- });
834
- if (u === null) return se(), E(), [];
835
- let d = ot(c), f = e === "refresh" && ae?.query === d.query, p = h.setMatches(u, f ? h.getResult()?.currentIndex ?? 0 : 0);
836
- return ae = d, y.value = u, b.value = u.length > 0 ? p.currentIndex : -1, C?.destroy(), C = o ? nt({
837
- container: o,
838
- document: i,
839
- bodyDoc: s,
840
- matches: u,
841
- commentRoot: l?.value ?? void 0,
842
- layout: a.value
843
- }) : null, C?.paint(b.value), u.at(0) && !f ? le(0) : E(), u;
844
- }, ue = () => {
845
- D(), ie = setTimeout(() => O("refresh"), 120);
846
- }, de = (e, t) => (g.value = e, Object.assign(v, it(), t), O(), T()), fe = (e) => {
847
- let t = h.goTo(e);
848
- return t ? le(t.index) : !1;
849
- }, pe = (e) => {
850
- let t = h.navigate(e);
851
- return t ? (le(t.index), t.match) : null;
852
- }, me = () => !w() && (O("refresh"), !0), he = () => {
853
- let e = S();
854
- return e !== null && (m?.(e), !0);
855
- };
856
- return d(f, () => {
857
- g.value.trim() && O();
858
- }), i(() => {
859
- D(), C?.destroy();
860
- }), {
861
- searchText: g,
862
- replaceText: _,
863
- options: v,
864
- matches: y,
865
- currentIndex: b,
866
- currentMatch: x,
867
- canReplaceCurrent: re,
868
- replacementRefusal: ne,
869
- performSearch: O,
870
- scheduleSearch: ue,
871
- find: de,
872
- getFindResult: T,
873
- goToMatch: fe,
874
- findNext: () => pe("next"),
875
- findPrevious: () => pe("previous"),
876
- replaceCurrent: () => {
877
- let e = t.value;
878
- if (!e || he() || me()) return !1;
879
- let n = x.value;
880
- if (!re.value || !n) return !1;
881
- let r = e.state.doc, i = et(e, n, _.value);
882
- return e.state.doc !== r && O("refresh"), i;
883
- },
884
- replaceAll: () => {
885
- let e = t.value, n = y.value.length;
886
- if (!e || he() || me()) return {
887
- replacedCount: 0,
888
- skippedCount: n
889
- };
890
- let r = e.state.doc, i = tt(e, y.value, _.value);
891
- return e.state.doc !== r && O(), i;
892
- },
893
- clear: ce
894
- };
895
- }
896
- function Pt(e, t) {
897
- if (t < e.top + 40) {
898
- let n = Math.max(0, e.top + 40 - t);
899
- return -Math.min(12, n / 40 * 12);
900
- }
901
- if (t > e.bottom - 40) {
902
- let n = Math.max(0, t - (e.bottom - 40));
903
- return Math.min(12, n / 40 * 12);
904
- }
905
- return 0;
906
- }
907
- // src/composables/useDragAutoScroll.ts
908
- function Ft({ pagesContainer: e, onScrollExtendSelection: t }) {
909
- let n = null, r = 0, a = 0, o = !1;
910
- function s() {
911
- return b(e.value);
912
- }
913
- function c() {
914
- o = !1, n !== null && (cancelAnimationFrame(n), n = null);
915
- }
916
- function l() {
917
- if (!o) return;
918
- let e = s();
919
- if (!e) return;
920
- let i = Pt(e.getBoundingClientRect(), a);
921
- i !== 0 && (x(e, i), t(r, a)), n = requestAnimationFrame(l);
922
- }
923
- function u() {
924
- o || (o = !0, n = requestAnimationFrame(l));
925
- }
926
- function d(e, t) {
927
- if (r = e, a = t, !o) {
928
- let e = s();
929
- if (!e) return;
930
- let n = e.getBoundingClientRect();
931
- (t < n.top + 40 || t > n.bottom - 40) && u();
932
- }
933
- }
934
- return i(() => c()), {
935
- updateMousePosition: d,
936
- stopAutoScroll: c
937
- };
938
- }
939
- // src/composables/useTableResize.ts
940
- function It({ runCommand: e }) {
941
- let t = {
942
- active: !1,
943
- startX: 0,
944
- handle: null,
945
- columnIndex: 0,
946
- tablePmStart: 0,
947
- origWidths: {
948
- left: 0,
949
- right: 0
950
- }
951
- }, n = {
952
- active: !1,
953
- startY: 0,
954
- handle: null,
955
- rowIndex: 0,
956
- isEdge: !1,
957
- tablePmStart: 0,
958
- origHeight: 0,
959
- minimumHeight: ct
960
- }, r = {
961
- active: !1,
962
- startX: 0,
963
- handle: null,
964
- columnIndex: 0,
965
- tablePmStart: 0,
966
- origWidth: 0
967
- }, i = null;
968
- function a() {
969
- return t.active || n.active || r.active;
970
- }
971
- function o(e, a) {
972
- let o = e.target;
973
- return o instanceof HTMLElement ? o.classList.contains("layout-table-resize-handle") ? (e.preventDefault(), e.stopPropagation(), i = a, t.active = !0, t.startX = e.clientX, t.handle = o, o.classList.add("dragging"), t.columnIndex = parseInt(o.dataset.columnIndex ?? "0", 10), t.tablePmStart = T(o) ?? 0, H(a, t), !0) : o.classList.contains("layout-table-row-resize-handle") || o.classList.contains("layout-table-edge-handle-bottom") ? (e.preventDefault(), e.stopPropagation(), i = a, n.active = !0, n.startY = e.clientY, n.handle = o, n.isEdge = o.dataset.isEdge === "bottom", o.classList.add("dragging"), n.rowIndex = parseInt(o.dataset.rowIndex ?? "0", 10), n.tablePmStart = T(o) ?? 0, U(a, n, o), !0) : o.classList.contains("layout-table-edge-handle-right") ? (e.preventDefault(), e.stopPropagation(), i = a, r.active = !0, r.startX = e.clientX, r.handle = o, o.classList.add("dragging"), r.columnIndex = parseInt(o.dataset.columnIndex ?? "0", 10), r.tablePmStart = T(o) ?? 0, W(a, r), !0) : !1 : !1;
974
- }
975
- function s(e) {
976
- if (t.active && t.handle) {
977
- e.preventDefault();
978
- let n = e.clientX - t.startX, r = parseFloat(t.handle.style.left);
979
- t.handle.style.left = `${r + n}px`, t.startX = e.clientX;
980
- let i = Math.round(n * lt), a = t.origWidths.left + i, o = t.origWidths.right - i;
981
- a >= st && o >= st && (t.origWidths = {
982
- left: a,
983
- right: o
984
- });
985
- } else if (n.active && n.handle) {
986
- e.preventDefault();
987
- let t = e.clientY - n.startY, r = parseFloat(n.handle.style.top);
988
- n.startY = e.clientY;
989
- let i = Math.round(t * lt), a = ut({
990
- currentHeight: n.origHeight,
991
- delta: i,
992
- minimumHeight: n.minimumHeight
993
- });
994
- n.handle.style.top = `${r + a / lt}px`, n.origHeight += a;
995
- } else if (r.active && r.handle) {
996
- e.preventDefault();
997
- let t = e.clientX - r.startX, n = parseFloat(r.handle.style.left);
998
- r.handle.style.left = `${n + t}px`, r.startX = e.clientX;
999
- let i = Math.round(t * lt), a = r.origWidth + i;
1000
- a >= st && (r.origWidth = a);
1001
- }
1002
- }
1003
- function c(a) {
1004
- t.active ? (t.active = !1, t.handle?.classList.remove("dragging"), i && e(i, dt({
1005
- pmStart: t.tablePmStart,
1006
- colIdx: t.columnIndex,
1007
- newLeft: t.origWidths.left,
1008
- newRight: t.origWidths.right
1009
- })), t.handle = null) : n.active ? (n.active = !1, n.handle?.classList.remove("dragging"), i && e(i, gt({
1010
- pmStart: n.tablePmStart,
1011
- rowIdx: n.rowIndex,
1012
- newHeight: n.origHeight
1013
- })), n.handle = null) : r.active && (r.active = !1, r.handle?.classList.remove("dragging"), i && e(i, ht({
1014
- pmStart: r.tablePmStart,
1015
- colIdx: r.columnIndex,
1016
- newWidth: r.origWidth
1017
- })), r.handle = null);
1018
- }
1019
- function l() {
1020
- return document.addEventListener("mousemove", s), document.addEventListener("mouseup", c), () => {
1021
- document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", c);
1022
- };
1023
- }
1024
- return {
1025
- tryStartResize: o,
1026
- install: l,
1027
- isResizing: a
1028
- };
1029
- }
1030
- function H(e, t) {
1031
- let n = pt(e, t.tablePmStart, t.columnIndex);
1032
- n && (t.origWidths = n);
1033
- }
1034
- function U(e, t, n) {
1035
- let r = mt(e, t.tablePmStart, t.rowIndex);
1036
- if (r != null) t.origHeight = r;
1037
- else {
1038
- let e = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), r = e ? e.getBoundingClientRect().height : 30;
1039
- t.origHeight = Math.round(r * lt);
1040
- }
1041
- t.minimumHeight = Math.min(ct, t.origHeight);
1042
- }
1043
- function W(e, t) {
1044
- let n = ft(e, t.tablePmStart, t.columnIndex);
1045
- n != null && (t.origWidth = n);
1046
- }
1047
- // src/composables/useTrackedChanges.ts
1048
- function Lt(t, n) {
1049
- return e(() => {
1050
- n.value;
1051
- let e = t.value?.state ?? null, r = _t(e);
1052
- if (e === null) return r;
1053
- let i = {
1054
- accept: E(e, "accept"),
1055
- reject: E(e, "reject")
1056
- };
1057
- if (i.accept.size === 0 && i.reject.size === 0) return r;
1058
- let a = r.entries;
1059
- for (let e of a) {
1060
- let t = D(e);
1061
- e.heldByLock = {
1062
- accept: t.some((e) => i.accept.has(e)),
1063
- reject: t.some((e) => i.reject.has(e))
1064
- };
1065
- }
1066
- return {
1067
- ...r,
1068
- entries: a
1069
- };
1070
- });
1071
- }
1072
- // src/composables/useZoom.ts
1073
- var Rt = vt, zt = A, G = [
1074
- .5,
1075
- .75,
1076
- 1,
1077
- 1.25,
1078
- 1.5,
1079
- 2
1080
- ];
1081
- function Bt(t = 1) {
1082
- let i = s(Math.max(Rt, Math.min(zt, t))), a = e(() => Math.round(i.value * 100)), o = e(() => i.value <= Rt), c = e(() => i.value >= zt);
1083
- function l(e) {
1084
- i.value = Math.max(Rt, Math.min(zt, Math.round(e * 100) / 100));
1085
- }
1086
- function u() {
1087
- l(i.value + yt);
1088
- }
1089
- function d() {
1090
- l(i.value - yt);
1091
- }
1092
- function f() {
1093
- l(1);
1094
- }
1095
- function p(e) {
1096
- (e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d());
1097
- }
1098
- function m(e) {
1099
- (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())));
1100
- }
1101
- function ee() {
1102
- r(() => document.addEventListener("keydown", m)), n(() => document.removeEventListener("keydown", m));
1103
- }
1104
- return {
1105
- zoom: i,
1106
- zoomPercent: a,
1107
- isMinZoom: o,
1108
- isMaxZoom: c,
1109
- setZoom: l,
1110
- zoomIn: u,
1111
- zoomOut: d,
1112
- resetZoom: f,
1113
- handleWheel: p,
1114
- handleKeyDown: m,
1115
- installShortcuts: ee,
1116
- ZOOM_PRESETS: G
1117
- };
1118
- }
1119
- export { Ft as a, I as c, L as d, It as i, N as l, _t as n, Nt as o, Lt as r, V as s, Bt as t, F as u };