@eigenpal/docx-editor-vue 1.2.1 → 1.3.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/{KeyboardShortcutsDialog-5ZsgieYf.js → KeyboardShortcutsDialog-00eb4Ova.js} +23 -0
- package/dist/KeyboardShortcutsDialog-EW9K4wuO.cjs +1 -0
- package/dist/MenuBar-DeogoqFP.js +3330 -0
- package/dist/MenuBar-bU4-4dnA.cjs +4 -0
- package/dist/{TablePropertiesDialog-DTCcLpPC.cjs → TablePropertiesDialog-BZLpFAkg.cjs} +1 -1
- package/dist/{TablePropertiesDialog-PR4ftalH.js → TablePropertiesDialog-CBTvM4Xy.js} +1 -1
- package/dist/composables/useCommentLifecycle.d.ts +3 -0
- package/dist/composables/useCommentManagement.d.ts +6 -0
- package/dist/composables/useFormattingActions.d.ts +2 -22
- package/dist/composables/useMenuActions.d.ts +1 -0
- package/dist/composables/useSelectionSync.d.ts +16 -0
- package/dist/composables/useWatermarkControls.d.ts +15 -0
- package/dist/composables.cjs +1 -1
- package/dist/composables.js +124 -209
- package/dist/dialogs.cjs +1 -1
- package/dist/dialogs.js +2 -2
- package/dist/docx-editor-vue.css +1 -1
- package/dist/index.cjs +9 -10
- package/dist/index.js +1373 -1210
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +3 -3
- package/dist/useCommentSidebarItems-BHomCzpj.js +44 -0
- package/dist/useCommentSidebarItems-CbNvNCd3.cjs +1 -0
- package/dist/useDragAutoScroll-BT6oPYBj.cjs +1 -0
- package/dist/useDragAutoScroll-C56F_WS_.js +493 -0
- package/dist/utils/domQueries.d.ts +17 -6
- package/dist/utils/refApiQueries.d.ts +8 -44
- package/package.json +4 -4
- package/dist/KeyboardShortcutsDialog-DiG-tfJT.cjs +0 -1
- package/dist/MenuBar-DLXxthZk.js +0 -3365
- package/dist/MenuBar-De3YJFpj.cjs +0 -4
- package/dist/useTableResize-BcBdSaOE.js +0 -583
- package/dist/useTableResize-DTag4SY0.cjs +0 -1
- package/dist/utils/commentFactories.d.ts +0 -7
- package/dist/utils/paraTextHelpers.d.ts +0 -29
|
@@ -1,583 +0,0 @@
|
|
|
1
|
-
import { computed as e, onBeforeUnmount as t, onMounted as n, ref as r, shallowRef as i, unref as a, watch as o } from "vue";
|
|
2
|
-
import { EditorState as s } from "prosemirror-state";
|
|
3
|
-
import { buildFootnoteContentMap as c, buildFootnoteRenderItems as l, collectFootnoteRefs as u, convertHeaderFooterPmDocToContent as d, convertHeaderFooterToContent as f, getMargins as p, getPageSize as m, measureTableBlock as h, resolveHeaderFooter as ee, stabilizeFootnoteLayout as te } from "@eigenpal/docx-editor-core/layout-bridge";
|
|
4
|
-
import { applySdtFocus as g, enclosingSdtGroupIds as ne } from "@eigenpal/docx-editor-core/layout-painter";
|
|
5
|
-
import { createEmptyDoc as re, headerFooterToProseDoc as _, proseDocToBlocks as v, toProseDoc as ie } from "@eigenpal/docx-editor-core/prosemirror/conversion";
|
|
6
|
-
import { schema as y } from "@eigenpal/docx-editor-core/prosemirror";
|
|
7
|
-
import { EditorView as b } from "prosemirror-view";
|
|
8
|
-
import { parseDocx as x } from "@eigenpal/docx-editor-core/docx/parser";
|
|
9
|
-
import { fromProseDoc as S } from "@eigenpal/docx-editor-core/prosemirror/conversion/fromProseDoc";
|
|
10
|
-
import { singletonManager as C } from "@eigenpal/docx-editor-core/prosemirror/schema";
|
|
11
|
-
import { createDocumentStylesPlugin as w, createSuggestionModePlugin as T, setSuggestionMode as E } from "@eigenpal/docx-editor-core/prosemirror/plugins";
|
|
12
|
-
import { ExtensionManager as D, createStarterKit as O } from "@eigenpal/docx-editor-core/prosemirror/extensions";
|
|
13
|
-
import { toFlowBlocks as ae } from "@eigenpal/docx-editor-core/layout-bridge/toFlowBlocks";
|
|
14
|
-
import { measureBlocksWithFloats as k, measureParagraph as A } from "@eigenpal/docx-editor-core/layout-bridge/measuring";
|
|
15
|
-
import { DEFAULT_TEXTBOX_MARGINS as j, DEFAULT_TEXTBOX_WIDTH as M, assertExhaustiveFlowBlock as N, layoutDocument as oe } from "@eigenpal/docx-editor-core/layout-engine";
|
|
16
|
-
import { renderPages as se } from "@eigenpal/docx-editor-core/layout-painter/renderPage";
|
|
17
|
-
import "prosemirror-view/style/prosemirror.css";
|
|
18
|
-
import "@eigenpal/docx-editor-core/prosemirror/editor.css";
|
|
19
|
-
//#region src/composables/useDocxEditor.ts
|
|
20
|
-
var ce = 24;
|
|
21
|
-
function P(e, t, n, r) {
|
|
22
|
-
switch (e.kind) {
|
|
23
|
-
case "paragraph": return A(e, t, {
|
|
24
|
-
floatingZones: n,
|
|
25
|
-
paragraphYOffset: r ?? 0
|
|
26
|
-
});
|
|
27
|
-
case "table": return h(e, t, P);
|
|
28
|
-
case "image": {
|
|
29
|
-
let t = e;
|
|
30
|
-
return {
|
|
31
|
-
kind: "image",
|
|
32
|
-
width: t.width ?? 100,
|
|
33
|
-
height: t.height ?? 100
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
case "textBox": {
|
|
37
|
-
let t = e, n = t.margins ?? j, r = (t.width ?? M) - n.left - n.right, i = t.content.map((e) => A(e, r)), a = i.reduce((e, t) => e + t.totalHeight, 0), o = t.height ?? a + n.top + n.bottom;
|
|
38
|
-
return {
|
|
39
|
-
kind: "textBox",
|
|
40
|
-
width: t.width ?? M,
|
|
41
|
-
height: o,
|
|
42
|
-
innerMeasures: i
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
case "pageBreak": return { kind: "pageBreak" };
|
|
46
|
-
case "columnBreak": return { kind: "columnBreak" };
|
|
47
|
-
case "sectionBreak": return { kind: "sectionBreak" };
|
|
48
|
-
default: N(e, "vue useDocxEditor measureBlock");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function F(e, t) {
|
|
52
|
-
return k(e, t, P);
|
|
53
|
-
}
|
|
54
|
-
function I(e) {
|
|
55
|
-
let { hiddenContainer: n, pagesContainer: h, readOnly: k = !1, pageGap: A = ce, onChange: j, onError: M, onSelectionUpdate: N, externalPlugins: P = [], syncCoordinator: I, editorMode: L, author: R } = e, z = i(null), B = i(null), V = i(null), H = r(!1), U = r(null), W = i(null), G = C;
|
|
56
|
-
function K(e) {
|
|
57
|
-
let t = h.value;
|
|
58
|
-
if (!t || !z.value) return;
|
|
59
|
-
let n = I?.getStateSeq() ?? 0;
|
|
60
|
-
I?.onLayoutStart();
|
|
61
|
-
let r = z.value.package?.document, i = r?.sections?.[0]?.properties ?? r?.finalSectionProperties ?? null, a = r?.finalSectionProperties ?? i, o = m(i), s = p(i), re = m(a), _ = p(a), v = o.w - s.left - s.right, ie = o.h - s.top - s.bottom, y = z.value.package?.theme ?? null, b = z.value.package?.styles ?? null;
|
|
62
|
-
try {
|
|
63
|
-
let n = ae(e.doc, {
|
|
64
|
-
theme: y,
|
|
65
|
-
pageContentHeight: ie
|
|
66
|
-
}), r = F(n, v), { header: a, footer: p, firstHeader: m, firstFooter: h } = ee(z.value, i), x = {
|
|
67
|
-
section: "header",
|
|
68
|
-
pageSize: o,
|
|
69
|
-
margins: s
|
|
70
|
-
}, S = {
|
|
71
|
-
section: "footer",
|
|
72
|
-
pageSize: o,
|
|
73
|
-
margins: s
|
|
74
|
-
}, C = e.doc.attrs?.defaultTabStopTwips, w = {
|
|
75
|
-
styles: b,
|
|
76
|
-
theme: y,
|
|
77
|
-
measureBlocks: F,
|
|
78
|
-
defaultTabStopTwips: C
|
|
79
|
-
}, T = (e, t) => {
|
|
80
|
-
if (!e) return;
|
|
81
|
-
let n = de(e);
|
|
82
|
-
return n ? d(n.state.doc, v, t, w) : f(e, v, t, w);
|
|
83
|
-
}, E = T(a, x), D = T(p, S), O = i?.titlePg === !0, k = O ? T(m, x) : void 0, j = O ? T(h, S) : void 0, M = s.header ?? 48, N = s.footer ?? 48, ce = s.top - M, P = s.bottom - N, I = (e) => e ? e.visualBottom ?? e.height : 0, L = (e) => e ? Math.max((e.visualBottom ?? e.height) - (e.visualTop ?? 0), e.height) : 0, R = Math.max(I(E), I(k)), B = Math.max(L(D), L(j)), V = R > ce, H = B > P;
|
|
84
|
-
if (V || H) {
|
|
85
|
-
let e = (e) => {
|
|
86
|
-
let t = { ...e };
|
|
87
|
-
return V && (t.top = Math.max(e.top, M + R)), H && (t.bottom = Math.max(e.bottom, N + B)), t;
|
|
88
|
-
};
|
|
89
|
-
s = e(s), _ = e(_);
|
|
90
|
-
for (let t of n) {
|
|
91
|
-
if (t.kind !== "sectionBreak") continue;
|
|
92
|
-
let n = t;
|
|
93
|
-
n.margins &&= e(n.margins);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
let U = {
|
|
97
|
-
pageSize: o,
|
|
98
|
-
margins: s,
|
|
99
|
-
finalPageSize: re,
|
|
100
|
-
finalMargins: _,
|
|
101
|
-
pageGap: A
|
|
102
|
-
}, G = u(n), K = G.length > 0 && !!z.value.package?.footnotes, q = oe(n, r, U), J = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map();
|
|
103
|
-
if (K) {
|
|
104
|
-
Y = c(z.value.package.footnotes, G, v, {
|
|
105
|
-
styles: b,
|
|
106
|
-
theme: y,
|
|
107
|
-
measureBlocks: F,
|
|
108
|
-
defaultTabStopTwips: C
|
|
109
|
-
});
|
|
110
|
-
let e = te({
|
|
111
|
-
blocks: n,
|
|
112
|
-
measures: r,
|
|
113
|
-
layoutOpts: U,
|
|
114
|
-
footnoteRefs: G,
|
|
115
|
-
footnoteContentMap: Y,
|
|
116
|
-
initialLayout: q
|
|
117
|
-
});
|
|
118
|
-
q = e.layout, J = e.pageFootnoteMap;
|
|
119
|
-
}
|
|
120
|
-
W.value = q;
|
|
121
|
-
let X = /* @__PURE__ */ new Map();
|
|
122
|
-
for (let e = 0; e < n.length; e++) {
|
|
123
|
-
let t = n[e], i = r[e];
|
|
124
|
-
t && i && X.set(String(t.id), {
|
|
125
|
-
block: t,
|
|
126
|
-
measure: i
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
let Z = K ? l(J, Y, z.value) : void 0;
|
|
130
|
-
se(q.pages, t, {
|
|
131
|
-
pageGap: A,
|
|
132
|
-
showShadow: !0,
|
|
133
|
-
pageBackground: "#fff",
|
|
134
|
-
blockLookup: X,
|
|
135
|
-
theme: y,
|
|
136
|
-
headerContent: E,
|
|
137
|
-
footerContent: D,
|
|
138
|
-
firstPageHeaderContent: k,
|
|
139
|
-
firstPageFooterContent: j,
|
|
140
|
-
titlePage: O,
|
|
141
|
-
footnotesByPage: Z
|
|
142
|
-
}), t.style.overflowY = "auto", t.style.minHeight = "0";
|
|
143
|
-
for (let e of Array.from(t.children)) e.style.flexShrink = "0";
|
|
144
|
-
g(t, ne(e.doc, e.selection.from, e.selection.to));
|
|
145
|
-
} catch (e) {
|
|
146
|
-
console.error("[useDocxEditor] Layout pipeline error:", e), M?.(e instanceof Error ? e : Error(String(e)));
|
|
147
|
-
} finally {
|
|
148
|
-
I?.onLayoutComplete(n);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
function q() {
|
|
152
|
-
let e = n.value;
|
|
153
|
-
if (!e) return;
|
|
154
|
-
let t = z.value?.package?.styles, r = z.value ? ie(z.value, { styles: t ?? void 0 }) : re(), i = T(!1), o = w(t), c = [
|
|
155
|
-
i,
|
|
156
|
-
...P,
|
|
157
|
-
...G.getPlugins() ?? [],
|
|
158
|
-
o
|
|
159
|
-
], l = s.create({
|
|
160
|
-
doc: r,
|
|
161
|
-
schema: G.getSchema(),
|
|
162
|
-
plugins: c
|
|
163
|
-
});
|
|
164
|
-
V.value = l;
|
|
165
|
-
let u = new b(e, {
|
|
166
|
-
state: l,
|
|
167
|
-
editable: () => !a(k),
|
|
168
|
-
dispatchTransaction(e) {
|
|
169
|
-
if (!u) return;
|
|
170
|
-
let t = u.state.apply(e);
|
|
171
|
-
if (u.updateState(t), V.value = t, e.docChanged) {
|
|
172
|
-
I?.incrementStateSeq(), K(t);
|
|
173
|
-
try {
|
|
174
|
-
if (z.value) {
|
|
175
|
-
let e = S(t.doc, z.value);
|
|
176
|
-
z.value = e, j?.(e);
|
|
177
|
-
}
|
|
178
|
-
} catch (e) {
|
|
179
|
-
console.error("[useDocxEditor] fromProseDoc error:", e);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (I?.requestRender(), N?.(), !e.docChanged) {
|
|
183
|
-
let e = h.value;
|
|
184
|
-
e && g(e, ne(t.doc, t.selection.from, t.selection.to));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
B.value = u, H.value = !0, K(l), I?.requestRender();
|
|
189
|
-
}
|
|
190
|
-
o([
|
|
191
|
-
() => a(L),
|
|
192
|
-
() => a(R),
|
|
193
|
-
B
|
|
194
|
-
], ([e, t, n]) => {
|
|
195
|
-
n && E(e === "suggesting", n.state, n.dispatch, t);
|
|
196
|
-
}, { immediate: !0 });
|
|
197
|
-
function J() {
|
|
198
|
-
B.value &&= (B.value.destroy(), null), V.value = null, H.value = !1;
|
|
199
|
-
}
|
|
200
|
-
let Y = { current: null }, X = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map();
|
|
201
|
-
function le() {
|
|
202
|
-
if (Y.current && Y.current.isConnected) return Y.current;
|
|
203
|
-
let e = window.document.createElement("div");
|
|
204
|
-
return e.dataset.hfHost = "true", e.style.cssText = "position: fixed; left: -9999px; top: 0; opacity: 0; z-index: -1; pointer-events: none;", window.document.body.appendChild(e), Y.current = e, e;
|
|
205
|
-
}
|
|
206
|
-
function ue(e) {
|
|
207
|
-
let t = z.value?.package;
|
|
208
|
-
if (!t) return null;
|
|
209
|
-
if (t.headers) {
|
|
210
|
-
for (let [n, r] of t.headers) if (r === e) return n;
|
|
211
|
-
}
|
|
212
|
-
if (t.footers) {
|
|
213
|
-
for (let [n, r] of t.footers) if (r === e) return n;
|
|
214
|
-
}
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
|
-
function de(e) {
|
|
218
|
-
let t = ue(e);
|
|
219
|
-
return t ? X.get(t) ?? null : null;
|
|
220
|
-
}
|
|
221
|
-
function Q() {
|
|
222
|
-
let e = z.value?.package, t = le(), n = /* @__PURE__ */ new Set();
|
|
223
|
-
if (e?.headers) for (let t of e.headers.keys()) n.add(t);
|
|
224
|
-
if (e?.footers) for (let t of e.footers.keys()) n.add(t);
|
|
225
|
-
for (let [e, t] of X) n.has(e) || (t.destroy(), t.dom.parentElement?.remove(), Z.get(e)?.destroy(), Z.delete(e), X.delete(e));
|
|
226
|
-
if (!e) return;
|
|
227
|
-
let r = e.styles ?? null, i = e.theme ?? null, a = e.settings?.defaultTabStop ?? null;
|
|
228
|
-
for (let o of n) {
|
|
229
|
-
if (X.has(o)) continue;
|
|
230
|
-
let n = e.headers?.get(o) ?? e.footers?.get(o);
|
|
231
|
-
if (!n) continue;
|
|
232
|
-
let c = e.headers?.has(o) ? "header" : "footer", l = new D(O());
|
|
233
|
-
l.buildSchema(), l.initializeRuntime(), Z.set(o, l);
|
|
234
|
-
let u = window.document.createElement("div");
|
|
235
|
-
u.dataset.hfRId = o, u.dataset.hfKind = c, t.appendChild(u);
|
|
236
|
-
let d = _(n.content, {
|
|
237
|
-
styles: r ?? void 0,
|
|
238
|
-
theme: i,
|
|
239
|
-
defaultTabStopTwips: a
|
|
240
|
-
}), f = w(r), p = s.create({
|
|
241
|
-
doc: d,
|
|
242
|
-
schema: y,
|
|
243
|
-
plugins: [...l.getPlugins(), f]
|
|
244
|
-
}), m = c, h = new b(u, {
|
|
245
|
-
state: p,
|
|
246
|
-
dispatchTransaction(e) {
|
|
247
|
-
let t = h.state.apply(e);
|
|
248
|
-
if (h.updateState(t), e.docChanged) {
|
|
249
|
-
let e = z.value?.package, n = (m === "header" ? e?.headers : e?.footers)?.get(o);
|
|
250
|
-
n && (n.content = v(t.doc));
|
|
251
|
-
}
|
|
252
|
-
e.docChanged && V.value && K(V.value), fe.value?.(o, h, e.docChanged);
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
X.set(o, h);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
function $() {
|
|
259
|
-
for (let e of X.values()) e.destroy(), e.dom.parentElement?.remove();
|
|
260
|
-
X.clear();
|
|
261
|
-
for (let e of Z.values()) e.destroy();
|
|
262
|
-
Z.clear(), Y.current &&= (Y.current.remove(), null);
|
|
263
|
-
}
|
|
264
|
-
let fe = { value: null };
|
|
265
|
-
function pe(e) {
|
|
266
|
-
fe.value = e;
|
|
267
|
-
}
|
|
268
|
-
async function me(e) {
|
|
269
|
-
U.value = null, H.value = !1;
|
|
270
|
-
try {
|
|
271
|
-
let t;
|
|
272
|
-
t = e instanceof Blob || e instanceof File ? await e.arrayBuffer() : e instanceof Uint8Array ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : e, z.value = await x(t), J(), $(), q(), Q();
|
|
273
|
-
} catch (e) {
|
|
274
|
-
let t = e instanceof Error ? e : Error(String(e));
|
|
275
|
-
U.value = t.message, M?.(t);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function he(e) {
|
|
279
|
-
U.value = null, z.value = e, J(), $(), q(), Q();
|
|
280
|
-
}
|
|
281
|
-
async function ge() {
|
|
282
|
-
if (!B.value || !z.value) return null;
|
|
283
|
-
let { repackDocx: e, createDocx: t } = await import("@eigenpal/docx-editor-core/docx/rezip"), { injectReplyRangeMarkers: n, injectTCReplyRangeMarkers: r } = await import("@eigenpal/docx-editor-core/docx"), i = S(B.value.state.doc, z.value), a = i.package.document?.comments ?? [];
|
|
284
|
-
i.package.document?.content && a.length > 0 && (n(i.package.document.content, a), r(i.package.document.content, a));
|
|
285
|
-
let o;
|
|
286
|
-
return o = i.originalBuffer ? await e(i) : await t(i), new Blob([o], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
|
|
287
|
-
}
|
|
288
|
-
function _e() {
|
|
289
|
-
B.value?.focus();
|
|
290
|
-
}
|
|
291
|
-
function ve() {
|
|
292
|
-
J(), $(), z.value = null;
|
|
293
|
-
}
|
|
294
|
-
function ye() {
|
|
295
|
-
return z.value;
|
|
296
|
-
}
|
|
297
|
-
t(() => {
|
|
298
|
-
ve();
|
|
299
|
-
});
|
|
300
|
-
function be() {
|
|
301
|
-
return G.getCommands();
|
|
302
|
-
}
|
|
303
|
-
return {
|
|
304
|
-
editorView: B,
|
|
305
|
-
editorState: V,
|
|
306
|
-
isReady: H,
|
|
307
|
-
parseError: U,
|
|
308
|
-
layout: W,
|
|
309
|
-
loadBuffer: me,
|
|
310
|
-
loadDocument: he,
|
|
311
|
-
save: ge,
|
|
312
|
-
focus: _e,
|
|
313
|
-
destroy: ve,
|
|
314
|
-
getDocument: ye,
|
|
315
|
-
getCommands: be,
|
|
316
|
-
reLayout() {
|
|
317
|
-
B.value && K(B.value.state);
|
|
318
|
-
},
|
|
319
|
-
getHfPmView: de,
|
|
320
|
-
syncHfPMs: Q,
|
|
321
|
-
setHfTransactionListener: pe,
|
|
322
|
-
setDocument(e) {
|
|
323
|
-
z.value = e;
|
|
324
|
-
}
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/composables/useZoom.ts
|
|
329
|
-
var L = .25, R = 4, z = .1, B = [
|
|
330
|
-
.25,
|
|
331
|
-
.5,
|
|
332
|
-
.75,
|
|
333
|
-
1,
|
|
334
|
-
1.25,
|
|
335
|
-
1.5,
|
|
336
|
-
2,
|
|
337
|
-
3,
|
|
338
|
-
4
|
|
339
|
-
];
|
|
340
|
-
function V(i = 1) {
|
|
341
|
-
let a = r(Math.max(L, Math.min(R, i))), o = e(() => Math.round(a.value * 100)), s = e(() => a.value <= L), c = e(() => a.value >= R);
|
|
342
|
-
function l(e) {
|
|
343
|
-
a.value = Math.max(L, Math.min(R, Math.round(e * 100) / 100));
|
|
344
|
-
}
|
|
345
|
-
function u() {
|
|
346
|
-
l(a.value + z);
|
|
347
|
-
}
|
|
348
|
-
function d() {
|
|
349
|
-
l(a.value - z);
|
|
350
|
-
}
|
|
351
|
-
function f() {
|
|
352
|
-
l(1);
|
|
353
|
-
}
|
|
354
|
-
function p(e) {
|
|
355
|
-
(e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d());
|
|
356
|
-
}
|
|
357
|
-
function m(e) {
|
|
358
|
-
(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())));
|
|
359
|
-
}
|
|
360
|
-
function h() {
|
|
361
|
-
n(() => document.addEventListener("keydown", m)), t(() => document.removeEventListener("keydown", m));
|
|
362
|
-
}
|
|
363
|
-
return {
|
|
364
|
-
zoom: a,
|
|
365
|
-
zoomPercent: o,
|
|
366
|
-
isMinZoom: s,
|
|
367
|
-
isMaxZoom: c,
|
|
368
|
-
setZoom: l,
|
|
369
|
-
zoomIn: u,
|
|
370
|
-
zoomOut: d,
|
|
371
|
-
resetZoom: f,
|
|
372
|
-
handleWheel: p,
|
|
373
|
-
handleKeyDown: m,
|
|
374
|
-
installShortcuts: h,
|
|
375
|
-
ZOOM_PRESETS: B
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
//#endregion
|
|
379
|
-
//#region src/composables/useTableResize.ts
|
|
380
|
-
var H = 15, U = 300, W = 200, G = 15;
|
|
381
|
-
function K() {
|
|
382
|
-
let e = {
|
|
383
|
-
active: !1,
|
|
384
|
-
startX: 0,
|
|
385
|
-
handle: null,
|
|
386
|
-
columnIndex: 0,
|
|
387
|
-
tablePmStart: 0,
|
|
388
|
-
origWidths: {
|
|
389
|
-
left: 0,
|
|
390
|
-
right: 0
|
|
391
|
-
}
|
|
392
|
-
}, t = {
|
|
393
|
-
active: !1,
|
|
394
|
-
startY: 0,
|
|
395
|
-
handle: null,
|
|
396
|
-
rowIndex: 0,
|
|
397
|
-
isEdge: !1,
|
|
398
|
-
tablePmStart: 0,
|
|
399
|
-
origHeight: 0
|
|
400
|
-
}, n = {
|
|
401
|
-
active: !1,
|
|
402
|
-
startX: 0,
|
|
403
|
-
handle: null,
|
|
404
|
-
columnIndex: 0,
|
|
405
|
-
tablePmStart: 0,
|
|
406
|
-
origWidth: 0
|
|
407
|
-
}, r = null;
|
|
408
|
-
function i() {
|
|
409
|
-
return e.active || t.active || n.active;
|
|
410
|
-
}
|
|
411
|
-
function a(i, a) {
|
|
412
|
-
let o = i.target;
|
|
413
|
-
return o?.classList ? 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), q(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), J(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), Y(a, n), !0) : !1 : !1;
|
|
414
|
-
}
|
|
415
|
-
function o(r) {
|
|
416
|
-
if (e.active && e.handle) {
|
|
417
|
-
r.preventDefault();
|
|
418
|
-
let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
|
|
419
|
-
e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
|
|
420
|
-
let i = Math.round(t * H), a = e.origWidths.left + i, o = e.origWidths.right - i;
|
|
421
|
-
a >= U && o >= U && (e.origWidths = {
|
|
422
|
-
left: a,
|
|
423
|
-
right: o
|
|
424
|
-
});
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
if (t.active && t.handle) {
|
|
428
|
-
r.preventDefault();
|
|
429
|
-
let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
|
|
430
|
-
t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
|
|
431
|
-
let i = Math.round(e * H), a = t.origHeight + i;
|
|
432
|
-
a >= W && (t.origHeight = a);
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
if (n.active && n.handle) {
|
|
436
|
-
r.preventDefault();
|
|
437
|
-
let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
|
|
438
|
-
n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
|
|
439
|
-
let i = Math.round(e * H), a = n.origWidth + i;
|
|
440
|
-
a >= U && (n.origWidth = a);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
function s(i) {
|
|
444
|
-
if (e.active) {
|
|
445
|
-
e.active = !1, e.handle?.classList.remove("dragging"), r && X(r, e), e.handle = null;
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
if (t.active) {
|
|
449
|
-
t.active = !1, t.handle?.classList.remove("dragging"), r && Z(r, t), t.handle = null;
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && le(r, n), n.handle = null);
|
|
453
|
-
}
|
|
454
|
-
function c() {
|
|
455
|
-
return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
|
|
456
|
-
document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", s);
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
return {
|
|
460
|
-
tryStartResize: a,
|
|
461
|
-
install: c,
|
|
462
|
-
isResizing: i
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
function q(e, t) {
|
|
466
|
-
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
467
|
-
for (let e = n.depth; e >= 0; e--) {
|
|
468
|
-
let r = n.node(e);
|
|
469
|
-
if (r.type.name === "table") {
|
|
470
|
-
let e = r.attrs.columnWidths;
|
|
471
|
-
e && e[t.columnIndex] !== void 0 && e[t.columnIndex + 1] !== void 0 && (t.origWidths = {
|
|
472
|
-
left: e[t.columnIndex],
|
|
473
|
-
right: e[t.columnIndex + 1]
|
|
474
|
-
});
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
function J(e, t, n) {
|
|
480
|
-
let r = e.state.doc.resolve(t.tablePmStart + 1);
|
|
481
|
-
for (let e = r.depth; e >= 0; e--) {
|
|
482
|
-
let i = r.node(e);
|
|
483
|
-
if (i.type.name === "table") {
|
|
484
|
-
let e = null, r = 0;
|
|
485
|
-
if (i.forEach((n) => {
|
|
486
|
-
r === t.rowIndex && (e = n), r++;
|
|
487
|
-
}), e) {
|
|
488
|
-
let r = e.attrs.height;
|
|
489
|
-
if (r) t.origHeight = r;
|
|
490
|
-
else {
|
|
491
|
-
let e = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), r = e ? e.getBoundingClientRect().height : 30;
|
|
492
|
-
t.origHeight = Math.round(r * G);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
function Y(e, t) {
|
|
500
|
-
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
501
|
-
for (let e = n.depth; e >= 0; e--) {
|
|
502
|
-
let r = n.node(e);
|
|
503
|
-
if (r.type.name === "table") {
|
|
504
|
-
let e = r.attrs.columnWidths;
|
|
505
|
-
e && e[t.columnIndex] !== void 0 && (t.origWidth = e[t.columnIndex]);
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
function X(e, t) {
|
|
511
|
-
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
512
|
-
for (let r = n.depth; r >= 0; r--) {
|
|
513
|
-
let i = n.node(r);
|
|
514
|
-
if (i.type.name !== "table") continue;
|
|
515
|
-
let a = n.before(r), o = e.state.tr, s = [...i.attrs.columnWidths || []];
|
|
516
|
-
s[t.columnIndex] = t.origWidths.left, s[t.columnIndex + 1] = t.origWidths.right, o.setNodeMarkup(a, void 0, {
|
|
517
|
-
...i.attrs,
|
|
518
|
-
columnWidths: s
|
|
519
|
-
});
|
|
520
|
-
let c = a + 1;
|
|
521
|
-
i.forEach((e) => {
|
|
522
|
-
let n = c + 1, r = 0;
|
|
523
|
-
e.forEach((e) => {
|
|
524
|
-
let i = e.attrs.colspan || 1;
|
|
525
|
-
if (r === t.columnIndex || r === t.columnIndex + 1) {
|
|
526
|
-
let i = r === t.columnIndex ? t.origWidths.left : t.origWidths.right;
|
|
527
|
-
o.setNodeMarkup(o.mapping.map(n), void 0, {
|
|
528
|
-
...e.attrs,
|
|
529
|
-
width: i,
|
|
530
|
-
widthType: "dxa",
|
|
531
|
-
colwidth: null
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
n += e.nodeSize, r += i;
|
|
535
|
-
}), c += e.nodeSize;
|
|
536
|
-
}), e.dispatch(o);
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
function Z(e, t) {
|
|
541
|
-
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
542
|
-
for (let r = n.depth; r >= 0; r--) {
|
|
543
|
-
let i = n.node(r);
|
|
544
|
-
if (i.type.name !== "table") continue;
|
|
545
|
-
let a = n.before(r), o = e.state.tr, s = a + 1, c = 0;
|
|
546
|
-
i.forEach((e) => {
|
|
547
|
-
c === t.rowIndex && o.setNodeMarkup(o.mapping.map(s), void 0, {
|
|
548
|
-
...e.attrs,
|
|
549
|
-
height: t.origHeight,
|
|
550
|
-
heightRule: "atLeast"
|
|
551
|
-
}), s += e.nodeSize, c++;
|
|
552
|
-
}), e.dispatch(o);
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
function le(e, t) {
|
|
557
|
-
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
558
|
-
for (let r = n.depth; r >= 0; r--) {
|
|
559
|
-
let i = n.node(r);
|
|
560
|
-
if (i.type.name !== "table") continue;
|
|
561
|
-
let a = n.before(r), o = e.state.tr, s = [...i.attrs.columnWidths || []];
|
|
562
|
-
s[t.columnIndex] = t.origWidth, o.setNodeMarkup(a, void 0, {
|
|
563
|
-
...i.attrs,
|
|
564
|
-
columnWidths: s
|
|
565
|
-
});
|
|
566
|
-
let c = a + 1;
|
|
567
|
-
i.forEach((e) => {
|
|
568
|
-
let n = c + 1, r = 0;
|
|
569
|
-
e.forEach((e) => {
|
|
570
|
-
let i = e.attrs.colspan || 1;
|
|
571
|
-
r === t.columnIndex && o.setNodeMarkup(o.mapping.map(n), void 0, {
|
|
572
|
-
...e.attrs,
|
|
573
|
-
width: t.origWidth,
|
|
574
|
-
widthType: "dxa",
|
|
575
|
-
colwidth: null
|
|
576
|
-
}), n += e.nodeSize, r += i;
|
|
577
|
-
}), c += e.nodeSize;
|
|
578
|
-
}), e.dispatch(o);
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
//#endregion
|
|
583
|
-
export { V as n, I as r, K as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let e=require(`vue`),t=require(`prosemirror-state`),n=require(`@eigenpal/docx-editor-core/layout-bridge`),r=require(`@eigenpal/docx-editor-core/layout-painter`),i=require(`@eigenpal/docx-editor-core/prosemirror/conversion`),a=require(`@eigenpal/docx-editor-core/prosemirror`),o=require(`prosemirror-view`),s=require(`@eigenpal/docx-editor-core/docx/parser`),c=require(`@eigenpal/docx-editor-core/prosemirror/conversion/fromProseDoc`),l=require(`@eigenpal/docx-editor-core/prosemirror/schema`),u=require(`@eigenpal/docx-editor-core/prosemirror/plugins`),d=require(`@eigenpal/docx-editor-core/prosemirror/extensions`),f=require(`@eigenpal/docx-editor-core/layout-bridge/toFlowBlocks`),p=require(`@eigenpal/docx-editor-core/layout-bridge/measuring`),m=require(`@eigenpal/docx-editor-core/layout-engine`),h=require(`@eigenpal/docx-editor-core/layout-painter/renderPage`);require(`prosemirror-view/style/prosemirror.css`),require(`@eigenpal/docx-editor-core/prosemirror/editor.css`);var g=24;function _(e,t,r,i){switch(e.kind){case`paragraph`:return(0,p.measureParagraph)(e,t,{floatingZones:r,paragraphYOffset:i??0});case`table`:return(0,n.measureTableBlock)(e,t,_);case`image`:{let t=e;return{kind:`image`,width:t.width??100,height:t.height??100}}case`textBox`:{let t=e,n=t.margins??m.DEFAULT_TEXTBOX_MARGINS,r=(t.width??m.DEFAULT_TEXTBOX_WIDTH)-n.left-n.right,i=t.content.map(e=>(0,p.measureParagraph)(e,r)),a=i.reduce((e,t)=>e+t.totalHeight,0),o=t.height??a+n.top+n.bottom;return{kind:`textBox`,width:t.width??m.DEFAULT_TEXTBOX_WIDTH,height:o,innerMeasures:i}}case`pageBreak`:return{kind:`pageBreak`};case`columnBreak`:return{kind:`columnBreak`};case`sectionBreak`:return{kind:`sectionBreak`};default:(0,m.assertExhaustiveFlowBlock)(e,`vue useDocxEditor measureBlock`)}}function v(e,t){return(0,p.measureBlocksWithFloats)(e,t,_)}function y(p){let{hiddenContainer:_,pagesContainer:y,readOnly:b=!1,pageGap:x=g,onChange:S,onError:C,onSelectionUpdate:w,externalPlugins:T=[],syncCoordinator:E,editorMode:D,author:O}=p,k=(0,e.shallowRef)(null),A=(0,e.shallowRef)(null),j=(0,e.shallowRef)(null),M=(0,e.ref)(!1),N=(0,e.ref)(null),P=(0,e.shallowRef)(null),F=l.singletonManager;function I(e){let t=y.value;if(!t||!k.value)return;let i=E?.getStateSeq()??0;E?.onLayoutStart();let a=k.value.package?.document,o=a?.sections?.[0]?.properties??a?.finalSectionProperties??null,s=a?.finalSectionProperties??o,c=(0,n.getPageSize)(o),l=(0,n.getMargins)(o),u=(0,n.getPageSize)(s),d=(0,n.getMargins)(s),p=c.w-l.left-l.right,g=c.h-l.top-l.bottom,_=k.value.package?.theme??null,b=k.value.package?.styles??null;try{let i=(0,f.toFlowBlocks)(e.doc,{theme:_,pageContentHeight:g}),a=v(i,p),{header:s,footer:y,firstHeader:S,firstFooter:C}=(0,n.resolveHeaderFooter)(k.value,o),w={section:`header`,pageSize:c,margins:l},T={section:`footer`,pageSize:c,margins:l},E=e.doc.attrs?.defaultTabStopTwips,D={styles:b,theme:_,measureBlocks:v,defaultTabStopTwips:E},O=(e,t)=>{if(!e)return;let r=W(e);return r?(0,n.convertHeaderFooterPmDocToContent)(r.state.doc,p,t,D):(0,n.convertHeaderFooterToContent)(e,p,t,D)},A=O(s,w),j=O(y,T),M=o?.titlePg===!0,N=M?O(S,w):void 0,F=M?O(C,T):void 0,I=l.header??48,L=l.footer??48,R=l.top-I,z=l.bottom-L,B=e=>e?e.visualBottom??e.height:0,V=e=>e?Math.max((e.visualBottom??e.height)-(e.visualTop??0),e.height):0,H=Math.max(B(A),B(N)),U=Math.max(V(j),V(F)),G=H>R,K=U>z;if(G||K){let e=e=>{let t={...e};return G&&(t.top=Math.max(e.top,I+H)),K&&(t.bottom=Math.max(e.bottom,L+U)),t};l=e(l),d=e(d);for(let t of i){if(t.kind!==`sectionBreak`)continue;let n=t;n.margins&&=e(n.margins)}}let q={pageSize:c,margins:l,finalPageSize:u,finalMargins:d,pageGap:x},J=(0,n.collectFootnoteRefs)(i),Y=J.length>0&&!!k.value.package?.footnotes,X=(0,m.layoutDocument)(i,a,q),Z=new Map,Q=new Map;if(Y){Q=(0,n.buildFootnoteContentMap)(k.value.package.footnotes,J,p,{styles:b,theme:_,measureBlocks:v,defaultTabStopTwips:E});let e=(0,n.stabilizeFootnoteLayout)({blocks:i,measures:a,layoutOpts:q,footnoteRefs:J,footnoteContentMap:Q,initialLayout:X});X=e.layout,Z=e.pageFootnoteMap}P.value=X;let $=new Map;for(let e=0;e<i.length;e++){let t=i[e],n=a[e];t&&n&&$.set(String(t.id),{block:t,measure:n})}let ee=Y?(0,n.buildFootnoteRenderItems)(Z,Q,k.value):void 0;(0,h.renderPages)(X.pages,t,{pageGap:x,showShadow:!0,pageBackground:`#fff`,blockLookup:$,theme:_,headerContent:A,footerContent:j,firstPageHeaderContent:N,firstPageFooterContent:F,titlePage:M,footnotesByPage:ee}),t.style.overflowY=`auto`,t.style.minHeight=`0`;for(let e of Array.from(t.children))e.style.flexShrink=`0`;(0,r.applySdtFocus)(t,(0,r.enclosingSdtGroupIds)(e.doc,e.selection.from,e.selection.to))}catch(e){console.error(`[useDocxEditor] Layout pipeline error:`,e),C?.(e instanceof Error?e:Error(String(e)))}finally{E?.onLayoutComplete(i)}}function L(){let n=_.value;if(!n)return;let a=k.value?.package?.styles,s=k.value?(0,i.toProseDoc)(k.value,{styles:a??void 0}):(0,i.createEmptyDoc)(),l=(0,u.createSuggestionModePlugin)(!1),d=(0,u.createDocumentStylesPlugin)(a),f=[l,...T,...F.getPlugins()??[],d],p=t.EditorState.create({doc:s,schema:F.getSchema(),plugins:f});j.value=p;let m=new o.EditorView(n,{state:p,editable:()=>!(0,e.unref)(b),dispatchTransaction(e){if(!m)return;let t=m.state.apply(e);if(m.updateState(t),j.value=t,e.docChanged){E?.incrementStateSeq(),I(t);try{if(k.value){let e=(0,c.fromProseDoc)(t.doc,k.value);k.value=e,S?.(e)}}catch(e){console.error(`[useDocxEditor] fromProseDoc error:`,e)}}if(E?.requestRender(),w?.(),!e.docChanged){let e=y.value;e&&(0,r.applySdtFocus)(e,(0,r.enclosingSdtGroupIds)(t.doc,t.selection.from,t.selection.to))}}});A.value=m,M.value=!0,I(p),E?.requestRender()}(0,e.watch)([()=>(0,e.unref)(D),()=>(0,e.unref)(O),A],([e,t,n])=>{n&&(0,u.setSuggestionMode)(e===`suggesting`,n.state,n.dispatch,t)},{immediate:!0});function R(){A.value&&=(A.value.destroy(),null),j.value=null,M.value=!1}let z={current:null},B=new Map,V=new Map;function H(){if(z.current&&z.current.isConnected)return z.current;let e=window.document.createElement(`div`);return e.dataset.hfHost=`true`,e.style.cssText=`position: fixed; left: -9999px; top: 0; opacity: 0; z-index: -1; pointer-events: none;`,window.document.body.appendChild(e),z.current=e,e}function U(e){let t=k.value?.package;if(!t)return null;if(t.headers){for(let[n,r]of t.headers)if(r===e)return n}if(t.footers){for(let[n,r]of t.footers)if(r===e)return n}return null}function W(e){let t=U(e);return t?B.get(t)??null:null}function G(){let e=k.value?.package,n=H(),r=new Set;if(e?.headers)for(let t of e.headers.keys())r.add(t);if(e?.footers)for(let t of e.footers.keys())r.add(t);for(let[e,t]of B)r.has(e)||(t.destroy(),t.dom.parentElement?.remove(),V.get(e)?.destroy(),V.delete(e),B.delete(e));if(!e)return;let s=e.styles??null,c=e.theme??null,l=e.settings?.defaultTabStop??null;for(let f of r){if(B.has(f))continue;let r=e.headers?.get(f)??e.footers?.get(f);if(!r)continue;let p=e.headers?.has(f)?`header`:`footer`,m=new d.ExtensionManager((0,d.createStarterKit)());m.buildSchema(),m.initializeRuntime(),V.set(f,m);let h=window.document.createElement(`div`);h.dataset.hfRId=f,h.dataset.hfKind=p,n.appendChild(h);let g=(0,i.headerFooterToProseDoc)(r.content,{styles:s??void 0,theme:c,defaultTabStopTwips:l}),_=(0,u.createDocumentStylesPlugin)(s),v=t.EditorState.create({doc:g,schema:a.schema,plugins:[...m.getPlugins(),_]}),y=p,b=new o.EditorView(h,{state:v,dispatchTransaction(e){let t=b.state.apply(e);if(b.updateState(t),e.docChanged){let e=k.value?.package,n=(y===`header`?e?.headers:e?.footers)?.get(f);n&&(n.content=(0,i.proseDocToBlocks)(t.doc))}e.docChanged&&j.value&&I(j.value),q.value?.(f,b,e.docChanged)}});B.set(f,b)}}function K(){for(let e of B.values())e.destroy(),e.dom.parentElement?.remove();B.clear();for(let e of V.values())e.destroy();V.clear(),z.current&&=(z.current.remove(),null)}let q={value:null};function J(e){q.value=e}async function Y(e){N.value=null,M.value=!1;try{let t;t=e instanceof Blob||e instanceof File?await e.arrayBuffer():e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e,k.value=await(0,s.parseDocx)(t),R(),K(),L(),G()}catch(e){let t=e instanceof Error?e:Error(String(e));N.value=t.message,C?.(t)}}function X(e){N.value=null,k.value=e,R(),K(),L(),G()}async function Z(){if(!A.value||!k.value)return null;let{repackDocx:e,createDocx:t}=await import(`@eigenpal/docx-editor-core/docx/rezip`),{injectReplyRangeMarkers:n,injectTCReplyRangeMarkers:r}=await import(`@eigenpal/docx-editor-core/docx`),i=(0,c.fromProseDoc)(A.value.state.doc,k.value),a=i.package.document?.comments??[];i.package.document?.content&&a.length>0&&(n(i.package.document.content,a),r(i.package.document.content,a));let o;return o=i.originalBuffer?await e(i):await t(i),new Blob([o],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})}function Q(){A.value?.focus()}function $(){R(),K(),k.value=null}function ee(){return k.value}(0,e.onBeforeUnmount)(()=>{$()});function te(){return F.getCommands()}return{editorView:A,editorState:j,isReady:M,parseError:N,layout:P,loadBuffer:Y,loadDocument:X,save:Z,focus:Q,destroy:$,getDocument:ee,getCommands:te,reLayout(){A.value&&I(A.value.state)},getHfPmView:W,syncHfPMs:G,setHfTransactionListener:J,setDocument(e){k.value=e}}}var b=.25,x=4,S=.1,C=[.25,.5,.75,1,1.25,1.5,2,3,4];function w(t=1){let n=(0,e.ref)(Math.max(b,Math.min(x,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=b),a=(0,e.computed)(()=>n.value>=x);function o(e){n.value=Math.max(b,Math.min(x,Math.round(e*100)/100))}function s(){o(n.value+S)}function c(){o(n.value-S)}function l(){o(1)}function u(e){(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.deltaY<0?s():c())}function d(e){(e.ctrlKey||e.metaKey)&&(e.shiftKey||e.altKey||(e.key===`=`||e.key===`+`?(e.preventDefault(),s()):e.key===`-`?(e.preventDefault(),c()):e.key===`0`&&(e.preventDefault(),l())))}function f(){(0,e.onMounted)(()=>document.addEventListener(`keydown`,d)),(0,e.onBeforeUnmount)(()=>document.removeEventListener(`keydown`,d))}return{zoom:n,zoomPercent:r,isMinZoom:i,isMaxZoom:a,setZoom:o,zoomIn:s,zoomOut:c,resetZoom:l,handleWheel:u,handleKeyDown:d,installShortcuts:f,ZOOM_PRESETS:C}}var T=15,E=300,D=200,O=15;function k(){let e={active:!1,startX:0,handle:null,columnIndex:0,tablePmStart:0,origWidths:{left:0,right:0}},t={active:!1,startY:0,handle:null,rowIndex:0,isEdge:!1,tablePmStart:0,origHeight:0},n={active:!1,startX:0,handle:null,columnIndex:0,tablePmStart:0,origWidth:0},r=null;function i(){return e.active||t.active||n.active}function a(i,a){let o=i.target;return o?.classList?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),A(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),j(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),M(a,n),!0):!1:!1}function o(r){if(e.active&&e.handle){r.preventDefault();let t=r.clientX-e.startX,n=parseFloat(e.handle.style.left);e.handle.style.left=`${n+t}px`,e.startX=r.clientX;let i=Math.round(t*T),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=E&&o>=E&&(e.origWidths={left:a,right:o});return}if(t.active&&t.handle){r.preventDefault();let e=r.clientY-t.startY,n=parseFloat(t.handle.style.top);t.handle.style.top=`${n+e}px`,t.startY=r.clientY;let i=Math.round(e*T),a=t.origHeight+i;a>=D&&(t.origHeight=a);return}if(n.active&&n.handle){r.preventDefault();let e=r.clientX-n.startX,t=parseFloat(n.handle.style.left);n.handle.style.left=`${t+e}px`,n.startX=r.clientX;let i=Math.round(e*T),a=n.origWidth+i;a>=E&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&N(r,e),e.handle=null;return}if(t.active){t.active=!1,t.handle?.classList.remove(`dragging`),r&&P(r,t),t.handle=null;return}n.active&&(n.active=!1,n.handle?.classList.remove(`dragging`),r&&F(r,n),n.handle=null)}function c(){return document.addEventListener(`mousemove`,o),document.addEventListener(`mouseup`,s),()=>{document.removeEventListener(`mousemove`,o),document.removeEventListener(`mouseup`,s)}}return{tryStartResize:a,install:c,isResizing:i}}function A(e,t){let n=e.state.doc.resolve(t.tablePmStart+1);for(let e=n.depth;e>=0;e--){let r=n.node(e);if(r.type.name===`table`){let e=r.attrs.columnWidths;e&&e[t.columnIndex]!==void 0&&e[t.columnIndex+1]!==void 0&&(t.origWidths={left:e[t.columnIndex],right:e[t.columnIndex+1]});return}}}function j(e,t,n){let r=e.state.doc.resolve(t.tablePmStart+1);for(let e=r.depth;e>=0;e--){let i=r.node(e);if(i.type.name===`table`){let e=null,r=0;if(i.forEach(n=>{r===t.rowIndex&&(e=n),r++}),e){let r=e.attrs.height;if(r)t.origHeight=r;else{let e=n.closest(`.layout-table`)?.querySelector(`[data-row-index="${t.rowIndex}"]`),r=e?e.getBoundingClientRect().height:30;t.origHeight=Math.round(r*O)}}return}}}function M(e,t){let n=e.state.doc.resolve(t.tablePmStart+1);for(let e=n.depth;e>=0;e--){let r=n.node(e);if(r.type.name===`table`){let e=r.attrs.columnWidths;e&&e[t.columnIndex]!==void 0&&(t.origWidth=e[t.columnIndex]);return}}}function N(e,t){let n=e.state.doc.resolve(t.tablePmStart+1);for(let r=n.depth;r>=0;r--){let i=n.node(r);if(i.type.name!==`table`)continue;let a=n.before(r),o=e.state.tr,s=[...i.attrs.columnWidths||[]];s[t.columnIndex]=t.origWidths.left,s[t.columnIndex+1]=t.origWidths.right,o.setNodeMarkup(a,void 0,{...i.attrs,columnWidths:s});let c=a+1;i.forEach(e=>{let n=c+1,r=0;e.forEach(e=>{let i=e.attrs.colspan||1;if(r===t.columnIndex||r===t.columnIndex+1){let i=r===t.columnIndex?t.origWidths.left:t.origWidths.right;o.setNodeMarkup(o.mapping.map(n),void 0,{...e.attrs,width:i,widthType:`dxa`,colwidth:null})}n+=e.nodeSize,r+=i}),c+=e.nodeSize}),e.dispatch(o);return}}function P(e,t){let n=e.state.doc.resolve(t.tablePmStart+1);for(let r=n.depth;r>=0;r--){let i=n.node(r);if(i.type.name!==`table`)continue;let a=n.before(r),o=e.state.tr,s=a+1,c=0;i.forEach(e=>{c===t.rowIndex&&o.setNodeMarkup(o.mapping.map(s),void 0,{...e.attrs,height:t.origHeight,heightRule:`atLeast`}),s+=e.nodeSize,c++}),e.dispatch(o);return}}function F(e,t){let n=e.state.doc.resolve(t.tablePmStart+1);for(let r=n.depth;r>=0;r--){let i=n.node(r);if(i.type.name!==`table`)continue;let a=n.before(r),o=e.state.tr,s=[...i.attrs.columnWidths||[]];s[t.columnIndex]=t.origWidth,o.setNodeMarkup(a,void 0,{...i.attrs,columnWidths:s});let c=a+1;i.forEach(e=>{let n=c+1,r=0;e.forEach(e=>{let i=e.attrs.colspan||1;r===t.columnIndex&&o.setNodeMarkup(o.mapping.map(n),void 0,{...e.attrs,width:t.origWidth,widthType:`dxa`,colwidth:null}),n+=e.nodeSize,r+=i}),c+=e.nodeSize}),e.dispatch(o);return}}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return k}});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Comment } from '@eigenpal/docx-editor-core/types/document';
|
|
2
|
-
/**
|
|
3
|
-
* Build a `Comment` with an id one past the current max id in
|
|
4
|
-
* `existingComments`. Pass an empty array for the first comment in a
|
|
5
|
-
* fresh document.
|
|
6
|
-
*/
|
|
7
|
-
export declare function createComment(existingComments: Comment[], text: string, author: string, parentId?: number): Comment;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Node as ProseMirrorNode } from 'prosemirror-model';
|
|
2
|
-
/**
|
|
3
|
-
* Find the ProseMirror position range for a paragraph by Word `w14:paraId`.
|
|
4
|
-
* Returns `from` (position before the textblock) and `to` (`from + nodeSize`).
|
|
5
|
-
*/
|
|
6
|
-
export declare function findParaIdRange(doc: ProseMirrorNode, paraId: string): {
|
|
7
|
-
from: number;
|
|
8
|
-
to: number;
|
|
9
|
-
} | null;
|
|
10
|
-
/**
|
|
11
|
-
* Vanilla-view text of a PM node — concatenates descendant text content,
|
|
12
|
-
* skipping any text inside an `insertion` mark so what the agent reads
|
|
13
|
-
* matches what comment/suggest tools can anchor.
|
|
14
|
-
*/
|
|
15
|
-
export declare function getVanillaNodeText(node: ProseMirrorNode): string;
|
|
16
|
-
/**
|
|
17
|
-
* Vanilla-view text between two doc positions. Same semantics as
|
|
18
|
-
* `getVanillaNodeText`, range-scoped instead of node-scoped.
|
|
19
|
-
*/
|
|
20
|
-
export declare function getVanillaTextBetween(doc: ProseMirrorNode, from: number, to: number): string;
|
|
21
|
-
/**
|
|
22
|
-
* Find a text string within a ProseMirror paragraph node range and return
|
|
23
|
-
* its positions. Returns null when not found, when ambiguous (multiple
|
|
24
|
-
* matches in the same paragraph), or when searchText is empty.
|
|
25
|
-
*/
|
|
26
|
-
export declare function findTextInPmParagraph(doc: ProseMirrorNode, paragraphFrom: number, paragraphTo: number, searchText: string): {
|
|
27
|
-
from: number;
|
|
28
|
-
to: number;
|
|
29
|
-
} | null;
|