@eigenpal/docx-editor-vue 1.2.1 → 1.3.0

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