@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.
@@ -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 { createEmptyDoc as ne, headerFooterToProseDoc as g, proseDocToBlocks as _, toProseDoc as re } from "@eigenpal/docx-editor-core/prosemirror/conversion";
5
- import { schema as v } from "@eigenpal/docx-editor-core/prosemirror";
6
- import { EditorView as y } from "prosemirror-view";
7
- import { parseDocx as b } from "@eigenpal/docx-editor-core/docx/parser";
8
- import { fromProseDoc as x } from "@eigenpal/docx-editor-core/prosemirror/conversion/fromProseDoc";
9
- import { singletonManager as S } from "@eigenpal/docx-editor-core/prosemirror/schema";
10
- import { createSuggestionModePlugin as C, setSuggestionMode as w } from "@eigenpal/docx-editor-core/prosemirror/plugins";
11
- import { ExtensionManager as T, createStarterKit as E } from "@eigenpal/docx-editor-core/prosemirror/extensions";
12
- import { toFlowBlocks as ie } from "@eigenpal/docx-editor-core/layout-bridge/toFlowBlocks";
13
- import { measureBlocksWithFloats as D, measureParagraph as O } from "@eigenpal/docx-editor-core/layout-bridge/measuring";
14
- import { DEFAULT_TEXTBOX_MARGINS as k, DEFAULT_TEXTBOX_WIDTH as A, assertExhaustiveFlowBlock as j, layoutDocument as ae } from "@eigenpal/docx-editor-core/layout-engine";
15
- import { renderPages as oe } from "@eigenpal/docx-editor-core/layout-painter/renderPage";
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 M = 24;
20
- function N(e, t, n, r) {
20
+ var ce = 24;
21
+ function P(e, t, n, r) {
21
22
  switch (e.kind) {
22
- case "paragraph": return O(e, t, {
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, N);
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 ?? k, r = (t.width ?? A) - n.left - n.right, i = t.content.map((e) => O(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 ?? 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 ?? A,
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: j(e, "vue useDocxEditor measureBlock");
48
+ default: N(e, "vue useDocxEditor measureBlock");
48
49
  }
49
50
  }
50
- function P(e, t) {
51
- return D(e, t, N);
51
+ function F(e, t) {
52
+ return k(e, t, P);
52
53
  }
53
- function F(e) {
54
- let { hiddenContainer: n, pagesContainer: h, readOnly: D = !1, pageGap: O = M, onChange: k, onError: A, onSelectionUpdate: j, externalPlugins: N = [], syncCoordinator: F, editorMode: I, author: L } = e, R = i(null), z = i(null), B = i(null), V = r(!1), H = r(null), U = i(null), W = S;
55
- function G(e) {
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 || !R.value) return;
58
- let n = F?.getStateSeq() ?? 0;
59
- F?.onLayoutStart();
60
- let r = R.value.package?.document, i = r?.sections?.[0]?.properties ?? r?.finalSectionProperties ?? null, a = r?.finalSectionProperties ?? i, o = m(i), s = p(i), ne = m(a), g = p(a), _ = o.w - s.left - s.right, re = o.h - s.top - s.bottom, v = R.value.package?.theme ?? null, y = R.value.package?.styles ?? null;
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 = ie(e.doc, {
63
- theme: v,
64
- pageContentHeight: re
65
- }), r = P(n, _), { header: a, footer: p, firstHeader: m, firstFooter: h } = ee(R.value, i), b = {
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
- }, x = {
70
+ }, S = {
70
71
  section: "footer",
71
72
  pageSize: o,
72
73
  margins: s
73
- }, S = e.doc.attrs?.defaultTabStopTwips, C = {
74
- styles: y,
75
- theme: v,
76
- measureBlocks: P,
77
- defaultTabStopTwips: S
78
- }, w = (e, t) => {
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 = ce(e);
81
- return n ? d(n.state.doc, _, t, C) : f(e, _, t, C);
82
- }, T = w(a, b), E = w(p, x), D = i?.titlePg === !0, k = D ? w(m, b) : void 0, A = D ? w(h, x) : void 0, j = s.header ?? 48, M = s.footer ?? 48, N = s.top - j, F = s.bottom - M, I = (e) => e ? e.visualBottom ?? e.height : 0, L = (e) => e ? Math.max((e.visualBottom ?? e.height) - (e.visualTop ?? 0), e.height) : 0, z = Math.max(I(T), I(k)), B = Math.max(L(E), L(A)), V = z > N, H = B > F;
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, j + z)), H && (t.bottom = Math.max(e.bottom, M + B)), t;
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), g = e(g);
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 W = {
96
+ let U = {
96
97
  pageSize: o,
97
98
  margins: s,
98
- finalPageSize: ne,
99
- finalMargins: g,
100
- pageGap: O
101
- }, G = u(n), K = G.length > 0 && !!R.value.package?.footnotes, q = ae(n, r, W), J = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map();
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(R.value.package.footnotes, G, _, {
104
- styles: y,
105
- theme: v,
106
- measureBlocks: P,
107
- defaultTabStopTwips: S
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: W,
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
- U.value = q;
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, R.value) : void 0;
129
- oe(q.pages, t, {
130
- pageGap: O,
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: v,
135
- headerContent: T,
136
- footerContent: E,
135
+ theme: y,
136
+ headerContent: E,
137
+ footerContent: D,
137
138
  firstPageHeaderContent: k,
138
- firstPageFooterContent: A,
139
- titlePage: D,
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), A?.(e instanceof Error ? e : Error(String(e)));
146
+ console.error("[useDocxEditor] Layout pipeline error:", e), M?.(e instanceof Error ? e : Error(String(e)));
145
147
  } finally {
146
- F?.onLayoutComplete(n);
148
+ I?.onLayoutComplete(n);
147
149
  }
148
150
  }
149
- function K() {
151
+ function q() {
150
152
  let e = n.value;
151
153
  if (!e) return;
152
- let t = R.value ? re(R.value, { styles: R.value.package?.styles ?? void 0 }) : ne(), r = [
153
- C(!1),
154
- ...N,
155
- ...W.getPlugins() ?? []
156
- ], i = s.create({
157
- doc: t,
158
- schema: W.getSchema(),
159
- plugins: r
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
- B.value = i;
162
- let o = new y(e, {
163
- state: i,
164
- editable: () => !a(D),
164
+ V.value = l;
165
+ let u = new b(e, {
166
+ state: l,
167
+ editable: () => !a(k),
165
168
  dispatchTransaction(e) {
166
- if (!o) return;
167
- let t = o.state.apply(e);
168
- if (o.updateState(t), B.value = t, e.docChanged) {
169
- F?.incrementStateSeq(), G(t);
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 (R.value) {
172
- let e = x(t.doc, R.value);
173
- R.value = e, k?.(e);
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
- F?.requestRender(), j?.();
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
- z.value = o, V.value = !0, G(i), F?.requestRender();
188
+ B.value = u, H.value = !0, K(l), I?.requestRender();
183
189
  }
184
190
  o([
185
- () => a(I),
186
191
  () => a(L),
187
- z
192
+ () => a(R),
193
+ B
188
194
  ], ([e, t, n]) => {
189
- n && w(e === "suggesting", n.state, n.dispatch, t);
195
+ n && E(e === "suggesting", n.state, n.dispatch, t);
190
196
  }, { immediate: !0 });
191
- function q() {
192
- z.value &&= (z.value.destroy(), null), B.value = null, V.value = !1;
197
+ function J() {
198
+ B.value &&= (B.value.destroy(), null), V.value = null, H.value = !1;
193
199
  }
194
- let J = { current: null }, Y = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map();
195
- function Z() {
196
- if (J.current && J.current.isConnected) return J.current;
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), J.current = e, 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 se(e) {
201
- let t = R.value?.package;
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 ce(e) {
212
- let t = se(e);
213
- return t ? Y.get(t) ?? null : null;
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 = R.value?.package, t = Z(), n = /* @__PURE__ */ new Set();
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 Y) n.has(e) || (t.destroy(), t.dom.parentElement?.remove(), X.get(e)?.destroy(), X.delete(e), Y.delete(e));
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 (Y.has(o)) continue;
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 T(E());
227
- l.buildSchema(), l.initializeRuntime(), X.set(o, l);
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 = g(n.content, {
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: v,
237
- plugins: l.getPlugins()
238
- }), p = c, m = new y(u, {
239
- state: f,
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 = m.state.apply(e);
242
- if (m.updateState(t), e.docChanged) {
243
- let e = R.value?.package, n = (p === "header" ? e?.headers : e?.footers)?.get(o);
244
- n && (n.content = _(t.doc));
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 && B.value && G(B.value), le.value?.(o, m, e.docChanged);
252
+ e.docChanged && V.value && K(V.value), fe.value?.(o, h, e.docChanged);
247
253
  }
248
254
  });
249
- Y.set(o, m);
255
+ X.set(o, h);
250
256
  }
251
257
  }
252
258
  function $() {
253
- for (let e of Y.values()) e.destroy(), e.dom.parentElement?.remove();
254
- Y.clear();
255
- for (let e of X.values()) e.destroy();
256
- X.clear(), J.current &&= (J.current.remove(), null);
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 le = { value: null };
259
- function ue(e) {
260
- le.value = e;
264
+ let fe = { value: null };
265
+ function pe(e) {
266
+ fe.value = e;
261
267
  }
262
- async function de(e) {
263
- H.value = null, V.value = !1;
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, R.value = await b(t), q(), $(), K(), Q();
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
- H.value = t.message, A?.(t);
275
+ U.value = t.message, M?.(t);
270
276
  }
271
277
  }
272
- function fe(e) {
273
- H.value = null, R.value = e, q(), $(), K(), Q();
278
+ function he(e) {
279
+ U.value = null, z.value = e, J(), $(), q(), Q();
274
280
  }
275
- async function pe() {
276
- if (!z.value || !R.value) return null;
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 = x(z.value.state.doc, R.value), a = i.package.document?.comments ?? [];
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 me() {
283
- z.value?.focus();
288
+ function _e() {
289
+ B.value?.focus();
284
290
  }
285
- function he() {
286
- q(), $(), R.value = null;
291
+ function ve() {
292
+ J(), $(), z.value = null;
287
293
  }
288
- function ge() {
289
- return R.value;
294
+ function ye() {
295
+ return z.value;
290
296
  }
291
297
  t(() => {
292
- he();
298
+ ve();
293
299
  });
294
- function _e() {
295
- return W.getCommands();
300
+ function be() {
301
+ return G.getCommands();
296
302
  }
297
303
  return {
298
- editorView: z,
299
- editorState: B,
300
- isReady: V,
301
- parseError: H,
302
- layout: U,
303
- loadBuffer: de,
304
- loadDocument: fe,
305
- save: pe,
306
- focus: me,
307
- destroy: he,
308
- getDocument: ge,
309
- getCommands: _e,
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
- z.value && G(z.value.state);
317
+ B.value && K(B.value.state);
312
318
  },
313
- getHfPmView: ce,
319
+ getHfPmView: de,
314
320
  syncHfPMs: Q,
315
- setHfTransactionListener: ue,
321
+ setHfTransactionListener: pe,
316
322
  setDocument(e) {
317
- R.value = e;
323
+ z.value = e;
318
324
  }
319
325
  };
320
326
  }
321
327
  //#endregion
322
328
  //#region src/composables/useZoom.ts
323
- var I = .25, L = 4, R = .1, z = [
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 B(i = 1) {
335
- let a = r(Math.max(I, Math.min(L, i))), o = e(() => Math.round(a.value * 100)), s = e(() => a.value <= I), c = e(() => a.value >= L);
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(I, Math.min(L, Math.round(e * 100) / 100));
343
+ a.value = Math.max(L, Math.min(R, Math.round(e * 100) / 100));
338
344
  }
339
345
  function u() {
340
- l(a.value + R);
346
+ l(a.value + z);
341
347
  }
342
348
  function d() {
343
- l(a.value - R);
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: z
375
+ ZOOM_PRESETS: B
370
376
  };
371
377
  }
372
378
  //#endregion
373
379
  //#region src/composables/useTableResize.ts
374
- var V = 15, H = 300, U = 200, W = 15;
375
- function G() {
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), K(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), q(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), J(a, n), !0) : !1 : !1;
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 * V), a = e.origWidths.left + i, o = e.origWidths.right - i;
415
- a >= H && o >= H && (e.origWidths = {
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 * V), a = t.origHeight + i;
426
- a >= U && (t.origHeight = 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 * V), a = n.origWidth + i;
434
- a >= H && (n.origWidth = 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 && Y(r, e), e.handle = null;
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 && X(r, t), t.handle = null;
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 && Z(r, n), n.handle = null);
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 K(e, t) {
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 q(e, t, n) {
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 * W);
492
+ t.origHeight = Math.round(r * G);
487
493
  }
488
494
  }
489
495
  return;
490
496
  }
491
497
  }
492
498
  }
493
- function J(e, t) {
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 Y(e, t) {
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 X(e, t) {
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 Z(e, t) {
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 { B as n, F as r, G as t };
583
+ export { V as n, I as r, K as t };