@eigenpal/docx-editor-vue 1.1.0 → 1.2.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/components/DocxEditor/types.d.ts +19 -0
- package/dist/composables/usePagesPointer.d.ts +2 -2
- package/dist/composables.cjs +1 -1
- package/dist/composables.js +1 -1
- package/dist/docx-editor-vue.css +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +738 -553
- package/dist/{useTableResize-BbyKMoa9.js → useTableResize-BcBdSaOE.js} +193 -187
- package/dist/useTableResize-DTag4SY0.cjs +1 -0
- package/package.json +4 -4
- package/dist/useTableResize-CIV2YW70.cjs +0 -1
|
@@ -1,29 +1,30 @@
|
|
|
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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
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";
|
|
16
17
|
import "prosemirror-view/style/prosemirror.css";
|
|
17
18
|
import "@eigenpal/docx-editor-core/prosemirror/editor.css";
|
|
18
19
|
//#region src/composables/useDocxEditor.ts
|
|
19
|
-
var
|
|
20
|
-
function
|
|
20
|
+
var ce = 24;
|
|
21
|
+
function P(e, t, n, r) {
|
|
21
22
|
switch (e.kind) {
|
|
22
|
-
case "paragraph": return
|
|
23
|
+
case "paragraph": return A(e, t, {
|
|
23
24
|
floatingZones: n,
|
|
24
25
|
paragraphYOffset: r ?? 0
|
|
25
26
|
});
|
|
26
|
-
case "table": return h(e, t,
|
|
27
|
+
case "table": return h(e, t, P);
|
|
27
28
|
case "image": {
|
|
28
29
|
let t = e;
|
|
29
30
|
return {
|
|
@@ -33,10 +34,10 @@ function N(e, t, n, r) {
|
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
case "textBox": {
|
|
36
|
-
let t = e, n = t.margins ??
|
|
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;
|
|
37
38
|
return {
|
|
38
39
|
kind: "textBox",
|
|
39
|
-
width: t.width ??
|
|
40
|
+
width: t.width ?? M,
|
|
40
41
|
height: o,
|
|
41
42
|
innerMeasures: i
|
|
42
43
|
};
|
|
@@ -44,79 +45,79 @@ function N(e, t, n, r) {
|
|
|
44
45
|
case "pageBreak": return { kind: "pageBreak" };
|
|
45
46
|
case "columnBreak": return { kind: "columnBreak" };
|
|
46
47
|
case "sectionBreak": return { kind: "sectionBreak" };
|
|
47
|
-
default:
|
|
48
|
+
default: N(e, "vue useDocxEditor measureBlock");
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
51
|
+
function F(e, t) {
|
|
52
|
+
return k(e, t, P);
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
-
let { hiddenContainer: n, pagesContainer: h, readOnly:
|
|
55
|
-
function
|
|
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) {
|
|
56
57
|
let t = h.value;
|
|
57
|
-
if (!t || !
|
|
58
|
-
let n =
|
|
59
|
-
|
|
60
|
-
let r =
|
|
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;
|
|
61
62
|
try {
|
|
62
|
-
let n =
|
|
63
|
-
theme:
|
|
64
|
-
pageContentHeight:
|
|
65
|
-
}), r =
|
|
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 = {
|
|
66
67
|
section: "header",
|
|
67
68
|
pageSize: o,
|
|
68
69
|
margins: s
|
|
69
|
-
},
|
|
70
|
+
}, S = {
|
|
70
71
|
section: "footer",
|
|
71
72
|
pageSize: o,
|
|
72
73
|
margins: s
|
|
73
|
-
},
|
|
74
|
-
styles:
|
|
75
|
-
theme:
|
|
76
|
-
measureBlocks:
|
|
77
|
-
defaultTabStopTwips:
|
|
78
|
-
},
|
|
74
|
+
}, C = e.doc.attrs?.defaultTabStopTwips, w = {
|
|
75
|
+
styles: b,
|
|
76
|
+
theme: y,
|
|
77
|
+
measureBlocks: F,
|
|
78
|
+
defaultTabStopTwips: C
|
|
79
|
+
}, T = (e, t) => {
|
|
79
80
|
if (!e) return;
|
|
80
|
-
let n =
|
|
81
|
-
return n ? d(n.state.doc,
|
|
82
|
-
},
|
|
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;
|
|
83
84
|
if (V || H) {
|
|
84
85
|
let e = (e) => {
|
|
85
86
|
let t = { ...e };
|
|
86
|
-
return V && (t.top = Math.max(e.top,
|
|
87
|
+
return V && (t.top = Math.max(e.top, M + R)), H && (t.bottom = Math.max(e.bottom, N + B)), t;
|
|
87
88
|
};
|
|
88
|
-
s = e(s),
|
|
89
|
+
s = e(s), _ = e(_);
|
|
89
90
|
for (let t of n) {
|
|
90
91
|
if (t.kind !== "sectionBreak") continue;
|
|
91
92
|
let n = t;
|
|
92
93
|
n.margins &&= e(n.margins);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
|
-
let
|
|
96
|
+
let U = {
|
|
96
97
|
pageSize: o,
|
|
97
98
|
margins: s,
|
|
98
|
-
finalPageSize:
|
|
99
|
-
finalMargins:
|
|
100
|
-
pageGap:
|
|
101
|
-
}, G = u(n), K = G.length > 0 && !!
|
|
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();
|
|
102
103
|
if (K) {
|
|
103
|
-
Y = c(
|
|
104
|
-
styles:
|
|
105
|
-
theme:
|
|
106
|
-
measureBlocks:
|
|
107
|
-
defaultTabStopTwips:
|
|
104
|
+
Y = c(z.value.package.footnotes, G, v, {
|
|
105
|
+
styles: b,
|
|
106
|
+
theme: y,
|
|
107
|
+
measureBlocks: F,
|
|
108
|
+
defaultTabStopTwips: C
|
|
108
109
|
});
|
|
109
110
|
let e = te({
|
|
110
111
|
blocks: n,
|
|
111
112
|
measures: r,
|
|
112
|
-
layoutOpts:
|
|
113
|
+
layoutOpts: U,
|
|
113
114
|
footnoteRefs: G,
|
|
114
115
|
footnoteContentMap: Y,
|
|
115
116
|
initialLayout: q
|
|
116
117
|
});
|
|
117
118
|
q = e.layout, J = e.pageFootnoteMap;
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
+
W.value = q;
|
|
120
121
|
let X = /* @__PURE__ */ new Map();
|
|
121
122
|
for (let e = 0; e < n.length; e++) {
|
|
122
123
|
let t = n[e], i = r[e];
|
|
@@ -125,80 +126,85 @@ function F(e) {
|
|
|
125
126
|
measure: i
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
|
-
let Z = K ? l(J, Y,
|
|
129
|
-
|
|
130
|
-
pageGap:
|
|
129
|
+
let Z = K ? l(J, Y, z.value) : void 0;
|
|
130
|
+
se(q.pages, t, {
|
|
131
|
+
pageGap: A,
|
|
131
132
|
showShadow: !0,
|
|
132
133
|
pageBackground: "#fff",
|
|
133
134
|
blockLookup: X,
|
|
134
|
-
theme:
|
|
135
|
-
headerContent:
|
|
136
|
-
footerContent:
|
|
135
|
+
theme: y,
|
|
136
|
+
headerContent: E,
|
|
137
|
+
footerContent: D,
|
|
137
138
|
firstPageHeaderContent: k,
|
|
138
|
-
firstPageFooterContent:
|
|
139
|
-
titlePage:
|
|
139
|
+
firstPageFooterContent: j,
|
|
140
|
+
titlePage: O,
|
|
140
141
|
footnotesByPage: Z
|
|
141
142
|
}), t.style.overflowY = "auto", t.style.minHeight = "0";
|
|
142
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));
|
|
143
145
|
} catch (e) {
|
|
144
|
-
console.error("[useDocxEditor] Layout pipeline error:", e),
|
|
146
|
+
console.error("[useDocxEditor] Layout pipeline error:", e), M?.(e instanceof Error ? e : Error(String(e)));
|
|
145
147
|
} finally {
|
|
146
|
-
|
|
148
|
+
I?.onLayoutComplete(n);
|
|
147
149
|
}
|
|
148
150
|
}
|
|
149
|
-
function
|
|
151
|
+
function q() {
|
|
150
152
|
let e = n.value;
|
|
151
153
|
if (!e) return;
|
|
152
|
-
let t =
|
|
153
|
-
|
|
154
|
-
...
|
|
155
|
-
...
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
|
160
163
|
});
|
|
161
|
-
|
|
162
|
-
let
|
|
163
|
-
state:
|
|
164
|
-
editable: () => !a(
|
|
164
|
+
V.value = l;
|
|
165
|
+
let u = new b(e, {
|
|
166
|
+
state: l,
|
|
167
|
+
editable: () => !a(k),
|
|
165
168
|
dispatchTransaction(e) {
|
|
166
|
-
if (!
|
|
167
|
-
let t =
|
|
168
|
-
if (
|
|
169
|
-
|
|
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);
|
|
170
173
|
try {
|
|
171
|
-
if (
|
|
172
|
-
let e =
|
|
173
|
-
|
|
174
|
+
if (z.value) {
|
|
175
|
+
let e = S(t.doc, z.value);
|
|
176
|
+
z.value = e, j?.(e);
|
|
174
177
|
}
|
|
175
178
|
} catch (e) {
|
|
176
179
|
console.error("[useDocxEditor] fromProseDoc error:", e);
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
|
-
|
|
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
|
+
}
|
|
180
186
|
}
|
|
181
187
|
});
|
|
182
|
-
|
|
188
|
+
B.value = u, H.value = !0, K(l), I?.requestRender();
|
|
183
189
|
}
|
|
184
190
|
o([
|
|
185
|
-
() => a(I),
|
|
186
191
|
() => a(L),
|
|
187
|
-
|
|
192
|
+
() => a(R),
|
|
193
|
+
B
|
|
188
194
|
], ([e, t, n]) => {
|
|
189
|
-
n &&
|
|
195
|
+
n && E(e === "suggesting", n.state, n.dispatch, t);
|
|
190
196
|
}, { immediate: !0 });
|
|
191
|
-
function
|
|
192
|
-
|
|
197
|
+
function J() {
|
|
198
|
+
B.value &&= (B.value.destroy(), null), V.value = null, H.value = !1;
|
|
193
199
|
}
|
|
194
|
-
let
|
|
195
|
-
function
|
|
196
|
-
if (
|
|
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;
|
|
197
203
|
let e = window.document.createElement("div");
|
|
198
|
-
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),
|
|
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;
|
|
199
205
|
}
|
|
200
|
-
function
|
|
201
|
-
let t =
|
|
206
|
+
function ue(e) {
|
|
207
|
+
let t = z.value?.package;
|
|
202
208
|
if (!t) return null;
|
|
203
209
|
if (t.headers) {
|
|
204
210
|
for (let [n, r] of t.headers) if (r === e) return n;
|
|
@@ -208,119 +214,119 @@ function F(e) {
|
|
|
208
214
|
}
|
|
209
215
|
return null;
|
|
210
216
|
}
|
|
211
|
-
function
|
|
212
|
-
let t =
|
|
213
|
-
return t ?
|
|
217
|
+
function de(e) {
|
|
218
|
+
let t = ue(e);
|
|
219
|
+
return t ? X.get(t) ?? null : null;
|
|
214
220
|
}
|
|
215
221
|
function Q() {
|
|
216
|
-
let e =
|
|
222
|
+
let e = z.value?.package, t = le(), n = /* @__PURE__ */ new Set();
|
|
217
223
|
if (e?.headers) for (let t of e.headers.keys()) n.add(t);
|
|
218
224
|
if (e?.footers) for (let t of e.footers.keys()) n.add(t);
|
|
219
|
-
for (let [e, t] of
|
|
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));
|
|
220
226
|
if (!e) return;
|
|
221
227
|
let r = e.styles ?? null, i = e.theme ?? null, a = e.settings?.defaultTabStop ?? null;
|
|
222
228
|
for (let o of n) {
|
|
223
|
-
if (
|
|
229
|
+
if (X.has(o)) continue;
|
|
224
230
|
let n = e.headers?.get(o) ?? e.footers?.get(o);
|
|
225
231
|
if (!n) continue;
|
|
226
|
-
let c = e.headers?.has(o) ? "header" : "footer", l = new
|
|
227
|
-
l.buildSchema(), l.initializeRuntime(),
|
|
232
|
+
let c = e.headers?.has(o) ? "header" : "footer", l = new D(O());
|
|
233
|
+
l.buildSchema(), l.initializeRuntime(), Z.set(o, l);
|
|
228
234
|
let u = window.document.createElement("div");
|
|
229
235
|
u.dataset.hfRId = o, u.dataset.hfKind = c, t.appendChild(u);
|
|
230
|
-
let d =
|
|
236
|
+
let d = _(n.content, {
|
|
231
237
|
styles: r ?? void 0,
|
|
232
238
|
theme: i,
|
|
233
239
|
defaultTabStopTwips: a
|
|
234
|
-
}), f = s.create({
|
|
240
|
+
}), f = w(r), p = s.create({
|
|
235
241
|
doc: d,
|
|
236
|
-
schema:
|
|
237
|
-
plugins: l.getPlugins()
|
|
238
|
-
}),
|
|
239
|
-
state:
|
|
242
|
+
schema: y,
|
|
243
|
+
plugins: [...l.getPlugins(), f]
|
|
244
|
+
}), m = c, h = new b(u, {
|
|
245
|
+
state: p,
|
|
240
246
|
dispatchTransaction(e) {
|
|
241
|
-
let t =
|
|
242
|
-
if (
|
|
243
|
-
let e =
|
|
244
|
-
n && (n.content =
|
|
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));
|
|
245
251
|
}
|
|
246
|
-
e.docChanged &&
|
|
252
|
+
e.docChanged && V.value && K(V.value), fe.value?.(o, h, e.docChanged);
|
|
247
253
|
}
|
|
248
254
|
});
|
|
249
|
-
|
|
255
|
+
X.set(o, h);
|
|
250
256
|
}
|
|
251
257
|
}
|
|
252
258
|
function $() {
|
|
253
|
-
for (let e of
|
|
254
|
-
|
|
255
|
-
for (let e of
|
|
256
|
-
|
|
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);
|
|
257
263
|
}
|
|
258
|
-
let
|
|
259
|
-
function
|
|
260
|
-
|
|
264
|
+
let fe = { value: null };
|
|
265
|
+
function pe(e) {
|
|
266
|
+
fe.value = e;
|
|
261
267
|
}
|
|
262
|
-
async function
|
|
263
|
-
|
|
268
|
+
async function me(e) {
|
|
269
|
+
U.value = null, H.value = !1;
|
|
264
270
|
try {
|
|
265
271
|
let t;
|
|
266
|
-
t = e instanceof Blob || e instanceof File ? await e.arrayBuffer() : e instanceof Uint8Array ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : e,
|
|
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();
|
|
267
273
|
} catch (e) {
|
|
268
274
|
let t = e instanceof Error ? e : Error(String(e));
|
|
269
|
-
|
|
275
|
+
U.value = t.message, M?.(t);
|
|
270
276
|
}
|
|
271
277
|
}
|
|
272
|
-
function
|
|
273
|
-
|
|
278
|
+
function he(e) {
|
|
279
|
+
U.value = null, z.value = e, J(), $(), q(), Q();
|
|
274
280
|
}
|
|
275
|
-
async function
|
|
276
|
-
if (!
|
|
277
|
-
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 =
|
|
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 ?? [];
|
|
278
284
|
i.package.document?.content && a.length > 0 && (n(i.package.document.content, a), r(i.package.document.content, a));
|
|
279
285
|
let o;
|
|
280
286
|
return o = i.originalBuffer ? await e(i) : await t(i), new Blob([o], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
|
|
281
287
|
}
|
|
282
|
-
function
|
|
283
|
-
|
|
288
|
+
function _e() {
|
|
289
|
+
B.value?.focus();
|
|
284
290
|
}
|
|
285
|
-
function
|
|
286
|
-
|
|
291
|
+
function ve() {
|
|
292
|
+
J(), $(), z.value = null;
|
|
287
293
|
}
|
|
288
|
-
function
|
|
289
|
-
return
|
|
294
|
+
function ye() {
|
|
295
|
+
return z.value;
|
|
290
296
|
}
|
|
291
297
|
t(() => {
|
|
292
|
-
|
|
298
|
+
ve();
|
|
293
299
|
});
|
|
294
|
-
function
|
|
295
|
-
return
|
|
300
|
+
function be() {
|
|
301
|
+
return G.getCommands();
|
|
296
302
|
}
|
|
297
303
|
return {
|
|
298
|
-
editorView:
|
|
299
|
-
editorState:
|
|
300
|
-
isReady:
|
|
301
|
-
parseError:
|
|
302
|
-
layout:
|
|
303
|
-
loadBuffer:
|
|
304
|
-
loadDocument:
|
|
305
|
-
save:
|
|
306
|
-
focus:
|
|
307
|
-
destroy:
|
|
308
|
-
getDocument:
|
|
309
|
-
getCommands:
|
|
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,
|
|
310
316
|
reLayout() {
|
|
311
|
-
|
|
317
|
+
B.value && K(B.value.state);
|
|
312
318
|
},
|
|
313
|
-
getHfPmView:
|
|
319
|
+
getHfPmView: de,
|
|
314
320
|
syncHfPMs: Q,
|
|
315
|
-
setHfTransactionListener:
|
|
321
|
+
setHfTransactionListener: pe,
|
|
316
322
|
setDocument(e) {
|
|
317
|
-
|
|
323
|
+
z.value = e;
|
|
318
324
|
}
|
|
319
325
|
};
|
|
320
326
|
}
|
|
321
327
|
//#endregion
|
|
322
328
|
//#region src/composables/useZoom.ts
|
|
323
|
-
var
|
|
329
|
+
var L = .25, R = 4, z = .1, B = [
|
|
324
330
|
.25,
|
|
325
331
|
.5,
|
|
326
332
|
.75,
|
|
@@ -331,16 +337,16 @@ var I = .25, L = 4, R = .1, z = [
|
|
|
331
337
|
3,
|
|
332
338
|
4
|
|
333
339
|
];
|
|
334
|
-
function
|
|
335
|
-
let a = r(Math.max(
|
|
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);
|
|
336
342
|
function l(e) {
|
|
337
|
-
a.value = Math.max(
|
|
343
|
+
a.value = Math.max(L, Math.min(R, Math.round(e * 100) / 100));
|
|
338
344
|
}
|
|
339
345
|
function u() {
|
|
340
|
-
l(a.value +
|
|
346
|
+
l(a.value + z);
|
|
341
347
|
}
|
|
342
348
|
function d() {
|
|
343
|
-
l(a.value -
|
|
349
|
+
l(a.value - z);
|
|
344
350
|
}
|
|
345
351
|
function f() {
|
|
346
352
|
l(1);
|
|
@@ -366,13 +372,13 @@ function B(i = 1) {
|
|
|
366
372
|
handleWheel: p,
|
|
367
373
|
handleKeyDown: m,
|
|
368
374
|
installShortcuts: h,
|
|
369
|
-
ZOOM_PRESETS:
|
|
375
|
+
ZOOM_PRESETS: B
|
|
370
376
|
};
|
|
371
377
|
}
|
|
372
378
|
//#endregion
|
|
373
379
|
//#region src/composables/useTableResize.ts
|
|
374
|
-
var
|
|
375
|
-
function
|
|
380
|
+
var H = 15, U = 300, W = 200, G = 15;
|
|
381
|
+
function K() {
|
|
376
382
|
let e = {
|
|
377
383
|
active: !1,
|
|
378
384
|
startX: 0,
|
|
@@ -404,15 +410,15 @@ function G() {
|
|
|
404
410
|
}
|
|
405
411
|
function a(i, a) {
|
|
406
412
|
let o = i.target;
|
|
407
|
-
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),
|
|
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;
|
|
408
414
|
}
|
|
409
415
|
function o(r) {
|
|
410
416
|
if (e.active && e.handle) {
|
|
411
417
|
r.preventDefault();
|
|
412
418
|
let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
|
|
413
419
|
e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
|
|
414
|
-
let i = Math.round(t *
|
|
415
|
-
a >=
|
|
420
|
+
let i = Math.round(t * H), a = e.origWidths.left + i, o = e.origWidths.right - i;
|
|
421
|
+
a >= U && o >= U && (e.origWidths = {
|
|
416
422
|
left: a,
|
|
417
423
|
right: o
|
|
418
424
|
});
|
|
@@ -422,28 +428,28 @@ function G() {
|
|
|
422
428
|
r.preventDefault();
|
|
423
429
|
let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
|
|
424
430
|
t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
|
|
425
|
-
let i = Math.round(e *
|
|
426
|
-
a >=
|
|
431
|
+
let i = Math.round(e * H), a = t.origHeight + i;
|
|
432
|
+
a >= W && (t.origHeight = a);
|
|
427
433
|
return;
|
|
428
434
|
}
|
|
429
435
|
if (n.active && n.handle) {
|
|
430
436
|
r.preventDefault();
|
|
431
437
|
let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
|
|
432
438
|
n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
|
|
433
|
-
let i = Math.round(e *
|
|
434
|
-
a >=
|
|
439
|
+
let i = Math.round(e * H), a = n.origWidth + i;
|
|
440
|
+
a >= U && (n.origWidth = a);
|
|
435
441
|
}
|
|
436
442
|
}
|
|
437
443
|
function s(i) {
|
|
438
444
|
if (e.active) {
|
|
439
|
-
e.active = !1, e.handle?.classList.remove("dragging"), r &&
|
|
445
|
+
e.active = !1, e.handle?.classList.remove("dragging"), r && X(r, e), e.handle = null;
|
|
440
446
|
return;
|
|
441
447
|
}
|
|
442
448
|
if (t.active) {
|
|
443
|
-
t.active = !1, t.handle?.classList.remove("dragging"), r &&
|
|
449
|
+
t.active = !1, t.handle?.classList.remove("dragging"), r && Z(r, t), t.handle = null;
|
|
444
450
|
return;
|
|
445
451
|
}
|
|
446
|
-
n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r &&
|
|
452
|
+
n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && le(r, n), n.handle = null);
|
|
447
453
|
}
|
|
448
454
|
function c() {
|
|
449
455
|
return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
|
|
@@ -456,7 +462,7 @@ function G() {
|
|
|
456
462
|
isResizing: i
|
|
457
463
|
};
|
|
458
464
|
}
|
|
459
|
-
function
|
|
465
|
+
function q(e, t) {
|
|
460
466
|
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
461
467
|
for (let e = n.depth; e >= 0; e--) {
|
|
462
468
|
let r = n.node(e);
|
|
@@ -470,7 +476,7 @@ function K(e, t) {
|
|
|
470
476
|
}
|
|
471
477
|
}
|
|
472
478
|
}
|
|
473
|
-
function
|
|
479
|
+
function J(e, t, n) {
|
|
474
480
|
let r = e.state.doc.resolve(t.tablePmStart + 1);
|
|
475
481
|
for (let e = r.depth; e >= 0; e--) {
|
|
476
482
|
let i = r.node(e);
|
|
@@ -483,14 +489,14 @@ function q(e, t, n) {
|
|
|
483
489
|
if (r) t.origHeight = r;
|
|
484
490
|
else {
|
|
485
491
|
let e = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), r = e ? e.getBoundingClientRect().height : 30;
|
|
486
|
-
t.origHeight = Math.round(r *
|
|
492
|
+
t.origHeight = Math.round(r * G);
|
|
487
493
|
}
|
|
488
494
|
}
|
|
489
495
|
return;
|
|
490
496
|
}
|
|
491
497
|
}
|
|
492
498
|
}
|
|
493
|
-
function
|
|
499
|
+
function Y(e, t) {
|
|
494
500
|
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
495
501
|
for (let e = n.depth; e >= 0; e--) {
|
|
496
502
|
let r = n.node(e);
|
|
@@ -501,7 +507,7 @@ function J(e, t) {
|
|
|
501
507
|
}
|
|
502
508
|
}
|
|
503
509
|
}
|
|
504
|
-
function
|
|
510
|
+
function X(e, t) {
|
|
505
511
|
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
506
512
|
for (let r = n.depth; r >= 0; r--) {
|
|
507
513
|
let i = n.node(r);
|
|
@@ -531,7 +537,7 @@ function Y(e, t) {
|
|
|
531
537
|
return;
|
|
532
538
|
}
|
|
533
539
|
}
|
|
534
|
-
function
|
|
540
|
+
function Z(e, t) {
|
|
535
541
|
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
536
542
|
for (let r = n.depth; r >= 0; r--) {
|
|
537
543
|
let i = n.node(r);
|
|
@@ -547,7 +553,7 @@ function X(e, t) {
|
|
|
547
553
|
return;
|
|
548
554
|
}
|
|
549
555
|
}
|
|
550
|
-
function
|
|
556
|
+
function le(e, t) {
|
|
551
557
|
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
552
558
|
for (let r = n.depth; r >= 0; r--) {
|
|
553
559
|
let i = n.node(r);
|
|
@@ -574,4 +580,4 @@ function Z(e, t) {
|
|
|
574
580
|
}
|
|
575
581
|
}
|
|
576
582
|
//#endregion
|
|
577
|
-
export {
|
|
583
|
+
export { V as n, I as r, K as t };
|