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