@eigenpal/docx-editor-vue 1.3.0 → 1.3.1

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