@eigenpal/docx-editor-vue 1.2.0 → 1.3.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.
- 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/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 +102 -143
- package/dist/dialogs.cjs +1 -1
- package/dist/dialogs.js +2 -2
- package/dist/docx-editor-vue.css +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.js +1330 -956
- 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/useTableResize-DBpEiuGQ.cjs +1 -0
- package/dist/{useTableResize-BcBdSaOE.js → useTableResize-uq2ksRDf.js} +118 -114
- package/dist/utils/domQueries.d.ts +17 -6
- 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-DTag4SY0.cjs +0 -1
|
@@ -1,26 +1,26 @@
|
|
|
1
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
2
|
import { EditorState as s } from "prosemirror-state";
|
|
3
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
|
|
5
|
-
import { createEmptyDoc as
|
|
6
|
-
import { schema as
|
|
7
|
-
import { EditorView as
|
|
8
|
-
import { parseDocx as
|
|
9
|
-
import { fromProseDoc as
|
|
10
|
-
import { singletonManager as
|
|
11
|
-
import { createDocumentStylesPlugin as
|
|
12
|
-
import { ExtensionManager as
|
|
13
|
-
import { toFlowBlocks as
|
|
14
|
-
import { measureBlocksWithFloats as
|
|
15
|
-
import { DEFAULT_TEXTBOX_MARGINS as
|
|
16
|
-
import { renderPages as
|
|
4
|
+
import { applySdtFocus as ne, enclosingSdtGroupIds as re, pageGeometryFromPage as ie } from "@eigenpal/docx-editor-core/layout-painter";
|
|
5
|
+
import { createEmptyDoc as ae, headerFooterToProseDoc as g, proseDocToBlocks as _, toProseDoc as oe } from "@eigenpal/docx-editor-core/prosemirror/conversion";
|
|
6
|
+
import { schema as v } from "@eigenpal/docx-editor-core/prosemirror";
|
|
7
|
+
import { EditorView as y } from "prosemirror-view";
|
|
8
|
+
import { parseDocx as b } from "@eigenpal/docx-editor-core/docx/parser";
|
|
9
|
+
import { fromProseDoc as x } from "@eigenpal/docx-editor-core/prosemirror/conversion/fromProseDoc";
|
|
10
|
+
import { singletonManager as S } from "@eigenpal/docx-editor-core/prosemirror/schema";
|
|
11
|
+
import { createDocumentStylesPlugin as C, createSuggestionModePlugin as w, setSuggestionMode as T } from "@eigenpal/docx-editor-core/prosemirror/plugins";
|
|
12
|
+
import { ExtensionManager as E, createStarterKit as D } from "@eigenpal/docx-editor-core/prosemirror/extensions";
|
|
13
|
+
import { toFlowBlocks as se } from "@eigenpal/docx-editor-core/layout-bridge/toFlowBlocks";
|
|
14
|
+
import { measureBlocksWithFloats as O, measureParagraph as k } from "@eigenpal/docx-editor-core/layout-bridge/measuring";
|
|
15
|
+
import { DEFAULT_TEXTBOX_MARGINS as A, DEFAULT_TEXTBOX_WIDTH as j, assertExhaustiveFlowBlock as M, layoutDocument as ce } from "@eigenpal/docx-editor-core/layout-engine";
|
|
16
|
+
import { renderPages as le } from "@eigenpal/docx-editor-core/layout-painter/renderPage";
|
|
17
17
|
import "prosemirror-view/style/prosemirror.css";
|
|
18
18
|
import "@eigenpal/docx-editor-core/prosemirror/editor.css";
|
|
19
19
|
//#region src/composables/useDocxEditor.ts
|
|
20
|
-
var
|
|
20
|
+
var N = 24;
|
|
21
21
|
function P(e, t, n, r) {
|
|
22
22
|
switch (e.kind) {
|
|
23
|
-
case "paragraph": return
|
|
23
|
+
case "paragraph": return k(e, t, {
|
|
24
24
|
floatingZones: n,
|
|
25
25
|
paragraphYOffset: r ?? 0
|
|
26
26
|
});
|
|
@@ -34,10 +34,10 @@ function P(e, t, n, r) {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
case "textBox": {
|
|
37
|
-
let t = e, n = t.margins ??
|
|
37
|
+
let t = e, n = t.margins ?? A, r = (t.width ?? j) - n.left - n.right, i = t.content.map((e) => k(e, r)), a = i.reduce((e, t) => e + t.totalHeight, 0), o = t.height ?? a + n.top + n.bottom;
|
|
38
38
|
return {
|
|
39
39
|
kind: "textBox",
|
|
40
|
-
width: t.width ??
|
|
40
|
+
width: t.width ?? j,
|
|
41
41
|
height: o,
|
|
42
42
|
innerMeasures: i
|
|
43
43
|
};
|
|
@@ -45,105 +45,109 @@ function P(e, t, n, r) {
|
|
|
45
45
|
case "pageBreak": return { kind: "pageBreak" };
|
|
46
46
|
case "columnBreak": return { kind: "columnBreak" };
|
|
47
47
|
case "sectionBreak": return { kind: "sectionBreak" };
|
|
48
|
-
default:
|
|
48
|
+
default: M(e, "vue useDocxEditor measureBlock");
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
function F(e, t) {
|
|
52
|
-
return
|
|
51
|
+
function F(e, t, n) {
|
|
52
|
+
return O(e, t, P, n);
|
|
53
53
|
}
|
|
54
54
|
function I(e) {
|
|
55
|
-
let { hiddenContainer: n, pagesContainer: h, readOnly:
|
|
55
|
+
let { hiddenContainer: n, pagesContainer: h, readOnly: O = !1, pageGap: k = N, onChange: A, onError: j, onSelectionUpdate: M, 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 = S;
|
|
56
56
|
function K(e) {
|
|
57
57
|
let t = h.value;
|
|
58
58
|
if (!t || !z.value) return;
|
|
59
59
|
let n = I?.getStateSeq() ?? 0;
|
|
60
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),
|
|
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), ae = m(a), g = p(a), _ = o.w - s.left - s.right, oe = o.h - s.top - s.bottom, v = z.value.package?.theme ?? null, y = z.value.package?.styles ?? null;
|
|
62
62
|
try {
|
|
63
|
-
let n =
|
|
64
|
-
theme:
|
|
65
|
-
pageContentHeight:
|
|
66
|
-
}), r = F(n,
|
|
63
|
+
let n = se(e.doc, {
|
|
64
|
+
theme: v,
|
|
65
|
+
pageContentHeight: oe
|
|
66
|
+
}), r = F(n, _, ie({
|
|
67
|
+
size: o,
|
|
68
|
+
margins: s
|
|
69
|
+
})), { header: a, footer: p, firstHeader: m, firstFooter: h } = ee(z.value, i), b = {
|
|
67
70
|
section: "header",
|
|
68
71
|
pageSize: o,
|
|
69
72
|
margins: s
|
|
70
|
-
},
|
|
73
|
+
}, x = {
|
|
71
74
|
section: "footer",
|
|
72
75
|
pageSize: o,
|
|
73
76
|
margins: s
|
|
74
|
-
},
|
|
75
|
-
styles:
|
|
76
|
-
theme:
|
|
77
|
+
}, S = e.doc.attrs?.defaultTabStopTwips, C = {
|
|
78
|
+
styles: y,
|
|
79
|
+
theme: v,
|
|
77
80
|
measureBlocks: F,
|
|
78
|
-
defaultTabStopTwips:
|
|
79
|
-
},
|
|
81
|
+
defaultTabStopTwips: S
|
|
82
|
+
}, w = (e, t) => {
|
|
80
83
|
if (!e) return;
|
|
81
84
|
let n = de(e);
|
|
82
|
-
return n ? d(n.state.doc,
|
|
83
|
-
},
|
|
84
|
-
if (
|
|
85
|
+
return n ? d(n.state.doc, _, t, C) : f(e, _, t, C);
|
|
86
|
+
}, T = w(a, b), E = w(p, x), D = i?.titlePg === !0, O = D ? w(m, b) : void 0, A = D ? w(h, x) : void 0, j = e.doc.attrs?.watermark ?? void 0, M = s.header ?? 48, N = s.footer ?? 48, P = s.top - M, I = s.bottom - N, L = (e) => e ? e.visualBottom ?? e.height : 0, R = (e) => e ? Math.max((e.visualBottom ?? e.height) - (e.visualTop ?? 0), e.height) : 0, B = Math.max(L(T), L(O)), V = Math.max(R(E), R(A)), H = B > P, U = V > I;
|
|
87
|
+
if (H || U) {
|
|
85
88
|
let e = (e) => {
|
|
86
89
|
let t = { ...e };
|
|
87
|
-
return
|
|
90
|
+
return H && (t.top = Math.max(e.top, M + B)), U && (t.bottom = Math.max(e.bottom, N + V)), t;
|
|
88
91
|
};
|
|
89
|
-
s = e(s),
|
|
92
|
+
s = e(s), g = e(g);
|
|
90
93
|
for (let t of n) {
|
|
91
94
|
if (t.kind !== "sectionBreak") continue;
|
|
92
95
|
let n = t;
|
|
93
96
|
n.margins &&= e(n.margins);
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
|
-
let
|
|
99
|
+
let G = {
|
|
97
100
|
pageSize: o,
|
|
98
101
|
margins: s,
|
|
99
|
-
finalPageSize:
|
|
100
|
-
finalMargins:
|
|
101
|
-
pageGap:
|
|
102
|
-
},
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
styles:
|
|
106
|
-
theme:
|
|
102
|
+
finalPageSize: ae,
|
|
103
|
+
finalMargins: g,
|
|
104
|
+
pageGap: k
|
|
105
|
+
}, K = u(n), q = K.length > 0 && !!z.value.package?.footnotes, J = ce(n, r, G), Y = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map();
|
|
106
|
+
if (q) {
|
|
107
|
+
X = c(z.value.package.footnotes, K, _, {
|
|
108
|
+
styles: y,
|
|
109
|
+
theme: v,
|
|
107
110
|
measureBlocks: F,
|
|
108
|
-
defaultTabStopTwips:
|
|
111
|
+
defaultTabStopTwips: S
|
|
109
112
|
});
|
|
110
113
|
let e = te({
|
|
111
114
|
blocks: n,
|
|
112
115
|
measures: r,
|
|
113
|
-
layoutOpts:
|
|
114
|
-
footnoteRefs:
|
|
115
|
-
footnoteContentMap:
|
|
116
|
-
initialLayout:
|
|
116
|
+
layoutOpts: G,
|
|
117
|
+
footnoteRefs: K,
|
|
118
|
+
footnoteContentMap: X,
|
|
119
|
+
initialLayout: J
|
|
117
120
|
});
|
|
118
|
-
|
|
121
|
+
J = e.layout, Y = e.pageFootnoteMap;
|
|
119
122
|
}
|
|
120
|
-
W.value =
|
|
121
|
-
let
|
|
123
|
+
W.value = J;
|
|
124
|
+
let Z = /* @__PURE__ */ new Map();
|
|
122
125
|
for (let e = 0; e < n.length; e++) {
|
|
123
126
|
let t = n[e], i = r[e];
|
|
124
|
-
t && i &&
|
|
127
|
+
t && i && Z.set(String(t.id), {
|
|
125
128
|
block: t,
|
|
126
129
|
measure: i
|
|
127
130
|
});
|
|
128
131
|
}
|
|
129
|
-
let
|
|
130
|
-
|
|
131
|
-
pageGap:
|
|
132
|
+
let Q = q ? l(Y, X, z.value) : void 0;
|
|
133
|
+
le(J.pages, t, {
|
|
134
|
+
pageGap: k,
|
|
132
135
|
showShadow: !0,
|
|
133
136
|
pageBackground: "#fff",
|
|
134
|
-
blockLookup:
|
|
135
|
-
theme:
|
|
136
|
-
headerContent:
|
|
137
|
-
footerContent:
|
|
138
|
-
firstPageHeaderContent:
|
|
139
|
-
firstPageFooterContent:
|
|
140
|
-
titlePage:
|
|
141
|
-
|
|
137
|
+
blockLookup: Z,
|
|
138
|
+
theme: v,
|
|
139
|
+
headerContent: T,
|
|
140
|
+
footerContent: E,
|
|
141
|
+
firstPageHeaderContent: O,
|
|
142
|
+
firstPageFooterContent: A,
|
|
143
|
+
titlePage: D,
|
|
144
|
+
watermark: j,
|
|
145
|
+
footnotesByPage: Q
|
|
142
146
|
}), t.style.overflowY = "auto", t.style.minHeight = "0";
|
|
143
147
|
for (let e of Array.from(t.children)) e.style.flexShrink = "0";
|
|
144
|
-
|
|
148
|
+
ne(t, re(e.doc, e.selection.from, e.selection.to));
|
|
145
149
|
} catch (e) {
|
|
146
|
-
console.error("[useDocxEditor] Layout pipeline error:", e),
|
|
150
|
+
console.error("[useDocxEditor] Layout pipeline error:", e), j?.(e instanceof Error ? e : Error(String(e)));
|
|
147
151
|
} finally {
|
|
148
152
|
I?.onLayoutComplete(n);
|
|
149
153
|
}
|
|
@@ -151,7 +155,7 @@ function I(e) {
|
|
|
151
155
|
function q() {
|
|
152
156
|
let e = n.value;
|
|
153
157
|
if (!e) return;
|
|
154
|
-
let t = z.value?.package?.styles, r = z.value ?
|
|
158
|
+
let t = z.value?.package?.styles, r = z.value ? oe(z.value, { styles: t ?? void 0 }) : ae(), i = w(!1), o = C(t), c = [
|
|
155
159
|
i,
|
|
156
160
|
...P,
|
|
157
161
|
...G.getPlugins() ?? [],
|
|
@@ -162,9 +166,9 @@ function I(e) {
|
|
|
162
166
|
plugins: c
|
|
163
167
|
});
|
|
164
168
|
V.value = l;
|
|
165
|
-
let u = new
|
|
169
|
+
let u = new y(e, {
|
|
166
170
|
state: l,
|
|
167
|
-
editable: () => !a(
|
|
171
|
+
editable: () => !a(O),
|
|
168
172
|
dispatchTransaction(e) {
|
|
169
173
|
if (!u) return;
|
|
170
174
|
let t = u.state.apply(e);
|
|
@@ -172,16 +176,16 @@ function I(e) {
|
|
|
172
176
|
I?.incrementStateSeq(), K(t);
|
|
173
177
|
try {
|
|
174
178
|
if (z.value) {
|
|
175
|
-
let e =
|
|
176
|
-
z.value = e,
|
|
179
|
+
let e = x(t.doc, z.value);
|
|
180
|
+
z.value = e, A?.(e);
|
|
177
181
|
}
|
|
178
182
|
} catch (e) {
|
|
179
183
|
console.error("[useDocxEditor] fromProseDoc error:", e);
|
|
180
184
|
}
|
|
181
185
|
}
|
|
182
|
-
if (I?.requestRender(),
|
|
186
|
+
if (I?.requestRender(), M?.(), !e.docChanged) {
|
|
183
187
|
let e = h.value;
|
|
184
|
-
e &&
|
|
188
|
+
e && ne(e, re(t.doc, t.selection.from, t.selection.to));
|
|
185
189
|
}
|
|
186
190
|
}
|
|
187
191
|
});
|
|
@@ -192,13 +196,13 @@ function I(e) {
|
|
|
192
196
|
() => a(R),
|
|
193
197
|
B
|
|
194
198
|
], ([e, t, n]) => {
|
|
195
|
-
n &&
|
|
199
|
+
n && T(e === "suggesting", n.state, n.dispatch, t);
|
|
196
200
|
}, { immediate: !0 });
|
|
197
201
|
function J() {
|
|
198
202
|
B.value &&= (B.value.destroy(), null), V.value = null, H.value = !1;
|
|
199
203
|
}
|
|
200
204
|
let Y = { current: null }, X = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map();
|
|
201
|
-
function
|
|
205
|
+
function Q() {
|
|
202
206
|
if (Y.current && Y.current.isConnected) return Y.current;
|
|
203
207
|
let e = window.document.createElement("div");
|
|
204
208
|
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;
|
|
@@ -218,8 +222,8 @@ function I(e) {
|
|
|
218
222
|
let t = ue(e);
|
|
219
223
|
return t ? X.get(t) ?? null : null;
|
|
220
224
|
}
|
|
221
|
-
function
|
|
222
|
-
let e = z.value?.package, t =
|
|
225
|
+
function $() {
|
|
226
|
+
let e = z.value?.package, t = Q(), n = /* @__PURE__ */ new Set();
|
|
223
227
|
if (e?.headers) for (let t of e.headers.keys()) n.add(t);
|
|
224
228
|
if (e?.footers) for (let t of e.footers.keys()) n.add(t);
|
|
225
229
|
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));
|
|
@@ -229,75 +233,75 @@ function I(e) {
|
|
|
229
233
|
if (X.has(o)) continue;
|
|
230
234
|
let n = e.headers?.get(o) ?? e.footers?.get(o);
|
|
231
235
|
if (!n) continue;
|
|
232
|
-
let c = e.headers?.has(o) ? "header" : "footer", l = new D(
|
|
236
|
+
let c = e.headers?.has(o) ? "header" : "footer", l = new E(D());
|
|
233
237
|
l.buildSchema(), l.initializeRuntime(), Z.set(o, l);
|
|
234
238
|
let u = window.document.createElement("div");
|
|
235
239
|
u.dataset.hfRId = o, u.dataset.hfKind = c, t.appendChild(u);
|
|
236
|
-
let d =
|
|
240
|
+
let d = g(n.content, {
|
|
237
241
|
styles: r ?? void 0,
|
|
238
242
|
theme: i,
|
|
239
243
|
defaultTabStopTwips: a
|
|
240
|
-
}), f =
|
|
244
|
+
}), f = C(r), p = s.create({
|
|
241
245
|
doc: d,
|
|
242
|
-
schema:
|
|
246
|
+
schema: v,
|
|
243
247
|
plugins: [...l.getPlugins(), f]
|
|
244
|
-
}), m = c, h = new
|
|
248
|
+
}), m = c, h = new y(u, {
|
|
245
249
|
state: p,
|
|
246
250
|
dispatchTransaction(e) {
|
|
247
251
|
let t = h.state.apply(e);
|
|
248
252
|
if (h.updateState(t), e.docChanged) {
|
|
249
253
|
let e = z.value?.package, n = (m === "header" ? e?.headers : e?.footers)?.get(o);
|
|
250
|
-
n && (n.content =
|
|
254
|
+
n && (n.content = _(t.doc));
|
|
251
255
|
}
|
|
252
|
-
e.docChanged && V.value && K(V.value),
|
|
256
|
+
e.docChanged && V.value && K(V.value), pe.value?.(o, h, e.docChanged);
|
|
253
257
|
}
|
|
254
258
|
});
|
|
255
259
|
X.set(o, h);
|
|
256
260
|
}
|
|
257
261
|
}
|
|
258
|
-
function
|
|
262
|
+
function fe() {
|
|
259
263
|
for (let e of X.values()) e.destroy(), e.dom.parentElement?.remove();
|
|
260
264
|
X.clear();
|
|
261
265
|
for (let e of Z.values()) e.destroy();
|
|
262
266
|
Z.clear(), Y.current &&= (Y.current.remove(), null);
|
|
263
267
|
}
|
|
264
|
-
let
|
|
265
|
-
function
|
|
266
|
-
|
|
268
|
+
let pe = { value: null };
|
|
269
|
+
function me(e) {
|
|
270
|
+
pe.value = e;
|
|
267
271
|
}
|
|
268
|
-
async function
|
|
272
|
+
async function he(e) {
|
|
269
273
|
U.value = null, H.value = !1;
|
|
270
274
|
try {
|
|
271
275
|
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
|
|
276
|
+
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 b(t), J(), fe(), q(), $();
|
|
273
277
|
} catch (e) {
|
|
274
278
|
let t = e instanceof Error ? e : Error(String(e));
|
|
275
|
-
U.value = t.message,
|
|
279
|
+
U.value = t.message, j?.(t);
|
|
276
280
|
}
|
|
277
281
|
}
|
|
278
|
-
function
|
|
279
|
-
U.value = null, z.value = e, J(),
|
|
282
|
+
function ge(e) {
|
|
283
|
+
U.value = null, z.value = e, J(), fe(), q(), $();
|
|
280
284
|
}
|
|
281
|
-
async function
|
|
285
|
+
async function _e() {
|
|
282
286
|
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 =
|
|
287
|
+
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 = x(B.value.state.doc, z.value), a = i.package.document?.comments ?? [];
|
|
284
288
|
i.package.document?.content && a.length > 0 && (n(i.package.document.content, a), r(i.package.document.content, a));
|
|
285
289
|
let o;
|
|
286
290
|
return o = i.originalBuffer ? await e(i) : await t(i), new Blob([o], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
|
|
287
291
|
}
|
|
288
|
-
function _e() {
|
|
289
|
-
B.value?.focus();
|
|
290
|
-
}
|
|
291
292
|
function ve() {
|
|
292
|
-
|
|
293
|
+
B.value?.focus();
|
|
293
294
|
}
|
|
294
295
|
function ye() {
|
|
296
|
+
J(), fe(), z.value = null;
|
|
297
|
+
}
|
|
298
|
+
function be() {
|
|
295
299
|
return z.value;
|
|
296
300
|
}
|
|
297
301
|
t(() => {
|
|
298
|
-
|
|
302
|
+
ye();
|
|
299
303
|
});
|
|
300
|
-
function
|
|
304
|
+
function xe() {
|
|
301
305
|
return G.getCommands();
|
|
302
306
|
}
|
|
303
307
|
return {
|
|
@@ -306,19 +310,19 @@ function I(e) {
|
|
|
306
310
|
isReady: H,
|
|
307
311
|
parseError: U,
|
|
308
312
|
layout: W,
|
|
309
|
-
loadBuffer:
|
|
310
|
-
loadDocument:
|
|
311
|
-
save:
|
|
312
|
-
focus:
|
|
313
|
-
destroy:
|
|
314
|
-
getDocument:
|
|
315
|
-
getCommands:
|
|
313
|
+
loadBuffer: he,
|
|
314
|
+
loadDocument: ge,
|
|
315
|
+
save: _e,
|
|
316
|
+
focus: ve,
|
|
317
|
+
destroy: ye,
|
|
318
|
+
getDocument: be,
|
|
319
|
+
getCommands: xe,
|
|
316
320
|
reLayout() {
|
|
317
321
|
B.value && K(B.value.state);
|
|
318
322
|
},
|
|
319
323
|
getHfPmView: de,
|
|
320
|
-
syncHfPMs:
|
|
321
|
-
setHfTransactionListener:
|
|
324
|
+
syncHfPMs: $,
|
|
325
|
+
setHfTransactionListener: me,
|
|
322
326
|
setDocument(e) {
|
|
323
327
|
z.value = e;
|
|
324
328
|
}
|
|
@@ -449,7 +453,7 @@ function K() {
|
|
|
449
453
|
t.active = !1, t.handle?.classList.remove("dragging"), r && Z(r, t), t.handle = null;
|
|
450
454
|
return;
|
|
451
455
|
}
|
|
452
|
-
n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r &&
|
|
456
|
+
n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && Q(r, n), n.handle = null);
|
|
453
457
|
}
|
|
454
458
|
function c() {
|
|
455
459
|
return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
|
|
@@ -553,7 +557,7 @@ function Z(e, t) {
|
|
|
553
557
|
return;
|
|
554
558
|
}
|
|
555
559
|
}
|
|
556
|
-
function
|
|
560
|
+
function Q(e, t) {
|
|
557
561
|
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
558
562
|
for (let r = n.depth; r >= 0; r--) {
|
|
559
563
|
let i = n.node(r);
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { EditorView } from 'prosemirror-view';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Resolve the painted header/footer instance nearest the viewport center — the
|
|
4
|
+
* one the user is editing. The same HF is painted on every page (shared
|
|
5
|
+
* `r:id`), so the chrome outline must track the active page rather than snap to
|
|
6
|
+
* page one's copy (mirrors core's `getHfDomSnapshot` host pick; #691).
|
|
6
7
|
*/
|
|
7
|
-
export declare function
|
|
8
|
+
export declare function nearestHfHostEl(position: 'header' | 'footer'): HTMLElement | null;
|
|
9
|
+
/**
|
|
10
|
+
* Find the painted span containing `pmPos`. By default scoped to body spans
|
|
11
|
+
* (which carry both pmStart and pmEnd) so HF runs in the separate PM document
|
|
12
|
+
* don't mis-resolve double-/triple-click selection. When `hfSection` is set
|
|
13
|
+
* (the user is editing a header/footer), scope to that section's painted host
|
|
14
|
+
* instead — the HF spans live in `.layout-page-header` / `.layout-page-footer`
|
|
15
|
+
* and carry PM positions from the HF document, so resolving against body spans
|
|
16
|
+
* would compute word/paragraph bounds from the wrong text (#691).
|
|
17
|
+
*/
|
|
18
|
+
export declare function findElementAtPosition(container: HTMLElement, pmPos: number, hfSection?: 'header' | 'footer'): HTMLElement | null;
|
|
8
19
|
/**
|
|
9
20
|
* Smooth-scroll the viewport so the painted element at `pmPos` is
|
|
10
21
|
* visible (48px top padding). Falls back to a CSS attribute selector
|
|
@@ -20,9 +31,9 @@ export declare function resolvePos(pagesContainer: HTMLElement | null, view: Edi
|
|
|
20
31
|
* Double-click word selection — expand `pos` to its word bounds and
|
|
21
32
|
* hand the resulting range to `setPmSelection`.
|
|
22
33
|
*/
|
|
23
|
-
export declare function selectWord(pagesContainer: HTMLElement | null, pos: number, setPmSelection: (from: number, to: number) => void): void;
|
|
34
|
+
export declare function selectWord(pagesContainer: HTMLElement | null, pos: number, setPmSelection: (from: number, to: number) => void, hfSection?: 'header' | 'footer'): void;
|
|
24
35
|
/**
|
|
25
36
|
* Triple-click paragraph selection — expand `pos` to the enclosing
|
|
26
37
|
* `.layout-paragraph` element's PM range.
|
|
27
38
|
*/
|
|
28
|
-
export declare function selectParagraph(pagesContainer: HTMLElement | null, pos: number, setPmSelection: (from: number, to: number) => void): void;
|
|
39
|
+
export declare function selectParagraph(pagesContainer: HTMLElement | null, pos: number, setPmSelection: (from: number, to: number) => void, hfSection?: 'header' | 'footer'): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eigenpal/docx-editor-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Vue 3 DOCX editor adapter for @eigenpal/docx-editor-core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"vue": "^3.3.0"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@eigenpal/docx-editor-agents": "^1.
|
|
87
|
-
"@eigenpal/docx-editor-core": "^1.
|
|
88
|
-
"@eigenpal/docx-editor-i18n": "^1.
|
|
86
|
+
"@eigenpal/docx-editor-agents": "^1.3.0",
|
|
87
|
+
"@eigenpal/docx-editor-core": "^1.3.0",
|
|
88
|
+
"@eigenpal/docx-editor-i18n": "^1.3.0"
|
|
89
89
|
},
|
|
90
90
|
"keywords": [
|
|
91
91
|
"docx",
|