@bireturn/word-editor 1.0.3 → 1.0.5

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,13 +1,13 @@
1
- var rn = Object.defineProperty;
2
- var cn = (i, e, t) => e in i ? rn(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var V = (i, e, t) => cn(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { computed as ke, ref as se, onMounted as ct, onUnmounted as et, openBlock as f, createElementBlock as p, normalizeStyle as j, createElementVNode as ce, Fragment as Y, renderList as oe, normalizeClass as Ee, createBlock as Fe, resolveDynamicComponent as Ze, toDisplayString as ie, unref as Ae, createCommentVNode as ve, render as Ot, h as dn, defineComponent as un, getCurrentInstance as hn, watch as Be, nextTick as xe, createVNode as J, createTextVNode as Le, isVNode as fn, renderSlot as gn, resolveComponent as pn, withCtx as lt, reactive as Bt, provide as vn, inject as mn } from "vue";
5
- import { DynamicScroller as yn, DynamicScrollerItem as _n } from "vue-virtual-scroller";
6
- import { ChevronRight as Ht, MoreHorizontal as yt, Download as at, Upload as bn, Save as xn, RotateCcw as kn, History as wn, Settings as Cn, Info as Mn, Globe as In, Lock as En, Share as Sn, ShieldCheck as Tn, Search as Fn, Filter as An, SortDesc as Pn, SortAsc as $n, Minus as Ln, Plus as _t, Eye as bt, FileText as ot, Grid as Rn, Type as xt, FileDown as kt, Layers as wt, Edit as On, Move as Bn, Copy as Hn, Trash2 as Ct, Clipboard as Mt, PlusCircle as It, ArrowDown as Et, Navigation as St, ChevronDown as Dn, PanelLeftOpen as zn, ListTree as Nn, PanelLeftClose as Vn } from "lucide-vue-next";
7
- const jn = { class: "we-vt-context-menu--option-wrapper modern-menu-wrapper" }, Kn = ["onMouseenter", "onMouseleave"], qn = ["onClick"], Wn = { class: "we-vt-context-menu--link-content menu-label" }, Un = {
1
+ var yn = Object.defineProperty;
2
+ var bn = (t, e, n) => e in t ? yn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var D = (t, e, n) => bn(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { computed as ae, ref as te, onMounted as ft, onUnmounted as lt, openBlock as u, createElementBlock as v, normalizeStyle as N, createElementVNode as ee, Fragment as U, renderList as Z, normalizeClass as Ie, createBlock as ke, resolveDynamicComponent as nt, toDisplayString as J, unref as z, createCommentVNode as ue, render as Vt, h as _n, defineComponent as xn, getCurrentInstance as kn, watch as Ve, nextTick as be, createVNode as q, createTextVNode as He, isVNode as wn, renderSlot as Cn, resolveComponent as Mn, inject as jt, withCtx as Ke, provide as Kt, createSlots as In, reactive as qt } from "vue";
5
+ import { DynamicScroller as En, DynamicScrollerItem as Sn } from "vue-virtual-scroller";
6
+ import { ChevronRight as Ut, MoreHorizontal as kt, Download as st, Upload as Tn, Save as Fn, RotateCcw as An, History as Pn, Settings as $n, Info as Ln, Globe as Rn, Lock as Hn, Share as On, ShieldCheck as Bn, Search as Dn, Filter as Nn, SortDesc as zn, SortAsc as Vn, Minus as jn, Plus as wt, Eye as Ct, FileText as rt, Grid as Kn, Type as Mt, FileDown as It, Layers as Et, Edit as qn, Move as Un, Copy as Wn, Trash2 as St, Clipboard as Tt, PlusCircle as Ft, ArrowDown as At, Navigation as Pt, ChevronDown as Gn, PanelLeftOpen as Jn, ListTree as Xn, PanelLeftClose as Yn } from "lucide-vue-next";
7
+ const Zn = { class: "we-vt-context-menu--option-wrapper modern-menu-wrapper" }, Qn = ["onMouseenter", "onMouseleave"], ei = ["onClick"], ti = { class: "we-vt-context-menu--link-content menu-label" }, ni = {
8
8
  key: 0,
9
9
  class: "we-vt-context-menu--submenu modern-submenu"
10
- }, Gn = ["onClick"], Jn = { class: "we-vt-context-menu--link-content submenu-label" }, Xn = {
10
+ }, ii = ["onClick"], li = { class: "we-vt-context-menu--link-content submenu-label" }, oi = {
11
11
  __name: "ContextMenu",
12
12
  props: {
13
13
  // 事件
@@ -29,258 +29,258 @@ const jn = { class: "we-vt-context-menu--option-wrapper modern-menu-wrapper" },
29
29
  }
30
30
  },
31
31
  emits: ["close", "menuClick"],
32
- setup(i, { emit: e }) {
33
- const t = e, a = i, o = ke(() => {
34
- var W, B;
32
+ setup(t, { emit: e }) {
33
+ const n = e, l = t, o = ae(() => {
34
+ var R, T;
35
35
  return {
36
- left: `${(W = a.e) == null ? void 0 : W.pageX}px`,
37
- top: `${(B = a.e) == null ? void 0 : B.pageY}px`
36
+ left: `${(R = l.e) == null ? void 0 : R.pageX}px`,
37
+ top: `${(T = l.e) == null ? void 0 : T.pageY}px`
38
38
  };
39
- }), u = se([]), P = se(null);
40
- let S = null;
41
- const z = se(), A = (W, B, T) => {
42
- if (W.children && W.children.length > 0) {
43
- B && B.preventDefault() && B.stopPropagation();
39
+ }), r = te([]), y = te(null);
40
+ let s = null;
41
+ const m = te(), h = (R, T, f) => {
42
+ if (R.children && R.children.length > 0) {
43
+ T && T.preventDefault() && T.stopPropagation();
44
44
  return;
45
45
  }
46
- W.disabled || (T ? t("menuClick", { ...W, parent: T.code }, a.row) : t("menuClick", W, a.row)), B && B.preventDefault() && B.stopPropagation();
47
- }, Z = (W) => {
48
- let B = W.target;
49
- for (; B && B != z.value; )
50
- B = B.parentNode;
51
- B != z.value && t("close");
52
- }, N = (W, B) => {
53
- W.currentTarget.classList.add("link--active"), S && (clearTimeout(S), S = null), B.children && B.children.length > 0 ? P.value = B.code : S = setTimeout(() => {
54
- P.value = null;
46
+ R.disabled || (f ? n("menuClick", { ...R, parent: f.code }, l.row) : n("menuClick", R, l.row)), T && T.preventDefault() && T.stopPropagation();
47
+ }, I = (R) => {
48
+ let T = R.target;
49
+ for (; T && T != m.value; )
50
+ T = T.parentNode;
51
+ T != m.value && n("close");
52
+ }, S = (R, T) => {
53
+ R.currentTarget.classList.add("link--active"), s && (clearTimeout(s), s = null), T.children && T.children.length > 0 ? y.value = T.code : s = setTimeout(() => {
54
+ y.value = null;
55
55
  }, 100);
56
- }, q = (W, B) => {
57
- W.currentTarget.classList.remove("link--active"), B.children && B.children.length > 0 && (S = setTimeout(() => {
58
- P.value === B.code && (P.value = null);
56
+ }, L = (R, T) => {
57
+ R.currentTarget.classList.remove("link--active"), T.children && T.children.length > 0 && (s = setTimeout(() => {
58
+ y.value === T.code && (y.value = null);
59
59
  }, 300));
60
- }, Q = (W) => {
61
- S && (clearTimeout(S), S = null), W.currentTarget.classList.add("link--active");
62
- }, ee = (W) => {
63
- W.currentTarget.classList.remove("link--active");
64
- }, be = (W) => {
65
- const B = W.code || "", T = (W.name || "").toLowerCase(), K = {
60
+ }, x = (R) => {
61
+ s && (clearTimeout(s), s = null), R.currentTarget.classList.add("link--active");
62
+ }, K = (R) => {
63
+ R.currentTarget.classList.remove("link--active");
64
+ }, ne = (R) => {
65
+ const T = R.code || "", f = (R.name || "").toLowerCase(), E = {
66
66
  // 添加操作 - 根据具体类型使用不同图标
67
- "add-current": St,
67
+ "add-current": Pt,
68
68
  // 添加(当前位置)
69
- "add-next": Et,
69
+ "add-next": At,
70
70
  // 添加(下一行)
71
- "add-child": It,
71
+ "add-child": Ft,
72
72
  // 添加(子节点)
73
73
  // 基本操作
74
- paste: Mt,
74
+ paste: Tt,
75
75
  // 粘贴
76
- delete: Ct,
76
+ delete: St,
77
77
  // 删除
78
- copy: Hn,
78
+ copy: Wn,
79
79
  // 复制
80
- cut: Bn,
80
+ cut: Un,
81
81
  // 剪切
82
- edit: On,
82
+ edit: qn,
83
83
  // 编辑
84
84
  // 导出操作 - 根据范围使用不同图标
85
- export_part_section: wt,
85
+ export_part_section: Et,
86
86
  // 导出此节点所在节
87
- export_part_chapter: kt,
87
+ export_part_chapter: It,
88
88
  // 导出此节点所在章
89
- export_full: at,
89
+ export_full: st,
90
90
  // 完整导出
91
91
  // 文件格式
92
- pdf: ot,
92
+ pdf: rt,
93
93
  // PDF格式
94
- word: xt,
94
+ word: Mt,
95
95
  // WORD格式
96
- excel: Rn,
96
+ excel: Kn,
97
97
  // Excel格式
98
- txt: ot,
98
+ txt: rt,
99
99
  // 文本格式
100
100
  // 视图操作
101
- view: bt,
101
+ view: Ct,
102
102
  // 查看
103
- preview: bt,
103
+ preview: Ct,
104
104
  // 预览
105
- expand: _t,
105
+ expand: wt,
106
106
  // 展开
107
- collapse: Ln,
107
+ collapse: jn,
108
108
  // 折叠
109
109
  // 排序和过滤
110
- "sort-asc": $n,
110
+ "sort-asc": Vn,
111
111
  // 升序
112
- "sort-desc": Pn,
112
+ "sort-desc": zn,
113
113
  // 降序
114
- filter: An,
114
+ filter: Nn,
115
115
  // 过滤
116
- search: Fn,
116
+ search: Dn,
117
117
  // 搜索
118
118
  // 权限操作
119
- permission: Tn,
119
+ permission: Bn,
120
120
  // 权限设置
121
- share: Sn,
121
+ share: On,
122
122
  // 分享
123
- lock: En,
123
+ lock: Hn,
124
124
  // 锁定
125
- unlock: In,
125
+ unlock: Rn,
126
126
  // 解锁
127
127
  // 其他操作
128
- info: Mn,
128
+ info: Ln,
129
129
  // 信息
130
- settings: Cn,
130
+ settings: $n,
131
131
  // 设置
132
- history: wn,
132
+ history: Pn,
133
133
  // 历史
134
- refresh: kn,
134
+ refresh: An,
135
135
  // 刷新
136
- save: xn,
136
+ save: Fn,
137
137
  // 保存
138
- upload: bn,
138
+ upload: Tn,
139
139
  // 上传
140
- download: at,
140
+ download: st,
141
141
  // 下载
142
- more: yt
142
+ more: kt
143
143
  // 更多
144
144
  };
145
- return K[B] ? K[B] : T.includes("添加") || T.includes("add") ? T.includes("当前") || T.includes("current") ? St : T.includes("下") || T.includes("next") ? Et : T.includes("子") || T.includes("child") ? It : _t : T.includes("导出") || T.includes("export") ? T.includes("节") || T.includes("section") ? wt : T.includes("章") || T.includes("chapter") ? kt : at : T.includes("粘贴") || T.includes("paste") ? Mt : T.includes("删除") || T.includes("delete") ? Ct : T.includes("pdf") ? ot : T.includes("word") ? xt : yt;
145
+ return E[T] ? E[T] : f.includes("添加") || f.includes("add") ? f.includes("当前") || f.includes("current") ? Pt : f.includes("下") || f.includes("next") ? At : f.includes("子") || f.includes("child") ? Ft : wt : f.includes("导出") || f.includes("export") ? f.includes("节") || f.includes("section") ? Et : f.includes("章") || f.includes("chapter") ? It : st : f.includes("粘贴") || f.includes("paste") ? Tt : f.includes("删除") || f.includes("delete") ? St : f.includes("pdf") ? rt : f.includes("word") ? Mt : kt;
146
146
  };
147
- return ct(() => {
148
- var W, B, T, K, y, _, r;
149
- (W = a.menuConfig) != null && W.visibleMethod && typeof ((B = a.menuConfig) == null ? void 0 : B.visibleMethod) == "function" && ((y = a.menuConfig) == null || y.visibleMethod({
150
- options: (K = (T = a.menuConfig) == null ? void 0 : T.body) == null ? void 0 : K.options,
151
- row: a.row
152
- })), u.value = (((r = (_ = a.menuConfig) == null ? void 0 : _.body) == null ? void 0 : r.options) || []).flat(), document.addEventListener("click", Z, !0);
153
- }), et(() => {
154
- document.removeEventListener("click", Z, !0);
155
- }), (W, B) => (f(), p("div", {
147
+ return ft(() => {
148
+ var R, T, f, E, B, A, P;
149
+ (R = l.menuConfig) != null && R.visibleMethod && typeof ((T = l.menuConfig) == null ? void 0 : T.visibleMethod) == "function" && ((B = l.menuConfig) == null || B.visibleMethod({
150
+ options: (E = (f = l.menuConfig) == null ? void 0 : f.body) == null ? void 0 : E.options,
151
+ row: l.row
152
+ })), r.value = (((P = (A = l.menuConfig) == null ? void 0 : A.body) == null ? void 0 : P.options) || []).flat(), document.addEventListener("click", I, !0);
153
+ }), lt(() => {
154
+ document.removeEventListener("click", I, !0);
155
+ }), (R, T) => (u(), v("div", {
156
156
  class: "we-vt-table--context-menu-wrapper virtual-table-menu modern-virtual-menu",
157
157
  ref_key: "contextMenuRef",
158
- ref: z,
159
- style: j([{ display: "inline-block" }, o.value])
158
+ ref: m,
159
+ style: N([{ display: "inline-block" }, o.value])
160
160
  }, [
161
- ce("ul", jn, [
162
- (f(!0), p(Y, null, oe(u.value, (T) => (f(), p("li", {
163
- class: Ee({
164
- "link--disabled": T.disabled,
165
- "has-children": T.children && T.children.length > 0,
161
+ ee("ul", Zn, [
162
+ (u(!0), v(U, null, Z(r.value, (f) => (u(), v("li", {
163
+ class: Ie({
164
+ "link--disabled": f.disabled,
165
+ "has-children": f.children && f.children.length > 0,
166
166
  "modern-menu-item": !0
167
167
  }),
168
- key: T.code,
169
- onMouseenter: (K) => N(K, T),
170
- onMouseleave: (K) => q(K, T)
168
+ key: f.code,
169
+ onMouseenter: (E) => S(E, f),
170
+ onMouseleave: (E) => L(E, f)
171
171
  }, [
172
- ce("a", {
172
+ ee("a", {
173
173
  class: "we-vt-context-menu--link modern-menu-link",
174
- onClick: (K) => A(T, K)
174
+ onClick: (E) => h(f, E)
175
175
  }, [
176
- (f(), Fe(Ze(be(T)), {
176
+ (u(), ke(nt(ne(f)), {
177
177
  size: 16,
178
178
  class: "menu-icon"
179
179
  })),
180
- ce("span", Wn, ie(T.name), 1),
181
- T.children && T.children.length > 0 ? (f(), Fe(Ae(Ht), {
180
+ ee("span", ti, J(f.name), 1),
181
+ f.children && f.children.length > 0 ? (u(), ke(z(Ut), {
182
182
  key: 0,
183
183
  size: 14,
184
184
  class: "submenu-arrow"
185
- })) : ve("", !0)
186
- ], 8, qn),
187
- T.children && T.children.length > 0 && P.value === T.code ? (f(), p("ul", Un, [
188
- (f(!0), p(Y, null, oe(T.children, (K) => (f(), p("li", {
189
- key: K.code,
190
- class: Ee({
191
- "link--disabled": K.disabled,
185
+ })) : ue("", !0)
186
+ ], 8, ei),
187
+ f.children && f.children.length > 0 && y.value === f.code ? (u(), v("ul", ni, [
188
+ (u(!0), v(U, null, Z(f.children, (E) => (u(), v("li", {
189
+ key: E.code,
190
+ class: Ie({
191
+ "link--disabled": E.disabled,
192
192
  "modern-submenu-item": !0
193
193
  }),
194
- onMouseenter: Q,
195
- onMouseleave: ee
194
+ onMouseenter: x,
195
+ onMouseleave: K
196
196
  }, [
197
- ce("a", {
197
+ ee("a", {
198
198
  class: "we-vt-context-menu--link modern-submenu-link",
199
- onClick: (y) => A(K, y, T)
199
+ onClick: (B) => h(E, B, f)
200
200
  }, [
201
- (f(), Fe(Ze(be(K)), {
201
+ (u(), ke(nt(ne(E)), {
202
202
  size: 14,
203
203
  class: "submenu-icon"
204
204
  })),
205
- ce("span", Jn, ie(K.name), 1)
206
- ], 8, Gn)
205
+ ee("span", li, J(E.name), 1)
206
+ ], 8, ii)
207
207
  ], 34))), 128))
208
- ])) : ve("", !0)
209
- ], 42, Kn))), 128))
208
+ ])) : ue("", !0)
209
+ ], 42, Qn))), 128))
210
210
  ])
211
211
  ], 4));
212
212
  }
213
- }, Dt = Symbol("component_container");
214
- function Yn(i, e, t) {
215
- const a = dn(i, { ...e }, t), o = document.createElement("div");
216
- return document.body.appendChild(o), a[Dt] = o, Ot(a, o), a.component;
213
+ }, Wt = Symbol("component_container");
214
+ function ai(t, e, n) {
215
+ const l = _n(t, { ...e }, n), o = document.createElement("div");
216
+ return document.body.appendChild(o), l[Wt] = o, Vt(l, o), l.component;
217
217
  }
218
- function Zn(i) {
219
- var t;
220
- const e = i.vnode[Dt];
221
- Ot(null, e), e != null && e.checkVisibility && (e != null && e.checkVisibility()) && ((t = document.body) == null || t.removeChild(e));
218
+ function si(t) {
219
+ var n;
220
+ const e = t.vnode[Wt];
221
+ Vt(null, e), e != null && e.checkVisibility && (e != null && e.checkVisibility()) && ((n = document.body) == null || n.removeChild(e));
222
222
  }
223
- let zt;
224
- const Qn = (i) => {
225
- zt = Yn(Xn, i, null);
226
- }, ei = function(i) {
227
- const e = i.onClose;
228
- return i.onClose = () => {
229
- e && e.call(), Zn(zt);
230
- }, Qn(i), i;
223
+ let Gt;
224
+ const ri = (t) => {
225
+ Gt = ai(oi, t, null);
226
+ }, ci = function(t) {
227
+ const e = t.onClose;
228
+ return t.onClose = () => {
229
+ e && e.call(), si(Gt);
230
+ }, ri(t), t;
231
231
  };
232
- function ti(i, e, t) {
233
- const a = (t == null ? void 0 : t.keyField) || (t == null ? void 0 : t.rowField) || "node_id", o = (t == null ? void 0 : t.parentField) || "parent_id", u = (t == null ? void 0 : t.parentField) || "order";
234
- if (!(i != null && i.length))
235
- return i;
236
- const P = {};
237
- i.forEach((Z) => {
238
- const N = Z[o];
239
- P[N] || (P[N] = []), P[N].push(Z);
232
+ function di(t, e, n) {
233
+ const l = (n == null ? void 0 : n.keyField) || (n == null ? void 0 : n.rowField) || "node_id", o = (n == null ? void 0 : n.parentField) || "parent_id", r = (n == null ? void 0 : n.parentField) || "order";
234
+ if (!(t != null && t.length))
235
+ return t;
236
+ const y = {};
237
+ t.forEach((I) => {
238
+ const S = I[o];
239
+ y[S] || (y[S] = []), y[S].push(I);
240
240
  });
241
- function S(Z) {
242
- const N = P[Z] || [];
243
- N.sort(
244
- (Q, ee) => Q[u] && ee[u] ? Q[u] - ee[u] : 0
241
+ function s(I) {
242
+ const S = y[I] || [];
243
+ S.sort(
244
+ (x, K) => x[r] && K[r] ? x[r] - K[r] : 0
245
245
  );
246
- const q = [];
247
- return N.forEach((Q) => {
248
- q.push(Q), q.push(...S(Q[a]));
249
- }), q;
246
+ const L = [];
247
+ return S.forEach((x) => {
248
+ L.push(x), L.push(...s(x[l]));
249
+ }), L;
250
250
  }
251
- let z = [];
251
+ let m = [];
252
252
  if (Array.isArray(e))
253
- z = e;
253
+ m = e;
254
254
  else {
255
- const Z = new Set(i.map((Q) => Q[a])), N = i.filter((Q) => !Z.has(Q[o]));
256
- if (N.length === 0)
255
+ const I = new Set(t.map((x) => x[l])), S = t.filter((x) => !I.has(x[o]));
256
+ if (S.length === 0)
257
257
  throw new Error("无法确定根节点:可能存在循环引用或数据不完整");
258
- const q = {};
259
- N.forEach((Q) => {
260
- const ee = Q[o];
261
- q[ee] = (q[ee] || 0) + 1;
262
- }), z = Object.entries(q).map(([Q]) => Q);
263
- }
264
- let A = [];
265
- return z.forEach((Z) => {
266
- A = A.concat(S(Z));
267
- }), A;
258
+ const L = {};
259
+ S.forEach((x) => {
260
+ const K = x[o];
261
+ L[K] = (L[K] || 0) + 1;
262
+ }), m = Object.entries(L).map(([x]) => x);
263
+ }
264
+ let h = [];
265
+ return m.forEach((I) => {
266
+ h = h.concat(s(I));
267
+ }), h;
268
268
  }
269
- function Tt(i, e, t) {
270
- let a;
271
- for (; i && i.nodeType && i !== document; ) {
272
- if (i.className && i.className.split && i.className.split(" ").indexOf(e) > -1)
273
- return a = i, a;
274
- if (i === t)
269
+ function $t(t, e, n) {
270
+ let l;
271
+ for (; t && t.nodeType && t !== document; ) {
272
+ if (t.className && t.className.split && t.className.split(" ").indexOf(e) > -1)
273
+ return l = t, l;
274
+ if (t === n)
275
275
  return null;
276
- i = i.parentNode;
276
+ t = t.parentNode;
277
277
  }
278
- return a;
278
+ return l;
279
279
  }
280
- function ni(i) {
281
- return typeof i == "function" || Object.prototype.toString.call(i) === "[object Object]" && !fn(i);
280
+ function ui(t) {
281
+ return typeof t == "function" || Object.prototype.toString.call(t) === "[object Object]" && !wn(t);
282
282
  }
283
- const ii = /* @__PURE__ */ un({
283
+ const hi = /* @__PURE__ */ xn({
284
284
  name: "VirtualTable",
285
285
  props: {
286
286
  data: {
@@ -338,8 +338,14 @@ const ii = /* @__PURE__ */ un({
338
338
  // 是否显示内容区边框
339
339
  pageBorderPadding: 5,
340
340
  // 内容区边框内边距(px)
341
- pageBorderStyle: "1px solid #000"
341
+ pageBorderStyle: "1px solid #000",
342
342
  // 内容区边框样式
343
+ headerHeight: 0,
344
+ // 页眉占用高度(px),从内容区高度中扣除
345
+ footerHeight: 0,
346
+ // 页脚占用高度(px),从内容区高度中扣除
347
+ showPageNumber: !0
348
+ // 是否显示默认页码
343
349
  })
344
350
  },
345
351
  // 页面数据映射 - key是页码,value是node_id数组,用于和pdf分页对应
@@ -349,210 +355,212 @@ const ii = /* @__PURE__ */ un({
349
355
  }
350
356
  },
351
357
  emits: ["current-change", "menu-click", "edit-activated", "edit-closed", "scroll-end", "selection-change"],
352
- setup(i, {
358
+ setup(t, {
353
359
  emit: e,
354
- slots: t,
355
- expose: a
360
+ slots: n,
361
+ expose: l
356
362
  }) {
357
- var vt;
358
- const o = hn(), u = se(), P = se(!1), S = se(null), z = se(null), A = se([]);
359
- let Z = /* @__PURE__ */ new Map();
360
- const N = /* @__PURE__ */ new Map();
361
- se(0);
362
- const q = se([]);
363
- se([]);
364
- const Q = se(/* @__PURE__ */ new Set()), ee = se(/* @__PURE__ */ new Set()), be = se(null), W = 2, B = /* @__PURE__ */ new WeakMap(), T = se(null), K = se(""), y = /* @__PURE__ */ new Set(), _ = ke(() => {
363
+ var xt;
364
+ const o = kn(), r = te(), y = te(!1), s = te(null), m = te(null), h = te([]);
365
+ let I = /* @__PURE__ */ new Map();
366
+ const S = /* @__PURE__ */ new Map();
367
+ te(0);
368
+ const L = te([]);
369
+ te([]);
370
+ const x = te(/* @__PURE__ */ new Set()), K = te(/* @__PURE__ */ new Set()), ne = te(null), R = 2, T = /* @__PURE__ */ new WeakMap(), f = te(null), E = te(""), B = /* @__PURE__ */ new Set(), A = ae(() => {
365
371
  try {
366
- return Array.isArray(A.value) ? A.value : [];
372
+ return Array.isArray(h.value) ? h.value : [];
367
373
  } catch {
368
374
  return [];
369
375
  }
370
- }), r = (n) => {
371
- var g, d, h;
372
- if (!n) return 30;
373
- if (n.height) return n.height;
374
- const l = `${n.content_type}_${((g = n.content) == null ? void 0 : g.length) || 0}_${((d = n.title) == null ? void 0 : d.length) || 0}_${n._editing ? 1 : 0}`;
375
- if (B.has(n)) {
376
- const x = B.get(n);
377
- if (x.key === l)
378
- return x.height;
376
+ }), P = (i) => {
377
+ var p, d, g;
378
+ if (!i) return 30;
379
+ if (i.height) return i.height;
380
+ const a = `${i.content_type}_${((p = i.content) == null ? void 0 : p.length) || 0}_${((d = i.title) == null ? void 0 : d.length) || 0}_${i._editing ? 1 : 0}`;
381
+ if (T.has(i)) {
382
+ const w = T.get(i);
383
+ if (w.key === a)
384
+ return w.height;
379
385
  }
380
- let s = 30;
381
- switch (n.content_type) {
386
+ let c = 30;
387
+ switch (i.content_type) {
382
388
  case "image":
383
- s = 150;
389
+ c = 150;
384
390
  break;
385
391
  case "table-row":
386
- s = n.rowHeight || 35;
392
+ c = i.rowHeight || 35;
387
393
  break;
388
394
  case "table":
389
- const w = ((n.content || "").match(/<tr/g) || []).length;
390
- s = Math.max(100, w * 35 + 30);
395
+ const k = ((i.content || "").match(/<tr/g) || []).length;
396
+ c = Math.max(100, k * 35 + 30);
391
397
  break;
392
398
  case "flowchart":
393
- s = 200;
399
+ c = 200;
394
400
  break;
395
401
  default: {
396
- const m = (n.content || "").length, v = (n.title || "").length, k = m + v, L = ((h = (n.content || "").match(/[\u4e00-\u9fa5]/g)) == null ? void 0 : h.length) || 0, R = k - L, F = L * 12 + R * 6, H = Math.max(1, Math.ceil(F / 760));
397
- s = Math.max(20, H * 18), n._editing && (s += 20);
402
+ const b = (i.content || "").length, _ = (i.title || "").length, C = b + _, F = ((g = (i.content || "").match(/[\u4e00-\u9fa5]/g)) == null ? void 0 : g.length) || 0, O = C - F, M = F * 12 + O * 6, $ = Math.max(1, Math.ceil(M / 760));
403
+ c = Math.max(20, $ * 18), i._editing && (c += 20);
398
404
  break;
399
405
  }
400
406
  }
401
- return B.set(n, {
402
- key: l,
403
- height: s
404
- }), s;
405
- }, D = ke(() => {
406
- if (_.value.length === 0) return 30;
407
- const n = _.value.slice(0, Math.min(100, _.value.length));
408
- if (n.length === 0) return 30;
409
- const l = n.reduce((g, d) => g + r(d), 0) / n.length, s = Math.max(20, Math.floor(l * 0.6));
410
- return Math.min(s, 60);
407
+ return T.set(i, {
408
+ key: a,
409
+ height: c
410
+ }), c;
411
+ }, Q = ae(() => {
412
+ if (A.value.length === 0) return 30;
413
+ const i = A.value.slice(0, Math.min(100, A.value.length));
414
+ if (i.length === 0) return 30;
415
+ const a = i.reduce((p, d) => p + P(d), 0) / i.length, c = Math.max(20, Math.floor(a * 0.6));
416
+ return Math.min(c, 60);
411
417
  });
412
- let c;
413
- const $ = (n, l) => {
418
+ let le;
419
+ const ot = (i, a) => {
414
420
  e("menu-click", {
415
- menu: n,
416
- row: l
417
- }), c == null || c.onClose(), c = null;
418
- }, M = (n) => {
419
- var s, g, d, h, x;
420
- if (!((d = (g = (s = i.menuConfig) == null ? void 0 : s.body) == null ? void 0 : g.options) != null && d.length)) return;
421
- c == null || c.onClose(), c = null;
422
- let l = n.target;
423
- for (; l && (l != null && l.getAttribute) && !(l != null && l.getAttribute("data-id")) && l !== ((h = u.value) == null ? void 0 : h.$el); )
424
- l = l.parentNode;
425
- if ((x = l == null ? void 0 : l.getAttribute) != null && x.call(l, "data-id")) {
426
- const w = l.getAttribute("data-id"), m = Ce(w);
427
- m && (c = ei({
428
- e: n,
429
- row: m,
430
- menuConfig: i.menuConfig,
431
- onMenuClick: $
432
- }), n.preventDefault(), n.stopPropagation());
421
+ menu: i,
422
+ row: a
423
+ }), le == null || le.onClose(), le = null;
424
+ }, W = (i) => {
425
+ var c, p, d, g, w;
426
+ if (!((d = (p = (c = t.menuConfig) == null ? void 0 : c.body) == null ? void 0 : p.options) != null && d.length)) return;
427
+ le == null || le.onClose(), le = null;
428
+ let a = i.target;
429
+ for (; a && (a != null && a.getAttribute) && !(a != null && a.getAttribute("data-id")) && a !== ((g = r.value) == null ? void 0 : g.$el); )
430
+ a = a.parentNode;
431
+ if ((w = a == null ? void 0 : a.getAttribute) != null && w.call(a, "data-id")) {
432
+ const k = a.getAttribute("data-id"), b = Me(k);
433
+ b && (le = ci({
434
+ e: i,
435
+ row: b,
436
+ menuConfig: t.menuConfig,
437
+ onMenuClick: ot
438
+ }), i.preventDefault(), i.stopPropagation());
433
439
  }
434
- }, C = (n) => {
435
- var s, g, d;
436
- if (!S.value)
440
+ }, pe = (i) => {
441
+ var c, p, d;
442
+ if (!s.value)
437
443
  return;
438
- let l = n.target;
439
- for (; l && (l != null && l.getAttribute) && !(l != null && l.getAttribute("data-id")) && l !== ((s = u.value) == null ? void 0 : s.$el); )
440
- if (l = l.parentNode, l != null && l.classList && ["el-popper", "ck-body-wrapper"].some((h) => l.classList.contains(h)))
444
+ let a = i.target;
445
+ for (; a && (a != null && a.getAttribute) && !(a != null && a.getAttribute("data-id")) && a !== ((c = r.value) == null ? void 0 : c.$el); )
446
+ if (a = a.parentNode, a != null && a.classList && ["el-popper", "ck-body-wrapper"].some((g) => a.classList.contains(g)))
441
447
  return;
442
- ((g = l == null ? void 0 : l.getAttribute) == null ? void 0 : g.call(l, "data-id")) != ((d = S.value) == null ? void 0 : d.node_id) && (S.value._editing = !1, e("edit-closed", {
443
- row: S.value,
448
+ ((p = a == null ? void 0 : a.getAttribute) == null ? void 0 : p.call(a, "data-id")) != ((d = s.value) == null ? void 0 : d.node_id) && (s.value._editing = !1, e("edit-closed", {
449
+ row: s.value,
444
450
  column: {},
445
451
  $table: o == null ? void 0 : o.exposed
446
- }), S.value = null);
452
+ }), s.value = null);
447
453
  };
448
- ((vt = i.editConfig) == null ? void 0 : vt.trigger) === "dblclick" && Be(() => S.value, (n) => {
449
- document.removeEventListener("click", C, !0), n && setTimeout(() => {
450
- document.addEventListener("click", C, !0);
454
+ ((xt = t.editConfig) == null ? void 0 : xt.trigger) === "dblclick" && Ve(() => s.value, (i) => {
455
+ document.removeEventListener("click", pe, !0), i && setTimeout(() => {
456
+ document.addEventListener("click", pe, !0);
451
457
  }, 200);
452
458
  });
453
- const I = (n) => JSON.stringify(n.map((l) => {
454
- var s;
459
+ const ye = (i) => JSON.stringify(i.map((a) => {
460
+ var c;
455
461
  return {
456
- id: l[i.rowConfig.keyField],
457
- content: ((s = l.content) == null ? void 0 : s.length) || 0,
458
- type: l.content_type,
459
- editing: l._editing
462
+ id: a[t.rowConfig.keyField],
463
+ content: ((c = a.content) == null ? void 0 : c.length) || 0,
464
+ type: a.content_type,
465
+ editing: a._editing
460
466
  };
461
- })), O = () => {
462
- if (!i.pageConfig.enabled) {
463
- q.value = [{
464
- items: A.value,
467
+ })), _e = () => {
468
+ if (!t.pageConfig.enabled) {
469
+ L.value = [{
470
+ items: h.value,
465
471
  startIndex: 0,
466
- endIndex: A.value.length
472
+ endIndex: h.value.length
467
473
  }];
468
474
  return;
469
475
  }
470
- if (i.pageData && Object.keys(i.pageData).length) {
471
- const n = [], l = i.rowConfig.keyField || "node_id", s = /* @__PURE__ */ new Map();
472
- A.value.forEach((d) => {
473
- s.set(String(d[l]), d);
474
- }), Object.keys(i.pageData).sort((d, h) => parseInt(d) - parseInt(h)).forEach((d) => {
475
- const h = i.pageData[d], x = [];
476
- h.forEach((w) => {
477
- const m = s.get(String(w));
478
- m && x.push(m);
479
- }), x.length > 0 && n.push({
480
- items: x,
476
+ if (t.pageData && Object.keys(t.pageData).length) {
477
+ const i = [], a = t.rowConfig.keyField || "node_id", c = /* @__PURE__ */ new Map();
478
+ h.value.forEach((d) => {
479
+ c.set(String(d[a]), d);
480
+ }), Object.keys(t.pageData).sort((d, g) => parseInt(d) - parseInt(g)).forEach((d) => {
481
+ const g = t.pageData[d], w = [];
482
+ g.forEach((k) => {
483
+ const b = c.get(String(k));
484
+ b && w.push(b);
485
+ }), w.length > 0 && i.push({
486
+ items: w,
481
487
  pageNumber: parseInt(d),
482
- height: x.reduce((w, m) => w + r(m), 0)
488
+ height: w.reduce((k, b) => k + P(b), 0)
483
489
  });
484
- }), q.value = n;
490
+ }), L.value = i;
485
491
  } else {
486
492
  const {
487
- pageHeight: n,
488
- margin: l
489
- } = i.pageConfig, s = n - l * 2, g = [];
490
- let d = [], h = 0, x = 0, w = 1;
491
- A.value.forEach((m, v) => {
492
- const k = r(m);
493
- (m.layer || 0) <= 2 && d.length > 0 ? (g.push({
494
- items: [...d],
495
- startIndex: x,
496
- endIndex: v,
497
- height: h,
498
- pageNumber: w++
499
- }), d = [m], h = k, x = v) : h + k > s && d.length > 0 ? (g.push({
500
- items: [...d],
501
- startIndex: x,
502
- endIndex: v,
503
- height: h,
504
- pageNumber: w++
505
- }), d = [m], h = Math.min(k, s), x = v) : (d.push(m), h += k);
506
- }), d.length > 0 && g.push({
507
- items: d,
508
- startIndex: x,
509
- endIndex: A.value.length,
510
- height: h,
511
- pageNumber: w
512
- }), q.value = g;
493
+ pageHeight: i,
494
+ margin: a,
495
+ headerHeight: c = 0,
496
+ footerHeight: p = 0
497
+ } = t.pageConfig, g = Math.max(100, i - a * 2 - c - p - 20), w = [];
498
+ let k = [], b = 0, _ = 0, C = 1;
499
+ h.value.forEach((F, O) => {
500
+ const M = P(F);
501
+ (F.layer || 0) <= 2 && k.length > 0 ? (w.push({
502
+ items: [...k],
503
+ startIndex: _,
504
+ endIndex: O,
505
+ height: b,
506
+ pageNumber: C++
507
+ }), k = [F], b = M, _ = O) : b + M > g && k.length > 0 ? (w.push({
508
+ items: [...k],
509
+ startIndex: _,
510
+ endIndex: O,
511
+ height: b,
512
+ pageNumber: C++
513
+ }), k = [F], b = Math.min(M, g), _ = O) : (k.push(F), b += M);
514
+ }), k.length > 0 && w.push({
515
+ items: k,
516
+ startIndex: _,
517
+ endIndex: h.value.length,
518
+ height: b,
519
+ pageNumber: C
520
+ }), L.value = w;
513
521
  }
514
- }, b = () => {
522
+ }, De = () => {
515
523
  try {
516
- const n = Array.isArray(i.data) ? i.data : [], l = I(n);
517
- if (!(l !== K.value) && A.value.length > 0)
524
+ const i = Array.isArray(t.data) ? t.data : [], a = ye(i);
525
+ if (!(a !== E.value) && h.value.length > 0)
518
526
  return;
519
- K.value = l;
520
- const g = (i.treeConfig ? ti(n, void 0, i.treeConfig) : n).map((h, x) => {
521
- const w = h[i.rowConfig.keyField], m = N.get(w);
522
- if (!m || m.content !== h.content || m.content_type !== h.content_type) {
523
- y.add(w);
524
- const v = {
525
- ...h,
526
- index: x,
527
- _editing: h._editing || !1,
528
- _original: (m == null ? void 0 : m._original) || {
529
- ...h
527
+ E.value = a;
528
+ const p = (t.treeConfig ? di(i, void 0, t.treeConfig) : i).map((g, w) => {
529
+ const k = g[t.rowConfig.keyField], b = S.get(k);
530
+ if (!b || b.content !== g.content || b.content_type !== g.content_type) {
531
+ B.add(k);
532
+ const _ = {
533
+ ...g,
534
+ index: w,
535
+ _editing: g._editing || !1,
536
+ _original: (b == null ? void 0 : b._original) || {
537
+ ...g
530
538
  }
531
539
  // 保留原始数据,避免重复深拷贝
532
540
  };
533
- return N.set(w, v), v;
541
+ return S.set(k, _), _;
534
542
  }
535
- return m.index = x, m;
543
+ return b.index = w, b;
536
544
  });
537
- A.value = g, O();
538
- const d = new Set(g.map((h) => h[i.rowConfig.keyField]));
539
- for (const [h] of N)
540
- d.has(h) || (N.delete(h), y.delete(h));
545
+ h.value = p, _e();
546
+ const d = new Set(p.map((g) => g[t.rowConfig.keyField]));
547
+ for (const [g] of S)
548
+ d.has(g) || (S.delete(g), B.delete(g));
541
549
  } catch {
542
- A.value = [], q.value = [], N.clear(), y.clear();
550
+ h.value = [], L.value = [], S.clear(), B.clear();
543
551
  }
544
552
  };
545
- Be(() => i.data, (n, l) => {
553
+ Ve(() => t.data, (i, a) => {
546
554
  try {
547
- if (!Array.isArray(n))
555
+ if (!Array.isArray(i))
548
556
  return;
549
- xe(() => {
550
- if (b(), i.pageConfig.enabled) {
551
- ee.value.clear(), Q.value.clear();
552
- for (let s = 0; s < Math.min(3, q.value.length); s++)
553
- ee.value.add(s);
554
- xe(() => {
555
- ne();
557
+ be(() => {
558
+ if (De(), t.pageConfig.enabled) {
559
+ K.value.clear(), x.value.clear();
560
+ for (let c = 0; c < Math.min(3, L.value.length); c++)
561
+ K.value.add(c);
562
+ be(() => {
563
+ re();
556
564
  });
557
565
  }
558
566
  });
@@ -561,779 +569,780 @@ const ii = /* @__PURE__ */ un({
561
569
  }, {
562
570
  deep: !1,
563
571
  immediate: !1
564
- }), Be(() => i.pageData, () => {
565
- if (i.pageConfig.enabled) {
566
- O(), ee.value.clear(), Q.value.clear();
567
- for (let n = 0; n < Math.min(3, q.value.length); n++)
568
- ee.value.add(n);
569
- xe(() => {
570
- ne();
572
+ }), Ve(() => t.pageData, () => {
573
+ if (t.pageConfig.enabled) {
574
+ _e(), K.value.clear(), x.value.clear();
575
+ for (let i = 0; i < Math.min(3, L.value.length); i++)
576
+ K.value.add(i);
577
+ be(() => {
578
+ re();
571
579
  });
572
580
  }
573
581
  }, {
574
582
  deep: !0
575
- }), Be(() => i.pageConfig, () => {
576
- if (i.pageConfig.enabled) {
577
- O(), ee.value.clear(), Q.value.clear();
578
- for (let n = 0; n < Math.min(3, q.value.length); n++)
579
- ee.value.add(n);
580
- xe(() => {
581
- ne();
583
+ }), Ve(() => t.pageConfig, () => {
584
+ if (t.pageConfig.enabled) {
585
+ _e(), K.value.clear(), x.value.clear();
586
+ for (let i = 0; i < Math.min(3, L.value.length); i++)
587
+ K.value.add(i);
588
+ be(() => {
589
+ re();
582
590
  });
583
591
  }
584
592
  }, {
585
593
  deep: !0
586
- }), Be(z, () => e("current-change", {
587
- row: z.value
594
+ }), Ve(m, () => e("current-change", {
595
+ row: m.value
588
596
  }));
589
- let ge = null;
590
- const de = () => {
591
- window.ResizeObserver && (ge = new ResizeObserver((n) => {
592
- var l, s;
593
- for (const g of n) {
594
- const d = (l = g.target.dataset) == null ? void 0 : l.id;
597
+ let Ee = null;
598
+ const se = () => {
599
+ window.ResizeObserver && (Ee = new ResizeObserver((i) => {
600
+ var a, c;
601
+ for (const p of i) {
602
+ const d = (a = p.target.dataset) == null ? void 0 : a.id;
595
603
  if (!d) continue;
596
- const h = Ce(d);
597
- if (!h) continue;
598
- const x = g.contentRect.height, w = ((s = B.get(h)) == null ? void 0 : s.height) || 0;
599
- if (Math.abs(w - x) > 5) {
600
- const m = B.get(h) || {};
601
- B.set(h, {
602
- ...m,
603
- height: x
604
+ const g = Me(d);
605
+ if (!g) continue;
606
+ const w = p.contentRect.height, k = ((c = T.get(g)) == null ? void 0 : c.height) || 0;
607
+ if (Math.abs(k - w) > 5) {
608
+ const b = T.get(g) || {};
609
+ T.set(g, {
610
+ ...b,
611
+ height: w
604
612
  }), requestAnimationFrame(() => {
605
- var k;
606
- const v = g.target.__vueParentComponent;
607
- (k = v == null ? void 0 : v.proxy) != null && k.updateSize && v.proxy.updateSize();
613
+ var C;
614
+ const _ = p.target.__vueParentComponent;
615
+ (C = _ == null ? void 0 : _.proxy) != null && C.updateSize && _.proxy.updateSize();
608
616
  });
609
617
  }
610
618
  }
611
- }), xe(() => {
612
- var s;
613
- const n = (s = u.value) == null ? void 0 : s.$el;
614
- if (!n) return;
615
- n.querySelectorAll("[data-id]").forEach((g) => {
616
- g.dataset.id && ge.observe(g);
619
+ }), be(() => {
620
+ var c;
621
+ const i = (c = r.value) == null ? void 0 : c.$el;
622
+ if (!i) return;
623
+ i.querySelectorAll("[data-id]").forEach((p) => {
624
+ p.dataset.id && Ee.observe(p);
617
625
  });
618
626
  }));
619
- }, le = () => {
620
- T.value && (T.value.disconnect(), T.value = null), ge && (ge.disconnect(), ge = null);
621
- }, ne = () => {
622
- i.pageConfig.enabled && (be.value && be.value.disconnect(), be.value = new IntersectionObserver((n) => {
623
- n.forEach((l) => {
624
- const s = parseInt(l.target.dataset.pageIndex);
625
- if (l.isIntersecting) {
626
- Q.value.add(s);
627
- for (let g = Math.max(0, s - W); g <= Math.min(q.value.length - 1, s + W); g++)
628
- ee.value.add(g);
627
+ }, fe = () => {
628
+ f.value && (f.value.disconnect(), f.value = null), Ee && (Ee.disconnect(), Ee = null);
629
+ }, re = () => {
630
+ t.pageConfig.enabled && (ne.value && ne.value.disconnect(), ne.value = new IntersectionObserver((i) => {
631
+ i.forEach((a) => {
632
+ const c = parseInt(a.target.dataset.pageIndex);
633
+ if (a.isIntersecting) {
634
+ x.value.add(c);
635
+ for (let p = Math.max(0, c - R); p <= Math.min(L.value.length - 1, c + R); p++)
636
+ K.value.add(p);
629
637
  } else
630
- Q.value.delete(s), setTimeout(() => {
631
- Q.value.has(s) || Array.from(Q.value).some((d) => Math.abs(d - s) <= W * 2) || ee.value.delete(s);
638
+ x.value.delete(c), setTimeout(() => {
639
+ x.value.has(c) || Array.from(x.value).some((d) => Math.abs(d - c) <= R * 2) || K.value.delete(c);
632
640
  }, 3e3);
633
641
  });
634
642
  }, {
635
643
  root: null,
636
644
  rootMargin: "100px",
637
645
  threshold: 0.01
638
- }), xe(() => {
639
- const n = document.querySelector(".a4-pages-container");
640
- n && n.querySelectorAll(".a4-page-placeholder").forEach((s) => {
641
- be.value.observe(s);
646
+ }), be(() => {
647
+ const i = document.querySelector(".a4-pages-container");
648
+ i && i.querySelectorAll(".a4-page-placeholder").forEach((c) => {
649
+ ne.value.observe(c);
642
650
  });
643
651
  }));
644
652
  };
645
- ct(() => {
646
- b(), xe(() => {
647
- var n;
648
- if (de(), ue.setup(), ne(), ((n = i.editConfig) == null ? void 0 : n.trigger) === "contenteditable" && (document.addEventListener("selectionchange", dt), document.addEventListener("mouseup", ut)), i.pageConfig.enabled)
649
- for (let l = 0; l < Math.min(3, q.value.length); l++)
650
- ee.value.add(l);
651
- }), P.value = !0;
652
- }), et(() => {
653
- var n;
654
- le(), ue.cleanup(), be.value && (be.value.disconnect(), be.value = null), ((n = i.editConfig) == null ? void 0 : n.trigger) === "contenteditable" && (document.removeEventListener("selectionchange", dt), document.removeEventListener("mouseup", ut)), fe && clearTimeout(fe), Z = /* @__PURE__ */ new Map(), N.clear(), ee.value.clear(), Q.value.clear();
653
+ ft(() => {
654
+ De(), be(() => {
655
+ var i;
656
+ if (se(), we.setup(), re(), ((i = t.editConfig) == null ? void 0 : i.trigger) === "contenteditable" && (document.addEventListener("selectionchange", pt), document.addEventListener("mouseup", vt)), t.pageConfig.enabled)
657
+ for (let a = 0; a < Math.min(3, L.value.length); a++)
658
+ K.value.add(a);
659
+ }), y.value = !0;
660
+ }), lt(() => {
661
+ var i;
662
+ fe(), we.cleanup(), ne.value && (ne.value.disconnect(), ne.value = null), ((i = t.editConfig) == null ? void 0 : i.trigger) === "contenteditable" && (document.removeEventListener("selectionchange", pt), document.removeEventListener("mouseup", vt)), Se && clearTimeout(Se), I = /* @__PURE__ */ new Map(), S.clear(), K.value.clear(), x.value.clear();
655
663
  });
656
- const ue = {
664
+ const we = {
657
665
  handlers: /* @__PURE__ */ new Map(),
658
666
  setup() {
659
- xe(() => {
660
- var l;
661
- const n = (l = u.value) == null ? void 0 : l.$el;
662
- n && (n.addEventListener("click", this.handleClick.bind(this), {
667
+ be(() => {
668
+ var a;
669
+ const i = (a = r.value) == null ? void 0 : a.$el;
670
+ i && (i.addEventListener("click", this.handleClick.bind(this), {
663
671
  passive: !0
664
- }), n.addEventListener("dblclick", this.handleDblClick.bind(this), {
672
+ }), i.addEventListener("dblclick", this.handleDblClick.bind(this), {
665
673
  passive: !0
666
674
  }));
667
675
  });
668
676
  },
669
- handleClick(n) {
670
- const l = n.target.closest("[data-id]");
671
- if (!l) return;
672
- const s = l.dataset.id, g = Ce(s);
673
- g && Ke(g);
677
+ handleClick(i) {
678
+ const a = i.target.closest("[data-id]");
679
+ if (!a) return;
680
+ const c = a.dataset.id, p = Me(c);
681
+ p && Je(p);
674
682
  },
675
- handleDblClick(n) {
683
+ handleDblClick(i) {
676
684
  var d;
677
- if (!((d = i.editConfig) != null && d.trigger) === "dblclick") return;
678
- const l = n.target.closest("[data-id]");
679
- if (!l) return;
680
- const s = l.dataset.id, g = Ce(s);
681
- g && Oe(g);
685
+ if (!((d = t.editConfig) != null && d.trigger) === "dblclick") return;
686
+ const a = i.target.closest("[data-id]");
687
+ if (!a) return;
688
+ const c = a.dataset.id, p = Me(c);
689
+ p && Ne(p);
682
690
  },
683
691
  cleanup() {
684
- var l, s;
685
- const n = (s = (l = u.value) == null ? void 0 : l.$el) == null ? void 0 : s.querySelector(".virtual-table-wrapper");
686
- n && (n.removeEventListener("click", this.handleClick), n.removeEventListener("dblclick", this.handleDblClick));
692
+ var a, c;
693
+ const i = (c = (a = r.value) == null ? void 0 : a.$el) == null ? void 0 : c.querySelector(".virtual-table-wrapper");
694
+ i && (i.removeEventListener("click", this.handleClick), i.removeEventListener("dblclick", this.handleDblClick));
687
695
  }
688
- }, me = (n) => {
689
- Ke(n);
690
- }, re = (n) => Oe(n);
691
- let E = null, X;
692
- const Ne = ({
693
- row: n,
694
- column: l
695
- }, s, g) => {
696
- var x, w;
697
- const d = g || s.target, h = Tt(d, "virtual-table-cell", (x = u.value) == null ? void 0 : x.$el);
698
- E === h && X && (clearTimeout(X), E = null), ((w = S.value) == null ? void 0 : w[i.rowConfig.keyField]) != (n == null ? void 0 : n[i.rowConfig.keyField]) && setTimeout(() => {
699
- var v, k;
700
- S.value = n;
701
- let m = (v = d == null ? void 0 : d.getAttribute) == null ? void 0 : v.call(d, "field");
702
- if (!m) {
696
+ }, de = (i) => {
697
+ Je(i);
698
+ }, X = (i) => Ne(i);
699
+ let Ce = null, Fe;
700
+ const me = ({
701
+ row: i,
702
+ column: a
703
+ }, c, p) => {
704
+ var w, k;
705
+ const d = p || c.target, g = $t(d, "virtual-table-cell", (w = r.value) == null ? void 0 : w.$el);
706
+ Ce === g && Fe && (clearTimeout(Fe), Ce = null), ((k = s.value) == null ? void 0 : k[t.rowConfig.keyField]) != (i == null ? void 0 : i[t.rowConfig.keyField]) && setTimeout(() => {
707
+ var _, C;
708
+ s.value = i;
709
+ let b = (_ = d == null ? void 0 : d.getAttribute) == null ? void 0 : _.call(d, "field");
710
+ if (!b) {
703
711
  try {
704
- const L = document.getSelection();
705
- let R = L == null ? void 0 : L.anchorNode;
706
- R && R.nodeType === 3 && (R = R.parentElement);
707
- const F = (k = R == null ? void 0 : R.closest) == null ? void 0 : k.call(R, "[field]");
708
- F && (m = F.getAttribute("field"));
712
+ const F = document.getSelection();
713
+ let O = F == null ? void 0 : F.anchorNode;
714
+ O && O.nodeType === 3 && (O = O.parentElement);
715
+ const M = (C = O == null ? void 0 : O.closest) == null ? void 0 : C.call(O, "[field]");
716
+ M && (b = M.getAttribute("field"));
709
717
  } catch {
710
718
  }
711
- if (!m && (s != null && s.composedPath)) {
712
- for (const L of s.composedPath())
713
- if (L != null && L.getAttribute && L.getAttribute("field")) {
714
- m = L.getAttribute("field");
719
+ if (!b && (c != null && c.composedPath)) {
720
+ for (const F of c.composedPath())
721
+ if (F != null && F.getAttribute && F.getAttribute("field")) {
722
+ b = F.getAttribute("field");
715
723
  break;
716
724
  }
717
725
  }
718
726
  }
719
727
  e("edit-activated", {
720
- row: n,
728
+ row: i,
721
729
  column: {
722
- ...l,
723
- field: m
730
+ ...a,
731
+ field: b
724
732
  },
725
733
  $table: o == null ? void 0 : o.exposed
726
734
  });
727
735
  }, 200);
728
- }, ye = ({
729
- row: n,
730
- column: l
731
- }, s, g) => {
732
- var h;
733
- const d = g || s.target;
734
- E = Tt(d, "virtual-table-cell", (h = u.value) == null ? void 0 : h.$el), X && clearTimeout(X), X = setTimeout(() => {
735
- var m, v, k, L, R;
736
- const x = n.content_type;
737
- let w = (m = d == null ? void 0 : d.getAttribute) == null ? void 0 : m.call(d, "field");
738
- if (!w) {
736
+ }, xe = ({
737
+ row: i,
738
+ column: a
739
+ }, c, p) => {
740
+ var g;
741
+ const d = p || c.target;
742
+ Ce = $t(d, "virtual-table-cell", (g = r.value) == null ? void 0 : g.$el), Fe && clearTimeout(Fe), Fe = setTimeout(() => {
743
+ var b, _, C, F, O;
744
+ const w = i.content_type;
745
+ let k = (b = d == null ? void 0 : d.getAttribute) == null ? void 0 : b.call(d, "field");
746
+ if (!k) {
739
747
  try {
740
- const F = document.getSelection();
741
- let H = F == null ? void 0 : F.anchorNode;
742
- H && H.nodeType === 3 && (H = H.parentElement);
743
- const te = (v = H == null ? void 0 : H.closest) == null ? void 0 : v.call(H, "[field]");
744
- te && (w = te.getAttribute("field"));
748
+ const M = document.getSelection();
749
+ let $ = M == null ? void 0 : M.anchorNode;
750
+ $ && $.nodeType === 3 && ($ = $.parentElement);
751
+ const Y = (_ = $ == null ? void 0 : $.closest) == null ? void 0 : _.call($, "[field]");
752
+ Y && (k = Y.getAttribute("field"));
745
753
  } catch {
746
754
  }
747
- if (!w && (s != null && s.composedPath)) {
748
- for (const F of s.composedPath())
749
- if (F != null && F.getAttribute && F.getAttribute("field")) {
750
- w = F.getAttribute("field");
755
+ if (!k && (c != null && c.composedPath)) {
756
+ for (const M of c.composedPath())
757
+ if (M != null && M.getAttribute && M.getAttribute("field")) {
758
+ k = M.getAttribute("field");
751
759
  break;
752
760
  }
753
761
  }
754
762
  }
755
- if (x !== "table") {
756
- if (x === "text") {
757
- let F = null, H = null;
758
- if ((k = d == null ? void 0 : d.getAttribute) != null && k.call(d, "field") ? F = d : (L = d == null ? void 0 : d.closest) != null && L.call(d, "[field]") && (F = d.closest("[field]")), F && (H = F.textContent), w && H !== void 0 && H !== null) {
759
- H = H.trim();
760
- const te = ((R = n[w]) == null ? void 0 : R.trim()) || "";
761
- H !== te && (n[w] = H);
763
+ if (w !== "table") {
764
+ if (w === "text") {
765
+ let M = null, $ = null;
766
+ if ((C = d == null ? void 0 : d.getAttribute) != null && C.call(d, "field") ? M = d : (F = d == null ? void 0 : d.closest) != null && F.call(d, "[field]") && (M = d.closest("[field]")), M && ($ = M.textContent), k && $ !== void 0 && $ !== null) {
767
+ $ = $.trim();
768
+ const Y = ((O = i[k]) == null ? void 0 : O.trim()) || "";
769
+ $ !== Y && (i[k] = $);
762
770
  }
763
771
  }
764
772
  }
765
773
  e("edit-closed", {
766
- row: n,
774
+ row: i,
767
775
  column: {
768
- ...l,
769
- field: w
776
+ ...a,
777
+ field: k
770
778
  },
771
779
  $table: o == null ? void 0 : o.exposed
772
780
  });
773
781
  }, 50);
774
782
  };
775
- let U = null, fe = null;
776
- const Re = (n) => {
777
- var l;
778
- ((l = i.editConfig) == null ? void 0 : l.trigger) === "contenteditable" && Ve("focusin", n);
779
- }, Pe = (n) => {
780
- var l, s, g, d, h;
781
- if (((l = i.editConfig) == null ? void 0 : l.trigger) === "contenteditable")
782
- if (U != null && U.cellEl) {
783
- let x = U.fieldEl;
784
- !x && U.field && (x = (g = (s = U.cellEl) == null ? void 0 : s.querySelector) == null ? void 0 : g.call(s, `[field="${U.field}"]`)), x || (x = ((h = (d = U.cellEl).querySelector) == null ? void 0 : h.call(d, "[field]")) || U.cellEl), ye(U, {
785
- target: x
786
- }, x), U = null;
783
+ let H = null, Se = null;
784
+ const Pe = (i) => {
785
+ var a;
786
+ ((a = t.editConfig) == null ? void 0 : a.trigger) === "contenteditable" && gt("focusin", i);
787
+ }, We = (i) => {
788
+ var a, c, p, d, g;
789
+ if (((a = t.editConfig) == null ? void 0 : a.trigger) === "contenteditable")
790
+ if (H != null && H.cellEl) {
791
+ let w = H.fieldEl;
792
+ !w && H.field && (w = (p = (c = H.cellEl) == null ? void 0 : c.querySelector) == null ? void 0 : p.call(c, `[field="${H.field}"]`)), w || (w = ((g = (d = H.cellEl).querySelector) == null ? void 0 : g.call(d, "[field]")) || H.cellEl), xe(H, {
793
+ target: w
794
+ }, w), H = null;
787
795
  } else
788
- Ve("focusout", n);
789
- }, Ve = (n, l) => {
790
- var s, g, d, h, x, w;
796
+ gt("focusout", i);
797
+ }, gt = (i, a) => {
798
+ var c, p, d, g, w, k;
791
799
  try {
792
- const m = document.getSelection();
793
- let v = m == null ? void 0 : m.anchorNode;
794
- v && v.nodeType === 3 && (v = v.parentElement);
795
- const k = (s = v == null ? void 0 : v.closest) == null ? void 0 : s.call(v, ".virtual-table-cell"), L = (g = v == null ? void 0 : v.closest) == null ? void 0 : g.call(v, ".virtual-table-row");
796
- if (!k || !L) return;
797
- const R = L.getAttribute("data-id"), F = k.getAttribute("data-prop"), H = Ce(R), te = $e.value.find((pe) => `${pe.prop}` == `${F}`) || {}, he = ((d = v == null ? void 0 : v.closest) == null ? void 0 : d.call(v, "[field]")) || null, G = ((h = he == null ? void 0 : he.getAttribute) == null ? void 0 : h.call(he, "field")) || void 0;
798
- n === "focusin" ? (U = {
799
- row: H,
800
- column: te,
801
- cellEl: k,
802
- rowEl: L,
803
- fieldEl: he,
804
- field: G
805
- }, Ne({
806
- row: H,
807
- column: te
808
- }, l, he || ((x = v == null ? void 0 : v.closest) == null ? void 0 : x.call(v, "[field]")))) : ye({
809
- row: H,
810
- column: te
811
- }, l, he || ((w = v == null ? void 0 : v.closest) == null ? void 0 : w.call(v, "[field]")));
800
+ const b = document.getSelection();
801
+ let _ = b == null ? void 0 : b.anchorNode;
802
+ _ && _.nodeType === 3 && (_ = _.parentElement);
803
+ const C = (c = _ == null ? void 0 : _.closest) == null ? void 0 : c.call(_, ".virtual-table-cell"), F = (p = _ == null ? void 0 : _.closest) == null ? void 0 : p.call(_, ".virtual-table-row");
804
+ if (!C || !F) return;
805
+ const O = F.getAttribute("data-id"), M = C.getAttribute("data-prop"), $ = Me(O), Y = $e.value.find((oe) => `${oe.prop}` == `${M}`) || {}, j = ((d = _ == null ? void 0 : _.closest) == null ? void 0 : d.call(_, "[field]")) || null, V = ((g = j == null ? void 0 : j.getAttribute) == null ? void 0 : g.call(j, "field")) || void 0;
806
+ i === "focusin" ? (H = {
807
+ row: $,
808
+ column: Y,
809
+ cellEl: C,
810
+ rowEl: F,
811
+ fieldEl: j,
812
+ field: V
813
+ }, me({
814
+ row: $,
815
+ column: Y
816
+ }, a, j || ((w = _ == null ? void 0 : _.closest) == null ? void 0 : w.call(_, "[field]")))) : xe({
817
+ row: $,
818
+ column: Y
819
+ }, a, j || ((k = _ == null ? void 0 : _.closest) == null ? void 0 : k.call(_, "[field]")));
812
820
  } catch {
813
821
  }
814
- }, dt = () => {
815
- var n;
816
- ((n = i.editConfig) == null ? void 0 : n.trigger) === "contenteditable" && (fe && clearTimeout(fe), fe = setTimeout(() => {
817
- var l, s, g, d, h, x, w, m, v, k, L, R, F, H;
822
+ }, pt = () => {
823
+ var i;
824
+ ((i = t.editConfig) == null ? void 0 : i.trigger) === "contenteditable" && (Se && clearTimeout(Se), Se = setTimeout(() => {
825
+ var a, c, p, d, g, w, k, b, _, C, F, O, M, $;
818
826
  try {
819
- const te = document.getSelection();
820
- if (te.rangeCount === 0) return;
821
- const he = te.getRangeAt(0);
822
- let G = he.startContainer;
823
- G.nodeType === 3 && (G = G.parentElement);
824
- const pe = (l = G == null ? void 0 : G.closest) == null ? void 0 : l.call(G, ".virtual-table-cell"), Me = (s = G == null ? void 0 : G.closest) == null ? void 0 : s.call(G, ".virtual-table-row");
825
- if (!pe || !Me) return;
826
- const nt = Me.getAttribute("data-id"), it = pe.getAttribute("data-prop"), Se = Ce(nt), _e = $e.value.find((ae) => `${ae.prop}` == `${it}`) || {};
827
- if (!U || ((g = U.row) == null ? void 0 : g[i.rowConfig.keyField]) !== (Se == null ? void 0 : Se[i.rowConfig.keyField]) || ((d = U.column) == null ? void 0 : d.prop) !== (_e == null ? void 0 : _e.prop)) {
828
- if (U) {
829
- let ae = U.fieldEl;
830
- !ae && U.field && (ae = (x = (h = U.cellEl) == null ? void 0 : h.querySelector) == null ? void 0 : x.call(h, `[field="${U.field}"]`)), ae || (ae = ((m = (w = U.cellEl) == null ? void 0 : w.querySelector) == null ? void 0 : m.call(w, "[field]")) || U.cellEl), ye(U, {
831
- target: ae
832
- }, ae);
827
+ const Y = document.getSelection();
828
+ if (Y.rangeCount === 0) return;
829
+ const j = Y.getRangeAt(0);
830
+ let V = j.startContainer;
831
+ V.nodeType === 3 && (V = V.parentElement);
832
+ const oe = (a = V == null ? void 0 : V.closest) == null ? void 0 : a.call(V, ".virtual-table-cell"), ie = (c = V == null ? void 0 : V.closest) == null ? void 0 : c.call(V, ".virtual-table-row");
833
+ if (!oe || !ie) return;
834
+ const Le = ie.getAttribute("data-id"), Re = oe.getAttribute("data-prop"), ge = Me(Le), ce = $e.value.find((G) => `${G.prop}` == `${Re}`) || {};
835
+ if (!H || ((p = H.row) == null ? void 0 : p[t.rowConfig.keyField]) !== (ge == null ? void 0 : ge[t.rowConfig.keyField]) || ((d = H.column) == null ? void 0 : d.prop) !== (ce == null ? void 0 : ce.prop)) {
836
+ if (H) {
837
+ let G = H.fieldEl;
838
+ !G && H.field && (G = (w = (g = H.cellEl) == null ? void 0 : g.querySelector) == null ? void 0 : w.call(g, `[field="${H.field}"]`)), G || (G = ((b = (k = H.cellEl) == null ? void 0 : k.querySelector) == null ? void 0 : b.call(k, "[field]")) || H.cellEl), xe(H, {
839
+ target: G
840
+ }, G);
833
841
  }
834
- U = {
835
- row: Se,
836
- column: _e,
837
- cellEl: pe,
838
- rowEl: Me,
839
- fieldEl: ((v = G == null ? void 0 : G.closest) == null ? void 0 : v.call(G, "[field]")) || null,
840
- field: ((R = (L = ((k = G == null ? void 0 : G.closest) == null ? void 0 : k.call(G, "[field]")) || null) == null ? void 0 : L.getAttribute) == null ? void 0 : R.call(L, "field")) || void 0
841
- }, Ne({
842
- row: Se,
843
- column: _e
842
+ H = {
843
+ row: ge,
844
+ column: ce,
845
+ cellEl: oe,
846
+ rowEl: ie,
847
+ fieldEl: ((_ = V == null ? void 0 : V.closest) == null ? void 0 : _.call(V, "[field]")) || null,
848
+ field: ((O = (F = ((C = V == null ? void 0 : V.closest) == null ? void 0 : C.call(V, "[field]")) || null) == null ? void 0 : F.getAttribute) == null ? void 0 : O.call(F, "field")) || void 0
849
+ }, me({
850
+ row: ge,
851
+ column: ce
844
852
  }, {
845
- target: pe
846
- }, pe);
853
+ target: oe
854
+ }, oe);
847
855
  }
848
- if (te.toString()) {
849
- const ae = he.endContainer.nodeType === 3 ? he.endContainer.parentElement : he.endContainer, Ge = (F = ae == null ? void 0 : ae.closest) == null ? void 0 : F.call(ae, ".virtual-table-cell"), Je = (H = ae == null ? void 0 : ae.closest) == null ? void 0 : H.call(ae, ".virtual-table-row");
856
+ if (Y.toString()) {
857
+ const G = j.endContainer.nodeType === 3 ? j.endContainer.parentElement : j.endContainer, Ae = (M = G == null ? void 0 : G.closest) == null ? void 0 : M.call(G, ".virtual-table-cell"), Qe = ($ = G == null ? void 0 : G.closest) == null ? void 0 : $.call(G, ".virtual-table-row");
850
858
  }
851
859
  } catch {
852
860
  }
853
861
  }, 50));
854
- }, ut = () => {
855
- var n;
856
- ((n = i.editConfig) == null ? void 0 : n.trigger) === "contenteditable" && setTimeout(() => {
857
- var g, d, h, x;
858
- const l = document.getSelection();
859
- if (!l) return;
860
- const s = l.toString();
861
- if (s) {
862
- const w = l.rangeCount > 0 ? l.getRangeAt(0) : null;
863
- let m = null, v = null;
862
+ }, vt = () => {
863
+ var i;
864
+ ((i = t.editConfig) == null ? void 0 : i.trigger) === "contenteditable" && setTimeout(() => {
865
+ var p, d, g, w;
866
+ const a = document.getSelection();
867
+ if (!a) return;
868
+ const c = a.toString();
869
+ if (c) {
870
+ const k = a.rangeCount > 0 ? a.getRangeAt(0) : null;
871
+ let b = null, _ = null;
864
872
  try {
865
- if (w) {
866
- let k = w.startContainer;
867
- (k == null ? void 0 : k.nodeType) === 3 && (k = k.parentElement);
868
- const L = (g = k == null ? void 0 : k.closest) == null ? void 0 : g.call(k, ".virtual-table-cell"), R = (d = k == null ? void 0 : k.closest) == null ? void 0 : d.call(k, ".virtual-table-row");
869
- m = L && R ? {
870
- rowId: R.getAttribute("data-id"),
871
- prop: L.getAttribute("data-prop")
873
+ if (k) {
874
+ let C = k.startContainer;
875
+ (C == null ? void 0 : C.nodeType) === 3 && (C = C.parentElement);
876
+ const F = (p = C == null ? void 0 : C.closest) == null ? void 0 : p.call(C, ".virtual-table-cell"), O = (d = C == null ? void 0 : C.closest) == null ? void 0 : d.call(C, ".virtual-table-row");
877
+ b = F && O ? {
878
+ rowId: O.getAttribute("data-id"),
879
+ prop: F.getAttribute("data-prop")
872
880
  } : null;
873
- let F = w.endContainer;
874
- (F == null ? void 0 : F.nodeType) === 3 && (F = F.parentElement);
875
- const H = (h = F == null ? void 0 : F.closest) == null ? void 0 : h.call(F, ".virtual-table-cell"), te = (x = F == null ? void 0 : F.closest) == null ? void 0 : x.call(F, ".virtual-table-row");
876
- v = H && te ? {
877
- rowId: te.getAttribute("data-id"),
878
- prop: H.getAttribute("data-prop")
881
+ let M = k.endContainer;
882
+ (M == null ? void 0 : M.nodeType) === 3 && (M = M.parentElement);
883
+ const $ = (g = M == null ? void 0 : M.closest) == null ? void 0 : g.call(M, ".virtual-table-cell"), Y = (w = M == null ? void 0 : M.closest) == null ? void 0 : w.call(M, ".virtual-table-row");
884
+ _ = $ && Y ? {
885
+ rowId: Y.getAttribute("data-id"),
886
+ prop: $.getAttribute("data-prop")
879
887
  } : null;
880
888
  }
881
889
  } catch {
882
890
  }
883
891
  e("selection-change", {
884
- text: s,
885
- selection: l,
886
- range: w,
887
- start: m,
888
- end: v
892
+ text: c,
893
+ selection: a,
894
+ range: k,
895
+ start: b,
896
+ end: _
889
897
  });
890
898
  }
891
899
  }, 10);
892
- }, Vt = (n) => (n == null ? void 0 : n._editing) === !0, jt = (n) => n != null && n.parent_id ? Z.get(n.parent_id) : null, Kt = (n) => {
893
- var s;
894
- const l = A.value.findIndex((g) => g[i.rowConfig.keyField] == n[i.rowConfig.keyField]);
895
- return l < 1 ? null : ((s = A.value[l - 1]) == null ? void 0 : s.layer) === n.layer ? A.value[l - 1] : null;
896
- }, qt = (n) => {
897
- const l = A.value.findIndex((s) => s[i.rowConfig.keyField] == n[i.rowConfig.keyField]);
898
- return l >= A.value.length - 1 ? null : A.value[l + 1];
899
- }, Ce = (n) => {
900
- if (!n) return null;
901
- let l = N.get(n);
902
- return l || (typeof n == "number" ? N.get(`${n}`) : typeof n == "string" && /^\d+$/.test(n) ? N.get(Number(n)) : null);
900
+ }, Zt = (i) => (i == null ? void 0 : i._editing) === !0, Qt = (i) => i != null && i.parent_id ? I.get(i.parent_id) : null, en = (i) => {
901
+ var c;
902
+ const a = h.value.findIndex((p) => p[t.rowConfig.keyField] == i[t.rowConfig.keyField]);
903
+ return a < 1 ? null : ((c = h.value[a - 1]) == null ? void 0 : c.layer) === i.layer ? h.value[a - 1] : null;
904
+ }, tn = (i) => {
905
+ const a = h.value.findIndex((c) => c[t.rowConfig.keyField] == i[t.rowConfig.keyField]);
906
+ return a >= h.value.length - 1 ? null : h.value[a + 1];
907
+ }, Me = (i) => {
908
+ if (!i) return null;
909
+ let a = S.get(i);
910
+ return a || (typeof i == "number" ? S.get(`${i}`) : typeof i == "string" && /^\d+$/.test(i) ? S.get(Number(i)) : null);
903
911
  };
904
- let je = null;
905
- const Wt = (n) => {
906
- je && cancelAnimationFrame(je), je = requestAnimationFrame(() => {
907
- var g;
908
- const l = i.rowConfig.keyField, s = n[l];
909
- if (i.pageConfig.enabled) {
912
+ let Ge = null;
913
+ const nn = (i) => {
914
+ Ge && cancelAnimationFrame(Ge), Ge = requestAnimationFrame(() => {
915
+ var p;
916
+ const a = t.rowConfig.keyField, c = i[a];
917
+ if (t.pageConfig.enabled) {
910
918
  let d = -1;
911
- for (let h = 0; h < q.value.length; h++)
912
- if (q.value[h].items.some((m) => m[l] === s)) {
913
- d = h;
919
+ for (let g = 0; g < L.value.length; g++)
920
+ if (L.value[g].items.some((b) => b[a] === c)) {
921
+ d = g;
914
922
  break;
915
923
  }
916
924
  if (d !== -1) {
917
- for (let h = Math.max(0, d - 1); h <= Math.min(q.value.length - 1, d + 1); h++)
918
- ee.value.has(h) || ee.value.add(h);
919
- xe(() => {
920
- const h = document.querySelector(".a4-pages-container");
921
- if (!h) return;
922
- const x = (w = 0) => {
923
- const m = h.querySelector(`[data-id="${s}"]`);
924
- if (m) {
925
- let v = 0, k = m;
926
- for (; k && k !== h; )
927
- v += k.offsetTop, k = k.offsetParent;
928
- const L = h.clientHeight;
929
- let R = v - L * 0.3;
930
- R = Math.max(0, R);
931
- const F = h.scrollTop, H = Math.abs(R - F), te = (he) => {
932
- const G = h.scrollTop, pe = he - G, Me = Math.min(800, Math.max(300, H * 0.5)), nt = performance.now(), it = (_e) => _e < 0.5 ? 4 * _e * _e * _e : 1 - Math.pow(-2 * _e + 2, 3) / 2, Se = (_e) => {
933
- const mt = _e - nt, ae = Math.min(mt / Me, 1), Ge = it(ae), Je = G + pe * Ge;
934
- h.scrollTop = Je, ae < 1 ? requestAnimationFrame(Se) : setTimeout(() => {
935
- h.scrollTop = he;
925
+ for (let g = Math.max(0, d - 1); g <= Math.min(L.value.length - 1, d + 1); g++)
926
+ K.value.has(g) || K.value.add(g);
927
+ be(() => {
928
+ const g = document.querySelector(".a4-pages-container");
929
+ if (!g) return;
930
+ const w = (k = 0) => {
931
+ const b = g.querySelector(`[data-id="${c}"]`);
932
+ if (b) {
933
+ let _ = 0, C = b;
934
+ for (; C && C !== g; )
935
+ _ += C.offsetTop, C = C.offsetParent;
936
+ const F = g.clientHeight;
937
+ let O = _ - F * 0.3;
938
+ O = Math.max(0, O);
939
+ const M = g.scrollTop, $ = Math.abs(O - M), Y = (j) => {
940
+ const V = g.scrollTop, oe = j - V, ie = Math.min(800, Math.max(300, $ * 0.5)), Le = performance.now(), Re = (ce) => ce < 0.5 ? 4 * ce * ce * ce : 1 - Math.pow(-2 * ce + 2, 3) / 2, ge = (ce) => {
941
+ const ze = ce - Le, G = Math.min(ze / ie, 1), Ae = Re(G), Qe = V + oe * Ae;
942
+ g.scrollTop = Qe, G < 1 ? requestAnimationFrame(ge) : setTimeout(() => {
943
+ g.scrollTop = j;
936
944
  }, 50);
937
945
  };
938
- requestAnimationFrame(Se);
946
+ requestAnimationFrame(ge);
939
947
  };
940
- H > 3e3 ? h.scrollTo({
941
- top: R,
948
+ $ > 3e3 ? g.scrollTo({
949
+ top: O,
942
950
  behavior: "instant"
943
- }) : te(R), m.classList.add("row--highlight"), setTimeout(() => {
944
- m.classList.remove("row--highlight");
951
+ }) : Y(O), b.classList.add("row--highlight"), setTimeout(() => {
952
+ b.classList.remove("row--highlight");
945
953
  }, 1500);
946
- } else w < 10 && setTimeout(() => x(w + 1), 150);
954
+ } else k < 10 && setTimeout(() => w(k + 1), 150);
947
955
  };
948
- setTimeout(x, 200);
956
+ setTimeout(w, 200);
949
957
  });
950
958
  }
951
959
  } else {
952
- const d = A.value.findIndex((h) => h[l] === s);
953
- d !== -1 && ((g = u.value) != null && g.scrollToItem) && u.value.scrollToItem(d);
960
+ const d = h.value.findIndex((g) => g[a] === c);
961
+ d !== -1 && ((p = r.value) != null && p.scrollToItem) && r.value.scrollToItem(d);
954
962
  }
955
- je = null;
963
+ Ge = null;
956
964
  });
957
- }, Ke = (n) => {
958
- if (n) {
959
- if (!P.value) {
960
- setTimeout(() => Ke(n), 200);
965
+ }, Je = (i) => {
966
+ if (i) {
967
+ if (!y.value) {
968
+ setTimeout(() => Je(i), 200);
961
969
  return;
962
970
  }
963
- z.value = n, z.value !== S.value && S.value && (S.value._editing = !1, setTimeout(() => {
964
- S.value = null;
971
+ m.value = i, m.value !== s.value && s.value && (s.value._editing = !1, setTimeout(() => {
972
+ s.value = null;
965
973
  }, 200));
966
974
  }
967
- }, Oe = (n, l) => new Promise((s) => {
968
- var g, d;
969
- if (!((g = i == null ? void 0 : i.editConfig) != null && g.beforeEditMethod && typeof ((d = i == null ? void 0 : i.editConfig) == null ? void 0 : d.beforeEditMethod) == "function" && !i.editConfig.beforeEditMethod({
970
- row: n
975
+ }, Ne = (i, a) => new Promise((c) => {
976
+ var p, d;
977
+ if (!((p = t == null ? void 0 : t.editConfig) != null && p.beforeEditMethod && typeof ((d = t == null ? void 0 : t.editConfig) == null ? void 0 : d.beforeEditMethod) == "function" && !t.editConfig.beforeEditMethod({
978
+ row: i
971
979
  }))) {
972
- if (!n || !P.value) {
973
- setTimeout(() => Oe(n), 200);
980
+ if (!i || !y.value) {
981
+ setTimeout(() => Ne(i), 200);
974
982
  return;
975
983
  }
976
- n !== S.value && (A.value.forEach((h) => {
977
- h._editing && e("edit-closed", {
978
- row: h,
984
+ i !== s.value && (h.value.forEach((g) => {
985
+ g._editing && e("edit-closed", {
986
+ row: g,
979
987
  column: {
980
- field: l
988
+ field: a
981
989
  },
982
990
  $table: o == null ? void 0 : o.exposed
983
- }), h._editing = !1;
984
- }), n._editing = !0, setTimeout(() => {
985
- S.value = n, e("edit-activated", {
986
- row: n,
991
+ }), g._editing = !1;
992
+ }), i._editing = !0, setTimeout(() => {
993
+ s.value = i, e("edit-activated", {
994
+ row: i,
987
995
  column: {
988
- field: l
996
+ field: a
989
997
  },
990
998
  $table: o == null ? void 0 : o.exposed
991
- }), s(!0);
999
+ }), c(!0);
992
1000
  }));
993
1001
  }
994
- }), Ut = (n) => Oe(n), tt = () => {
995
- if (O(), i.pageConfig.enabled) {
996
- const n = Array.from(Q.value);
997
- if (n.length > 0) {
998
- const l = Math.min(...n);
999
- for (let s = Math.max(0, l - 1); s <= Math.min(q.value.length - 1, l + 2); s++)
1000
- ee.value.add(s);
1002
+ }), ln = (i) => Ne(i), at = () => {
1003
+ if (_e(), t.pageConfig.enabled) {
1004
+ const i = Array.from(x.value);
1005
+ if (i.length > 0) {
1006
+ const a = Math.min(...i);
1007
+ for (let c = Math.max(0, a - 1); c <= Math.min(L.value.length - 1, a + 2); c++)
1008
+ K.value.add(c);
1001
1009
  } else
1002
- for (let l = 0; l < Math.min(3, q.value.length); l++)
1003
- ee.value.add(l);
1004
- xe(() => {
1005
- ne();
1010
+ for (let a = 0; a < Math.min(3, L.value.length); a++)
1011
+ K.value.add(a);
1012
+ be(() => {
1013
+ re();
1006
1014
  });
1007
1015
  }
1008
- xe(() => {
1009
- !i.pageConfig.enabled && u.value && u.value.$forceUpdate && u.value.$forceUpdate();
1016
+ be(() => {
1017
+ !t.pageConfig.enabled && r.value && r.value.$forceUpdate && r.value.$forceUpdate();
1010
1018
  });
1011
- }, Gt = (n, l) => new Promise((s) => {
1012
- let g = -1;
1013
- if (l == -1) {
1014
- const d = Ce(n.parent_id);
1015
- for (g = A.value.findIndex((h) => h[i.rowConfig.keyField] == d[i.rowConfig.keyField]) + 1; A.value[g].parent_id == d[i.rowConfig.keyField]; )
1016
- g += 1;
1019
+ }, on = (i, a) => new Promise((c) => {
1020
+ let p = -1;
1021
+ if (a == -1) {
1022
+ const d = Me(i.parent_id);
1023
+ for (p = h.value.findIndex((g) => g[t.rowConfig.keyField] == d[t.rowConfig.keyField]) + 1; h.value[p].parent_id == d[t.rowConfig.keyField]; )
1024
+ p += 1;
1017
1025
  } else
1018
- g = A.value.findIndex((d) => d[i.rowConfig.keyField] == l[i.rowConfig.keyField]);
1019
- Z.set(n.node_id, n), N.set(n[i.rowConfig.keyField], n), A.value.splice(g, 0, n), tt(), s({
1020
- row: n
1026
+ p = h.value.findIndex((d) => d[t.rowConfig.keyField] == a[t.rowConfig.keyField]);
1027
+ I.set(i.node_id, i), S.set(i[t.rowConfig.keyField], i), h.value.splice(p, 0, i), at(), c({
1028
+ row: i
1021
1029
  });
1022
- }), Jt = (n, l) => new Promise((s) => {
1023
- const g = A.value.findIndex((d) => d[i.rowConfig.keyField] == l[i.rowConfig.keyField]) + 1;
1024
- Z.set(n.node_id, n), N.set(n[i.rowConfig.keyField], n), A.value.splice(g, 0, n), tt(), s({
1025
- row: n
1030
+ }), an = (i, a) => new Promise((c) => {
1031
+ const p = h.value.findIndex((d) => d[t.rowConfig.keyField] == a[t.rowConfig.keyField]) + 1;
1032
+ I.set(i.node_id, i), S.set(i[t.rowConfig.keyField], i), h.value.splice(p, 0, i), at(), c({
1033
+ row: i
1026
1034
  });
1027
- }), ht = (n) => {
1028
- const l = A.value.findIndex((s) => s[i.rowConfig.keyField] == n[i.rowConfig.keyField] || s === n);
1029
- if (l > -1) {
1030
- const s = n[i.rowConfig.keyField];
1031
- Z.delete(n.node_id), N.delete(s), A.value.splice(l, 1), tt();
1035
+ }), mt = (i) => {
1036
+ const a = h.value.findIndex((c) => c[t.rowConfig.keyField] == i[t.rowConfig.keyField] || c === i);
1037
+ if (a > -1) {
1038
+ const c = i[t.rowConfig.keyField];
1039
+ I.delete(i.node_id), S.delete(c), h.value.splice(a, 1), at();
1032
1040
  }
1033
- }, Xt = (n, l) => {
1034
- if (!n || !n[i.rowConfig.keyField]) return !1;
1035
- const s = n._original;
1036
- return s ? l ? n[l] !== s[l] : Object.keys(s).some((g) => s[g] !== n[g]) : !1;
1037
- }, Yt = (n) => n && n[i.rowConfig.keyField] && !n._original, Zt = (n, l) => {
1038
- n && n[i.rowConfig.keyField] && (l && Object.assign(n, l), n._original = {
1039
- ...n,
1041
+ }, sn = (i, a) => {
1042
+ if (!i || !i[t.rowConfig.keyField]) return !1;
1043
+ const c = i._original;
1044
+ return c ? a ? i[a] !== c[a] : Object.keys(c).some((p) => c[p] !== i[p]) : !1;
1045
+ }, rn = (i) => i && i[t.rowConfig.keyField] && !i._original, cn = (i, a) => {
1046
+ i && i[t.rowConfig.keyField] && (a && Object.assign(i, a), i._original = {
1047
+ ...i,
1040
1048
  _editing: void 0,
1041
1049
  _X_ROW_CHILD: void 0,
1042
1050
  _original: void 0
1043
1051
  });
1044
- }, Qt = (n) => {
1045
- if (n && n[i.rowConfig.keyField]) {
1046
- const l = Ce(n[i.rowConfig.keyField]);
1047
- l._original ? Object.assign(l, l._original) : ht(l);
1052
+ }, dn = (i) => {
1053
+ if (i && i[t.rowConfig.keyField]) {
1054
+ const a = Me(i[t.rowConfig.keyField]);
1055
+ a._original ? Object.assign(a, a._original) : mt(a);
1048
1056
  }
1049
- }, en = () => {
1050
- }, tn = () => {
1051
- z.value = {};
1052
- }, ft = (n) => {
1053
- var s, g, d;
1054
- let l = A.value.findIndex((h) => h[i.rowConfig.keyField] == n[i.rowConfig.keyField]);
1055
- if (l > -1 && i.treeConfig) {
1056
- const h = ((s = i.treeConfig) == null ? void 0 : s.keyField) || ((g = i.treeConfig) == null ? void 0 : g.rowField) || "node_id", x = ((d = i.treeConfig) == null ? void 0 : d.parentField) || "parent_id", w = [], m = /* @__PURE__ */ new Map();
1057
- m.set(n[h], !0);
1058
- for (let v = l + 1; v < A.value.length; v++) {
1059
- const k = A.value[v];
1060
- if (k && m.has(k[x]))
1061
- w.push(k), m.set(k[h]);
1057
+ }, un = () => {
1058
+ }, hn = () => {
1059
+ m.value = {};
1060
+ }, yt = (i) => {
1061
+ var c, p, d;
1062
+ let a = h.value.findIndex((g) => g[t.rowConfig.keyField] == i[t.rowConfig.keyField]);
1063
+ if (a > -1 && t.treeConfig) {
1064
+ const g = ((c = t.treeConfig) == null ? void 0 : c.keyField) || ((p = t.treeConfig) == null ? void 0 : p.rowField) || "node_id", w = ((d = t.treeConfig) == null ? void 0 : d.parentField) || "parent_id", k = [], b = /* @__PURE__ */ new Map();
1065
+ b.set(i[g], !0);
1066
+ for (let _ = a + 1; _ < h.value.length; _++) {
1067
+ const C = h.value[_];
1068
+ if (C && b.has(C[w]))
1069
+ k.push(C), b.set(C[g]);
1062
1070
  else
1063
1071
  break;
1064
1072
  }
1065
- return w;
1073
+ return k;
1066
1074
  }
1067
1075
  return [];
1068
1076
  };
1069
- a({
1070
- isEditByRow: Vt,
1071
- getParentRow: jt,
1072
- getSiblingRow: Kt,
1073
- getNextRow: qt,
1074
- getRowById: Ce,
1075
- scrollToRow: Wt,
1076
- setCurrentRow: Ke,
1077
- setEditRow: Oe,
1078
- setEditCell: Ut,
1079
- insertAt: Gt,
1080
- insertNextAt: Jt,
1081
- isUpdateByRow: Xt,
1082
- isInsertByRow: Yt,
1083
- reloadRow: Zt,
1084
- revertData: Qt,
1085
- remove: ht,
1086
- setAllTreeExpand: en,
1087
- clearCurrentRow: tn,
1088
- getAllChilds: ft
1077
+ l({
1078
+ isEditByRow: Zt,
1079
+ getParentRow: Qt,
1080
+ getSiblingRow: en,
1081
+ getNextRow: tn,
1082
+ getRowById: Me,
1083
+ scrollToRow: nn,
1084
+ setCurrentRow: Je,
1085
+ setEditRow: Ne,
1086
+ setEditCell: ln,
1087
+ insertAt: on,
1088
+ insertNextAt: an,
1089
+ isUpdateByRow: sn,
1090
+ isInsertByRow: rn,
1091
+ reloadRow: cn,
1092
+ revertData: dn,
1093
+ remove: mt,
1094
+ setAllTreeExpand: un,
1095
+ clearCurrentRow: hn,
1096
+ getAllChilds: yt
1089
1097
  });
1090
- const $e = ke(() => t.default().filter((n) => {
1091
- var l;
1092
- return ((l = n.type) == null ? void 0 : l.name) === "VirtualTableColumn";
1093
- }).map((n) => {
1094
- var l, s, g;
1098
+ const $e = ae(() => n.default().filter((i) => {
1099
+ var a;
1100
+ return ((a = i.type) == null ? void 0 : a.name) === "VirtualTableColumn";
1101
+ }).map((i) => {
1102
+ var a, c, p;
1095
1103
  return {
1096
- prop: (l = n.props) == null ? void 0 : l.prop,
1097
- title: (s = n.props) == null ? void 0 : s.title,
1098
- width: (g = n.props) == null ? void 0 : g.width,
1099
- slots: n.children
1104
+ prop: (a = i.props) == null ? void 0 : a.prop,
1105
+ title: (c = i.props) == null ? void 0 : c.title,
1106
+ width: (p = i.props) == null ? void 0 : p.width,
1107
+ slots: i.children
1100
1108
  };
1101
- })), qe = (n) => {
1109
+ })), Xe = (i) => {
1102
1110
  try {
1103
- return n === 0 ? {
1111
+ return i === 0 ? {
1104
1112
  width: "0px"
1105
- } : n ? {
1106
- flex: /^\d+$/.test(n) ? `0 0 ${n}px` : `0 0 ${n}`
1113
+ } : i ? {
1114
+ flex: /^\d+$/.test(i) ? `0 0 ${i}px` : `0 0 ${i}`
1107
1115
  } : {
1108
1116
  flex: "1 1 100%"
1109
1117
  };
1110
- } catch (l) {
1111
- return console.warn("[VirtualTable] computeColumnWidth error:", l), {
1118
+ } catch (a) {
1119
+ return console.warn("[VirtualTable] computeColumnWidth error:", a), {
1112
1120
  flex: "1 1 100%"
1113
1121
  };
1114
1122
  }
1115
- }, gt = ke(() => {
1116
- var n;
1117
- return (n = i.treeConfig) != null && n.childCurrent && z.value ? ft(z.value).map((l) => l[i.rowConfig.keyField]) : [];
1118
- }), pt = se({
1123
+ }, bt = ae(() => {
1124
+ var i;
1125
+ return (i = t.treeConfig) != null && i.childCurrent && m.value ? yt(m.value).map((a) => a[t.rowConfig.keyField]) : [];
1126
+ }), _t = te({
1119
1127
  viewStartIndex: 0,
1120
1128
  viewEndIndex: 0,
1121
1129
  visibleStartIndex: 0,
1122
1130
  visibleEndIndex: 0
1123
1131
  });
1124
- let We = null, Ue = null;
1125
- const nn = (n, l) => {
1126
- We && cancelAnimationFrame(We), We = requestAnimationFrame(() => {
1132
+ let Ye = null, Ze = null;
1133
+ const fn = (i, a) => {
1134
+ Ye && cancelAnimationFrame(Ye), Ye = requestAnimationFrame(() => {
1127
1135
  e("scroll-end", {
1128
- ...pt.value
1129
- }), We = null;
1136
+ ..._t.value
1137
+ }), Ye = null;
1130
1138
  });
1131
- }, ln = (n, l, s, g) => {
1132
- Ue && cancelAnimationFrame(Ue), Ue = requestAnimationFrame(() => {
1133
- pt.value = {
1134
- viewStartIndex: n,
1135
- viewEndIndex: l,
1136
- visibleStartIndex: s,
1137
- visibleEndIndex: g
1138
- }, Ue = null;
1139
+ }, gn = (i, a, c, p) => {
1140
+ Ze && cancelAnimationFrame(Ze), Ze = requestAnimationFrame(() => {
1141
+ _t.value = {
1142
+ viewStartIndex: i,
1143
+ viewEndIndex: a,
1144
+ visibleStartIndex: c,
1145
+ visibleEndIndex: p
1146
+ }, Ze = null;
1139
1147
  });
1140
- }, an = (n, l) => {
1141
- var w, m;
1148
+ }, pn = (i, a) => {
1149
+ var $, Y;
1142
1150
  const {
1143
- pageHeight: s,
1144
- margin: g,
1151
+ pageHeight: c,
1152
+ margin: p,
1145
1153
  showPageBorder: d,
1146
- pageBorderPadding: h,
1147
- pageBorderStyle: x
1148
- } = i.pageConfig;
1149
- return ee.value.has(l) ? J(Y, null, [i.pageConfig.showPageHeader && t["page-header"] ? (w = t["page-header"]) == null ? void 0 : w.call(t, {
1150
- pageNumber: n.pageNumber || l + 1,
1151
- pageIndex: l
1152
- }) : null, l === 0 && i.showHeader ? J("div", {
1154
+ pageBorderPadding: g,
1155
+ pageBorderStyle: w,
1156
+ showPageHeader: k,
1157
+ headerHeight: b = 0,
1158
+ footerHeight: _ = 0,
1159
+ showPageNumber: C
1160
+ } = t.pageConfig, F = i.pageNumber || a + 1, M = Math.max(100, c - p * 2 - b - _ - 20);
1161
+ return K.value.has(a) ? q(U, null, [k !== !1 && (n["page-header"] || b > 0) ? q("div", {
1162
+ class: "a4-page-header",
1163
+ style: {
1164
+ minHeight: `${Math.max(b, 1)}px`
1165
+ }
1166
+ }, [($ = n["page-header"]) == null ? void 0 : $.call(n, {
1167
+ pageNumber: F,
1168
+ pageIndex: a,
1169
+ totalPages: L.value.length
1170
+ })]) : null, a === 0 && t.showHeader ? q("div", {
1153
1171
  class: "a4-table-header"
1154
- }, [J("div", {
1172
+ }, [q("div", {
1155
1173
  class: "virtual-table-header we-vt-table--header we-vt-table--header-wrapper"
1156
- }, [$e.value.map((v) => {
1157
- var k, L, R;
1158
- return J("div", {
1174
+ }, [$e.value.map((j) => {
1175
+ var V, oe, ie;
1176
+ return q("div", {
1159
1177
  class: "we-vt-header--column",
1160
- key: v.prop,
1161
- style: qe(v.width)
1162
- }, [J("div", {
1178
+ key: j.prop,
1179
+ style: Xe(j.width)
1180
+ }, [q("div", {
1163
1181
  class: "we-vt-cell"
1164
- }, [(k = v.slots) != null && k.header ? (R = (L = v.slots) == null ? void 0 : L.header) == null ? void 0 : R.call(L, {
1165
- column: v
1166
- }) : v.title])]);
1167
- })])]) : null, J("div", {
1182
+ }, [(V = j.slots) != null && V.header ? (ie = (oe = j.slots) == null ? void 0 : oe.header) == null ? void 0 : ie.call(oe, {
1183
+ column: j
1184
+ }) : j.title])]);
1185
+ })])]) : null, q("div", {
1168
1186
  class: "a4-page-content",
1169
1187
  style: {
1170
- minHeight: `${s - g * 2}px`,
1188
+ minHeight: `${M}px`,
1171
1189
  ...d ? {
1172
- border: x,
1173
- padding: `${h}px`
1190
+ border: w,
1191
+ padding: `${g}px`
1174
1192
  } : {}
1175
1193
  }
1176
- }, [n.items.map((v) => {
1177
- var k, L;
1178
- return J("div", {
1179
- key: v[i.rowConfig.keyField],
1180
- "data-id": v[i.rowConfig.keyField],
1194
+ }, [i.items.map((j) => {
1195
+ var V, oe;
1196
+ return q("div", {
1197
+ key: j[t.rowConfig.keyField],
1198
+ "data-id": j[t.rowConfig.keyField],
1181
1199
  class: {
1182
1200
  "virtual-table-row": !0,
1183
1201
  "we-vt-body--row": !0,
1184
- "row--current": v[i.rowConfig.keyField] === ((k = z.value) == null ? void 0 : k[i.rowConfig.keyField]) || ((L = i.treeConfig) == null ? void 0 : L.childCurrent) && gt.value.includes(v[i.rowConfig.keyField])
1202
+ "row--current": j[t.rowConfig.keyField] === ((V = m.value) == null ? void 0 : V[t.rowConfig.keyField]) || ((oe = t.treeConfig) == null ? void 0 : oe.childCurrent) && bt.value.includes(j[t.rowConfig.keyField])
1185
1203
  },
1186
1204
  style: {
1187
1205
  width: "100%"
1188
1206
  },
1189
- onClick: () => me(v),
1190
- onDblclick: () => re(v)
1191
- }, [$e.value.map((R) => {
1192
- var F, H, te, he, G, pe, Me;
1193
- return J("div", {
1194
- key: R.prop,
1207
+ onClick: () => de(j),
1208
+ onDblclick: () => X(j)
1209
+ }, [$e.value.map((ie) => {
1210
+ var Le, Re, ge, ce, ze, G, Ae;
1211
+ return q("div", {
1212
+ key: ie.prop,
1195
1213
  class: "virtual-table-cell we-vt-cell",
1196
- style: qe(R.width),
1197
- "data-prop": R.prop
1198
- }, [v._editing && ((F = i.editConfig) == null ? void 0 : F.trigger) === "dblclick" ? ((H = R.slots) == null ? void 0 : H.edit) && ((he = (te = R.slots) == null ? void 0 : te.edit) == null ? void 0 : he.call(te, {
1199
- row: v,
1200
- column: R
1201
- })) : ((G = R.slots) == null ? void 0 : G.default) && ((Me = (pe = R.slots) == null ? void 0 : pe.default) == null ? void 0 : Me.call(pe, {
1202
- row: v,
1203
- column: R
1214
+ style: Xe(ie.width),
1215
+ "data-prop": ie.prop
1216
+ }, [j._editing && ((Le = t.editConfig) == null ? void 0 : Le.trigger) === "dblclick" ? ((Re = ie.slots) == null ? void 0 : Re.edit) && ((ce = (ge = ie.slots) == null ? void 0 : ge.edit) == null ? void 0 : ce.call(ge, {
1217
+ row: j,
1218
+ column: ie
1219
+ })) : ((ze = ie.slots) == null ? void 0 : ze.default) && ((Ae = (G = ie.slots) == null ? void 0 : G.default) == null ? void 0 : Ae.call(G, {
1220
+ row: j,
1221
+ column: ie
1204
1222
  }))]);
1205
1223
  })]);
1206
- })]), t["page-footer"] ? (m = t["page-footer"]) == null ? void 0 : m.call(t, {
1207
- pageNumber: n.pageNumber || l + 1,
1208
- pageIndex: l
1209
- }) : J("div", {
1224
+ })]), n["page-footer"] ? (Y = n["page-footer"]) == null ? void 0 : Y.call(n, {
1225
+ pageNumber: F,
1226
+ pageIndex: a,
1227
+ totalPages: L.value.length
1228
+ }) : q("div", {
1210
1229
  class: "a4-page-footer",
1211
- contenteditable: "false"
1212
- }, [J("span", {
1230
+ contenteditable: "false",
1231
+ style: {
1232
+ height: `${Math.max(_ || 0, 20)}px`
1233
+ }
1234
+ }, [C !== !1 ? q("span", {
1213
1235
  class: "page-number",
1214
1236
  contenteditable: "false"
1215
- }, [n.pageNumber || l + 1, Le(" / "), q.value.length])])]) : J("div", {
1237
+ }, [F, He(" / "), L.value.length]) : null])]) : q("div", {
1216
1238
  class: "a4-page-loading"
1217
- }, [J("div", {
1239
+ }, [q("div", {
1218
1240
  class: "loading-spinner"
1219
- }, null), J("div", {
1241
+ }, null), q("div", {
1220
1242
  class: "loading-text"
1221
- }, [Le("加载中...")])]);
1222
- }, on = () => {
1223
- var x;
1243
+ }, [He("加载中...")])]);
1244
+ }, vn = () => {
1245
+ var w;
1224
1246
  const {
1225
- pageHeight: n,
1226
- pageWidth: l,
1227
- margin: s,
1228
- gap: g,
1247
+ pageHeight: i,
1248
+ pageWidth: a,
1249
+ margin: c,
1250
+ gap: p,
1229
1251
  showPageBorder: d,
1230
- pageBorderPadding: h
1231
- } = i.pageConfig;
1232
- return J("div", {
1252
+ pageBorderPadding: g
1253
+ } = t.pageConfig;
1254
+ return q("div", {
1233
1255
  class: "virtual-table we-vt-table we-vt-table--render-default border--none"
1234
- }, [J("div", {
1256
+ }, [q("div", {
1235
1257
  class: "a4-pages-container",
1236
- contenteditable: ((x = i.editConfig) == null ? void 0 : x.trigger) === "contenteditable" ? "true" : void 0,
1237
- onContextmenu: M,
1238
- onFocusin: Re,
1239
- onFocusout: Pe
1240
- }, [q.value.map((w, m) => {
1241
- const v = ee.value.has(m);
1242
- return J("div", {
1243
- key: `page-${m}`,
1244
- class: v ? "a4-page" : "a4-page-placeholder",
1245
- "data-page-index": m,
1258
+ contenteditable: ((w = t.editConfig) == null ? void 0 : w.trigger) === "contenteditable" ? "true" : void 0,
1259
+ onContextmenu: W,
1260
+ onFocusin: Pe,
1261
+ onFocusout: We
1262
+ }, [L.value.map((k, b) => {
1263
+ const _ = K.value.has(b);
1264
+ return q("div", {
1265
+ key: `page-${b}`,
1266
+ class: _ ? "a4-page" : "a4-page-placeholder",
1267
+ "data-page-index": b,
1246
1268
  style: {
1247
- width: `${l}px`,
1248
- // 不设置minHeight,让内容自然决定高度
1249
- marginBottom: `${g}px`,
1250
- padding: v ? `${d ? s - h : s}px` : "0",
1269
+ width: `${a}px`,
1270
+ minHeight: `${i}px`,
1271
+ marginBottom: `${p}px`,
1272
+ padding: _ ? `${d ? c - g : c}px` : "0",
1251
1273
  boxSizing: "border-box",
1252
- // 使用relative定位,确保内部元素定位正确
1253
- position: "relative",
1254
- // 确保内容能够正常撑开
1255
- overflow: "visible"
1256
- }
1257
- }, [J("div", {
1258
- style: {
1259
- position: "absolute",
1260
- top: 0,
1261
- left: 0,
1262
- width: "1px",
1263
- height: `${n}px`,
1264
- visibility: "hidden",
1265
- pointerEvents: "none"
1274
+ position: "relative"
1266
1275
  }
1267
- }, null), an(w, m)]);
1276
+ }, [pn(k, b)]);
1268
1277
  })])]);
1269
- }, sn = () => {
1270
- var n;
1271
- return J("div", {
1278
+ }, mn = () => {
1279
+ var i;
1280
+ return q("div", {
1272
1281
  class: "virtual-table we-vt-table we-vt-table--render-default border--none"
1273
- }, [i.showHeader ? J("div", {
1282
+ }, [t.showHeader ? q("div", {
1274
1283
  class: "virtual-table-header we-vt-table--header we-vt-table--header-wrapper"
1275
- }, [$e.value.map((l) => {
1276
- var s, g, d;
1277
- return J("div", {
1284
+ }, [$e.value.map((a) => {
1285
+ var c, p, d;
1286
+ return q("div", {
1278
1287
  class: "we-vt-header--column",
1279
- key: l.prop,
1280
- style: qe(l.width)
1281
- }, [J("div", {
1288
+ key: a.prop,
1289
+ style: Xe(a.width)
1290
+ }, [q("div", {
1282
1291
  class: "we-vt-cell"
1283
- }, [(s = l.slots) != null && s.header ? (d = (g = l.slots) == null ? void 0 : g.header) == null ? void 0 : d.call(g, {
1284
- column: l
1285
- }) : l.title]), J("div", {
1292
+ }, [(c = a.slots) != null && c.header ? (d = (p = a.slots) == null ? void 0 : p.header) == null ? void 0 : d.call(p, {
1293
+ column: a
1294
+ }) : a.title]), q("div", {
1286
1295
  class: "we-vt-resizable is--line"
1287
1296
  }, null)]);
1288
- })]) : void 0, J(yn, {
1289
- ref: u,
1290
- items: _.value,
1291
- minItemSize: D.value,
1292
- keyField: i.rowConfig.keyField,
1297
+ })]) : void 0, q(En, {
1298
+ ref: r,
1299
+ items: A.value,
1300
+ minItemSize: Q.value,
1301
+ keyField: t.rowConfig.keyField,
1293
1302
  emitUpdate: !1,
1294
1303
  buffer: 300,
1295
1304
  class: "virtual-table-wrapper",
1296
- contenteditable: ((n = i.editConfig) == null ? void 0 : n.trigger) === "contenteditable" ? "true" : void 0,
1297
- onContextmenu: M,
1298
- onScrollend: nn,
1299
- onUpdate: ln,
1300
- onFocusin: Re,
1301
- onFocusout: Pe
1305
+ contenteditable: ((i = t.editConfig) == null ? void 0 : i.trigger) === "contenteditable" ? "true" : void 0,
1306
+ onContextmenu: W,
1307
+ onScrollend: fn,
1308
+ onUpdate: gn,
1309
+ onFocusin: Pe,
1310
+ onFocusout: We
1302
1311
  }, {
1303
1312
  default: ({
1304
- item: l,
1305
- index: s,
1306
- active: g
1313
+ item: a,
1314
+ index: c,
1315
+ active: p
1307
1316
  }) => {
1308
- var h, x, w;
1317
+ var g, w, k;
1309
1318
  let d;
1310
- return J(_n, {
1311
- key: l[i.rowConfig.keyField],
1312
- item: l,
1313
- active: g,
1314
- sizeDependencies: [(h = l.content) == null ? void 0 : h.length, l._editing, l.content_type],
1315
- "data-id": l[i.rowConfig.keyField],
1316
- "data-index": s,
1317
- "data-active": g,
1319
+ return q(Sn, {
1320
+ key: a[t.rowConfig.keyField],
1321
+ item: a,
1322
+ active: p,
1323
+ sizeDependencies: [(g = a.content) == null ? void 0 : g.length, a._editing, a.content_type],
1324
+ "data-id": a[t.rowConfig.keyField],
1325
+ "data-index": c,
1326
+ "data-active": p,
1318
1327
  class: {
1319
1328
  "virtual-table-row": !0,
1320
1329
  "we-vt-body--row": !0,
1321
- "row--current": l[i.rowConfig.keyField] === ((x = z.value) == null ? void 0 : x[i.rowConfig.keyField]) || // 如果是树,并且配置了childCurrent高亮子节点
1322
- ((w = i.treeConfig) == null ? void 0 : w.childCurrent) && gt.value.includes(l[i.rowConfig.keyField])
1330
+ "row--current": a[t.rowConfig.keyField] === ((w = m.value) == null ? void 0 : w[t.rowConfig.keyField]) || // 如果是树,并且配置了childCurrent高亮子节点
1331
+ ((k = t.treeConfig) == null ? void 0 : k.childCurrent) && bt.value.includes(a[t.rowConfig.keyField])
1323
1332
  }
1324
- }, ni(d = $e.value.map((m) => {
1325
- var v, k, L, R, F, H, te;
1326
- return J("div", {
1327
- key: m.prop,
1333
+ }, ui(d = $e.value.map((b) => {
1334
+ var _, C, F, O, M, $, Y;
1335
+ return q("div", {
1336
+ key: b.prop,
1328
1337
  class: "virtual-table-cell we-vt-cell",
1329
- style: qe(m.width),
1330
- "data-prop": m.prop
1331
- }, [l._editing && ((v = i.editConfig) == null ? void 0 : v.trigger) === "dblclick" ? ((k = m.slots) == null ? void 0 : k.edit) && ((R = (L = m.slots) == null ? void 0 : L.edit) == null ? void 0 : R.call(L, {
1332
- row: l,
1333
- column: m
1334
- })) : ((F = m.slots) == null ? void 0 : F.default) && ((te = (H = m.slots) == null ? void 0 : H.default) == null ? void 0 : te.call(H, {
1335
- row: l,
1336
- column: m
1338
+ style: Xe(b.width),
1339
+ "data-prop": b.prop
1340
+ }, [a._editing && ((_ = t.editConfig) == null ? void 0 : _.trigger) === "dblclick" ? ((C = b.slots) == null ? void 0 : C.edit) && ((O = (F = b.slots) == null ? void 0 : F.edit) == null ? void 0 : O.call(F, {
1341
+ row: a,
1342
+ column: b
1343
+ })) : ((M = b.slots) == null ? void 0 : M.default) && ((Y = ($ = b.slots) == null ? void 0 : $.default) == null ? void 0 : Y.call($, {
1344
+ row: a,
1345
+ column: b
1337
1346
  }))]);
1338
1347
  })) ? d : {
1339
1348
  default: () => [d]
@@ -1341,14 +1350,14 @@ const ii = /* @__PURE__ */ un({
1341
1350
  }
1342
1351
  })]);
1343
1352
  };
1344
- return () => i.pageConfig.enabled ? on() : sn();
1345
- }
1346
- }), ze = (i, e) => {
1347
- const t = i.__vccOpts || i;
1348
- for (const [a, o] of e)
1349
- t[a] = o;
1350
- return t;
1351
- }, li = /* @__PURE__ */ ze(ii, [["__scopeId", "data-v-274d8f6d"]]), ai = {
1353
+ return () => t.pageConfig.enabled ? vn() : mn();
1354
+ }
1355
+ }), Be = (t, e) => {
1356
+ const n = t.__vccOpts || t;
1357
+ for (const [l, o] of e)
1358
+ n[l] = o;
1359
+ return n;
1360
+ }, fi = /* @__PURE__ */ Be(hi, [["__scopeId", "data-v-3756d9b0"]]), gi = {
1352
1361
  name: "VirtualTableColumn",
1353
1362
  props: {
1354
1363
  prop: String,
@@ -1356,13 +1365,13 @@ const ii = /* @__PURE__ */ un({
1356
1365
  width: [String, Number]
1357
1366
  }
1358
1367
  };
1359
- function oi(i, e, t, a, o, u) {
1360
- return gn(i.$slots, "default");
1368
+ function pi(t, e, n, l, o, r) {
1369
+ return Cn(t.$slots, "default");
1361
1370
  }
1362
- const si = /* @__PURE__ */ ze(ai, [["render", oi]]), ri = { class: "catalog-node" }, ci = ["title"], di = { class: "catalog-node__text" }, ui = {
1371
+ const vi = /* @__PURE__ */ Be(gi, [["render", pi]]), mi = { class: "catalog-node" }, yi = ["title"], bi = { class: "catalog-node__text" }, _i = {
1363
1372
  key: 0,
1364
1373
  class: "catalog-node__children"
1365
- }, hi = {
1374
+ }, xi = {
1366
1375
  __name: "CatalogNode",
1367
1376
  props: {
1368
1377
  item: { type: Object, required: !0 },
@@ -1370,97 +1379,97 @@ const si = /* @__PURE__ */ ze(ai, [["render", oi]]), ri = { class: "catalog-node
1370
1379
  activeId: { type: String, default: "" }
1371
1380
  },
1372
1381
  emits: ["navigate"],
1373
- setup(i, { emit: e }) {
1374
- const t = i, a = e, o = se(!0), u = ke(() => t.item.children && t.item.children.length > 0);
1375
- function P(S) {
1376
- S.stopPropagation(), o.value = !o.value;
1382
+ setup(t, { emit: e }) {
1383
+ const n = t, l = e, o = te(!0), r = ae(() => n.item.children && n.item.children.length > 0);
1384
+ function y(s) {
1385
+ s.stopPropagation(), o.value = !o.value;
1377
1386
  }
1378
- return (S, z) => {
1379
- const A = pn("CatalogNode", !0);
1380
- return f(), p("div", ri, [
1381
- ce("div", {
1382
- class: Ee(["catalog-node__label", { "is-active": i.activeId === i.item.nodeId }]),
1383
- style: j({ paddingLeft: 10 + i.depth * 14 + "px" }),
1384
- title: i.item.name,
1385
- onClick: z[0] || (z[0] = (Z) => a("navigate", i.item))
1387
+ return (s, m) => {
1388
+ const h = Mn("CatalogNode", !0);
1389
+ return u(), v("div", mi, [
1390
+ ee("div", {
1391
+ class: Ie(["catalog-node__label", { "is-active": t.activeId === t.item.nodeId }]),
1392
+ style: N({ paddingLeft: 10 + t.depth * 14 + "px" }),
1393
+ title: t.item.name,
1394
+ onClick: m[0] || (m[0] = (I) => l("navigate", t.item))
1386
1395
  }, [
1387
- ce("span", {
1396
+ ee("span", {
1388
1397
  class: "catalog-node__toggle",
1389
- onClick: P
1398
+ onClick: y
1390
1399
  }, [
1391
- u.value ? (f(), Fe(Ze(o.value ? Ae(Dn) : Ae(Ht)), {
1400
+ r.value ? (u(), ke(nt(o.value ? z(Gn) : z(Ut)), {
1392
1401
  key: 0,
1393
1402
  size: 14
1394
- })) : ve("", !0)
1403
+ })) : ue("", !0)
1395
1404
  ]),
1396
- ce("span", di, ie(i.item.name || "(无标题)"), 1)
1397
- ], 14, ci),
1398
- u.value && o.value ? (f(), p("div", ui, [
1399
- (f(!0), p(Y, null, oe(i.item.children, (Z) => (f(), Fe(A, {
1400
- key: Z.nodeId,
1401
- item: Z,
1402
- depth: i.depth + 1,
1403
- "active-id": i.activeId,
1404
- onNavigate: z[1] || (z[1] = (N) => a("navigate", N))
1405
+ ee("span", bi, J(t.item.name || "(无标题)"), 1)
1406
+ ], 14, yi),
1407
+ r.value && o.value ? (u(), v("div", _i, [
1408
+ (u(!0), v(U, null, Z(t.item.children, (I) => (u(), ke(h, {
1409
+ key: I.nodeId,
1410
+ item: I,
1411
+ depth: t.depth + 1,
1412
+ "active-id": t.activeId,
1413
+ onNavigate: m[1] || (m[1] = (S) => l("navigate", S))
1405
1414
  }, null, 8, ["item", "depth", "active-id"]))), 128))
1406
- ])) : ve("", !0)
1415
+ ])) : ue("", !0)
1407
1416
  ]);
1408
1417
  };
1409
1418
  }
1410
- }, fi = /* @__PURE__ */ ze(hi, [["__scopeId", "data-v-75ca10a3"]]), gi = {
1419
+ }, ki = /* @__PURE__ */ Be(xi, [["__scopeId", "data-v-ac882917"]]), wi = {
1411
1420
  key: 0,
1412
1421
  class: "catalog catalog--collapsed"
1413
- }, pi = {
1422
+ }, Ci = {
1414
1423
  key: 1,
1415
1424
  class: "catalog"
1416
- }, vi = { class: "catalog__header" }, mi = { class: "catalog__title" }, yi = { class: "catalog__body" }, _i = {
1425
+ }, Mi = { class: "catalog__header" }, Ii = { class: "catalog__title" }, Ei = { class: "catalog__body" }, Si = {
1417
1426
  key: 0,
1418
1427
  class: "catalog__empty"
1419
- }, bi = {
1428
+ }, Ti = {
1420
1429
  __name: "index",
1421
1430
  props: {
1422
1431
  items: { type: Array, default: () => [] }
1423
1432
  },
1424
1433
  emits: ["navigate"],
1425
- setup(i, { emit: e }) {
1426
- const t = e, a = se(!1), o = se("");
1427
- function u(P) {
1428
- o.value = P.nodeId, t("navigate", P);
1434
+ setup(t, { emit: e }) {
1435
+ const n = e, l = te(!1), o = te("");
1436
+ function r(y) {
1437
+ o.value = y.nodeId, n("navigate", y);
1429
1438
  }
1430
- return (P, S) => a.value ? (f(), p("div", gi, [
1431
- ce("button", {
1439
+ return (y, s) => l.value ? (u(), v("div", wi, [
1440
+ ee("button", {
1432
1441
  class: "catalog__icon-btn",
1433
1442
  title: "展开目录",
1434
- onClick: S[0] || (S[0] = (z) => a.value = !1)
1443
+ onClick: s[0] || (s[0] = (m) => l.value = !1)
1435
1444
  }, [
1436
- J(Ae(zn), { size: 18 })
1445
+ q(z(Jn), { size: 18 })
1437
1446
  ])
1438
- ])) : (f(), p("div", pi, [
1439
- ce("div", vi, [
1440
- ce("span", mi, [
1441
- J(Ae(Nn), { size: 16 }),
1442
- S[2] || (S[2] = Le(" 目录 ", -1))
1447
+ ])) : (u(), v("div", Ci, [
1448
+ ee("div", Mi, [
1449
+ ee("span", Ii, [
1450
+ q(z(Xn), { size: 16 }),
1451
+ s[2] || (s[2] = He(" 目录 ", -1))
1443
1452
  ]),
1444
- ce("button", {
1453
+ ee("button", {
1445
1454
  class: "catalog__icon-btn",
1446
1455
  title: "收起目录",
1447
- onClick: S[1] || (S[1] = (z) => a.value = !0)
1456
+ onClick: s[1] || (s[1] = (m) => l.value = !0)
1448
1457
  }, [
1449
- J(Ae(Vn), { size: 18 })
1458
+ q(z(Yn), { size: 18 })
1450
1459
  ])
1451
1460
  ]),
1452
- ce("div", yi, [
1453
- (f(!0), p(Y, null, oe(i.items, (z) => (f(), Fe(fi, {
1454
- key: z.nodeId,
1455
- item: z,
1461
+ ee("div", Ei, [
1462
+ (u(!0), v(U, null, Z(t.items, (m) => (u(), ke(ki, {
1463
+ key: m.nodeId,
1464
+ item: m,
1456
1465
  "active-id": o.value,
1457
- onNavigate: u
1466
+ onNavigate: r
1458
1467
  }, null, 8, ["item", "active-id"]))), 128)),
1459
- i.items.length ? ve("", !0) : (f(), p("div", _i, " 暂无目录 "))
1468
+ t.items.length ? ue("", !0) : (u(), v("div", Si, " 暂无目录 "))
1460
1469
  ])
1461
1470
  ]));
1462
1471
  }
1463
- }, xi = /* @__PURE__ */ ze(bi, [["__scopeId", "data-v-c64a3b3a"]]), ki = {
1472
+ }, Fi = /* @__PURE__ */ Be(Ti, [["__scopeId", "data-v-8becafa1"]]), Ai = {
1464
1473
  first: 1,
1465
1474
  second: 2,
1466
1475
  third: 3,
@@ -1468,33 +1477,33 @@ const si = /* @__PURE__ */ ze(ai, [["render", oi]]), ri = { class: "catalog-node
1468
1477
  fifth: 5,
1469
1478
  sixth: 6
1470
1479
  };
1471
- function wi(i) {
1472
- return i.blockType !== "title" || !i.level ? 0 : ki[i.level] || 1;
1480
+ function Pi(t) {
1481
+ return t.blockType !== "title" || !t.level ? 0 : Ai[t.level] || 1;
1473
1482
  }
1474
- function Ci(i) {
1483
+ function $i(t) {
1475
1484
  const e = [];
1476
- for (const o of i || []) {
1477
- const u = wi(o);
1478
- u && e.push({
1485
+ for (const o of t || []) {
1486
+ const r = Pi(o);
1487
+ r && e.push({
1479
1488
  id: o.node_id,
1480
1489
  nodeId: o.node_id,
1481
1490
  name: (o.content || "").trim(),
1482
- level: u,
1491
+ level: r,
1483
1492
  children: []
1484
1493
  });
1485
1494
  }
1486
1495
  if (!e.length) return [];
1487
- const t = (o, u) => {
1488
- const P = u.children[u.children.length - 1];
1489
- P && o.level > P.level ? t(o, P) : u.children.push(o);
1490
- }, a = [];
1496
+ const n = (o, r) => {
1497
+ const y = r.children[r.children.length - 1];
1498
+ y && o.level > y.level ? n(o, y) : r.children.push(o);
1499
+ }, l = [];
1491
1500
  for (const o of e) {
1492
- const u = a[a.length - 1];
1493
- u && o.level > u.level ? t(o, u) : a.push(o);
1501
+ const r = l[l.length - 1];
1502
+ r && o.level > r.level ? n(o, r) : l.push(o);
1494
1503
  }
1495
- return a;
1504
+ return l;
1496
1505
  }
1497
- const Mi = {
1506
+ const Li = {
1498
1507
  first: 0,
1499
1508
  second: 1,
1500
1509
  third: 2,
@@ -1504,58 +1513,508 @@ const Mi = {
1504
1513
  seventh: 6,
1505
1514
  eighth: 7
1506
1515
  };
1507
- function Xe(i, e) {
1508
- let t = "", a = i;
1516
+ function et(t, e) {
1517
+ let n = "", l = t;
1509
1518
  const o = e ? 65 : 97;
1510
- for (; a > 0; ) {
1511
- const u = (a - 1) % 26;
1512
- t = String.fromCharCode(o + u) + t, a = Math.floor((a - 1) / 26);
1519
+ for (; l > 0; ) {
1520
+ const r = (l - 1) % 26;
1521
+ n = String.fromCharCode(o + r) + n, l = Math.floor((l - 1) / 26);
1513
1522
  }
1514
- return t;
1523
+ return n;
1515
1524
  }
1516
- const Ft = [
1517
- (i) => i.toString(),
1525
+ const Lt = [
1526
+ (t) => t.toString(),
1518
1527
  // first:数字
1519
- (i) => Xe(i, !0),
1528
+ (t) => et(t, !0),
1520
1529
  // second:大写字母
1521
- (i) => `(${i})`,
1530
+ (t) => `(${t})`,
1522
1531
  // third:括号数字
1523
- (i) => `(${Xe(i, !1)})`,
1532
+ (t) => `(${et(t, !1)})`,
1524
1533
  // fourth:括号小写字母
1525
- (i) => `${i})`,
1534
+ (t) => `${t})`,
1526
1535
  // fifth:数字+右括号
1527
- (i) => `${Xe(i, !1)})`,
1536
+ (t) => `${et(t, !1)})`,
1528
1537
  // sixth:小写字母+右括号
1529
- (i) => `<${i}>`,
1538
+ (t) => `<${t}>`,
1530
1539
  // seventh:数字+尖括号
1531
- (i) => `<${Xe(i, !1)}>`
1540
+ (t) => `<${et(t, !1)}>`
1532
1541
  // eighth:小写字母+尖括号
1533
1542
  ];
1534
- function Ii() {
1535
- const i = new Array(8).fill(0);
1543
+ function Ri() {
1544
+ const t = new Array(8).fill(0);
1536
1545
  return {
1537
- next(e, t) {
1538
- const a = Mi[e];
1539
- if (a == null) return "";
1540
- i[a]++;
1541
- for (let u = a + 1; u < i.length; u++) i[u] = 0;
1542
- if (t != null && t !== "")
1543
- return `${t} `;
1544
- const o = Ft[Math.min(a, Ft.length - 1)];
1545
- return `${o(i[a])}. `;
1546
+ next(e, n) {
1547
+ const l = Li[e];
1548
+ if (l == null) return "";
1549
+ t[l]++;
1550
+ for (let r = l + 1; r < t.length; r++) t[r] = 0;
1551
+ if (n != null && n !== "")
1552
+ return `${n} `;
1553
+ const o = Lt[Math.min(l, Lt.length - 1)];
1554
+ return `${o(t[l])}. `;
1546
1555
  }
1547
1556
  };
1548
1557
  }
1549
- const Ei = { class: "editor-layout word-editor-scope" }, Si = { class: "editor-container" }, Ti = {
1550
- key: 0,
1551
- class: "editor-loading"
1552
- }, Fi = {
1558
+ const qe = 14, Jt = 760, Rt = 756, Hi = {
1559
+ left: "left",
1560
+ center: "center",
1561
+ right: "right",
1562
+ alignment: "justify",
1563
+ justify: "justify"
1564
+ };
1565
+ function Xt(t) {
1566
+ const e = [];
1567
+ let n = !1;
1568
+ const l = (o) => {
1569
+ if (n) {
1570
+ if (o && o.value != null && /^[\n200B]+$/.test(o.value)) {
1571
+ e.push(o);
1572
+ return;
1573
+ }
1574
+ n = !1, e.push({ ...o, _coverBreakBefore: !0 });
1575
+ } else
1576
+ e.push(o);
1577
+ };
1578
+ for (const o of t || []) {
1579
+ if (o && o.type === "pageBreak") {
1580
+ n = !0;
1581
+ continue;
1582
+ }
1583
+ if (o && o.type === "area") {
1584
+ const r = Xt(o.valueList || []), y = (o.areaId || "").includes("cover");
1585
+ for (const s of r) l(s);
1586
+ y && (n = !0);
1587
+ } else
1588
+ l(o);
1589
+ }
1590
+ return e;
1591
+ }
1592
+ function Ue(t) {
1593
+ const e = Xt(t), n = [];
1594
+ let l = [], o = 0, r = null;
1595
+ const y = (m) => {
1596
+ l.length && (n.push({ type: "paragraph", elements: [...l], rowFlex: m }), l = []);
1597
+ }, s = () => {
1598
+ if (o === 0) return;
1599
+ const m = r;
1600
+ y(m);
1601
+ for (let h = 1; h < o; h++)
1602
+ n.push({ type: "paragraph", elements: [], rowFlex: m });
1603
+ o = 0, r = null;
1604
+ };
1605
+ for (const m of e || [])
1606
+ if (m.type === "table")
1607
+ s(), y(), n.push({ type: "table", el: m });
1608
+ else if (m.type === "title")
1609
+ s(), y(), n.push({ type: "title", el: m });
1610
+ else if (m.type === "list") {
1611
+ s(), y();
1612
+ const h = [];
1613
+ let I = [];
1614
+ for (const S of m.valueList || [])
1615
+ S.value === `
1616
+ ` || S.value === "​" ? (h.push([...I]), I = []) : I.push(S);
1617
+ (I.length || h.length === 0) && h.push([...I]), n.push({ type: "list", listType: m.listType || "ul", listStyle: m.listStyle || "disc", items: h });
1618
+ } else if (m.listId) {
1619
+ s(), y();
1620
+ const h = m.value === "​" || m.value === "" ? [] : [m];
1621
+ n.push({ type: "list", listType: m.listType || "ul", listStyle: m.listStyle || "disc", items: [h] });
1622
+ } else m.value != null && /^[\n200B]+$/.test(m.value) ? (o += m.value.length, m.rowFlex && (r = m.rowFlex)) : (s(), l.push(m));
1623
+ return s(), y(), n;
1624
+ }
1625
+ function Oe(t) {
1626
+ const e = t.filter((h) => h.type === "image").reduce((h, I) => h + (I.height || I.width || 0), 0), n = t.filter((h) => h.type !== "image").map((h) => h.value || "").join("");
1627
+ if (!n) return e || 20;
1628
+ const l = t.reduce((h, I) => Math.max(h, I.size || 0), 0) || 14, o = l + 6, r = (n.match(/[一-龥]/g) || []).length, y = n.length - r, s = r * l + y * (l * 0.5), m = Math.max(1, Math.ceil(s / Jt));
1629
+ return e + Math.max(o, m * o);
1630
+ }
1631
+ function Oi(t) {
1632
+ if (!t || !t.length) return [[]];
1633
+ const e = [];
1634
+ let n = [];
1635
+ for (const l of t)
1636
+ l.type === "image" && (l.width || 0) >= Jt ? (n.length && (e.push(n), n = []), e.push([l])) : n.push(l);
1637
+ return n.length && e.push(n), e.length ? e : [[]];
1638
+ }
1639
+ function Ht(t) {
1640
+ if (t.length === 0) return [];
1641
+ const e = new Array(t.length).fill(0);
1642
+ t.forEach((r, y) => {
1643
+ (r.tdList || []).forEach((s) => {
1644
+ const m = s.rowspan || 1;
1645
+ if (m > 1) {
1646
+ const h = Math.min(y + m - 1, t.length - 1);
1647
+ e[y] = Math.max(e[y], h);
1648
+ for (let I = 1; I < m && y + I < t.length; I++)
1649
+ e[y + I] = Math.max(e[y + I], h);
1650
+ }
1651
+ });
1652
+ });
1653
+ const n = [];
1654
+ let l = 0, o = 0;
1655
+ for (let r = 0; r < t.length; r++)
1656
+ o = Math.max(o, e[r]), o <= r && (n.push(t.slice(l, r + 1)), l = r + 1, o = 0);
1657
+ return l < t.length && n.push(t.slice(l)), n;
1658
+ }
1659
+ function ct(t) {
1660
+ const e = (t == null ? void 0 : t.width) || 0;
1661
+ return !e || e <= Rt ? 1 : Rt / e;
1662
+ }
1663
+ function Ot(t) {
1664
+ var r, y;
1665
+ const e = t.elements || [], n = ((r = e.find((s) => s.rowFlex)) == null ? void 0 : r.rowFlex) || t.rowFlex, l = { textAlign: Hi[n] || "left" }, o = (y = e.find((s) => s.rowMargin)) == null ? void 0 : y.rowMargin;
1666
+ return o && (l.lineHeight = o), l;
1667
+ }
1668
+ function Bi(t) {
1669
+ var r;
1670
+ const e = Ue(t.value);
1671
+ let n = 0, l = 0, o = !1;
1672
+ for (const y of e)
1673
+ if (y.type === "paragraph") {
1674
+ if (!y.elements.length) continue;
1675
+ n++;
1676
+ for (const s of y.elements)
1677
+ (s.type === "image" || s.type === "table") && (o = !0), l += (s.value || "").length;
1678
+ } else y.type === "list" ? (n += ((r = y.items) == null ? void 0 : r.length) || 1, o = !0) : (n++, o = !0);
1679
+ return n > 1 || l > 30 || o ? "top" : t.verticalAlign || "middle";
1680
+ }
1681
+ function he(t) {
1682
+ const e = {};
1683
+ t.font && (e.fontFamily = t.font), e.fontSize = (t.size || qe) + "px", t.bold != null && (e.fontWeight = t.bold ? "bold" : "normal"), t.italic != null && (e.fontStyle = t.italic ? "italic" : "normal"), t.color && (e.color = t.color), t.highlight && t.highlight !== "rgb(255, 255, 255)" && t.highlight !== "#ffffff" && (e.backgroundColor = t.highlight);
1684
+ const n = [t.underline && "underline", t.strikeout && "line-through"].filter(Boolean).join(" ");
1685
+ return n && (e.textDecoration = n), t.letterSpacing && (e.letterSpacing = t.letterSpacing + "px"), e;
1686
+ }
1687
+ const Di = 5;
1688
+ function Bt(t, e = !1) {
1689
+ var l, o;
1690
+ let n = 0;
1691
+ for (const r of t)
1692
+ if (r.type === "table") {
1693
+ const y = ((l = r.el) == null ? void 0 : l.trList) || [];
1694
+ n += y.reduce((s, m) => s + (m.height || m.minHeight || 35), 0);
1695
+ } else if (r.type === "title")
1696
+ n += Oe(r.titleValueList || ((o = r.el) == null ? void 0 : o.valueList) || []);
1697
+ else if (r.type === "paragraph")
1698
+ n += Oe(r.elements || []);
1699
+ else if (r.type === "list") {
1700
+ const y = Math.round(18), s = (r.items || []).reduce(
1701
+ (m, h) => m + (h.length ? Oe(h) : y),
1702
+ 0
1703
+ );
1704
+ n += Math.max(s, y);
1705
+ }
1706
+ return n + (e && n > 0 ? Di : 0);
1707
+ }
1708
+ const Ni = {
1553
1709
  key: 0,
1554
1710
  class: "empty-line"
1555
- }, Ai = ["href"], Pi = ["src"], $i = ["checked"], Li = ["checked"], Ri = {
1711
+ }, zi = ["href"], Vi = ["src"], ji = ["checked"], Ki = ["checked"], qi = {
1556
1712
  key: 4,
1557
1713
  class: "ctrl-input"
1558
- }, Oi = ["checked"], Bi = ["checked"], Hi = { key: 0 }, Di = ["colspan", "rowspan"], zi = { key: 0 }, Ni = ["src"], Vi = ["href"], ji = ["checked"], Ki = ["checked"], qi = ["checked"], He = 14, Ie = 1123, At = 760, Pt = 756, Wi = {
1714
+ }, Ui = ["checked"], Wi = ["checked"], Gi = { key: 0 }, Ji = ["colspan", "rowspan"], Xi = { key: 0 }, Yi = ["src"], Zi = ["href"], Qi = ["checked"], el = ["checked"], tl = ["checked"], nl = {
1715
+ __name: "DocBlock",
1716
+ props: {
1717
+ block: {
1718
+ type: Object,
1719
+ required: !0
1720
+ },
1721
+ isHeaderFooter: {
1722
+ type: Boolean,
1723
+ default: !1
1724
+ }
1725
+ },
1726
+ setup(t) {
1727
+ const e = t, n = jt("bindTableObserver", null), l = ae(() => e.isHeaderFooter ? 0 : e.block.indentPx ?? 0);
1728
+ return (o, r) => {
1729
+ var y;
1730
+ return t.block.blockType === "title" ? (u(), v("p", {
1731
+ key: 0,
1732
+ class: Ie(["doc-title", `doc-title--${t.block.level}`]),
1733
+ style: N({ paddingLeft: l.value ? l.value + "px" : void 0 })
1734
+ }, [
1735
+ (u(!0), v(U, null, Z(t.block.titleValueList || [], (s, m) => (u(), v("span", {
1736
+ key: m,
1737
+ style: N(z(he)(s))
1738
+ }, J(s.value), 5))), 128))
1739
+ ], 6)) : t.block.blockType === "paragraph" ? (u(), v("p", {
1740
+ key: 1,
1741
+ class: "doc-para",
1742
+ style: N({ ...z(Ot)(t.block), paddingLeft: l.value ? l.value + "px" : void 0 })
1743
+ }, [
1744
+ t.block.elements.length ? ue("", !0) : (u(), v("span", Ni, " ")),
1745
+ (u(!0), v(U, null, Z(t.block.elements, (s, m) => {
1746
+ var h, I, S, L, x, K, ne, R, T, f, E, B, A;
1747
+ return u(), v(U, { key: m }, [
1748
+ !s.type || s.type === "text" ? (u(), v("span", {
1749
+ key: 0,
1750
+ style: N(z(he)(s))
1751
+ }, J(s.value), 5)) : s.type === "hyperlink" ? (u(), v("a", {
1752
+ key: 1,
1753
+ href: s.url,
1754
+ class: "doc-link",
1755
+ target: "_blank",
1756
+ rel: "noopener"
1757
+ }, [
1758
+ (u(!0), v(U, null, Z(s.valueList || [], (P, Q) => (u(), v("span", {
1759
+ key: Q,
1760
+ style: N(z(he)(P))
1761
+ }, J(P.value), 5))), 128))
1762
+ ], 8, zi)) : s.type === "image" ? (u(), v("img", {
1763
+ key: 2,
1764
+ src: s.value,
1765
+ class: "doc-image",
1766
+ style: N({
1767
+ width: s.width ? s.width + "px" : "auto",
1768
+ height: s.height ? s.height + "px" : "auto"
1769
+ })
1770
+ }, null, 12, Vi)) : s.type === "control" ? (u(), v(U, { key: 3 }, [
1771
+ ((h = s.control) == null ? void 0 : h.type) === "text" ? (u(), v("span", {
1772
+ key: 0,
1773
+ style: N({ fontSize: (s.control.size || 12) + "px" })
1774
+ }, [
1775
+ (u(!0), v(U, null, Z(s.control.value || [], (P, Q) => (u(), v("span", {
1776
+ key: Q,
1777
+ style: N(z(he)(P))
1778
+ }, J(P.value), 5))), 128))
1779
+ ], 4)) : ((I = s.control) == null ? void 0 : I.type) === "input" ? (u(), v("span", {
1780
+ key: 1,
1781
+ class: "ctrl-input",
1782
+ style: N({
1783
+ minWidth: (s.control.minWidth || 60) + "px",
1784
+ fontSize: (s.control.size || 12) + "px"
1785
+ })
1786
+ }, [
1787
+ (u(!0), v(U, null, Z(s.control.value || [], (P, Q) => (u(), v("span", { key: Q }, J(P.value), 1))), 128))
1788
+ ], 4)) : ((S = s.control) == null ? void 0 : S.type) === "radio" ? (u(), v("span", {
1789
+ key: 2,
1790
+ class: Ie(["ctrl-options", { "ctrl-options--vertical": ((x = (L = s.control.extension) == null ? void 0 : L.elementAttributes) == null ? void 0 : x.layout) === "vertical" }]),
1791
+ style: N({ fontSize: (s.control.size || z(qe)) + "px" })
1792
+ }, [
1793
+ (u(!0), v(U, null, Z(s.control.valueSets || [], (P, Q) => (u(), v("label", {
1794
+ key: Q,
1795
+ class: "ctrl-option"
1796
+ }, [
1797
+ ee("input", {
1798
+ type: "radio",
1799
+ disabled: "",
1800
+ checked: s.control.code === P.code
1801
+ }, null, 8, ji),
1802
+ He(" " + J(P.value), 1)
1803
+ ]))), 128))
1804
+ ], 6)) : ((K = s.control) == null ? void 0 : K.type) === "checkbox" ? (u(), v("span", {
1805
+ key: 3,
1806
+ class: Ie(["ctrl-options", { "ctrl-options--vertical": ((R = (ne = s.control.extension) == null ? void 0 : ne.elementAttributes) == null ? void 0 : R.layout) === "vertical" }]),
1807
+ style: N({ fontSize: (s.control.size || z(qe)) + "px" })
1808
+ }, [
1809
+ (u(!0), v(U, null, Z(s.control.valueSets || [], (P, Q) => (u(), v("label", {
1810
+ key: Q,
1811
+ class: "ctrl-option"
1812
+ }, [
1813
+ ee("input", {
1814
+ type: "checkbox",
1815
+ disabled: "",
1816
+ checked: (s.control.code || "").split(",").includes(P.code)
1817
+ }, null, 8, Ki),
1818
+ He(" " + J(P.value), 1)
1819
+ ]))), 128))
1820
+ ], 6)) : ((T = s.control) == null ? void 0 : T.type) === "select" ? (u(), v("span", qi, J(((E = (f = s.control.value) == null ? void 0 : f[0]) == null ? void 0 : E.value) || s.control.placeholder || ""), 1)) : ue("", !0)
1821
+ ], 64)) : s.type === "checkbox" ? (u(), v("input", {
1822
+ key: 4,
1823
+ type: "checkbox",
1824
+ checked: !!((B = s.checkbox) != null && B.value),
1825
+ disabled: "",
1826
+ class: "el-check"
1827
+ }, null, 8, Ui)) : s.type === "radio" ? (u(), v("input", {
1828
+ key: 5,
1829
+ type: "radio",
1830
+ checked: !!((A = s.radio) != null && A.value),
1831
+ disabled: "",
1832
+ class: "el-check"
1833
+ }, null, 8, Wi)) : s.type === "superscript" ? (u(), v("sup", {
1834
+ key: 6,
1835
+ style: N(z(he)(s))
1836
+ }, J(s.value), 5)) : s.type === "subscript" ? (u(), v("sub", {
1837
+ key: 7,
1838
+ style: N(z(he)(s))
1839
+ }, J(s.value), 5)) : s.type === "tab" ? (u(), v("span", {
1840
+ key: 8,
1841
+ class: "doc-tab",
1842
+ style: N({ width: (s.size || z(qe)) + "px" })
1843
+ }, null, 4)) : ue("", !0)
1844
+ ], 64);
1845
+ }), 128))
1846
+ ], 4)) : t.block.blockType === "list" ? (u(), ke(nt(t.block.listType === "ol" ? "ol" : "ul"), {
1847
+ key: 2,
1848
+ class: "doc-list",
1849
+ style: N({ listStyleType: t.block.listStyle === "decimal" ? "decimal" : t.block.listStyle === "lower-alpha" ? "lower-alpha" : "disc", paddingLeft: l.value ? l.value + 24 + "px" : void 0 })
1850
+ }, {
1851
+ default: Ke(() => [
1852
+ (u(!0), v(U, null, Z(t.block.items, (s, m) => (u(), v("li", {
1853
+ key: m,
1854
+ class: "doc-list-item"
1855
+ }, [
1856
+ (u(!0), v(U, null, Z(s, (h, I) => (u(), v(U, { key: I }, [
1857
+ !h.type || h.type === "text" ? (u(), v("span", {
1858
+ key: 0,
1859
+ style: N(z(he)(h))
1860
+ }, J(h.value), 5)) : h.type === "superscript" ? (u(), v("sup", {
1861
+ key: 1,
1862
+ style: N(z(he)(h))
1863
+ }, J(h.value), 5)) : h.type === "subscript" ? (u(), v("sub", {
1864
+ key: 2,
1865
+ style: N(z(he)(h))
1866
+ }, J(h.value), 5)) : ue("", !0)
1867
+ ], 64))), 128))
1868
+ ]))), 128))
1869
+ ]),
1870
+ _: 1
1871
+ }, 8, ["style"])) : t.block.blockType === "table-row-group" ? (u(), v("div", {
1872
+ key: 3,
1873
+ class: Ie(["doc-table-row-wrap", { "is-first": t.block.isFirst, "is-last": t.block.isLast, "is-page-break": t.block.isPageBreak }]),
1874
+ style: N({
1875
+ display: t.block.tableRowFlex ? "flex" : void 0,
1876
+ justifyContent: t.block.tableRowFlex === "right" ? "flex-end" : t.block.tableRowFlex === "center" ? "center" : t.block.tableRowFlex === "left" ? "flex-start" : void 0,
1877
+ paddingLeft: l.value ? l.value + "px" : void 0
1878
+ })
1879
+ }, [
1880
+ ee("div", {
1881
+ style: N({
1882
+ overflow: t.block.sliceHeight != null ? "hidden" : void 0,
1883
+ height: t.block.sliceHeight != null ? (t.block.isLast ? t.block.sliceHeight + 1 : t.block.sliceHeight) + "px" : void 0,
1884
+ width: t.block.tableEl.width ? "max-content" : "100%"
1885
+ })
1886
+ }, [
1887
+ ee("table", {
1888
+ ref: t.block._baseKey && z(n) ? (s) => z(n)(s, t.block._baseKey) : void 0,
1889
+ class: Ie(["doc-table", { "doc-table--no-border": t.block.tableEl.borderType === "empty" }]),
1890
+ style: N({
1891
+ width: t.block.tableEl.width ? t.block.tableEl.width * z(ct)(t.block.tableEl) + "px" : "100%",
1892
+ transform: t.block.sliceOffset ? `translateY(-${t.block.sliceOffset}px)` : void 0
1893
+ })
1894
+ }, [
1895
+ (y = t.block.tableEl.colgroup) != null && y.length ? (u(), v("colgroup", Gi, [
1896
+ (u(!0), v(U, null, Z(t.block.tableEl.colgroup, (s, m) => (u(), v("col", {
1897
+ key: m,
1898
+ style: N({ width: s.width * z(ct)(t.block.tableEl) + "px" })
1899
+ }, null, 4))), 128))
1900
+ ])) : ue("", !0),
1901
+ ee("tbody", null, [
1902
+ (u(!0), v(U, null, Z(t.block.trGroup, (s, m) => (u(), v("tr", {
1903
+ key: m,
1904
+ style: N({ height: (s.height || s.minHeight || 30) + "px" })
1905
+ }, [
1906
+ (u(!0), v(U, null, Z(s.tdList || [], (h, I) => (u(), v("td", {
1907
+ key: I,
1908
+ colspan: h.colspan || 1,
1909
+ rowspan: h.rowspan || 1,
1910
+ style: N({
1911
+ backgroundColor: h.backgroundColor || void 0,
1912
+ verticalAlign: z(Bi)(h),
1913
+ width: h.width ? h.width * z(ct)(t.block.tableEl) + "px" : void 0,
1914
+ height: h.height ? h.height + "px" : void 0
1915
+ })
1916
+ }, [
1917
+ (u(!0), v(U, null, Z(z(Ue)(h.value), (S, L) => (u(), v(U, { key: L }, [
1918
+ S.type === "paragraph" ? (u(), v("p", {
1919
+ key: 0,
1920
+ class: "cell-para",
1921
+ style: N(z(Ot)(S))
1922
+ }, [
1923
+ S.elements.length ? ue("", !0) : (u(), v("span", Xi, " ")),
1924
+ (u(!0), v(U, null, Z(S.elements, (x, K) => {
1925
+ var ne, R, T, f, E, B, A;
1926
+ return u(), v(U, { key: K }, [
1927
+ !x.type || x.type === "text" ? (u(), v("span", {
1928
+ key: 0,
1929
+ style: N(z(he)(x))
1930
+ }, J(x.value), 5)) : x.type === "image" ? (u(), v("img", {
1931
+ key: 1,
1932
+ src: x.value,
1933
+ class: "doc-image",
1934
+ style: N({
1935
+ width: x.width ? x.width + "px" : "auto",
1936
+ height: x.height ? x.height + "px" : "auto"
1937
+ })
1938
+ }, null, 12, Yi)) : x.type === "hyperlink" ? (u(), v("a", {
1939
+ key: 2,
1940
+ href: x.url,
1941
+ class: "doc-link",
1942
+ target: "_blank"
1943
+ }, [
1944
+ (u(!0), v(U, null, Z(x.valueList || [], (P, Q) => (u(), v("span", {
1945
+ key: Q,
1946
+ style: N(z(he)(P))
1947
+ }, J(P.value), 5))), 128))
1948
+ ], 8, Zi)) : x.type === "control" ? (u(), v(U, { key: 3 }, [
1949
+ ((ne = x.control) == null ? void 0 : ne.type) === "text" ? (u(), v("span", {
1950
+ key: 0,
1951
+ style: N({ fontSize: (x.control.size || 12) + "px" })
1952
+ }, [
1953
+ (u(!0), v(U, null, Z(x.control.value || [], (P, Q) => (u(), v("span", {
1954
+ key: Q,
1955
+ style: N(z(he)(P))
1956
+ }, J(P.value), 5))), 128))
1957
+ ], 4)) : ((R = x.control) == null ? void 0 : R.type) === "input" ? (u(), v("span", {
1958
+ key: 1,
1959
+ class: "ctrl-input",
1960
+ style: N({ fontSize: (x.control.size || 12) + "px" })
1961
+ }, [
1962
+ (u(!0), v(U, null, Z(x.control.value || [], (P, Q) => (u(), v("span", { key: Q }, J(P.value), 1))), 128))
1963
+ ], 4)) : ((T = x.control) == null ? void 0 : T.type) === "radio" ? (u(), v("span", {
1964
+ key: 2,
1965
+ class: Ie(["ctrl-options", { "ctrl-options--vertical": ((E = (f = x.control.extension) == null ? void 0 : f.elementAttributes) == null ? void 0 : E.layout) === "vertical" }])
1966
+ }, [
1967
+ (u(!0), v(U, null, Z(x.control.valueSets || [], (P, Q) => (u(), v("label", {
1968
+ key: Q,
1969
+ class: "ctrl-option"
1970
+ }, [
1971
+ ee("input", {
1972
+ type: "radio",
1973
+ disabled: "",
1974
+ checked: x.control.code === P.code
1975
+ }, null, 8, Qi),
1976
+ He(J(P.value), 1)
1977
+ ]))), 128))
1978
+ ], 2)) : ue("", !0)
1979
+ ], 64)) : x.type === "checkbox" ? (u(), v("input", {
1980
+ key: 4,
1981
+ type: "checkbox",
1982
+ checked: !!((B = x.checkbox) != null && B.value),
1983
+ disabled: "",
1984
+ class: "el-check"
1985
+ }, null, 8, el)) : x.type === "radio" ? (u(), v("input", {
1986
+ key: 5,
1987
+ type: "radio",
1988
+ checked: !!((A = x.radio) != null && A.value),
1989
+ disabled: "",
1990
+ class: "el-check"
1991
+ }, null, 8, tl)) : x.type === "superscript" ? (u(), v("sup", {
1992
+ key: 6,
1993
+ style: N(z(he)(x))
1994
+ }, J(x.value), 5)) : x.type === "subscript" ? (u(), v("sub", {
1995
+ key: 7,
1996
+ style: N(z(he)(x))
1997
+ }, J(x.value), 5)) : x.type === "tab" ? (u(), v("span", {
1998
+ key: 8,
1999
+ class: "doc-tab",
2000
+ style: N({ width: (x.size || z(qe)) + "px" })
2001
+ }, null, 4)) : ue("", !0)
2002
+ ], 64);
2003
+ }), 128))
2004
+ ], 4)) : ue("", !0)
2005
+ ], 64))), 128))
2006
+ ], 12, Ji))), 128))
2007
+ ], 4))), 128))
2008
+ ])
2009
+ ], 6)
2010
+ ], 4)
2011
+ ], 6)) : ue("", !0);
2012
+ };
2013
+ }
2014
+ }, dt = /* @__PURE__ */ Be(nl, [["__scopeId", "data-v-27e51e18"]]), il = { class: "editor-layout word-editor-scope" }, ll = { class: "editor-container" }, ol = {
2015
+ key: 0,
2016
+ class: "editor-loading"
2017
+ }, al = { class: "doc-header" }, sl = { class: "doc-footer" }, rl = { class: "doc-page-number" }, cl = 1123, dl = 50, ul = 20, hl = {
1559
2018
  __name: "index",
1560
2019
  props: {
1561
2020
  // 文档结构数据(IElement[]),来源由使用方决定
@@ -1569,296 +2028,201 @@ const Ei = { class: "editor-layout word-editor-scope" }, Si = { class: "editor-c
1569
2028
  default: !1
1570
2029
  }
1571
2030
  },
1572
- setup(i) {
1573
- const e = i, t = ke(() => e.data || []), a = se(null), o = se({});
1574
- let u = null;
1575
- ct(() => {
1576
- u = new ResizeObserver((y) => {
1577
- const _ = {};
1578
- for (const r of y) {
1579
- const D = r.target._rowKey;
1580
- if (!D) continue;
1581
- const c = Math.round(r.contentRect.height);
1582
- c > (o.value[D] || 0) && (_[D] = c);
2031
+ setup(t) {
2032
+ const e = t, n = ae(() => {
2033
+ const f = e.data;
2034
+ return f ? !Array.isArray(f) && f.main ? f.main : Array.isArray(f) ? f : [] : [];
2035
+ }), l = te(null), o = te({});
2036
+ let r = null;
2037
+ ft(() => {
2038
+ r = new ResizeObserver((f) => {
2039
+ const E = {};
2040
+ for (const B of f) {
2041
+ const A = B.target._rowKey;
2042
+ if (!A) continue;
2043
+ const P = Math.round(B.contentRect.height);
2044
+ P > (o.value[A] || 0) && (E[A] = P);
1583
2045
  }
1584
- Object.keys(_).length && (o.value = { ...o.value, ..._ });
2046
+ Object.keys(E).length && (o.value = { ...o.value, ...E });
1585
2047
  });
1586
- }), et(() => {
1587
- u == null || u.disconnect(), u = null;
2048
+ }), lt(() => {
2049
+ r == null || r.disconnect(), r = null;
1588
2050
  });
1589
- function P(y, _) {
1590
- !y || !u || (y._rowKey = _, u.observe(y));
2051
+ function y(f, E) {
2052
+ !f || !r || (f._rowKey = E, r.observe(f));
1591
2053
  }
1592
- const S = {
1593
- left: "left",
1594
- center: "center",
1595
- right: "right",
1596
- alignment: "justify",
1597
- justify: "justify"
1598
- };
1599
- function z(y) {
1600
- const _ = [];
1601
- let r = !1;
1602
- const D = (c) => {
1603
- if (r) {
1604
- if (c && c.value != null && /^[\n\u200B]+$/.test(c.value)) {
1605
- _.push(c);
1606
- return;
1607
- }
1608
- r = !1, _.push({ ...c, _coverBreakBefore: !0 });
1609
- } else
1610
- _.push(c);
2054
+ Kt("bindTableObserver", y);
2055
+ const s = ae(
2056
+ () => Math.max(100, cl - dl * 2 - S.value - L.value - ul)
2057
+ ), m = ae(() => {
2058
+ const f = Ue(n.value), E = [], B = s.value;
2059
+ let A = 0;
2060
+ const P = Ri(), Q = { first: 0, second: 1, third: 2, fourth: 3, fifth: 4, sixth: 5, seventh: 6, eighth: 7 };
2061
+ let le = -1;
2062
+ const ot = (W) => {
2063
+ var pe, ye, _e;
2064
+ return !!((pe = W.el) != null && pe._coverBreakBefore || (_e = (ye = W.elements) == null ? void 0 : ye[0]) != null && _e._coverBreakBefore);
1611
2065
  };
1612
- for (const c of y || []) {
1613
- if (c && c.type === "pageBreak") {
1614
- r = !0;
1615
- continue;
1616
- }
1617
- if (c && c.type === "area") {
1618
- const $ = z(c.valueList || []);
1619
- for (const M of $) D(M);
1620
- } else
1621
- D(c);
1622
- }
1623
- return _;
1624
- }
1625
- function A(y) {
1626
- const _ = z(y), r = [];
1627
- let D = [], c = 0, $ = null;
1628
- const M = (I) => {
1629
- D.length && (r.push({ type: "paragraph", elements: [...D], rowFlex: I }), D = []);
1630
- }, C = () => {
1631
- if (c === 0) return;
1632
- const I = $;
1633
- M(I);
1634
- for (let O = 1; O < c; O++)
1635
- r.push({ type: "paragraph", elements: [], rowFlex: I });
1636
- c = 0, $ = null;
1637
- };
1638
- for (const I of _ || [])
1639
- if (I.type === "table")
1640
- C(), M(), r.push({ type: "table", el: I });
1641
- else if (I.type === "title")
1642
- C(), M(), r.push({ type: "title", el: I });
1643
- else if (I.type === "list") {
1644
- C(), M();
1645
- const O = [];
1646
- let b = [];
1647
- for (const ge of I.valueList || [])
1648
- ge.value === `
1649
- ` || ge.value === "​" ? (O.push([...b]), b = []) : b.push(ge);
1650
- (b.length || O.length === 0) && O.push([...b]), r.push({ type: "list", listType: I.listType || "ul", listStyle: I.listStyle || "disc", items: O });
1651
- } else if (I.listId) {
1652
- C(), M();
1653
- const O = I.value === "​" || I.value === "" ? [] : [I];
1654
- r.push({ type: "list", listType: I.listType || "ul", listStyle: I.listStyle || "disc", items: [O] });
1655
- } else I.value != null && /^[\n\u200B]+$/.test(I.value) ? (c += I.value.length, I.rowFlex && ($ = I.rowFlex)) : (C(), D.push(I));
1656
- return C(), M(), r;
1657
- }
1658
- function Z(y) {
1659
- const _ = (y == null ? void 0 : y.width) || 0;
1660
- return !_ || _ <= Pt ? 1 : Pt / _;
1661
- }
1662
- function N(y) {
1663
- const _ = y.filter((O) => O.type === "image").reduce((O, b) => O + (b.height || b.width || 0), 0), r = y.filter((O) => O.type !== "image").map((O) => O.value || "").join("");
1664
- if (!r) return _ || 20;
1665
- const D = y.reduce((O, b) => Math.max(O, b.size || 0), 0) || 14, c = D + 6, $ = (r.match(/[一-龥]/g) || []).length, M = r.length - $, C = $ * D + M * (D * 0.5), I = Math.max(1, Math.ceil(C / At));
1666
- return _ + Math.max(c, I * c);
1667
- }
1668
- function q(y) {
1669
- if (!y || !y.length) return [[]];
1670
- const _ = [];
1671
- let r = [];
1672
- for (const D of y)
1673
- D.type === "image" && (D.width || 0) >= At ? (r.length && (_.push(r), r = []), _.push([D])) : r.push(D);
1674
- return r.length && _.push(r), _.length ? _ : [[]];
1675
- }
1676
- function Q(y) {
1677
- if (y.length === 0) return [];
1678
- const _ = new Array(y.length).fill(0);
1679
- y.forEach(($, M) => {
1680
- ($.tdList || []).forEach((C) => {
1681
- const I = C.rowspan || 1;
1682
- if (I > 1) {
1683
- const O = Math.min(M + I - 1, y.length - 1);
1684
- _[M] = Math.max(_[M], O);
1685
- for (let b = 1; b < I && M + b < y.length; b++)
1686
- _[M + b] = Math.max(_[M + b], O);
1687
- }
1688
- });
1689
- });
1690
- const r = [];
1691
- let D = 0, c = 0;
1692
- for (let $ = 0; $ < y.length; $++)
1693
- c = Math.max(c, _[$]), c <= $ && (r.push(y.slice(D, $ + 1)), D = $ + 1, c = 0);
1694
- return D < y.length && r.push(y.slice(D)), r;
1695
- }
1696
- const ee = ke(() => {
1697
- const y = A(t.value), _ = [];
1698
- let r = 0;
1699
- const D = Ii(), c = { first: 0, second: 1, third: 2, fourth: 3, fifth: 4, sixth: 5, seventh: 6, eighth: 7 };
1700
- let $ = -1;
1701
- const M = (C) => {
1702
- var I, O, b;
1703
- return !!((I = C.el) != null && I._coverBreakBefore || (b = (O = C.elements) == null ? void 0 : O[0]) != null && b._coverBreakBefore);
1704
- };
1705
- return y.forEach((C, I) => {
1706
- var b, ge, we;
1707
- const O = M(C);
1708
- if (O && (r = 0), C.type === "title") {
1709
- const de = C.el.valueList || [], le = D.next(C.el.level, (b = C.el.extension) == null ? void 0 : b.startIndex), ne = de.some((E) => {
1710
- var X;
1711
- return (X = E.extension) == null ? void 0 : X.isIndex;
2066
+ return f.forEach((W, pe) => {
2067
+ var _e, De, Ee;
2068
+ const ye = ot(W);
2069
+ if (ye && (A = 0), W.type === "title") {
2070
+ const ve = W.el.valueList || [], se = P.next(W.el.level, (_e = W.el.extension) == null ? void 0 : _e.startIndex), fe = ve.some((X) => {
2071
+ var Ce;
2072
+ return (Ce = X.extension) == null ? void 0 : Ce.isIndex;
1712
2073
  });
1713
- let ue = de;
1714
- if (!ne && le) {
1715
- const E = de[0] || {};
1716
- ue = [
2074
+ let re = ve;
2075
+ if (!fe && se) {
2076
+ const X = ve[0] || {};
2077
+ re = [
1717
2078
  {
1718
- value: le,
1719
- size: E.size,
1720
- bold: E.bold,
1721
- italic: E.italic,
1722
- color: E.color,
1723
- font: E.font,
2079
+ value: se,
2080
+ size: X.size,
2081
+ bold: X.bold,
2082
+ italic: X.italic,
2083
+ color: X.color,
2084
+ font: X.font,
1724
2085
  extension: { isIndex: !0 }
1725
2086
  },
1726
- ...de
2087
+ ...ve
1727
2088
  ];
1728
2089
  }
1729
- const me = ue.map((E) => E.value || "").join(""), re = N(ue);
1730
- r = r + re > Ie && r > 0 ? re : r + re, $ = c[C.el.level] ?? 0, _.push({
1731
- node_id: `blk_${I}_0`,
1732
- layer: O ? 1 : 100,
2090
+ const we = re.map((X) => X.value || "").join(""), de = Oe(re);
2091
+ A = A + de > B && A > 0 ? de : A + de, le = Q[W.el.level] ?? 0, E.push({
2092
+ node_id: `blk_${pe}_0`,
2093
+ layer: ye ? 1 : 100,
1733
2094
  blockType: "title",
1734
- level: C.el.level,
1735
- titleEl: C.el,
1736
- titleValueList: ue,
2095
+ level: W.el.level,
2096
+ titleEl: W.el,
2097
+ titleValueList: re,
1737
2098
  content_type: "text",
1738
- content: me,
1739
- height: re,
1740
- indentPx: $ * 20
2099
+ content: we,
2100
+ height: de,
2101
+ indentPx: le * 20
1741
2102
  });
1742
- } else if (C.type === "paragraph") {
1743
- const de = q(C.elements), le = $ >= 0 ? ($ + 1) * 20 : 0;
1744
- de.forEach((ne, ue) => {
1745
- const me = ne.map((E) => E.value || "").join(""), re = N(ne);
1746
- r = r + re > Ie && r > 0 ? re : r + re, _.push({
1747
- node_id: `blk_${I}_${ue}`,
1748
- layer: O && ue === 0 ? 1 : 100,
2103
+ } else if (W.type === "paragraph") {
2104
+ const ve = Oi(W.elements), se = le >= 0 ? (le + 1) * 20 : 0;
2105
+ ve.forEach((fe, re) => {
2106
+ const we = fe.map((X) => X.value || "").join(""), de = Oe(fe);
2107
+ A = A + de > B && A > 0 ? de : A + de, E.push({
2108
+ node_id: `blk_${pe}_${re}`,
2109
+ layer: ye && re === 0 ? 1 : 100,
1749
2110
  blockType: "paragraph",
1750
- elements: ne,
1751
- rowFlex: C.rowFlex,
2111
+ elements: fe,
2112
+ rowFlex: W.rowFlex,
1752
2113
  content_type: "text",
1753
- content: me,
1754
- height: re,
1755
- indentPx: le
2114
+ content: we,
2115
+ height: de,
2116
+ indentPx: se
1756
2117
  });
1757
2118
  });
1758
- } else if (C.type === "table") {
1759
- const de = !!((ge = C.el.extension) != null && ge.isTitleTable), le = ((we = C.el.extension) == null ? void 0 : we.elementType) === "signOff", ne = de || le ? 0 : $ >= 0 ? ($ + 1) * 20 : 0, ue = Q(C.el.trList || []), me = ue.length;
1760
- ue.forEach((re, E) => {
1761
- const X = `blk_${I}_${E}`, Ne = re.reduce(
1762
- (U, fe) => U + (fe.height || fe.minHeight || 35),
2119
+ } else if (W.type === "table") {
2120
+ const ve = !!((De = W.el.extension) != null && De.isTitleTable), se = ((Ee = W.el.extension) == null ? void 0 : Ee.elementType) === "signOff", fe = ve || se ? 0 : le >= 0 ? (le + 1) * 20 : 0, re = Ht(W.el.trList || []), we = re.length;
2121
+ re.forEach((de, X) => {
2122
+ const Ce = `blk_${pe}_${X}`, Fe = de.reduce(
2123
+ (xe, H) => xe + (H.height || H.minHeight || 35),
1763
2124
  0
1764
- ), ye = Math.max(Ne, o.value[X] || 0);
1765
- if (ye > Ie) {
1766
- const U = Math.ceil(ye / Ie);
1767
- for (let fe = 0; fe < U; fe++) {
1768
- const Re = fe * Ie, Pe = Math.min(Ie, ye - Re), Ve = fe > 0 || r > 0;
1769
- r = Pe, _.push({
1770
- node_id: `blk_${I}_${E}_s${fe}`,
1771
- layer: O && E === 0 && fe === 0 ? 1 : 100,
2125
+ ), me = Math.max(Fe, o.value[Ce] || 0);
2126
+ if (me > B) {
2127
+ const xe = Math.ceil(me / B);
2128
+ for (let H = 0; H < xe; H++) {
2129
+ const Se = H * B, Pe = Math.min(B, me - Se), We = H > 0 || A > 0;
2130
+ A = Pe, E.push({
2131
+ node_id: `blk_${pe}_${X}_s${H}`,
2132
+ layer: ye && X === 0 && H === 0 ? 1 : 100,
1772
2133
  blockType: "table-row-group",
1773
2134
  content_type: "table-row",
1774
- rowHeight: ye,
1775
- trGroup: re,
1776
- tableEl: C.el,
1777
- tableRowFlex: C.el.rowFlex || null,
1778
- isFirst: E === 0 && fe === 0,
1779
- isLast: E === me - 1 && fe === U - 1,
1780
- isPageBreak: Ve,
1781
- sliceOffset: Re,
2135
+ rowHeight: me,
2136
+ trGroup: de,
2137
+ tableEl: W.el,
2138
+ tableRowFlex: W.el.rowFlex || null,
2139
+ isFirst: X === 0 && H === 0,
2140
+ isLast: X === we - 1 && H === xe - 1,
2141
+ isPageBreak: We,
2142
+ sliceOffset: Se,
1782
2143
  sliceHeight: Pe,
1783
- _baseKey: fe === 0 ? X : void 0,
2144
+ _baseKey: H === 0 ? Ce : void 0,
1784
2145
  height: Pe,
1785
- indentPx: ne
2146
+ indentPx: fe
1786
2147
  });
1787
2148
  }
1788
2149
  } else {
1789
- const U = E > 0 && r + ye > Ie;
1790
- r = r + ye > Ie ? ye : r + ye, _.push({
1791
- node_id: `blk_${I}_${E}`,
1792
- layer: O && E === 0 ? 1 : 100,
2150
+ const xe = X > 0 && A + me > B;
2151
+ A = A + me > B ? me : A + me, E.push({
2152
+ node_id: `blk_${pe}_${X}`,
2153
+ layer: ye && X === 0 ? 1 : 100,
1793
2154
  blockType: "table-row-group",
1794
2155
  content_type: "table-row",
1795
- rowHeight: ye,
1796
- trGroup: re,
1797
- tableEl: C.el,
1798
- tableRowFlex: C.el.rowFlex || null,
1799
- isFirst: E === 0,
1800
- isLast: E === me - 1,
1801
- isPageBreak: U,
1802
- indentPx: ne
2156
+ rowHeight: me,
2157
+ trGroup: de,
2158
+ tableEl: W.el,
2159
+ tableRowFlex: W.el.rowFlex || null,
2160
+ isFirst: X === 0,
2161
+ isLast: X === we - 1,
2162
+ isPageBreak: xe,
2163
+ indentPx: fe
1803
2164
  });
1804
2165
  }
1805
2166
  });
1806
- } else if (C.type === "list") {
1807
- const de = Math.round(18);
1808
- let le = 0;
1809
- for (const ne of C.items)
1810
- le += ne.length ? N(ne) : de;
1811
- le = Math.max(le, de), r = r + le > Ie && r > 0 ? le : r + le, _.push({
1812
- node_id: `blk_${I}_0`,
1813
- layer: O ? 1 : 100,
2167
+ } else if (W.type === "list") {
2168
+ const ve = Math.round(18);
2169
+ let se = 0;
2170
+ for (const fe of W.items)
2171
+ se += fe.length ? Oe(fe) : ve;
2172
+ se = Math.max(se, ve), A = A + se > B && A > 0 ? se : A + se, E.push({
2173
+ node_id: `blk_${pe}_0`,
2174
+ layer: ye ? 1 : 100,
1814
2175
  blockType: "list",
1815
- listType: C.listType,
1816
- listStyle: C.listStyle,
1817
- items: C.items,
1818
- height: le,
1819
- indentPx: $ >= 0 ? ($ + 1) * 20 : 0
2176
+ listType: W.listType,
2177
+ listStyle: W.listStyle,
2178
+ items: W.items,
2179
+ height: se,
2180
+ indentPx: le >= 0 ? (le + 1) * 20 : 0
1820
2181
  });
1821
2182
  }
1822
- }), _;
1823
- }), be = ke(() => Ci(ee.value));
1824
- function W(y) {
1825
- var _;
1826
- (_ = a.value) == null || _.scrollToRow({ node_id: y.nodeId });
1827
- }
1828
- function B(y) {
1829
- var $, M;
1830
- const _ = y.elements || [], r = (($ = _.find((C) => C.rowFlex)) == null ? void 0 : $.rowFlex) || y.rowFlex, D = { textAlign: S[r] || "left" }, c = (M = _.find((C) => C.rowMargin)) == null ? void 0 : M.rowMargin;
1831
- return c && (D.lineHeight = c), D;
1832
- }
1833
- function T(y) {
1834
- var $;
1835
- const _ = A(y.value);
1836
- let r = 0, D = 0, c = !1;
1837
- for (const M of _)
1838
- if (M.type === "paragraph") {
1839
- if (!M.elements.length) continue;
1840
- r++;
1841
- for (const C of M.elements)
1842
- (C.type === "image" || C.type === "table") && (c = !0), D += (C.value || "").length;
1843
- } else M.type === "list" ? (r += (($ = M.items) == null ? void 0 : $.length) || 1, c = !0) : (r++, c = !0);
1844
- return r > 1 || D > 30 || c ? "top" : y.verticalAlign || "middle";
2183
+ }), E;
2184
+ }), h = ae(() => {
2185
+ var E;
2186
+ const f = (E = e.data) == null ? void 0 : E.header;
2187
+ return f != null && f.length ? Ue(f) : [];
2188
+ }), I = ae(() => {
2189
+ var E;
2190
+ const f = (E = e.data) == null ? void 0 : E.footer;
2191
+ return f != null && f.length ? Ue(f) : [];
2192
+ }), S = ae(() => Bt(h.value, !0)), L = ae(() => Bt(I.value, !0)), x = ae(() => h.value.length > 0), K = ae(() => I.value.length > 0);
2193
+ function ne(f) {
2194
+ var E, B, A, P;
2195
+ return {
2196
+ blockType: f.type,
2197
+ elements: f.elements,
2198
+ rowFlex: f.rowFlex,
2199
+ level: (E = f.el) == null ? void 0 : E.level,
2200
+ titleValueList: ((B = f.el) == null ? void 0 : B.titleValueList) || f.titleValueList || ((A = f.el) == null ? void 0 : A.valueList),
2201
+ listType: f.listType,
2202
+ listStyle: f.listStyle,
2203
+ items: f.items,
2204
+ indentPx: 0,
2205
+ trGroup: (P = f.el) != null && P.trList ? Ht(f.el.trList).flat() : void 0,
2206
+ tableEl: f.el,
2207
+ isFirst: !0,
2208
+ isLast: !0
2209
+ };
1845
2210
  }
1846
- function K(y) {
1847
- const _ = {};
1848
- y.font && (_.fontFamily = y.font), _.fontSize = (y.size || He) + "px", y.bold != null && (_.fontWeight = y.bold ? "bold" : "normal"), y.italic != null && (_.fontStyle = y.italic ? "italic" : "normal"), y.color && (_.color = y.color), y.highlight && y.highlight !== "rgb(255, 255, 255)" && y.highlight !== "#ffffff" && (_.backgroundColor = y.highlight);
1849
- const r = [y.underline && "underline", y.strikeout && "line-through"].filter(Boolean).join(" ");
1850
- return r && (_.textDecoration = r), y.letterSpacing && (_.letterSpacing = y.letterSpacing + "px"), _;
2211
+ const R = ae(() => $i(m.value));
2212
+ function T(f) {
2213
+ var E;
2214
+ (E = l.value) == null || E.scrollToRow({ node_id: f.nodeId });
1851
2215
  }
1852
- return (y, _) => (f(), p("div", Ei, [
1853
- J(xi, {
1854
- items: be.value,
1855
- onNavigate: W
2216
+ return (f, E) => (u(), v("div", il, [
2217
+ q(Fi, {
2218
+ items: R.value,
2219
+ onNavigate: T
1856
2220
  }, null, 8, ["items"]),
1857
- ce("div", Si, [
1858
- i.loading ? (f(), p("div", Ti, " 加载中… ")) : (f(), Fe(Ae(li), {
2221
+ ee("div", ll, [
2222
+ t.loading ? (u(), v("div", ol, " 加载中… ")) : (u(), ke(z(fi), {
1859
2223
  key: 1,
1860
2224
  ref_key: "virtualTableRef",
1861
- ref: a,
2225
+ ref: l,
1862
2226
  "show-header": !1,
1863
2227
  "row-config": { keyField: "node_id" },
1864
2228
  "page-config": {
@@ -1867,320 +2231,67 @@ const Ei = { class: "editor-layout word-editor-scope" }, Si = { class: "editor-c
1867
2231
  pageWidth: 860,
1868
2232
  margin: 50,
1869
2233
  gap: 16,
1870
- showPageHeader: !1,
2234
+ showPageHeader: x.value,
1871
2235
  showPageBorder: !0,
1872
2236
  pageBorderPadding: 5,
1873
- pageBorderStyle: "1px solid #333"
2237
+ pageBorderStyle: "1px solid #333",
2238
+ headerHeight: S.value,
2239
+ footerHeight: L.value,
2240
+ showPageNumber: !0
1874
2241
  },
1875
- data: ee.value
1876
- }, {
1877
- default: lt(() => [
1878
- J(Ae(si), null, {
1879
- default: lt(({ row: r }) => {
1880
- var D;
1881
- return [
1882
- r.blockType === "title" ? (f(), p("p", {
1883
- key: 0,
1884
- class: Ee(["doc-title", `doc-title--${r.level}`]),
1885
- style: j({ paddingLeft: r.indentPx ? r.indentPx + "px" : void 0 })
1886
- }, [
1887
- (f(!0), p(Y, null, oe(r.titleValueList || [], (c, $) => (f(), p("span", {
1888
- key: $,
1889
- style: j(K(c))
1890
- }, ie(c.value), 5))), 128))
1891
- ], 6)) : r.blockType === "paragraph" ? (f(), p("p", {
1892
- key: 1,
1893
- class: "doc-para",
1894
- style: j({ ...B(r), paddingLeft: r.indentPx ? r.indentPx + "px" : void 0 })
1895
- }, [
1896
- r.elements.length ? ve("", !0) : (f(), p("span", Fi, " ")),
1897
- (f(!0), p(Y, null, oe(r.elements, (c, $) => {
1898
- var M, C, I, O, b, ge, we, de, le, ne, ue, me, re;
1899
- return f(), p(Y, { key: $ }, [
1900
- !c.type || c.type === "text" ? (f(), p("span", {
1901
- key: 0,
1902
- style: j(K(c))
1903
- }, ie(c.value), 5)) : c.type === "hyperlink" ? (f(), p("a", {
1904
- key: 1,
1905
- href: c.url,
1906
- class: "doc-link",
1907
- target: "_blank",
1908
- rel: "noopener"
1909
- }, [
1910
- (f(!0), p(Y, null, oe(c.valueList || [], (E, X) => (f(), p("span", {
1911
- key: X,
1912
- style: j(K(E))
1913
- }, ie(E.value), 5))), 128))
1914
- ], 8, Ai)) : c.type === "image" ? (f(), p("img", {
1915
- key: 2,
1916
- src: c.value,
1917
- class: "doc-image",
1918
- style: j({
1919
- width: c.width ? c.width + "px" : "auto",
1920
- height: c.height ? c.height + "px" : "auto"
1921
- })
1922
- }, null, 12, Pi)) : c.type === "control" ? (f(), p(Y, { key: 3 }, [
1923
- ((M = c.control) == null ? void 0 : M.type) === "text" ? (f(), p("span", {
1924
- key: 0,
1925
- style: j({ fontSize: (c.control.size || 12) + "px" })
1926
- }, [
1927
- (f(!0), p(Y, null, oe(c.control.value || [], (E, X) => (f(), p("span", {
1928
- key: X,
1929
- style: j(K(E))
1930
- }, ie(E.value), 5))), 128))
1931
- ], 4)) : ((C = c.control) == null ? void 0 : C.type) === "input" ? (f(), p("span", {
1932
- key: 1,
1933
- class: "ctrl-input",
1934
- style: j({
1935
- minWidth: (c.control.minWidth || 60) + "px",
1936
- fontSize: (c.control.size || 12) + "px"
1937
- })
1938
- }, [
1939
- (f(!0), p(Y, null, oe(c.control.value || [], (E, X) => (f(), p("span", { key: X }, ie(E.value), 1))), 128))
1940
- ], 4)) : ((I = c.control) == null ? void 0 : I.type) === "radio" ? (f(), p("span", {
1941
- key: 2,
1942
- class: Ee(["ctrl-options", { "ctrl-options--vertical": ((b = (O = c.control.extension) == null ? void 0 : O.elementAttributes) == null ? void 0 : b.layout) === "vertical" }]),
1943
- style: j({ fontSize: (c.control.size || He) + "px" })
1944
- }, [
1945
- (f(!0), p(Y, null, oe(c.control.valueSets || [], (E, X) => (f(), p("label", {
1946
- key: X,
1947
- class: "ctrl-option"
1948
- }, [
1949
- ce("input", {
1950
- type: "radio",
1951
- disabled: "",
1952
- checked: c.control.code === E.code
1953
- }, null, 8, $i),
1954
- Le(" " + ie(E.value), 1)
1955
- ]))), 128))
1956
- ], 6)) : ((ge = c.control) == null ? void 0 : ge.type) === "checkbox" ? (f(), p("span", {
1957
- key: 3,
1958
- class: Ee(["ctrl-options", { "ctrl-options--vertical": ((de = (we = c.control.extension) == null ? void 0 : we.elementAttributes) == null ? void 0 : de.layout) === "vertical" }]),
1959
- style: j({ fontSize: (c.control.size || He) + "px" })
1960
- }, [
1961
- (f(!0), p(Y, null, oe(c.control.valueSets || [], (E, X) => (f(), p("label", {
1962
- key: X,
1963
- class: "ctrl-option"
1964
- }, [
1965
- ce("input", {
1966
- type: "checkbox",
1967
- disabled: "",
1968
- checked: (c.control.code || "").split(",").includes(E.code)
1969
- }, null, 8, Li),
1970
- Le(" " + ie(E.value), 1)
1971
- ]))), 128))
1972
- ], 6)) : ((le = c.control) == null ? void 0 : le.type) === "select" ? (f(), p("span", Ri, ie(((ue = (ne = c.control.value) == null ? void 0 : ne[0]) == null ? void 0 : ue.value) || c.control.placeholder || ""), 1)) : ve("", !0)
1973
- ], 64)) : c.type === "checkbox" ? (f(), p("input", {
1974
- key: 4,
1975
- type: "checkbox",
1976
- checked: !!((me = c.checkbox) != null && me.value),
1977
- disabled: "",
1978
- class: "el-check"
1979
- }, null, 8, Oi)) : c.type === "radio" ? (f(), p("input", {
1980
- key: 5,
1981
- type: "radio",
1982
- checked: !!((re = c.radio) != null && re.value),
1983
- disabled: "",
1984
- class: "el-check"
1985
- }, null, 8, Bi)) : c.type === "superscript" ? (f(), p("sup", {
1986
- key: 6,
1987
- style: j(K(c))
1988
- }, ie(c.value), 5)) : c.type === "subscript" ? (f(), p("sub", {
1989
- key: 7,
1990
- style: j(K(c))
1991
- }, ie(c.value), 5)) : c.type === "tab" ? (f(), p("span", {
1992
- key: 8,
1993
- class: "doc-tab",
1994
- style: j({ width: (c.size || He) + "px" })
1995
- }, null, 4)) : ve("", !0)
1996
- ], 64);
1997
- }), 128))
1998
- ], 4)) : r.blockType === "list" ? (f(), Fe(Ze(r.listType === "ol" ? "ol" : "ul"), {
1999
- key: 2,
2000
- class: "doc-list",
2001
- style: j({ listStyleType: r.listStyle === "decimal" ? "decimal" : r.listStyle === "lower-alpha" ? "lower-alpha" : "disc", paddingLeft: r.indentPx ? r.indentPx + 24 + "px" : void 0 })
2002
- }, {
2003
- default: lt(() => [
2004
- (f(!0), p(Y, null, oe(r.items, (c, $) => (f(), p("li", {
2005
- key: $,
2006
- class: "doc-list-item"
2007
- }, [
2008
- (f(!0), p(Y, null, oe(c, (M, C) => (f(), p(Y, { key: C }, [
2009
- !M.type || M.type === "text" ? (f(), p("span", {
2010
- key: 0,
2011
- style: j(K(M))
2012
- }, ie(M.value), 5)) : M.type === "superscript" ? (f(), p("sup", {
2013
- key: 1,
2014
- style: j(K(M))
2015
- }, ie(M.value), 5)) : M.type === "subscript" ? (f(), p("sub", {
2016
- key: 2,
2017
- style: j(K(M))
2018
- }, ie(M.value), 5)) : ve("", !0)
2019
- ], 64))), 128))
2020
- ]))), 128))
2021
- ]),
2022
- _: 2
2023
- }, 1032, ["style"])) : r.blockType === "table-row-group" ? (f(), p("div", {
2024
- key: 3,
2025
- class: Ee(["doc-table-row-wrap", { "is-first": r.isFirst, "is-last": r.isLast, "is-page-break": r.isPageBreak }]),
2026
- style: j({
2027
- display: r.tableRowFlex ? "flex" : void 0,
2028
- justifyContent: r.tableRowFlex === "right" ? "flex-end" : r.tableRowFlex === "center" ? "center" : r.tableRowFlex === "left" ? "flex-start" : void 0,
2029
- paddingLeft: r.indentPx ? r.indentPx + "px" : void 0
2030
- })
2031
- }, [
2032
- ce("div", {
2033
- style: j({
2034
- overflow: r.sliceHeight != null ? "hidden" : void 0,
2035
- height: r.sliceHeight != null ? (r.isLast ? r.sliceHeight + 1 : r.sliceHeight) + "px" : void 0,
2036
- width: r.tableEl.width ? "max-content" : "100%"
2037
- })
2038
- }, [
2039
- ce("table", {
2040
- ref: r._baseKey ? (c) => P(c, r._baseKey) : void 0,
2041
- class: Ee(["doc-table", { "doc-table--no-border": r.tableEl.borderType === "empty" }]),
2042
- style: j({
2043
- width: r.tableEl.width ? r.tableEl.width * Z(r.tableEl) + "px" : "100%",
2044
- transform: r.sliceOffset ? `translateY(-${r.sliceOffset}px)` : void 0
2045
- })
2046
- }, [
2047
- (D = r.tableEl.colgroup) != null && D.length ? (f(), p("colgroup", Hi, [
2048
- (f(!0), p(Y, null, oe(r.tableEl.colgroup, (c, $) => (f(), p("col", {
2049
- key: $,
2050
- style: j({ width: c.width * Z(r.tableEl) + "px" })
2051
- }, null, 4))), 128))
2052
- ])) : ve("", !0),
2053
- ce("tbody", null, [
2054
- (f(!0), p(Y, null, oe(r.trGroup, (c, $) => (f(), p("tr", {
2055
- key: $,
2056
- style: j({ height: (c.height || c.minHeight || 30) + "px" })
2057
- }, [
2058
- (f(!0), p(Y, null, oe(c.tdList || [], (M, C) => (f(), p("td", {
2059
- key: C,
2060
- colspan: M.colspan || 1,
2061
- rowspan: M.rowspan || 1,
2062
- style: j({
2063
- backgroundColor: M.backgroundColor || void 0,
2064
- verticalAlign: T(M),
2065
- width: M.width ? M.width * Z(r.tableEl) + "px" : void 0,
2066
- height: M.height ? M.height + "px" : void 0
2067
- })
2068
- }, [
2069
- (f(!0), p(Y, null, oe(A(M.value), (I, O) => (f(), p(Y, { key: O }, [
2070
- I.type === "paragraph" ? (f(), p("p", {
2071
- key: 0,
2072
- class: "cell-para",
2073
- style: j(B(I))
2074
- }, [
2075
- I.elements.length ? ve("", !0) : (f(), p("span", zi, " ")),
2076
- (f(!0), p(Y, null, oe(I.elements, (b, ge) => {
2077
- var we, de, le, ne, ue, me, re;
2078
- return f(), p(Y, { key: ge }, [
2079
- !b.type || b.type === "text" ? (f(), p("span", {
2080
- key: 0,
2081
- style: j(K(b))
2082
- }, ie(b.value), 5)) : b.type === "image" ? (f(), p("img", {
2083
- key: 1,
2084
- src: b.value,
2085
- class: "doc-image",
2086
- style: j({
2087
- width: b.width ? b.width + "px" : "auto",
2088
- height: b.height ? b.height + "px" : "auto"
2089
- })
2090
- }, null, 12, Ni)) : b.type === "hyperlink" ? (f(), p("a", {
2091
- key: 2,
2092
- href: b.url,
2093
- class: "doc-link",
2094
- target: "_blank"
2095
- }, [
2096
- (f(!0), p(Y, null, oe(b.valueList || [], (E, X) => (f(), p("span", {
2097
- key: X,
2098
- style: j(K(E))
2099
- }, ie(E.value), 5))), 128))
2100
- ], 8, Vi)) : b.type === "control" ? (f(), p(Y, { key: 3 }, [
2101
- ((we = b.control) == null ? void 0 : we.type) === "text" ? (f(), p("span", {
2102
- key: 0,
2103
- style: j({ fontSize: (b.control.size || 12) + "px" })
2104
- }, [
2105
- (f(!0), p(Y, null, oe(b.control.value || [], (E, X) => (f(), p("span", {
2106
- key: X,
2107
- style: j(K(E))
2108
- }, ie(E.value), 5))), 128))
2109
- ], 4)) : ((de = b.control) == null ? void 0 : de.type) === "input" ? (f(), p("span", {
2110
- key: 1,
2111
- class: "ctrl-input",
2112
- style: j({ fontSize: (b.control.size || 12) + "px" })
2113
- }, [
2114
- (f(!0), p(Y, null, oe(b.control.value || [], (E, X) => (f(), p("span", { key: X }, ie(E.value), 1))), 128))
2115
- ], 4)) : ((le = b.control) == null ? void 0 : le.type) === "radio" ? (f(), p("span", {
2116
- key: 2,
2117
- class: Ee(["ctrl-options", { "ctrl-options--vertical": ((ue = (ne = b.control.extension) == null ? void 0 : ne.elementAttributes) == null ? void 0 : ue.layout) === "vertical" }])
2118
- }, [
2119
- (f(!0), p(Y, null, oe(b.control.valueSets || [], (E, X) => (f(), p("label", {
2120
- key: X,
2121
- class: "ctrl-option"
2122
- }, [
2123
- ce("input", {
2124
- type: "radio",
2125
- disabled: "",
2126
- checked: b.control.code === E.code
2127
- }, null, 8, ji),
2128
- Le(ie(E.value), 1)
2129
- ]))), 128))
2130
- ], 2)) : ve("", !0)
2131
- ], 64)) : b.type === "checkbox" ? (f(), p("input", {
2132
- key: 4,
2133
- type: "checkbox",
2134
- checked: !!((me = b.checkbox) != null && me.value),
2135
- disabled: "",
2136
- class: "el-check"
2137
- }, null, 8, Ki)) : b.type === "radio" ? (f(), p("input", {
2138
- key: 5,
2139
- type: "radio",
2140
- checked: !!((re = b.radio) != null && re.value),
2141
- disabled: "",
2142
- class: "el-check"
2143
- }, null, 8, qi)) : b.type === "superscript" ? (f(), p("sup", {
2144
- key: 6,
2145
- style: j(K(b))
2146
- }, ie(b.value), 5)) : b.type === "subscript" ? (f(), p("sub", {
2147
- key: 7,
2148
- style: j(K(b))
2149
- }, ie(b.value), 5)) : b.type === "tab" ? (f(), p("span", {
2150
- key: 8,
2151
- class: "doc-tab",
2152
- style: j({ width: (b.size || He) + "px" })
2153
- }, null, 4)) : ve("", !0)
2154
- ], 64);
2155
- }), 128))
2156
- ], 4)) : ve("", !0)
2157
- ], 64))), 128))
2158
- ], 12, Di))), 128))
2159
- ], 4))), 128))
2160
- ])
2161
- ], 6)
2162
- ], 4)
2163
- ], 6)) : ve("", !0)
2164
- ];
2165
- }),
2242
+ data: m.value
2243
+ }, In({
2244
+ default: Ke(() => [
2245
+ q(z(vi), null, {
2246
+ default: Ke(({ row: B }) => [
2247
+ q(dt, { block: B }, null, 8, ["block"])
2248
+ ]),
2166
2249
  _: 1
2167
2250
  })
2168
2251
  ]),
2169
- _: 1
2170
- }, 8, ["data"]))
2252
+ _: 2
2253
+ }, [
2254
+ x.value ? {
2255
+ name: "page-header",
2256
+ fn: Ke(() => [
2257
+ ee("div", al, [
2258
+ (u(!0), v(U, null, Z(h.value, (B, A) => (u(), ke(dt, {
2259
+ key: A,
2260
+ block: ne(B),
2261
+ "is-header-footer": !0
2262
+ }, null, 8, ["block"]))), 128))
2263
+ ])
2264
+ ]),
2265
+ key: "0"
2266
+ } : void 0,
2267
+ K.value ? {
2268
+ name: "page-footer",
2269
+ fn: Ke(({ pageNumber: B, totalPages: A }) => [
2270
+ ee("div", sl, [
2271
+ (u(!0), v(U, null, Z(I.value, (P, Q) => (u(), ke(dt, {
2272
+ key: Q,
2273
+ block: ne(P),
2274
+ "is-header-footer": !0
2275
+ }, null, 8, ["block"]))), 128)),
2276
+ ee("div", rl, J(B) + " / " + J(A), 1)
2277
+ ])
2278
+ ]),
2279
+ key: "1"
2280
+ } : void 0
2281
+ ]), 1032, ["page-config", "data"]))
2171
2282
  ])
2172
2283
  ]));
2173
2284
  }
2174
- }, Ui = /* @__PURE__ */ ze(Wi, [["__scopeId", "data-v-fbf35559"]]), $t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
2175
- function Ye(i = 10) {
2176
- const e = crypto.getRandomValues(new Uint8Array(i));
2177
- return Array.from(e).map((t) => $t[t % $t.length]).join("");
2285
+ }, fl = /* @__PURE__ */ Be(hl, [["__scopeId", "data-v-f3f51b5c"]]), Dt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
2286
+ function tt(t = 10) {
2287
+ const e = crypto.getRandomValues(new Uint8Array(t));
2288
+ return Array.from(e).map((n) => Dt[n % Dt.length]).join("");
2178
2289
  }
2179
- class Qe {
2290
+ class it {
2180
2291
  constructor(e) {
2181
- V(this, "data");
2182
- this.data = Bt({
2183
- id: Ye(),
2292
+ D(this, "data");
2293
+ this.data = qt({
2294
+ id: tt(),
2184
2295
  version: 1,
2185
2296
  sections: [this.createEmptySection()],
2186
2297
  pageWidth: 595,
@@ -2195,24 +2306,24 @@ class Qe {
2195
2306
  // ─── 工厂方法 ─────────────────────────────────────────────────────────────
2196
2307
  createEmptySection() {
2197
2308
  return {
2198
- id: Ye(),
2309
+ id: tt(),
2199
2310
  paragraphs: [this.createEmptyParagraph()]
2200
2311
  };
2201
2312
  }
2202
2313
  createEmptyParagraph(e) {
2203
2314
  return {
2204
- id: Ye(),
2315
+ id: tt(),
2205
2316
  type: "paragraph",
2206
2317
  format: e ?? {},
2207
2318
  children: []
2208
2319
  };
2209
2320
  }
2210
- createTextElement(e, t) {
2321
+ createTextElement(e, n) {
2211
2322
  return {
2212
- id: Ye(),
2323
+ id: tt(),
2213
2324
  type: "text",
2214
2325
  value: e,
2215
- format: t ?? {}
2326
+ format: n ?? {}
2216
2327
  };
2217
2328
  }
2218
2329
  // ─── 查询方法 ─────────────────────────────────────────────────────────────
@@ -2220,86 +2331,86 @@ class Qe {
2220
2331
  return this.data.sections.length;
2221
2332
  }
2222
2333
  getParagraphCount(e = 0) {
2223
- var t;
2224
- return ((t = this.data.sections[e]) == null ? void 0 : t.paragraphs.length) ?? 0;
2334
+ var n;
2335
+ return ((n = this.data.sections[e]) == null ? void 0 : n.paragraphs.length) ?? 0;
2225
2336
  }
2226
2337
  /** 获取所有段落(展开所有 section) */
2227
2338
  getAllParagraphs() {
2228
2339
  const e = [];
2229
- return this.data.sections.forEach((t, a) => {
2230
- t.paragraphs.forEach((o, u) => {
2231
- e.push({ paragraph: o, sectionIndex: a, paragraphIndex: u });
2340
+ return this.data.sections.forEach((n, l) => {
2341
+ n.paragraphs.forEach((o, r) => {
2342
+ e.push({ paragraph: o, sectionIndex: l, paragraphIndex: r });
2232
2343
  });
2233
2344
  }), e;
2234
2345
  }
2235
- getParagraphAt(e, t) {
2236
- var a;
2237
- return ((a = this.data.sections[e]) == null ? void 0 : a.paragraphs[t]) ?? null;
2346
+ getParagraphAt(e, n) {
2347
+ var l;
2348
+ return ((l = this.data.sections[e]) == null ? void 0 : l.paragraphs[n]) ?? null;
2238
2349
  }
2239
2350
  getElementAt(e) {
2240
- const t = this.getParagraphAt(e.sectionIndex, e.paragraphIndex);
2241
- return (t == null ? void 0 : t.children[e.elementIndex]) ?? null;
2351
+ const n = this.getParagraphAt(e.sectionIndex, e.paragraphIndex);
2352
+ return (n == null ? void 0 : n.children[e.elementIndex]) ?? null;
2242
2353
  }
2243
2354
  // ─── 原子修改方法(由 Command 调用)─────────────────────────────────────
2244
2355
  /** 在指定位置插入文本(拆分/合并 text element) */
2245
- insertText(e, t, a) {
2356
+ insertText(e, n, l) {
2246
2357
  const o = this.getParagraphAt(e.sectionIndex, e.paragraphIndex);
2247
2358
  if (!o) return;
2248
- const u = o.children[e.elementIndex];
2249
- if (u && u.type === "text")
2250
- u.value = u.value.slice(0, e.offset) + t + u.value.slice(e.offset);
2359
+ const r = o.children[e.elementIndex];
2360
+ if (r && r.type === "text")
2361
+ r.value = r.value.slice(0, e.offset) + n + r.value.slice(e.offset);
2251
2362
  else {
2252
- const P = this.createTextElement(t, a);
2253
- o.children.splice(e.elementIndex, 0, P);
2363
+ const y = this.createTextElement(n, l);
2364
+ o.children.splice(e.elementIndex, 0, y);
2254
2365
  }
2255
2366
  this.bumpVersion();
2256
2367
  }
2257
2368
  /** 删除指定范围内容 */
2258
- deleteAt(e, t) {
2259
- const a = this.getParagraphAt(e.sectionIndex, e.paragraphIndex);
2260
- if (!a) return;
2261
- const o = a.children[e.elementIndex];
2262
- !o || o.type !== "text" || (o.value = o.value.slice(0, e.offset) + o.value.slice(e.offset + t), o.value === "" && a.children.splice(e.elementIndex, 1), this.bumpVersion());
2369
+ deleteAt(e, n) {
2370
+ const l = this.getParagraphAt(e.sectionIndex, e.paragraphIndex);
2371
+ if (!l) return;
2372
+ const o = l.children[e.elementIndex];
2373
+ !o || o.type !== "text" || (o.value = o.value.slice(0, e.offset) + o.value.slice(e.offset + n), o.value === "" && l.children.splice(e.elementIndex, 1), this.bumpVersion());
2263
2374
  }
2264
2375
  /** 在段落后插入新段落 */
2265
- insertParagraph(e, t, a) {
2376
+ insertParagraph(e, n, l) {
2266
2377
  const o = this.data.sections[e];
2267
2378
  if (!o) throw new Error(`Section ${e} not found`);
2268
- const u = this.createEmptyParagraph(a);
2269
- return o.paragraphs.splice(t + 1, 0, u), this.bumpVersion(), u;
2379
+ const r = this.createEmptyParagraph(l);
2380
+ return o.paragraphs.splice(n + 1, 0, r), this.bumpVersion(), r;
2270
2381
  }
2271
2382
  /** 合并两个相邻段落 */
2272
- mergeParagraphs(e, t) {
2273
- const a = this.data.sections[e];
2274
- if (!a) return;
2275
- const o = a.paragraphs[t], u = a.paragraphs[t + 1];
2276
- !o || !u || (o.children.push(...u.children), a.paragraphs.splice(t + 1, 1), this.bumpVersion());
2383
+ mergeParagraphs(e, n) {
2384
+ const l = this.data.sections[e];
2385
+ if (!l) return;
2386
+ const o = l.paragraphs[n], r = l.paragraphs[n + 1];
2387
+ !o || !r || (o.children.push(...r.children), l.paragraphs.splice(n + 1, 1), this.bumpVersion());
2277
2388
  }
2278
2389
  /** 更新段落格式 */
2279
- updateParagraphFormat(e, t, a) {
2280
- const o = this.getParagraphAt(e, t);
2281
- o && (o.format = { ...o.format, ...a }, this.bumpVersion());
2390
+ updateParagraphFormat(e, n, l) {
2391
+ const o = this.getParagraphAt(e, n);
2392
+ o && (o.format = { ...o.format, ...l }, this.bumpVersion());
2282
2393
  }
2283
2394
  /** 更新元素格式 */
2284
- updateElementFormat(e, t) {
2285
- const a = this.getElementAt(e);
2286
- a && (a.format = { ...a.format, ...t }, this.bumpVersion());
2395
+ updateElementFormat(e, n) {
2396
+ const l = this.getElementAt(e);
2397
+ l && (l.format = { ...l.format, ...n }, this.bumpVersion());
2287
2398
  }
2288
2399
  /** 批量更新选区内元素格式 */
2289
- updateRangeFormat(e, t, a) {
2400
+ updateRangeFormat(e, n, l) {
2290
2401
  const o = this.getAllParagraphs();
2291
- let u = !1;
2292
- for (const { paragraph: P, sectionIndex: S, paragraphIndex: z } of o) {
2293
- const A = S === e.sectionIndex && z === e.paragraphIndex, Z = S === t.sectionIndex && z === t.paragraphIndex;
2294
- if (A && (u = !0), u)
2295
- for (let N = 0; N < P.children.length; N++) {
2296
- const q = P.children[N];
2297
- if (!(A && N < e.elementIndex)) {
2298
- if (Z && N > t.elementIndex) break;
2299
- q.format = { ...q.format, ...a };
2402
+ let r = !1;
2403
+ for (const { paragraph: y, sectionIndex: s, paragraphIndex: m } of o) {
2404
+ const h = s === e.sectionIndex && m === e.paragraphIndex, I = s === n.sectionIndex && m === n.paragraphIndex;
2405
+ if (h && (r = !0), r)
2406
+ for (let S = 0; S < y.children.length; S++) {
2407
+ const L = y.children[S];
2408
+ if (!(h && S < e.elementIndex)) {
2409
+ if (I && S > n.elementIndex) break;
2410
+ L.format = { ...L.format, ...l };
2300
2411
  }
2301
2412
  }
2302
- if (Z) break;
2413
+ if (I) break;
2303
2414
  }
2304
2415
  this.bumpVersion();
2305
2416
  }
@@ -2312,26 +2423,26 @@ class Qe {
2312
2423
  }
2313
2424
  /** 从 JSON 恢复 */
2314
2425
  static fromJSON(e) {
2315
- const t = JSON.parse(e), a = new Qe();
2316
- return Object.assign(a.data, t), a;
2426
+ const n = JSON.parse(e), l = new it();
2427
+ return Object.assign(l.data, n), l;
2317
2428
  }
2318
2429
  }
2319
- function Te(i = 0, e = 0, t = 0, a = 0) {
2320
- return { sectionIndex: i, paragraphIndex: e, elementIndex: t, offset: a };
2430
+ function Te(t = 0, e = 0, n = 0, l = 0) {
2431
+ return { sectionIndex: t, paragraphIndex: e, elementIndex: n, offset: l };
2321
2432
  }
2322
- function Lt(i, e) {
2323
- return i.sectionIndex === e.sectionIndex && i.paragraphIndex === e.paragraphIndex && i.elementIndex === e.elementIndex && i.offset === e.offset;
2433
+ function Nt(t, e) {
2434
+ return t.sectionIndex === e.sectionIndex && t.paragraphIndex === e.paragraphIndex && t.elementIndex === e.elementIndex && t.offset === e.offset;
2324
2435
  }
2325
- class rt {
2436
+ class ht {
2326
2437
  constructor(e) {
2327
- V(this, "_selection", Bt({
2438
+ D(this, "_selection", qt({
2328
2439
  anchor: Te(),
2329
2440
  focus: Te(),
2330
2441
  isCollapsed: !0
2331
2442
  }));
2332
- V(this, "_docModel");
2443
+ D(this, "_docModel");
2333
2444
  /** 是否有选区(非光标) */
2334
- V(this, "hasSelection", ke(() => !this._selection.isCollapsed));
2445
+ D(this, "hasSelection", ae(() => !this._selection.isCollapsed));
2335
2446
  this._docModel = e;
2336
2447
  }
2337
2448
  get selection() {
@@ -2341,75 +2452,75 @@ class rt {
2341
2452
  setCursor(e) {
2342
2453
  this._selection.anchor = { ...e }, this._selection.focus = { ...e }, this._selection.isCollapsed = !0;
2343
2454
  }
2344
- setSelection(e, t) {
2345
- this._selection.anchor = { ...e }, this._selection.focus = { ...t }, this._selection.isCollapsed = Lt(e, t);
2455
+ setSelection(e, n) {
2456
+ this._selection.anchor = { ...e }, this._selection.focus = { ...n }, this._selection.isCollapsed = Nt(e, n);
2346
2457
  }
2347
2458
  collapse(e = !0) {
2348
2459
  e ? this._selection.anchor = { ...this._selection.focus } : this._selection.focus = { ...this._selection.anchor }, this._selection.isCollapsed = !0;
2349
2460
  }
2350
2461
  selectAll() {
2351
- const e = this._docModel.data.sections, t = e[e.length - 1], a = t == null ? void 0 : t.paragraphs[t.paragraphs.length - 1], o = a == null ? void 0 : a.children[a.children.length - 1], u = (o == null ? void 0 : o.type) === "text" ? o.value.length : 0;
2462
+ const e = this._docModel.data.sections, n = e[e.length - 1], l = n == null ? void 0 : n.paragraphs[n.paragraphs.length - 1], o = l == null ? void 0 : l.children[l.children.length - 1], r = (o == null ? void 0 : o.type) === "text" ? o.value.length : 0;
2352
2463
  this._selection.anchor = Te(0, 0, 0, 0), this._selection.focus = Te(
2353
2464
  e.length - 1,
2354
- ((t == null ? void 0 : t.paragraphs.length) ?? 1) - 1,
2355
- ((a == null ? void 0 : a.children.length) ?? 0) === 0 ? 0 : ((a == null ? void 0 : a.children.length) ?? 1) - 1,
2356
- u
2465
+ ((n == null ? void 0 : n.paragraphs.length) ?? 1) - 1,
2466
+ ((l == null ? void 0 : l.children.length) ?? 0) === 0 ? 0 : ((l == null ? void 0 : l.children.length) ?? 1) - 1,
2467
+ r
2357
2468
  ), this._selection.isCollapsed = !1;
2358
2469
  }
2359
2470
  // ─── 移动光标 ─────────────────────────────────────────────────────────────
2360
2471
  /** 光标向前移动一个字符 */
2361
2472
  moveForward(e = !1) {
2362
- const t = this._selection.focus, a = this._docModel.getParagraphAt(t.sectionIndex, t.paragraphIndex);
2363
- if (!a) return;
2364
- const o = a.children[t.elementIndex];
2365
- if ((o == null ? void 0 : o.type) === "text" && t.offset < o.value.length) {
2366
- const P = { ...t, offset: t.offset + 1 };
2367
- this._applyMove(P, e);
2473
+ const n = this._selection.focus, l = this._docModel.getParagraphAt(n.sectionIndex, n.paragraphIndex);
2474
+ if (!l) return;
2475
+ const o = l.children[n.elementIndex];
2476
+ if ((o == null ? void 0 : o.type) === "text" && n.offset < o.value.length) {
2477
+ const y = { ...n, offset: n.offset + 1 };
2478
+ this._applyMove(y, e);
2368
2479
  return;
2369
2480
  }
2370
- if (t.elementIndex < a.children.length - 1) {
2371
- const P = { ...t, elementIndex: t.elementIndex + 1, offset: 0 };
2372
- this._applyMove(P, e);
2481
+ if (n.elementIndex < l.children.length - 1) {
2482
+ const y = { ...n, elementIndex: n.elementIndex + 1, offset: 0 };
2483
+ this._applyMove(y, e);
2373
2484
  return;
2374
2485
  }
2375
- const u = this._getNextParagraphPoint(t);
2376
- u && this._applyMove(u, e);
2486
+ const r = this._getNextParagraphPoint(n);
2487
+ r && this._applyMove(r, e);
2377
2488
  }
2378
2489
  /** 光标向后移动一个字符 */
2379
2490
  moveBackward(e = !1) {
2380
- const t = this._selection.focus;
2381
- if (t.offset > 0) {
2382
- const o = { ...t, offset: t.offset - 1 };
2491
+ const n = this._selection.focus;
2492
+ if (n.offset > 0) {
2493
+ const o = { ...n, offset: n.offset - 1 };
2383
2494
  this._applyMove(o, e);
2384
2495
  return;
2385
2496
  }
2386
- if (t.elementIndex > 0) {
2387
- const o = this._docModel.getParagraphAt(t.sectionIndex, t.paragraphIndex), u = o == null ? void 0 : o.children[t.elementIndex - 1], P = (u == null ? void 0 : u.type) === "text" ? u.value.length : 0, S = { ...t, elementIndex: t.elementIndex - 1, offset: P };
2388
- this._applyMove(S, e);
2497
+ if (n.elementIndex > 0) {
2498
+ const o = this._docModel.getParagraphAt(n.sectionIndex, n.paragraphIndex), r = o == null ? void 0 : o.children[n.elementIndex - 1], y = (r == null ? void 0 : r.type) === "text" ? r.value.length : 0, s = { ...n, elementIndex: n.elementIndex - 1, offset: y };
2499
+ this._applyMove(s, e);
2389
2500
  return;
2390
2501
  }
2391
- const a = this._getPrevParagraphPoint(t);
2392
- a && this._applyMove(a, e);
2502
+ const l = this._getPrevParagraphPoint(n);
2503
+ l && this._applyMove(l, e);
2393
2504
  }
2394
- _applyMove(e, t) {
2395
- t ? (this._selection.focus = e, this._selection.isCollapsed = Lt(this._selection.anchor, e)) : (this._selection.anchor = { ...e }, this._selection.focus = { ...e }, this._selection.isCollapsed = !0);
2505
+ _applyMove(e, n) {
2506
+ n ? (this._selection.focus = e, this._selection.isCollapsed = Nt(this._selection.anchor, e)) : (this._selection.anchor = { ...e }, this._selection.focus = { ...e }, this._selection.isCollapsed = !0);
2396
2507
  }
2397
2508
  _getNextParagraphPoint(e) {
2398
- const t = this._docModel.data.sections[e.sectionIndex];
2399
- return t ? e.paragraphIndex < t.paragraphs.length - 1 ? Te(e.sectionIndex, e.paragraphIndex + 1, 0, 0) : e.sectionIndex < this._docModel.data.sections.length - 1 ? Te(e.sectionIndex + 1, 0, 0, 0) : null : null;
2509
+ const n = this._docModel.data.sections[e.sectionIndex];
2510
+ return n ? e.paragraphIndex < n.paragraphs.length - 1 ? Te(e.sectionIndex, e.paragraphIndex + 1, 0, 0) : e.sectionIndex < this._docModel.data.sections.length - 1 ? Te(e.sectionIndex + 1, 0, 0, 0) : null : null;
2400
2511
  }
2401
2512
  _getPrevParagraphPoint(e) {
2402
2513
  if (e.paragraphIndex > 0) {
2403
- const t = this._docModel.getParagraphAt(e.sectionIndex, e.paragraphIndex - 1);
2404
- if (!t) return null;
2405
- const a = t.children.length - 1, o = t.children[a], u = (o == null ? void 0 : o.type) === "text" ? o.value.length : 0;
2406
- return Te(e.sectionIndex, e.paragraphIndex - 1, Math.max(a, 0), u);
2514
+ const n = this._docModel.getParagraphAt(e.sectionIndex, e.paragraphIndex - 1);
2515
+ if (!n) return null;
2516
+ const l = n.children.length - 1, o = n.children[l], r = (o == null ? void 0 : o.type) === "text" ? o.value.length : 0;
2517
+ return Te(e.sectionIndex, e.paragraphIndex - 1, Math.max(l, 0), r);
2407
2518
  }
2408
2519
  if (e.sectionIndex > 0) {
2409
- const t = this._docModel.data.sections[e.sectionIndex - 1];
2410
- if (!t) return null;
2411
- const a = t.paragraphs.length - 1, o = t.paragraphs[a], u = ((o == null ? void 0 : o.children.length) ?? 0) - 1, P = o == null ? void 0 : o.children[u], S = (P == null ? void 0 : P.type) === "text" ? P.value.length : 0;
2412
- return Te(e.sectionIndex - 1, a, Math.max(u, 0), S);
2520
+ const n = this._docModel.data.sections[e.sectionIndex - 1];
2521
+ if (!n) return null;
2522
+ const l = n.paragraphs.length - 1, o = n.paragraphs[l], r = ((o == null ? void 0 : o.children.length) ?? 0) - 1, y = o == null ? void 0 : o.children[r], s = (y == null ? void 0 : y.type) === "text" ? y.value.length : 0;
2523
+ return Te(e.sectionIndex - 1, l, Math.max(r, 0), s);
2413
2524
  }
2414
2525
  return null;
2415
2526
  }
@@ -2418,27 +2529,27 @@ class rt {
2418
2529
  * 从 DOM element 的 data-* 属性解析模型坐标
2419
2530
  * 渲染时每个元素需附带 data-si/data-pi/data-ei 属性
2420
2531
  */
2421
- static domToModelPoint(e, t) {
2422
- let a = e instanceof Element ? e : e.parentElement;
2423
- for (; a; ) {
2424
- const o = a.getAttribute("data-si"), u = a.getAttribute("data-pi"), P = a.getAttribute("data-ei");
2425
- if (o !== null && u !== null && P !== null)
2532
+ static domToModelPoint(e, n) {
2533
+ let l = e instanceof Element ? e : e.parentElement;
2534
+ for (; l; ) {
2535
+ const o = l.getAttribute("data-si"), r = l.getAttribute("data-pi"), y = l.getAttribute("data-ei");
2536
+ if (o !== null && r !== null && y !== null)
2426
2537
  return {
2427
2538
  sectionIndex: parseInt(o),
2428
- paragraphIndex: parseInt(u),
2429
- elementIndex: parseInt(P),
2430
- offset: t
2539
+ paragraphIndex: parseInt(r),
2540
+ elementIndex: parseInt(y),
2541
+ offset: n
2431
2542
  };
2432
- a = a.parentElement;
2543
+ l = l.parentElement;
2433
2544
  }
2434
2545
  return null;
2435
2546
  }
2436
2547
  }
2437
- const Gi = 200;
2438
- class Ji {
2548
+ const gl = 200;
2549
+ class pl {
2439
2550
  constructor() {
2440
- V(this, "_undoStack", []);
2441
- V(this, "_redoStack", []);
2551
+ D(this, "_undoStack", []);
2552
+ D(this, "_redoStack", []);
2442
2553
  }
2443
2554
  get canUndo() {
2444
2555
  return this._undoStack.length > 0;
@@ -2451,14 +2562,14 @@ class Ji {
2451
2562
  * 支持合并连续同类命令(如连续输入文字)
2452
2563
  */
2453
2564
  push(e) {
2454
- var a, o;
2565
+ var l, o;
2455
2566
  this._redoStack = [];
2456
- const t = this._undoStack[this._undoStack.length - 1];
2457
- if (t && ((a = e.canMergeWith) != null && a.call(e, t))) {
2458
- (o = t.merge) == null || o.call(t, e);
2567
+ const n = this._undoStack[this._undoStack.length - 1];
2568
+ if (n && ((l = e.canMergeWith) != null && l.call(e, n))) {
2569
+ (o = n.merge) == null || o.call(n, e);
2459
2570
  return;
2460
2571
  }
2461
- this._undoStack.push(e), this._undoStack.length > Gi && this._undoStack.shift();
2572
+ this._undoStack.push(e), this._undoStack.length > gl && this._undoStack.shift();
2462
2573
  }
2463
2574
  undo() {
2464
2575
  const e = this._undoStack.pop();
@@ -2472,13 +2583,13 @@ class Ji {
2472
2583
  this._undoStack = [], this._redoStack = [];
2473
2584
  }
2474
2585
  }
2475
- class Xi {
2476
- constructor(e, t, a, o, u) {
2477
- V(this, "name", "insertText");
2478
- V(this, "_point");
2479
- V(this, "_text");
2480
- V(this, "_format");
2481
- this.docModel = e, this.selectionManager = t, this._point = { ...a }, this._text = o, this._format = u;
2586
+ class vl {
2587
+ constructor(e, n, l, o, r) {
2588
+ D(this, "name", "insertText");
2589
+ D(this, "_point");
2590
+ D(this, "_text");
2591
+ D(this, "_format");
2592
+ this.docModel = e, this.selectionManager = n, this._point = { ...l }, this._text = o, this._format = r;
2482
2593
  }
2483
2594
  execute() {
2484
2595
  this.docModel.insertText(this._point, this._text, this._format), this.selectionManager.setCursor({
@@ -2491,63 +2602,63 @@ class Xi {
2491
2602
  }
2492
2603
  canMergeWith(e) {
2493
2604
  if (e.name !== "insertText") return !1;
2494
- const t = e;
2495
- return t._point.sectionIndex === this._point.sectionIndex && t._point.paragraphIndex === this._point.paragraphIndex && t._point.elementIndex === this._point.elementIndex && t._point.offset === this._point.offset + this._text.length;
2605
+ const n = e;
2606
+ return n._point.sectionIndex === this._point.sectionIndex && n._point.paragraphIndex === this._point.paragraphIndex && n._point.elementIndex === this._point.elementIndex && n._point.offset === this._point.offset + this._text.length;
2496
2607
  }
2497
2608
  merge(e) {
2498
- const t = e;
2499
- this._text += t._text;
2609
+ const n = e;
2610
+ this._text += n._text;
2500
2611
  }
2501
2612
  }
2502
- class Yi {
2503
- constructor(e, t) {
2504
- V(this, "name", "insertParagraph");
2505
- V(this, "_insertedParagraphId", null);
2506
- this.docModel = e, this.selectionManager = t;
2613
+ class ml {
2614
+ constructor(e, n) {
2615
+ D(this, "name", "insertParagraph");
2616
+ D(this, "_insertedParagraphId", null);
2617
+ this.docModel = e, this.selectionManager = n;
2507
2618
  }
2508
2619
  execute() {
2509
- var z, A;
2510
- const { focus: e } = this.selectionManager.selection, { sectionIndex: t, paragraphIndex: a } = e, o = this.docModel.getParagraphAt(t, a);
2620
+ var m, h;
2621
+ const { focus: e } = this.selectionManager.selection, { sectionIndex: n, paragraphIndex: l } = e, o = this.docModel.getParagraphAt(n, l);
2511
2622
  if (!o) return;
2512
- const u = e.elementIndex, P = o.children.splice(u), S = this.docModel.createEmptyParagraph(o.format);
2513
- S.children.push(...P), this._insertedParagraphId = S.id, this.docModel.data.sections[t].paragraphs.splice(a + 1, 0, S), (A = (z = this.docModel).bumpVersion) == null || A.call(z), this.selectionManager.setCursor({
2514
- sectionIndex: t,
2515
- paragraphIndex: a + 1,
2623
+ const r = e.elementIndex, y = o.children.splice(r), s = this.docModel.createEmptyParagraph(o.format);
2624
+ s.children.push(...y), this._insertedParagraphId = s.id, this.docModel.data.sections[n].paragraphs.splice(l + 1, 0, s), (h = (m = this.docModel).bumpVersion) == null || h.call(m), this.selectionManager.setCursor({
2625
+ sectionIndex: n,
2626
+ paragraphIndex: l + 1,
2516
2627
  elementIndex: 0,
2517
2628
  offset: 0
2518
2629
  });
2519
2630
  }
2520
2631
  undo() {
2521
- const { focus: e } = this.selectionManager.selection, { sectionIndex: t, paragraphIndex: a } = e;
2522
- a !== 0 && (this.docModel.mergeParagraphs(t, a - 1), this.selectionManager.setCursor({
2523
- sectionIndex: t,
2524
- paragraphIndex: a - 1,
2632
+ const { focus: e } = this.selectionManager.selection, { sectionIndex: n, paragraphIndex: l } = e;
2633
+ l !== 0 && (this.docModel.mergeParagraphs(n, l - 1), this.selectionManager.setCursor({
2634
+ sectionIndex: n,
2635
+ paragraphIndex: l - 1,
2525
2636
  elementIndex: 0,
2526
2637
  offset: 0
2527
2638
  }));
2528
2639
  }
2529
2640
  }
2530
- class Rt {
2531
- constructor(e, t, a) {
2532
- V(this, "name");
2533
- V(this, "_deletedText", "");
2534
- this.docModel = e, this.selectionManager = t, this.name = a === "backward" ? "deleteBackward" : "deleteForward";
2641
+ class zt {
2642
+ constructor(e, n, l) {
2643
+ D(this, "name");
2644
+ D(this, "_deletedText", "");
2645
+ this.docModel = e, this.selectionManager = n, this.name = l === "backward" ? "deleteBackward" : "deleteForward";
2535
2646
  }
2536
2647
  execute() {
2537
- const { focus: e, isCollapsed: t } = this.selectionManager.selection;
2538
- if (t)
2648
+ const { focus: e, isCollapsed: n } = this.selectionManager.selection;
2649
+ if (n)
2539
2650
  if (this.name === "deleteBackward")
2540
2651
  if (e.offset > 0) {
2541
- const a = { ...e, offset: e.offset - 1 }, o = this.docModel.getElementAt(e);
2542
- (o == null ? void 0 : o.type) === "text" && (this._deletedText = o.value[e.offset - 1] ?? ""), this.docModel.deleteAt(a, 1), this.selectionManager.setCursor(a);
2652
+ const l = { ...e, offset: e.offset - 1 }, o = this.docModel.getElementAt(e);
2653
+ (o == null ? void 0 : o.type) === "text" && (this._deletedText = o.value[e.offset - 1] ?? ""), this.docModel.deleteAt(l, 1), this.selectionManager.setCursor(l);
2543
2654
  } else (e.paragraphIndex > 0 || e.elementIndex > 0) && (this.docModel.mergeParagraphs(e.sectionIndex, e.paragraphIndex - 1), this.selectionManager.setCursor({
2544
2655
  ...e,
2545
2656
  paragraphIndex: e.paragraphIndex - 1
2546
2657
  }));
2547
2658
  else {
2548
- const a = this.docModel.getElementAt(e);
2549
- if ((a == null ? void 0 : a.type) === "text" && e.offset < a.value.length)
2550
- this._deletedText = a.value[e.offset], this.docModel.deleteAt(e, 1);
2659
+ const l = this.docModel.getElementAt(e);
2660
+ if ((l == null ? void 0 : l.type) === "text" && e.offset < l.value.length)
2661
+ this._deletedText = l.value[e.offset], this.docModel.deleteAt(e, 1);
2551
2662
  else {
2552
2663
  const o = this.docModel.data.sections[e.sectionIndex];
2553
2664
  o && e.paragraphIndex < o.paragraphs.length - 1 && this.docModel.mergeParagraphs(e.sectionIndex, e.paragraphIndex);
@@ -2561,26 +2672,26 @@ class Rt {
2561
2672
  }
2562
2673
  }
2563
2674
  }
2564
- class De {
2565
- constructor(e, t, a, o) {
2566
- V(this, "name");
2567
- V(this, "_prevFormat", {});
2568
- this.docModel = e, this.selectionManager = t, this._value = o, this.name = a;
2675
+ class je {
2676
+ constructor(e, n, l, o) {
2677
+ D(this, "name");
2678
+ D(this, "_prevFormat", {});
2679
+ this.docModel = e, this.selectionManager = n, this._value = o, this.name = l;
2569
2680
  }
2570
2681
  execute() {
2571
- const { anchor: e, focus: t } = this.selectionManager.selection, a = this._getFormatKey();
2572
- if (!a) return;
2682
+ const { anchor: e, focus: n } = this.selectionManager.selection, l = this._getFormatKey();
2683
+ if (!l) return;
2573
2684
  const o = {};
2574
2685
  if (this._isToggle()) {
2575
- const u = this._getCurrentValue(a);
2576
- o[a] = !u;
2686
+ const r = this._getCurrentValue(l);
2687
+ o[l] = !r;
2577
2688
  } else
2578
- o[a] = this._value;
2579
- this.docModel.updateRangeFormat(e, t, o);
2689
+ o[l] = this._value;
2690
+ this.docModel.updateRangeFormat(e, n, o);
2580
2691
  }
2581
2692
  undo() {
2582
- const { anchor: e, focus: t } = this.selectionManager.selection;
2583
- this.docModel.updateRangeFormat(e, t, this._prevFormat);
2693
+ const { anchor: e, focus: n } = this.selectionManager.selection;
2694
+ this.docModel.updateRangeFormat(e, n, this._prevFormat);
2584
2695
  }
2585
2696
  _isToggle() {
2586
2697
  return ["bold", "italic", "underline", "strikethrough", "superscript", "subscript"].includes(this.name);
@@ -2599,47 +2710,47 @@ class De {
2599
2710
  }
2600
2711
  _getCurrentValue(e) {
2601
2712
  var o;
2602
- const { focus: t } = this.selectionManager.selection, a = this.docModel.getElementAt(t);
2603
- return (o = a == null ? void 0 : a.format) == null ? void 0 : o[e];
2713
+ const { focus: n } = this.selectionManager.selection, l = this.docModel.getElementAt(n);
2714
+ return (o = l == null ? void 0 : l.format) == null ? void 0 : o[e];
2604
2715
  }
2605
2716
  }
2606
- class st {
2607
- constructor(e, t, a, o) {
2608
- V(this, "name", "textAlign");
2609
- this.docModel = e, this.selectionManager = t, this._formatKey = a, this._value = o;
2717
+ class ut {
2718
+ constructor(e, n, l, o) {
2719
+ D(this, "name", "textAlign");
2720
+ this.docModel = e, this.selectionManager = n, this._formatKey = l, this._value = o;
2610
2721
  }
2611
2722
  execute() {
2612
- const { focus: e } = this.selectionManager.selection, t = {};
2613
- t[this._formatKey] = this._value, this.docModel.updateParagraphFormat(e.sectionIndex, e.paragraphIndex, t);
2723
+ const { focus: e } = this.selectionManager.selection, n = {};
2724
+ n[this._formatKey] = this._value, this.docModel.updateParagraphFormat(e.sectionIndex, e.paragraphIndex, n);
2614
2725
  }
2615
2726
  undo() {
2616
2727
  }
2617
2728
  }
2618
- class Zi {
2619
- constructor(e, t, a) {
2620
- V(this, "_factories", /* @__PURE__ */ new Map());
2621
- this.docModel = e, this.selectionManager = t, this.historyManager = a, this._registerBuiltinCommands();
2729
+ class yl {
2730
+ constructor(e, n, l) {
2731
+ D(this, "_factories", /* @__PURE__ */ new Map());
2732
+ this.docModel = e, this.selectionManager = n, this.historyManager = l, this._registerBuiltinCommands();
2622
2733
  }
2623
2734
  // ─── 注册内置命令 ─────────────────────────────────────────────────────────
2624
2735
  _registerBuiltinCommands() {
2625
- this.register("insertText", (t) => {
2626
- const { focus: a } = this.selectionManager.selection;
2627
- return new Xi(this.docModel, this.selectionManager, a, t);
2628
- }), this.register("insertParagraph", () => new Yi(this.docModel, this.selectionManager)), this.register("deleteBackward", () => new Rt(this.docModel, this.selectionManager, "backward")), this.register("deleteForward", () => new Rt(this.docModel, this.selectionManager, "forward")), this.register("undo", () => null), this.register("redo", () => null), ["bold", "italic", "underline", "strikethrough", "superscript", "subscript"].forEach((t) => {
2629
- this.register(t, () => new De(this.docModel, this.selectionManager, t));
2630
- }), this.register("fontSize", (t) => new De(this.docModel, this.selectionManager, "fontSize", t)), this.register("fontFamily", (t) => new De(this.docModel, this.selectionManager, "fontFamily", t)), this.register("color", (t) => new De(this.docModel, this.selectionManager, "color", t)), this.register("backgroundColor", (t) => new De(this.docModel, this.selectionManager, "backgroundColor", t)), this.register("textAlign", (t) => new st(this.docModel, this.selectionManager, "textAlign", t)), this.register("lineHeight", (t) => new st(this.docModel, this.selectionManager, "lineHeight", t)), this.register("heading", (t) => new st(this.docModel, this.selectionManager, "heading", t)), this.register("selectAll", () => (this.selectionManager.selectAll(), null)), this.register("setSelection", (t) => {
2631
- if (t) {
2632
- const a = t;
2633
- this.selectionManager.setSelection(a.anchor, a.focus);
2736
+ this.register("insertText", (n) => {
2737
+ const { focus: l } = this.selectionManager.selection;
2738
+ return new vl(this.docModel, this.selectionManager, l, n);
2739
+ }), this.register("insertParagraph", () => new ml(this.docModel, this.selectionManager)), this.register("deleteBackward", () => new zt(this.docModel, this.selectionManager, "backward")), this.register("deleteForward", () => new zt(this.docModel, this.selectionManager, "forward")), this.register("undo", () => null), this.register("redo", () => null), ["bold", "italic", "underline", "strikethrough", "superscript", "subscript"].forEach((n) => {
2740
+ this.register(n, () => new je(this.docModel, this.selectionManager, n));
2741
+ }), this.register("fontSize", (n) => new je(this.docModel, this.selectionManager, "fontSize", n)), this.register("fontFamily", (n) => new je(this.docModel, this.selectionManager, "fontFamily", n)), this.register("color", (n) => new je(this.docModel, this.selectionManager, "color", n)), this.register("backgroundColor", (n) => new je(this.docModel, this.selectionManager, "backgroundColor", n)), this.register("textAlign", (n) => new ut(this.docModel, this.selectionManager, "textAlign", n)), this.register("lineHeight", (n) => new ut(this.docModel, this.selectionManager, "lineHeight", n)), this.register("heading", (n) => new ut(this.docModel, this.selectionManager, "heading", n)), this.register("selectAll", () => (this.selectionManager.selectAll(), null)), this.register("setSelection", (n) => {
2742
+ if (n) {
2743
+ const l = n;
2744
+ this.selectionManager.setSelection(l.anchor, l.focus);
2634
2745
  }
2635
2746
  return null;
2636
2747
  });
2637
2748
  }
2638
2749
  // ─── 公共 API ─────────────────────────────────────────────────────────────
2639
- register(e, t) {
2640
- this._factories.set(e, t);
2750
+ register(e, n) {
2751
+ this._factories.set(e, n);
2641
2752
  }
2642
- exec(e, t) {
2753
+ exec(e, n) {
2643
2754
  if (e === "undo") {
2644
2755
  this.historyManager.undo();
2645
2756
  return;
@@ -2648,28 +2759,28 @@ class Zi {
2648
2759
  this.historyManager.redo();
2649
2760
  return;
2650
2761
  }
2651
- const a = this._factories.get(e);
2652
- if (!a) {
2762
+ const l = this._factories.get(e);
2763
+ if (!l) {
2653
2764
  console.warn(`[CommandManager] 未注册命令: ${e}`);
2654
2765
  return;
2655
2766
  }
2656
- const o = a(t);
2767
+ const o = l(n);
2657
2768
  o && (o.execute(), this.historyManager.push(o));
2658
2769
  }
2659
2770
  }
2660
- class Qi {
2661
- constructor(e, t) {
2662
- V(this, "_el", null);
2663
- V(this, "_commandManager");
2664
- V(this, "_selectionManager");
2665
- V(this, "_composing", !1);
2771
+ class bl {
2772
+ constructor(e, n) {
2773
+ D(this, "_el", null);
2774
+ D(this, "_commandManager");
2775
+ D(this, "_selectionManager");
2776
+ D(this, "_composing", !1);
2666
2777
  // 正在 IME 输入中
2667
- V(this, "_boundKeydown");
2668
- V(this, "_boundBeforeInput");
2669
- V(this, "_boundCompositionStart");
2670
- V(this, "_boundCompositionEnd");
2671
- V(this, "_boundSelectionChange");
2672
- this._commandManager = e, this._selectionManager = t, this._boundKeydown = this._onKeydown.bind(this), this._boundBeforeInput = this._onBeforeInput.bind(this), this._boundCompositionStart = () => {
2778
+ D(this, "_boundKeydown");
2779
+ D(this, "_boundBeforeInput");
2780
+ D(this, "_boundCompositionStart");
2781
+ D(this, "_boundCompositionEnd");
2782
+ D(this, "_boundSelectionChange");
2783
+ this._commandManager = e, this._selectionManager = n, this._boundKeydown = this._onKeydown.bind(this), this._boundBeforeInput = this._onBeforeInput.bind(this), this._boundCompositionStart = () => {
2673
2784
  this._composing = !0;
2674
2785
  }, this._boundCompositionEnd = this._onCompositionEnd.bind(this), this._boundSelectionChange = this._onSelectionChange.bind(this);
2675
2786
  }
@@ -2681,9 +2792,9 @@ class Qi {
2681
2792
  }
2682
2793
  // ─── 事件处理 ─────────────────────────────────────────────────────────────
2683
2794
  _onKeydown(e) {
2684
- const t = e.key, a = e.ctrlKey || e.metaKey, o = e.shiftKey;
2685
- if (a)
2686
- switch (t) {
2795
+ const n = e.key, l = e.ctrlKey || e.metaKey, o = e.shiftKey;
2796
+ if (l)
2797
+ switch (n) {
2687
2798
  case "z":
2688
2799
  e.preventDefault(), o ? this._commandManager.exec("redo") : this._commandManager.exec("undo");
2689
2800
  return;
@@ -2700,7 +2811,7 @@ class Qi {
2700
2811
  e.preventDefault(), this._commandManager.exec("selectAll");
2701
2812
  return;
2702
2813
  }
2703
- switch (t) {
2814
+ switch (n) {
2704
2815
  case "Enter":
2705
2816
  e.preventDefault(), this._composing || this._commandManager.exec("insertParagraph");
2706
2817
  break;
@@ -2730,24 +2841,24 @@ class Qi {
2730
2841
  _onSelectionChange() {
2731
2842
  const e = window.getSelection();
2732
2843
  if (!e || !this._el) return;
2733
- const t = e.anchorNode, a = e.focusNode;
2734
- if (!t || !a || !this._el.contains(t) && !this._el.contains(a)) return;
2735
- const o = rt.domToModelPoint(t, e.anchorOffset), u = rt.domToModelPoint(a, e.focusOffset);
2736
- o && u && this._selectionManager.setSelection(o, u);
2844
+ const n = e.anchorNode, l = e.focusNode;
2845
+ if (!n || !l || !this._el.contains(n) && !this._el.contains(l)) return;
2846
+ const o = ht.domToModelPoint(n, e.anchorOffset), r = ht.domToModelPoint(l, e.focusOffset);
2847
+ o && r && this._selectionManager.setSelection(o, r);
2737
2848
  }
2738
2849
  }
2739
- class el {
2850
+ class _l {
2740
2851
  constructor(e = {}) {
2741
- V(this, "docModel");
2742
- V(this, "selection");
2743
- V(this, "history");
2744
- V(this, "commands");
2745
- V(this, "input");
2746
- V(this, "_readonly");
2747
- V(this, "_plugins", []);
2748
- V(this, "_inputEl", null);
2749
- var t;
2750
- this._readonly = e.readonly ?? !1, this.docModel = new Qe(e.initialDocument), this.selection = new rt(this.docModel), this.history = new Ji(), this.commands = new Zi(this.docModel, this.selection, this.history), this.input = new Qi(this.commands, this.selection), (t = e.plugins) == null || t.forEach((a) => this.use(a));
2852
+ D(this, "docModel");
2853
+ D(this, "selection");
2854
+ D(this, "history");
2855
+ D(this, "commands");
2856
+ D(this, "input");
2857
+ D(this, "_readonly");
2858
+ D(this, "_plugins", []);
2859
+ D(this, "_inputEl", null);
2860
+ var n;
2861
+ this._readonly = e.readonly ?? !1, this.docModel = new it(e.initialDocument), this.selection = new ht(this.docModel), this.history = new pl(), this.commands = new yl(this.docModel, this.selection, this.history), this.input = new bl(this.commands, this.selection), (n = e.plugins) == null || n.forEach((l) => this.use(l));
2751
2862
  }
2752
2863
  // ─── 公共 API ─────────────────────────────────────────────────────────────
2753
2864
  /**
@@ -2756,12 +2867,12 @@ class el {
2756
2867
  * @example editor.exec('fontSize', 18)
2757
2868
  * @example editor.exec('insertText', 'hello')
2758
2869
  */
2759
- exec(e, t) {
2870
+ exec(e, n) {
2760
2871
  if (this._readonly && !this._isReadCommand(e)) {
2761
2872
  console.warn("[Editor] 只读模式,忽略写操作");
2762
2873
  return;
2763
2874
  }
2764
- this.commands.exec(e, t);
2875
+ this.commands.exec(e, n);
2765
2876
  }
2766
2877
  /** 挂载输入层到指定 DOM 元素 */
2767
2878
  mount(e) {
@@ -2773,7 +2884,7 @@ class el {
2773
2884
  }
2774
2885
  /** 安装插件 */
2775
2886
  use(e) {
2776
- return this._plugins.find((t) => t.name === e.name) ? (console.warn(`[Editor] 插件 ${e.name} 已安装`), this) : (e.install(this), this._plugins.push(e), this);
2887
+ return this._plugins.find((n) => n.name === e.name) ? (console.warn(`[Editor] 插件 ${e.name} 已安装`), this) : (e.install(this), this._plugins.push(e), this);
2777
2888
  }
2778
2889
  /** 获取序列化后的文档 JSON */
2779
2890
  getJSON() {
@@ -2781,8 +2892,8 @@ class el {
2781
2892
  }
2782
2893
  /** 从 JSON 加载文档(清空历史) */
2783
2894
  loadJSON(e) {
2784
- const t = Qe.fromJSON(e);
2785
- Object.assign(this.docModel.data, t.data), this.history.clear();
2895
+ const n = it.fromJSON(e);
2896
+ Object.assign(this.docModel.data, n.data), this.history.clear();
2786
2897
  }
2787
2898
  get isReadonly() {
2788
2899
  return this._readonly;
@@ -2791,29 +2902,29 @@ class el {
2791
2902
  return ["undo", "redo", "selectAll", "setSelection"].includes(e);
2792
2903
  }
2793
2904
  }
2794
- const Nt = Symbol("editor");
2795
- function ol(i) {
2796
- const e = new el(i);
2797
- return vn(Nt, e), et(() => {
2905
+ const Yt = Symbol("editor");
2906
+ function Il(t) {
2907
+ const e = new _l(t);
2908
+ return Kt(Yt, e), lt(() => {
2798
2909
  e.unmount();
2799
2910
  }), e;
2800
2911
  }
2801
- function sl() {
2802
- const i = mn(Nt);
2803
- if (!i)
2912
+ function El() {
2913
+ const t = jt(Yt);
2914
+ if (!t)
2804
2915
  throw new Error("[useEditor] 必须在 EditorContainer 组件内使用");
2805
- return i;
2916
+ return t;
2806
2917
  }
2807
- const tl = Ui, rl = {
2808
- install(i) {
2809
- i.component("EditorContainer", tl);
2918
+ const xl = fl, Sl = {
2919
+ install(t) {
2920
+ t.component("EditorContainer", xl);
2810
2921
  }
2811
2922
  };
2812
2923
  export {
2813
- el as Editor,
2814
- tl as EditorContainer,
2815
- Nt as EditorKey,
2816
- ol as createEditor,
2817
- rl as default,
2818
- sl as useEditor
2924
+ _l as Editor,
2925
+ xl as EditorContainer,
2926
+ Yt as EditorKey,
2927
+ Il as createEditor,
2928
+ Sl as default,
2929
+ El as useEditor
2819
2930
  };