@eigenpal/docx-editor-vue 0.0.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/LICENSE +204 -0
- package/README.md +60 -0
- package/dist/KeyboardShortcutsDialog-BtJB9UOD.js +2902 -0
- package/dist/KeyboardShortcutsDialog-D72k5DXR.cjs +1 -0
- package/dist/MenuBar-BrQW4COn.cjs +4 -0
- package/dist/MenuBar-D_Dvwb0F.js +3313 -0
- package/dist/RenderedDomContext-CHc18N_2.js +2 -0
- package/dist/TablePropertiesDialog-Ct5XChwd.cjs +1 -0
- package/dist/TablePropertiesDialog-cJx_xxxE.js +987 -0
- package/dist/_plugin-vue_export-helper-B52Kst-M.js +8 -0
- package/dist/_plugin-vue_export-helper-CX7YVcP6.cjs +1 -0
- package/dist/components/DocxEditor/types.d.ts +100 -0
- package/dist/components/EditorToolbarContext.d.ts +9 -0
- package/dist/components/Toolbar/presets.d.ts +42 -0
- package/dist/components/dialogs/index.d.ts +27 -0
- package/dist/components/imageContextMenuTypes.d.ts +30 -0
- package/dist/components/imageSelectionTypes.d.ts +14 -0
- package/dist/components/insertTableState.d.ts +9 -0
- package/dist/components/sidebar/cardStyles.d.ts +3 -0
- package/dist/components/sidebar/cardUtils.d.ts +1 -0
- package/dist/components/sidebar/resolveItemPositions.d.ts +4 -0
- package/dist/components/sidebar/sidebarUtils.d.ts +4 -0
- package/dist/components/tableStylePresets.d.ts +53 -0
- package/dist/components/toolbarUtils.d.ts +1 -0
- package/dist/components/ui/Icons.d.ts +1 -0
- package/dist/components/ui/hyperlinkPopupTypes.d.ts +20 -0
- package/dist/composables/index.d.ts +30 -0
- package/dist/composables/useAutoSave.d.ts +40 -0
- package/dist/composables/useClipboard.d.ts +22 -0
- package/dist/composables/useCommentLifecycle.d.ts +52 -0
- package/dist/composables/useCommentManagement.d.ts +41 -0
- package/dist/composables/useCommentSidebarItems.d.ts +24 -0
- package/dist/composables/useContextMenus.d.ts +39 -0
- package/dist/composables/useDocumentLifecycle.d.ts +11 -0
- package/dist/composables/useDocxEditor.d.ts +56 -0
- package/dist/composables/useDocxEditorRefApi.d.ts +49 -0
- package/dist/composables/useDragAutoScroll.d.ts +11 -0
- package/dist/composables/useFileIO.d.ts +30 -0
- package/dist/composables/useFindReplace.d.ts +34 -0
- package/dist/composables/useFixedDropdown.d.ts +14 -0
- package/dist/composables/useFormattingActions.d.ts +40 -0
- package/dist/composables/useHistory.d.ts +9 -0
- package/dist/composables/useHyperlinkManagement.d.ts +38 -0
- package/dist/composables/useImageActions.d.ts +30 -0
- package/dist/composables/useKeyboardShortcuts.d.ts +17 -0
- package/dist/composables/useMenuActions.d.ts +23 -0
- package/dist/composables/useOutlineSidebar.d.ts +17 -0
- package/dist/composables/usePageSetupControls.d.ts +22 -0
- package/dist/composables/usePagesPointer.d.ts +70 -0
- package/dist/composables/useSelectionHighlight.d.ts +19 -0
- package/dist/composables/useSelectionSync.d.ts +13 -0
- package/dist/composables/useTableResize.d.ts +7 -0
- package/dist/composables/useTableSelection.d.ts +10 -0
- package/dist/composables/useToolbarDropdowns.d.ts +14 -0
- package/dist/composables/useTrackedChanges.d.ts +12 -0
- package/dist/composables/useVisualLineNavigation.d.ts +11 -0
- package/dist/composables/useWheelZoom.d.ts +10 -0
- package/dist/composables/useZoom.d.ts +16 -0
- package/dist/composables.cjs +1 -0
- package/dist/composables.js +485 -0
- package/dist/dialogs.cjs +1 -0
- package/dist/dialogs.js +3 -0
- package/dist/docx-editor-vue.css +2 -0
- package/dist/i18n/LocaleContext.d.ts +1 -0
- package/dist/i18n/index.d.ts +26 -0
- package/dist/index.cjs +20 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +3600 -0
- package/dist/lib/utils.d.ts +10 -0
- package/dist/plugin-api/RenderedDomContext.d.ts +1 -0
- package/dist/plugin-api/index.d.ts +18 -0
- package/dist/plugin-api/types.d.ts +28 -0
- package/dist/plugin-api.cjs +1 -0
- package/dist/plugin-api.js +62 -0
- package/dist/renderAsync.d.ts +31 -0
- package/dist/styles/index.d.ts +12 -0
- package/dist/styles/zIndex.d.ts +24 -0
- package/dist/styles.cjs +1 -0
- package/dist/styles.js +5 -0
- package/dist/ui.cjs +18 -0
- package/dist/ui.d.ts +79 -0
- package/dist/ui.js +963 -0
- package/dist/useTableResize-1oSe9Kjk.js +480 -0
- package/dist/useTableResize-lWdIgX9x.cjs +1 -0
- package/dist/utils/commentFactories.d.ts +7 -0
- package/dist/utils/domQueries.d.ts +28 -0
- package/dist/utils/imageClipboard.d.ts +9 -0
- package/dist/utils/paraTextHelpers.d.ts +29 -0
- package/dist/utils/refApiQueries.d.ts +46 -0
- package/dist/zIndex-CH0jZ7U7.cjs +1 -0
- package/dist/zIndex-CxELVe_L.js +12 -0
- package/package.json +119 -0
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
import { computed as e, onBeforeUnmount as t, onMounted as n, ref as r, shallowRef as i, unref as a } from "vue";
|
|
2
|
+
import { EditorState as o } from "prosemirror-state";
|
|
3
|
+
import { EditorView as s } from "prosemirror-view";
|
|
4
|
+
import { singletonManager as c } from "@eigenpal/docx-editor-core/prosemirror/schema";
|
|
5
|
+
import { createEmptyDoc as l, toProseDoc as u } from "@eigenpal/docx-editor-core/prosemirror/conversion";
|
|
6
|
+
import "prosemirror-view/style/prosemirror.css";
|
|
7
|
+
import { parseDocx as d } from "@eigenpal/docx-editor-core/docx/parser";
|
|
8
|
+
import { fromProseDoc as f } from "@eigenpal/docx-editor-core/prosemirror/conversion/fromProseDoc";
|
|
9
|
+
import { toFlowBlocks as p } from "@eigenpal/docx-editor-core/layout-bridge/toFlowBlocks";
|
|
10
|
+
import { measureParagraph as m } from "@eigenpal/docx-editor-core/layout-bridge/measuring";
|
|
11
|
+
import { buildFootnoteContentMap as h, buildFootnoteRenderItems as g, collectFootnoteRefs as ee, convertHeaderFooterToContent as _, getMargins as v, getPageSize as y, measureTableBlock as b, resolveHeaderFooter as x, stabilizeFootnoteLayout as S } from "@eigenpal/docx-editor-core/layout-bridge";
|
|
12
|
+
import { DEFAULT_TEXTBOX_MARGINS as C, DEFAULT_TEXTBOX_WIDTH as w, assertExhaustiveFlowBlock as T, layoutDocument as E } from "@eigenpal/docx-editor-core/layout-engine";
|
|
13
|
+
import { renderPages as D } from "@eigenpal/docx-editor-core/layout-painter/renderPage";
|
|
14
|
+
import "@eigenpal/docx-editor-core/prosemirror/editor.css";
|
|
15
|
+
//#region src/composables/useDocxEditor.ts
|
|
16
|
+
var O = 24;
|
|
17
|
+
function k(e, t) {
|
|
18
|
+
switch (e.kind) {
|
|
19
|
+
case "paragraph": return m(e, t);
|
|
20
|
+
case "table": return b(e, t, k);
|
|
21
|
+
case "image": {
|
|
22
|
+
let t = e;
|
|
23
|
+
return {
|
|
24
|
+
kind: "image",
|
|
25
|
+
width: t.width ?? 100,
|
|
26
|
+
height: t.height ?? 100
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
case "textBox": {
|
|
30
|
+
let t = e, n = t.margins ?? C, r = (t.width ?? w) - n.left - n.right, i = t.content.map((e) => m(e, r)), a = i.reduce((e, t) => e + t.totalHeight, 0), o = t.height ?? a + n.top + n.bottom;
|
|
31
|
+
return {
|
|
32
|
+
kind: "textBox",
|
|
33
|
+
width: t.width ?? w,
|
|
34
|
+
height: o,
|
|
35
|
+
innerMeasures: i
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
case "pageBreak": return { kind: "pageBreak" };
|
|
39
|
+
case "columnBreak": return { kind: "columnBreak" };
|
|
40
|
+
case "sectionBreak": return { kind: "sectionBreak" };
|
|
41
|
+
default: T(e, "vue useDocxEditor measureBlock");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function A(e, t) {
|
|
45
|
+
return e.map((e) => k(e, t));
|
|
46
|
+
}
|
|
47
|
+
function j(e) {
|
|
48
|
+
let { hiddenContainer: n, pagesContainer: m, readOnly: b = !1, pageGap: C = O, onChange: w, onError: T, onSelectionUpdate: k, externalPlugins: j = [], syncCoordinator: M } = e, N = i(null), P = i(null), F = i(null), I = r(!1), L = r(null), R = i(null), z = c;
|
|
49
|
+
function B(e) {
|
|
50
|
+
let t = m.value;
|
|
51
|
+
if (!t || !N.value) return;
|
|
52
|
+
let n = M?.getStateSeq() ?? 0;
|
|
53
|
+
M?.onLayoutStart();
|
|
54
|
+
let r = N.value.package?.document, i = r?.sections?.[0]?.properties ?? r?.finalSectionProperties ?? null, a = r?.finalSectionProperties ?? i, o = y(i), s = v(i), c = y(a), l = v(a), u = o.w - s.left - s.right, d = o.h - s.top - s.bottom, f = N.value.package?.theme ?? null, b = N.value.package?.styles ?? null;
|
|
55
|
+
try {
|
|
56
|
+
let n = p(e.doc, {
|
|
57
|
+
theme: f,
|
|
58
|
+
pageContentHeight: d
|
|
59
|
+
}), r = A(n, u), { header: a, footer: m, firstHeader: v, firstFooter: y } = x(N.value, i), w = {
|
|
60
|
+
section: "header",
|
|
61
|
+
pageSize: o,
|
|
62
|
+
margins: s
|
|
63
|
+
}, T = {
|
|
64
|
+
section: "footer",
|
|
65
|
+
pageSize: o,
|
|
66
|
+
margins: s
|
|
67
|
+
}, O = {
|
|
68
|
+
styles: b,
|
|
69
|
+
theme: f,
|
|
70
|
+
measureBlocks: A
|
|
71
|
+
}, k = _(a, u, w, O), j = _(m, u, T, O), M = i?.titlePg === !0, P = M ? _(v, u, w, O) : void 0, F = M ? _(y, u, T, O) : void 0, I = s.header ?? 48, L = s.footer ?? 48, z = s.top - I, B = s.bottom - L, V = (e) => e ? e.visualBottom ?? e.height : 0, H = (e) => e ? Math.max((e.visualBottom ?? e.height) - (e.visualTop ?? 0), e.height) : 0, U = Math.max(V(k), V(P)), W = Math.max(H(j), H(F)), G = U > z, K = W > B;
|
|
72
|
+
if (G || K) {
|
|
73
|
+
let e = (e) => {
|
|
74
|
+
let t = { ...e };
|
|
75
|
+
return G && (t.top = Math.max(e.top, I + U)), K && (t.bottom = Math.max(e.bottom, L + W)), t;
|
|
76
|
+
};
|
|
77
|
+
s = e(s), l = e(l);
|
|
78
|
+
for (let t of n) {
|
|
79
|
+
if (t.kind !== "sectionBreak") continue;
|
|
80
|
+
let n = t;
|
|
81
|
+
n.margins &&= e(n.margins);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
let q = {
|
|
85
|
+
pageSize: o,
|
|
86
|
+
margins: s,
|
|
87
|
+
finalPageSize: c,
|
|
88
|
+
finalMargins: l,
|
|
89
|
+
pageGap: C
|
|
90
|
+
}, J = ee(n), Y = J.length > 0 && !!N.value.package?.footnotes, X = E(n, r, q), Z = /* @__PURE__ */ new Map(), Q = /* @__PURE__ */ new Map();
|
|
91
|
+
if (Y) {
|
|
92
|
+
Q = h(N.value.package.footnotes, J, u, {
|
|
93
|
+
styles: b,
|
|
94
|
+
theme: f,
|
|
95
|
+
measureBlocks: A
|
|
96
|
+
});
|
|
97
|
+
let e = S({
|
|
98
|
+
blocks: n,
|
|
99
|
+
measures: r,
|
|
100
|
+
layoutOpts: q,
|
|
101
|
+
footnoteRefs: J,
|
|
102
|
+
footnoteContentMap: Q,
|
|
103
|
+
initialLayout: X
|
|
104
|
+
});
|
|
105
|
+
X = e.layout, Z = e.pageFootnoteMap;
|
|
106
|
+
}
|
|
107
|
+
R.value = X;
|
|
108
|
+
let $ = /* @__PURE__ */ new Map();
|
|
109
|
+
for (let e = 0; e < n.length; e++) {
|
|
110
|
+
let t = n[e], i = r[e];
|
|
111
|
+
t && i && $.set(String(t.id), {
|
|
112
|
+
block: t,
|
|
113
|
+
measure: i
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
let te = Y ? g(Z, Q, N.value) : void 0;
|
|
117
|
+
D(X.pages, t, {
|
|
118
|
+
pageGap: C,
|
|
119
|
+
showShadow: !0,
|
|
120
|
+
pageBackground: "#fff",
|
|
121
|
+
blockLookup: $,
|
|
122
|
+
theme: f,
|
|
123
|
+
headerContent: k,
|
|
124
|
+
footerContent: j,
|
|
125
|
+
firstPageHeaderContent: P,
|
|
126
|
+
firstPageFooterContent: F,
|
|
127
|
+
titlePage: M,
|
|
128
|
+
footnotesByPage: te
|
|
129
|
+
}), t.style.overflowY = "auto", t.style.minHeight = "0";
|
|
130
|
+
for (let e of Array.from(t.children)) e.style.flexShrink = "0";
|
|
131
|
+
} catch (e) {
|
|
132
|
+
console.error("[useDocxEditor] Layout pipeline error:", e), T?.(e instanceof Error ? e : Error(String(e)));
|
|
133
|
+
} finally {
|
|
134
|
+
M?.onLayoutComplete(n);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function V() {
|
|
138
|
+
let e = n.value;
|
|
139
|
+
if (!e) return;
|
|
140
|
+
let t = N.value ? u(N.value, { styles: N.value.package?.styles ?? void 0 }) : l(), r = [...j, ...z.getPlugins() ?? []], i = o.create({
|
|
141
|
+
doc: t,
|
|
142
|
+
schema: z.getSchema(),
|
|
143
|
+
plugins: r
|
|
144
|
+
});
|
|
145
|
+
F.value = i;
|
|
146
|
+
let c = new s(e, {
|
|
147
|
+
state: i,
|
|
148
|
+
editable: () => !a(b),
|
|
149
|
+
dispatchTransaction(e) {
|
|
150
|
+
if (!c) return;
|
|
151
|
+
let t = c.state.apply(e);
|
|
152
|
+
if (c.updateState(t), F.value = t, e.docChanged) {
|
|
153
|
+
M?.incrementStateSeq(), B(t);
|
|
154
|
+
try {
|
|
155
|
+
if (N.value) {
|
|
156
|
+
let e = f(t.doc, N.value);
|
|
157
|
+
N.value = e, w?.(e);
|
|
158
|
+
}
|
|
159
|
+
} catch (e) {
|
|
160
|
+
console.error("[useDocxEditor] fromProseDoc error:", e);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
M?.requestRender(), k?.();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
P.value = c, I.value = !0, B(i), M?.requestRender();
|
|
167
|
+
}
|
|
168
|
+
function H() {
|
|
169
|
+
P.value &&= (P.value.destroy(), null), F.value = null, I.value = !1;
|
|
170
|
+
}
|
|
171
|
+
async function U(e) {
|
|
172
|
+
L.value = null, I.value = !1;
|
|
173
|
+
try {
|
|
174
|
+
let t;
|
|
175
|
+
t = e instanceof Blob || e instanceof File ? await e.arrayBuffer() : e instanceof Uint8Array ? e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength) : e, N.value = await d(t), H(), V();
|
|
176
|
+
} catch (e) {
|
|
177
|
+
let t = e instanceof Error ? e : Error(String(e));
|
|
178
|
+
L.value = t.message, T?.(t);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function W(e) {
|
|
182
|
+
L.value = null, N.value = e, H(), V();
|
|
183
|
+
}
|
|
184
|
+
async function G() {
|
|
185
|
+
if (!P.value || !N.value) return null;
|
|
186
|
+
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 = f(P.value.state.doc, N.value), a = i.package.document?.comments ?? [];
|
|
187
|
+
i.package.document?.content && a.length > 0 && (n(i.package.document.content, a), r(i.package.document.content, a));
|
|
188
|
+
let o;
|
|
189
|
+
return o = i.originalBuffer ? await e(i) : await t(i), new Blob([o], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
|
|
190
|
+
}
|
|
191
|
+
function K() {
|
|
192
|
+
P.value?.focus();
|
|
193
|
+
}
|
|
194
|
+
function q() {
|
|
195
|
+
H(), N.value = null;
|
|
196
|
+
}
|
|
197
|
+
function J() {
|
|
198
|
+
return N.value;
|
|
199
|
+
}
|
|
200
|
+
t(() => {
|
|
201
|
+
q();
|
|
202
|
+
});
|
|
203
|
+
function Y() {
|
|
204
|
+
return z.getCommands();
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
editorView: P,
|
|
208
|
+
editorState: F,
|
|
209
|
+
isReady: I,
|
|
210
|
+
parseError: L,
|
|
211
|
+
layout: R,
|
|
212
|
+
loadBuffer: U,
|
|
213
|
+
loadDocument: W,
|
|
214
|
+
save: G,
|
|
215
|
+
focus: K,
|
|
216
|
+
destroy: q,
|
|
217
|
+
getDocument: J,
|
|
218
|
+
getCommands: Y,
|
|
219
|
+
reLayout() {
|
|
220
|
+
P.value && B(P.value.state);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/composables/useZoom.ts
|
|
226
|
+
var M = .25, N = 4, P = .1, F = [
|
|
227
|
+
.25,
|
|
228
|
+
.5,
|
|
229
|
+
.75,
|
|
230
|
+
1,
|
|
231
|
+
1.25,
|
|
232
|
+
1.5,
|
|
233
|
+
2,
|
|
234
|
+
3,
|
|
235
|
+
4
|
|
236
|
+
];
|
|
237
|
+
function I(i = 1) {
|
|
238
|
+
let a = r(Math.max(M, Math.min(N, i))), o = e(() => Math.round(a.value * 100)), s = e(() => a.value <= M), c = e(() => a.value >= N);
|
|
239
|
+
function l(e) {
|
|
240
|
+
a.value = Math.max(M, Math.min(N, Math.round(e * 100) / 100));
|
|
241
|
+
}
|
|
242
|
+
function u() {
|
|
243
|
+
l(a.value + P);
|
|
244
|
+
}
|
|
245
|
+
function d() {
|
|
246
|
+
l(a.value - P);
|
|
247
|
+
}
|
|
248
|
+
function f() {
|
|
249
|
+
l(1);
|
|
250
|
+
}
|
|
251
|
+
function p(e) {
|
|
252
|
+
(e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d());
|
|
253
|
+
}
|
|
254
|
+
function m(e) {
|
|
255
|
+
(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())));
|
|
256
|
+
}
|
|
257
|
+
function h() {
|
|
258
|
+
n(() => document.addEventListener("keydown", m)), t(() => document.removeEventListener("keydown", m));
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
zoom: a,
|
|
262
|
+
zoomPercent: o,
|
|
263
|
+
isMinZoom: s,
|
|
264
|
+
isMaxZoom: c,
|
|
265
|
+
setZoom: l,
|
|
266
|
+
zoomIn: u,
|
|
267
|
+
zoomOut: d,
|
|
268
|
+
resetZoom: f,
|
|
269
|
+
handleWheel: p,
|
|
270
|
+
handleKeyDown: m,
|
|
271
|
+
installShortcuts: h,
|
|
272
|
+
ZOOM_PRESETS: F
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/composables/useTableResize.ts
|
|
277
|
+
var L = 15, R = 300, z = 200, B = 15;
|
|
278
|
+
function V() {
|
|
279
|
+
let e = {
|
|
280
|
+
active: !1,
|
|
281
|
+
startX: 0,
|
|
282
|
+
handle: null,
|
|
283
|
+
columnIndex: 0,
|
|
284
|
+
tablePmStart: 0,
|
|
285
|
+
origWidths: {
|
|
286
|
+
left: 0,
|
|
287
|
+
right: 0
|
|
288
|
+
}
|
|
289
|
+
}, t = {
|
|
290
|
+
active: !1,
|
|
291
|
+
startY: 0,
|
|
292
|
+
handle: null,
|
|
293
|
+
rowIndex: 0,
|
|
294
|
+
isEdge: !1,
|
|
295
|
+
tablePmStart: 0,
|
|
296
|
+
origHeight: 0
|
|
297
|
+
}, n = {
|
|
298
|
+
active: !1,
|
|
299
|
+
startX: 0,
|
|
300
|
+
handle: null,
|
|
301
|
+
columnIndex: 0,
|
|
302
|
+
tablePmStart: 0,
|
|
303
|
+
origWidth: 0
|
|
304
|
+
}, r = null;
|
|
305
|
+
function i() {
|
|
306
|
+
return e.active || t.active || n.active;
|
|
307
|
+
}
|
|
308
|
+
function a(i, a) {
|
|
309
|
+
let o = i.target;
|
|
310
|
+
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), H(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), U(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), W(a, n), !0) : !1 : !1;
|
|
311
|
+
}
|
|
312
|
+
function o(r) {
|
|
313
|
+
if (e.active && e.handle) {
|
|
314
|
+
r.preventDefault();
|
|
315
|
+
let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
|
|
316
|
+
e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
|
|
317
|
+
let i = Math.round(t * L), a = e.origWidths.left + i, o = e.origWidths.right - i;
|
|
318
|
+
a >= R && o >= R && (e.origWidths = {
|
|
319
|
+
left: a,
|
|
320
|
+
right: o
|
|
321
|
+
});
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (t.active && t.handle) {
|
|
325
|
+
r.preventDefault();
|
|
326
|
+
let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
|
|
327
|
+
t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
|
|
328
|
+
let i = Math.round(e * L), a = t.origHeight + i;
|
|
329
|
+
a >= z && (t.origHeight = a);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (n.active && n.handle) {
|
|
333
|
+
r.preventDefault();
|
|
334
|
+
let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
|
|
335
|
+
n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
|
|
336
|
+
let i = Math.round(e * L), a = n.origWidth + i;
|
|
337
|
+
a >= R && (n.origWidth = a);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function s(i) {
|
|
341
|
+
if (e.active) {
|
|
342
|
+
e.active = !1, e.handle?.classList.remove("dragging"), r && G(r, e), e.handle = null;
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (t.active) {
|
|
346
|
+
t.active = !1, t.handle?.classList.remove("dragging"), r && K(r, t), t.handle = null;
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && q(r, n), n.handle = null);
|
|
350
|
+
}
|
|
351
|
+
function c() {
|
|
352
|
+
return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
|
|
353
|
+
document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", s);
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
return {
|
|
357
|
+
tryStartResize: a,
|
|
358
|
+
install: c,
|
|
359
|
+
isResizing: i
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function H(e, t) {
|
|
363
|
+
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
364
|
+
for (let e = n.depth; e >= 0; e--) {
|
|
365
|
+
let r = n.node(e);
|
|
366
|
+
if (r.type.name === "table") {
|
|
367
|
+
let e = r.attrs.columnWidths;
|
|
368
|
+
e && e[t.columnIndex] !== void 0 && e[t.columnIndex + 1] !== void 0 && (t.origWidths = {
|
|
369
|
+
left: e[t.columnIndex],
|
|
370
|
+
right: e[t.columnIndex + 1]
|
|
371
|
+
});
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function U(e, t, n) {
|
|
377
|
+
let r = e.state.doc.resolve(t.tablePmStart + 1);
|
|
378
|
+
for (let e = r.depth; e >= 0; e--) {
|
|
379
|
+
let i = r.node(e);
|
|
380
|
+
if (i.type.name === "table") {
|
|
381
|
+
let e = null, r = 0;
|
|
382
|
+
if (i.forEach((n) => {
|
|
383
|
+
r === t.rowIndex && (e = n), r++;
|
|
384
|
+
}), e) {
|
|
385
|
+
let r = e.attrs.height;
|
|
386
|
+
if (r) t.origHeight = r;
|
|
387
|
+
else {
|
|
388
|
+
let e = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), r = e ? e.getBoundingClientRect().height : 30;
|
|
389
|
+
t.origHeight = Math.round(r * B);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function W(e, t) {
|
|
397
|
+
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
398
|
+
for (let e = n.depth; e >= 0; e--) {
|
|
399
|
+
let r = n.node(e);
|
|
400
|
+
if (r.type.name === "table") {
|
|
401
|
+
let e = r.attrs.columnWidths;
|
|
402
|
+
e && e[t.columnIndex] !== void 0 && (t.origWidth = e[t.columnIndex]);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function G(e, t) {
|
|
408
|
+
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
409
|
+
for (let r = n.depth; r >= 0; r--) {
|
|
410
|
+
let i = n.node(r);
|
|
411
|
+
if (i.type.name !== "table") continue;
|
|
412
|
+
let a = n.before(r), o = e.state.tr, s = [...i.attrs.columnWidths || []];
|
|
413
|
+
s[t.columnIndex] = t.origWidths.left, s[t.columnIndex + 1] = t.origWidths.right, o.setNodeMarkup(a, void 0, {
|
|
414
|
+
...i.attrs,
|
|
415
|
+
columnWidths: s
|
|
416
|
+
});
|
|
417
|
+
let c = a + 1;
|
|
418
|
+
i.forEach((e) => {
|
|
419
|
+
let n = c + 1, r = 0;
|
|
420
|
+
e.forEach((e) => {
|
|
421
|
+
let i = e.attrs.colspan || 1;
|
|
422
|
+
if (r === t.columnIndex || r === t.columnIndex + 1) {
|
|
423
|
+
let i = r === t.columnIndex ? t.origWidths.left : t.origWidths.right;
|
|
424
|
+
o.setNodeMarkup(o.mapping.map(n), void 0, {
|
|
425
|
+
...e.attrs,
|
|
426
|
+
width: i,
|
|
427
|
+
widthType: "dxa",
|
|
428
|
+
colwidth: null
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
n += e.nodeSize, r += i;
|
|
432
|
+
}), c += e.nodeSize;
|
|
433
|
+
}), e.dispatch(o);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function K(e, t) {
|
|
438
|
+
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
439
|
+
for (let r = n.depth; r >= 0; r--) {
|
|
440
|
+
let i = n.node(r);
|
|
441
|
+
if (i.type.name !== "table") continue;
|
|
442
|
+
let a = n.before(r), o = e.state.tr, s = a + 1, c = 0;
|
|
443
|
+
i.forEach((e) => {
|
|
444
|
+
c === t.rowIndex && o.setNodeMarkup(o.mapping.map(s), void 0, {
|
|
445
|
+
...e.attrs,
|
|
446
|
+
height: t.origHeight,
|
|
447
|
+
heightRule: "atLeast"
|
|
448
|
+
}), s += e.nodeSize, c++;
|
|
449
|
+
}), e.dispatch(o);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function q(e, t) {
|
|
454
|
+
let n = e.state.doc.resolve(t.tablePmStart + 1);
|
|
455
|
+
for (let r = n.depth; r >= 0; r--) {
|
|
456
|
+
let i = n.node(r);
|
|
457
|
+
if (i.type.name !== "table") continue;
|
|
458
|
+
let a = n.before(r), o = e.state.tr, s = [...i.attrs.columnWidths || []];
|
|
459
|
+
s[t.columnIndex] = t.origWidth, o.setNodeMarkup(a, void 0, {
|
|
460
|
+
...i.attrs,
|
|
461
|
+
columnWidths: s
|
|
462
|
+
});
|
|
463
|
+
let c = a + 1;
|
|
464
|
+
i.forEach((e) => {
|
|
465
|
+
let n = c + 1, r = 0;
|
|
466
|
+
e.forEach((e) => {
|
|
467
|
+
let i = e.attrs.colspan || 1;
|
|
468
|
+
r === t.columnIndex && o.setNodeMarkup(o.mapping.map(n), void 0, {
|
|
469
|
+
...e.attrs,
|
|
470
|
+
width: t.origWidth,
|
|
471
|
+
widthType: "dxa",
|
|
472
|
+
colwidth: null
|
|
473
|
+
}), n += e.nodeSize, r += i;
|
|
474
|
+
}), c += e.nodeSize;
|
|
475
|
+
}), e.dispatch(o);
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
//#endregion
|
|
480
|
+
export { I as n, j as r, V as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require(`vue`),t=require(`prosemirror-state`),n=require(`prosemirror-view`),r=require(`@eigenpal/docx-editor-core/prosemirror/schema`),i=require(`@eigenpal/docx-editor-core/prosemirror/conversion`);require(`prosemirror-view/style/prosemirror.css`);let a=require(`@eigenpal/docx-editor-core/docx/parser`),o=require(`@eigenpal/docx-editor-core/prosemirror/conversion/fromProseDoc`),s=require(`@eigenpal/docx-editor-core/layout-bridge/toFlowBlocks`),c=require(`@eigenpal/docx-editor-core/layout-bridge/measuring`),l=require(`@eigenpal/docx-editor-core/layout-bridge`),u=require(`@eigenpal/docx-editor-core/layout-engine`),d=require(`@eigenpal/docx-editor-core/layout-painter/renderPage`);require(`@eigenpal/docx-editor-core/prosemirror/editor.css`);var f=24;function p(e,t){switch(e.kind){case`paragraph`:return(0,c.measureParagraph)(e,t);case`table`:return(0,l.measureTableBlock)(e,t,p);case`image`:{let t=e;return{kind:`image`,width:t.width??100,height:t.height??100}}case`textBox`:{let t=e,n=t.margins??u.DEFAULT_TEXTBOX_MARGINS,r=(t.width??u.DEFAULT_TEXTBOX_WIDTH)-n.left-n.right,i=t.content.map(e=>(0,c.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??u.DEFAULT_TEXTBOX_WIDTH,height:o,innerMeasures:i}}case`pageBreak`:return{kind:`pageBreak`};case`columnBreak`:return{kind:`columnBreak`};case`sectionBreak`:return{kind:`sectionBreak`};default:(0,u.assertExhaustiveFlowBlock)(e,`vue useDocxEditor measureBlock`)}}function m(e,t){return e.map(e=>p(e,t))}function h(c){let{hiddenContainer:p,pagesContainer:h,readOnly:g=!1,pageGap:_=f,onChange:v,onError:y,onSelectionUpdate:b,externalPlugins:x=[],syncCoordinator:S}=c,C=(0,e.shallowRef)(null),w=(0,e.shallowRef)(null),T=(0,e.shallowRef)(null),E=(0,e.ref)(!1),D=(0,e.ref)(null),O=(0,e.shallowRef)(null),k=r.singletonManager;function A(e){let t=h.value;if(!t||!C.value)return;let n=S?.getStateSeq()??0;S?.onLayoutStart();let r=C.value.package?.document,i=r?.sections?.[0]?.properties??r?.finalSectionProperties??null,a=r?.finalSectionProperties??i,o=(0,l.getPageSize)(i),c=(0,l.getMargins)(i),f=(0,l.getPageSize)(a),p=(0,l.getMargins)(a),g=o.w-c.left-c.right,v=o.h-c.top-c.bottom,b=C.value.package?.theme??null,x=C.value.package?.styles??null;try{let n=(0,s.toFlowBlocks)(e.doc,{theme:b,pageContentHeight:v}),r=m(n,g),{header:a,footer:h,firstHeader:y,firstFooter:S}=(0,l.resolveHeaderFooter)(C.value,i),w={section:`header`,pageSize:o,margins:c},T={section:`footer`,pageSize:o,margins:c},E={styles:x,theme:b,measureBlocks:m},D=(0,l.convertHeaderFooterToContent)(a,g,w,E),k=(0,l.convertHeaderFooterToContent)(h,g,T,E),A=i?.titlePg===!0,j=A?(0,l.convertHeaderFooterToContent)(y,g,w,E):void 0,M=A?(0,l.convertHeaderFooterToContent)(S,g,T,E):void 0,N=c.header??48,P=c.footer??48,F=c.top-N,I=c.bottom-P,L=e=>e?e.visualBottom??e.height:0,R=e=>e?Math.max((e.visualBottom??e.height)-(e.visualTop??0),e.height):0,z=Math.max(L(D),L(j)),B=Math.max(R(k),R(M)),V=z>F,H=B>I;if(V||H){let e=e=>{let t={...e};return V&&(t.top=Math.max(e.top,N+z)),H&&(t.bottom=Math.max(e.bottom,P+B)),t};c=e(c),p=e(p);for(let t of n){if(t.kind!==`sectionBreak`)continue;let n=t;n.margins&&=e(n.margins)}}let U={pageSize:o,margins:c,finalPageSize:f,finalMargins:p,pageGap:_},W=(0,l.collectFootnoteRefs)(n),G=W.length>0&&!!C.value.package?.footnotes,K=(0,u.layoutDocument)(n,r,U),q=new Map,J=new Map;if(G){J=(0,l.buildFootnoteContentMap)(C.value.package.footnotes,W,g,{styles:x,theme:b,measureBlocks:m});let e=(0,l.stabilizeFootnoteLayout)({blocks:n,measures:r,layoutOpts:U,footnoteRefs:W,footnoteContentMap:J,initialLayout:K});K=e.layout,q=e.pageFootnoteMap}O.value=K;let Y=new Map;for(let e=0;e<n.length;e++){let t=n[e],i=r[e];t&&i&&Y.set(String(t.id),{block:t,measure:i})}let X=G?(0,l.buildFootnoteRenderItems)(q,J,C.value):void 0;(0,d.renderPages)(K.pages,t,{pageGap:_,showShadow:!0,pageBackground:`#fff`,blockLookup:Y,theme:b,headerContent:D,footerContent:k,firstPageHeaderContent:j,firstPageFooterContent:M,titlePage:A,footnotesByPage:X}),t.style.overflowY=`auto`,t.style.minHeight=`0`;for(let e of Array.from(t.children))e.style.flexShrink=`0`}catch(e){console.error(`[useDocxEditor] Layout pipeline error:`,e),y?.(e instanceof Error?e:Error(String(e)))}finally{S?.onLayoutComplete(n)}}function j(){let r=p.value;if(!r)return;let a=C.value?(0,i.toProseDoc)(C.value,{styles:C.value.package?.styles??void 0}):(0,i.createEmptyDoc)(),s=[...x,...k.getPlugins()??[]],c=t.EditorState.create({doc:a,schema:k.getSchema(),plugins:s});T.value=c;let l=new n.EditorView(r,{state:c,editable:()=>!(0,e.unref)(g),dispatchTransaction(e){if(!l)return;let t=l.state.apply(e);if(l.updateState(t),T.value=t,e.docChanged){S?.incrementStateSeq(),A(t);try{if(C.value){let e=(0,o.fromProseDoc)(t.doc,C.value);C.value=e,v?.(e)}}catch(e){console.error(`[useDocxEditor] fromProseDoc error:`,e)}}S?.requestRender(),b?.()}});w.value=l,E.value=!0,A(c),S?.requestRender()}function M(){w.value&&=(w.value.destroy(),null),T.value=null,E.value=!1}async function N(e){D.value=null,E.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,C.value=await(0,a.parseDocx)(t),M(),j()}catch(e){let t=e instanceof Error?e:Error(String(e));D.value=t.message,y?.(t)}}function P(e){D.value=null,C.value=e,M(),j()}async function F(){if(!w.value||!C.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,o.fromProseDoc)(w.value.state.doc,C.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 s;return s=i.originalBuffer?await e(i):await t(i),new Blob([s],{type:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`})}function I(){w.value?.focus()}function L(){M(),C.value=null}function R(){return C.value}(0,e.onBeforeUnmount)(()=>{L()});function z(){return k.getCommands()}return{editorView:w,editorState:T,isReady:E,parseError:D,layout:O,loadBuffer:N,loadDocument:P,save:F,focus:I,destroy:L,getDocument:R,getCommands:z,reLayout(){w.value&&A(w.value.state)}}}var g=.25,_=4,v=.1,y=[.25,.5,.75,1,1.25,1.5,2,3,4];function b(t=1){let n=(0,e.ref)(Math.max(g,Math.min(_,t))),r=(0,e.computed)(()=>Math.round(n.value*100)),i=(0,e.computed)(()=>n.value<=g),a=(0,e.computed)(()=>n.value>=_);function o(e){n.value=Math.max(g,Math.min(_,Math.round(e*100)/100))}function s(){o(n.value+v)}function c(){o(n.value-v)}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:y}}var x=15,S=300,C=200,w=15;function T(){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),E(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),D(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),O(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*x),a=e.origWidths.left+i,o=e.origWidths.right-i;a>=S&&o>=S&&(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*x),a=t.origHeight+i;a>=C&&(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*x),a=n.origWidth+i;a>=S&&(n.origWidth=a)}}function s(i){if(e.active){e.active=!1,e.handle?.classList.remove(`dragging`),r&&k(r,e),e.handle=null;return}if(t.active){t.active=!1,t.handle?.classList.remove(`dragging`),r&&A(r,t),t.handle=null;return}n.active&&(n.active=!1,n.handle?.classList.remove(`dragging`),r&&j(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 E(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 D(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*w)}}return}}}function O(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 k(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 A(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 j(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 b}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return T}});
|
|
@@ -0,0 +1,7 @@
|
|
|
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;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
/**
|
|
3
|
+
* Find the body PM span containing `pmPos`. Scoped to body spans (which
|
|
4
|
+
* carry both pmStart and pmEnd) so HF runs in the separate PM document
|
|
5
|
+
* don't mis-resolve double-/triple-click selection.
|
|
6
|
+
*/
|
|
7
|
+
export declare function findElementAtPosition(container: HTMLElement, pmPos: number): HTMLElement | null;
|
|
8
|
+
/**
|
|
9
|
+
* Smooth-scroll the viewport so the painted element at `pmPos` is
|
|
10
|
+
* visible (48px top padding). Falls back to a CSS attribute selector
|
|
11
|
+
* when no body span carries pmPos in its [start,end] range.
|
|
12
|
+
*/
|
|
13
|
+
export declare function scrollVisiblePositionIntoView(pagesContainer: HTMLElement | null, viewport: HTMLElement | null, pmPos: number): void;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a viewport-space click coordinate to a PM document position,
|
|
16
|
+
* clamped to `doc.content.size`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolvePos(pagesContainer: HTMLElement | null, view: EditorView | null, clientX: number, clientY: number): number | null;
|
|
19
|
+
/**
|
|
20
|
+
* Double-click word selection — expand `pos` to its word bounds and
|
|
21
|
+
* hand the resulting range to `setPmSelection`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function selectWord(pagesContainer: HTMLElement | null, pos: number, setPmSelection: (from: number, to: number) => void): void;
|
|
24
|
+
/**
|
|
25
|
+
* Triple-click paragraph selection — expand `pos` to the enclosing
|
|
26
|
+
* `.layout-paragraph` element's PM range.
|
|
27
|
+
*/
|
|
28
|
+
export declare function selectParagraph(pagesContainer: HTMLElement | null, pos: number, setPmSelection: (from: number, to: number) => void): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
export declare function copyImageToClipboard(view: EditorView, pmPos: number): void;
|
|
3
|
+
export declare function blobToDataUrl(blob: Blob): Promise<string>;
|
|
4
|
+
export declare function loadImageDimensions(src: string): Promise<{
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function pasteFromClipboard(view: EditorView): Promise<void>;
|
|
9
|
+
export declare function triggerReplaceImage(view: EditorView, pmPos: number): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
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;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { EditorView } from 'prosemirror-view';
|
|
2
|
+
import { Layout } from '@eigenpal/docx-editor-core/layout-engine';
|
|
3
|
+
export interface FindInDocumentMatch {
|
|
4
|
+
paraId: string;
|
|
5
|
+
match: string;
|
|
6
|
+
before: string;
|
|
7
|
+
after: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Walk the PM doc looking for `query`. Returns up to `limit` matches —
|
|
11
|
+
* one per paragraph (rejects paragraphs where the query appears more
|
|
12
|
+
* than once, mirroring `findTextInPmParagraph`'s ambiguity guard so the
|
|
13
|
+
* LLM gets a clearer error than a silent mistarget).
|
|
14
|
+
*/
|
|
15
|
+
export declare function findInDocument(view: EditorView | null, query: string, opts?: {
|
|
16
|
+
caseSensitive?: boolean;
|
|
17
|
+
limit?: number;
|
|
18
|
+
}): FindInDocumentMatch[];
|
|
19
|
+
export interface SelectionInfo {
|
|
20
|
+
paraId: string | null;
|
|
21
|
+
selectedText: string;
|
|
22
|
+
paragraphText: string;
|
|
23
|
+
before: string;
|
|
24
|
+
after: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Describe the current selection in agent-readable form — paraId of the
|
|
28
|
+
* containing paragraph, the selected text, the full paragraph text, and
|
|
29
|
+
* the leading/trailing slices.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getSelectionInfo(view: EditorView | null): SelectionInfo | null;
|
|
32
|
+
export interface PageContent {
|
|
33
|
+
pageNumber: number;
|
|
34
|
+
text: string;
|
|
35
|
+
paragraphs: Array<{
|
|
36
|
+
paraId: string;
|
|
37
|
+
text: string;
|
|
38
|
+
styleId?: string;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Collect paragraphs visible on `pageNumber` (1-indexed) from the
|
|
43
|
+
* paginated `layout`. Dedupes by paraId so paragraphs split across page
|
|
44
|
+
* boundaries are reported once.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getPageContent(view: EditorView | null, layout: Layout | null, pageNumber: number): PageContent | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={selectionOverlay:10,decorationLayer:11,imageOverlay:15,hfInlineEditor:10,ruler:30,dropdown:100,contextMenu:1e4};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|