@guodun/antdv 1.7.7 → 1.7.8

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.
Files changed (23) hide show
  1. package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +395 -325
  2. package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +851 -829
  3. package/dist/es/components/pro-contract-template-designer/src/composables/use-auto-pagination.mjs +122 -63
  4. package/dist/es/components/pro-contract-template-designer/src/utils/caret-viewport.mjs +41 -0
  5. package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
  6. package/dist/es/node_modules/@tiptap/pm/dist/transform/index.mjs +1 -0
  7. package/dist/es/node_modules/prosemirror-transform/dist/index.mjs +161 -67
  8. package/dist/lib/components/pro-contract-template-designer/src/DesignerPage.vue.cjs +2 -2
  9. package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
  10. package/dist/lib/components/pro-contract-template-designer/src/composables/use-auto-pagination.cjs +1 -1
  11. package/dist/lib/components/pro-contract-template-designer/src/utils/caret-viewport.cjs +1 -0
  12. package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
  13. package/dist/lib/node_modules/@tiptap/pm/dist/transform/index.cjs +1 -0
  14. package/dist/lib/node_modules/prosemirror-transform/dist/index.cjs +2 -2
  15. package/dist/theme/icon.css +1 -1
  16. package/dist/theme/index.css +1 -1
  17. package/dist/types/components/pro-contract-template-designer/src/DesignerPage.vue.d.ts +14 -0
  18. package/dist/types/components/pro-contract-template-designer/src/composables/use-auto-pagination.d.ts +17 -0
  19. package/dist/types/components/pro-contract-template-designer/src/utils/caret-viewport.d.ts +18 -0
  20. package/package.json +1 -1
  21. package/dist/theme/dept-selector.css +0 -1
  22. package/dist/theme/pro-selector-group.css +0 -1
  23. package/dist/theme/role-selector.css +0 -1
@@ -1,22 +1,25 @@
1
1
  import { CONTRACT_TEXT_STYLE_PRESETS as e, DEFAULT_CONTRACT_FONT_FAMILY as t } from "./constants.mjs";
2
2
  import { CONTRACT_PAGE_BASE_PADDING as n, getPageDecorationSafePadding as r, hasEnabledPageFooter as i, hasEnabledPageHeader as a, normalizePageDecorations as o } from "./utils/page-decorations.mjs";
3
- import { DEFAULT_FIELD_STYLE as s, resolvePageSize as c, splitPageContentByMeasurements as ee } from "./composables/use-template-designer.mjs";
4
- import { createEditorSnapshotCache as te } from "./utils/editor-snapshot-cache.mjs";
5
- import { usePageAuthoring as ne } from "./composables/use-page-authoring.mjs";
6
- import { buildTemplateVariableAttrs as re, insertTemplateVariableNode as ie } from "./extensions/template-variable.mjs";
7
- import { normalizeContractImageDimension as l } from "./utils/content-image.mjs";
8
- import { createEditorExtensions as ae, runContractTemplateEditorCommand as u } from "./extensions/editor-extensions.mjs";
9
- import { resolveEditorContextMenuKind as oe } from "./utils/context-variable.mjs";
3
+ import { DEFAULT_FIELD_STYLE as s, resolvePageSize as c, splitPageContentByMeasurements as l } from "./composables/use-template-designer.mjs";
4
+ import { createEditorSnapshotCache as ee } from "./utils/editor-snapshot-cache.mjs";
5
+ import { Mapping as te, StepMap as ne } from "../../../node_modules/prosemirror-transform/dist/index.mjs";
6
+ import { usePageAuthoring as re } from "./composables/use-page-authoring.mjs";
7
+ import "../../../node_modules/@tiptap/pm/dist/transform/index.mjs";
8
+ import { buildTemplateVariableAttrs as ie, insertTemplateVariableNode as ae } from "./extensions/template-variable.mjs";
9
+ import { normalizeContractImageDimension as u } from "./utils/content-image.mjs";
10
+ import { createEditorExtensions as oe, runContractTemplateEditorCommand as d } from "./extensions/editor-extensions.mjs";
11
+ import { resolveEditorContextMenuKind as f } from "./utils/context-variable.mjs";
10
12
  import { applyContractTemplateBlockStyle as se } from "./utils/block-style.mjs";
11
13
  import ce from "./ContractTemplatePageDecorations.mjs";
12
- import { computed as d, createBlock as le, createCommentVNode as ue, createElementBlock as de, createElementVNode as f, createVNode as fe, defineComponent as p, nextTick as pe, normalizeClass as me, normalizeStyle as m, onBeforeUnmount as he, openBlock as ge, ref as _e, toDisplayString as h, unref as g, watch as _, withModifiers as ve } from "vue";
13
- import { Modal as ye } from "ant-design-vue";
14
- import { EditorContent as be, useEditor as xe } from "@tiptap/vue-3";
15
- import { generateHTML as Se } from "@tiptap/core";
16
- import { CellSelection as v, deleteColumn as Ce, deleteRow as we, deleteTable as Te } from "@tiptap/pm/tables";
17
- import { NodeSelection as y } from "@tiptap/pm/state";
14
+ import { scrollCaretIntoCanvas as le } from "./utils/caret-viewport.mjs";
15
+ import { computed as p, createBlock as ue, createCommentVNode as de, createElementBlock as fe, createElementVNode as m, createVNode as pe, defineComponent as h, nextTick as me, normalizeClass as he, normalizeStyle as g, onBeforeUnmount as ge, openBlock as _e, ref as ve, toDisplayString as _, toRaw as ye, unref as v, watch as y, withModifiers as be } from "vue";
16
+ import { Modal as xe } from "ant-design-vue";
17
+ import { EditorContent as Se, useEditor as Ce } from "@tiptap/vue-3";
18
+ import { generateHTML as we } from "@tiptap/core";
19
+ import { CellSelection as b, deleteColumn as Te, deleteRow as Ee, deleteTable as De } from "@tiptap/pm/tables";
20
+ import { NodeSelection as x, Selection as Oe } from "@tiptap/pm/state";
18
21
  //#region src/components/pro-contract-template-designer/src/DesignerPage.vue?vue&type=script&setup=true&lang.ts
19
- var Ee = { class: "gd-contract-template-designer__page-title" }, b = "application/x-gd-contract-variable-move", De = 8, Oe = /* @__PURE__ */ p({
22
+ var ke = { class: "gd-contract-template-designer__page-title" }, S = "application/x-gd-contract-variable-move", Ae = 8, je = /* @__PURE__ */ h({
20
23
  name: "ProContractTemplateDesignerPage",
21
24
  __name: "DesignerPage",
22
25
  props: {
@@ -49,7 +52,11 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
49
52
  type: Boolean,
50
53
  default: !1
51
54
  },
52
- activeSearchMatch: { default: void 0 }
55
+ activeSearchMatch: { default: void 0 },
56
+ getScrollContainer: {
57
+ type: Function,
58
+ default: void 0
59
+ }
53
60
  },
54
61
  emits: [
55
62
  "page-update",
@@ -64,18 +71,18 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
64
71
  "editor-context-menu",
65
72
  "word-paste"
66
73
  ],
67
- setup(p, { expose: Oe, emit: ke }) {
68
- let x = p, S = ke, C = d(() => x.readonly || x.disabled), w = _e(), T = te(), E = !1, D, O, k = !1, Ae = !1, je = x.page.contentHtml;
69
- function A() {
70
- return Ae && !k;
74
+ setup(h, { expose: je, emit: Me }) {
75
+ let C = h, w = Me, T = p(() => C.readonly || C.disabled), E = ve(), D = ee(), O = !1, k, A, j = !1, M = !1, Ne = !1, N = !1, P = 0, F, Pe = C.page.contentHtml, Fe = ye(C.page);
76
+ function I() {
77
+ return M && !j;
71
78
  }
72
- function j() {
73
- return E || !!N.value?.view.composing;
79
+ function L() {
80
+ return O || !!R.value?.view.composing;
74
81
  }
75
- function Me(e) {
82
+ function Ie(e) {
76
83
  let t = e.filter(Boolean).join("、");
77
84
  return typeof window > "u" ? !1 : new Promise((e) => {
78
- ye.confirm({
85
+ xe.confirm({
79
86
  title: "粘贴内容包含不兼容字体",
80
87
  content: `检测到 ${t || "外部"} 字体。为保证 Mac 与 Windows 排版一致,将统一转换为合同标准字体(GD Contract Latin + 系统宋体)。是否继续粘贴?`,
81
88
  okText: "继续粘贴",
@@ -85,154 +92,166 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
85
92
  });
86
93
  });
87
94
  }
88
- let M = ae("请输入合同正文,或从 WPS / Word 粘贴合同内容", {
89
- processImageFile: x.processImageFile,
90
- confirmExternalFontPaste: Me,
91
- getZoom: () => Math.max(.1, x.zoom || 1)
92
- }), N = xe({
93
- content: x.page.contentHtml,
94
- editable: !C.value,
95
- extensions: M,
95
+ let Le = oe("请输入合同正文,或从 WPS / Word 粘贴合同内容", {
96
+ processImageFile: C.processImageFile,
97
+ confirmExternalFontPaste: Ie,
98
+ getZoom: () => Math.max(.1, C.zoom || 1)
99
+ }), R = Ce({
100
+ content: C.page.contentHtml,
101
+ editable: !T.value,
102
+ extensions: Le,
96
103
  editorProps: {
97
104
  attributes: { class: "gd-contract-template-designer__editor-prose" },
98
105
  handleClick: (e, t, n) => {
99
106
  let r = (n.target instanceof HTMLElement ? n.target.closest("[data-template-variable]") : void 0)?.dataset.key;
100
107
  if (!r) return !1;
101
- let i = x.variables.find((e) => e.key === r);
102
- return i && S("variable-select", i.key), !1;
108
+ let i = C.variables.find((e) => e.key === r);
109
+ return i && w("variable-select", i.key), !1;
103
110
  },
104
111
  handleDOMEvents: {
105
- compositionstart: () => (E = !0, D !== void 0 && clearTimeout(D), !1),
106
- compositionend: () => (E = !1, D = setTimeout(() => {
107
- if (D = void 0, !(k || j())) {
108
- if (O !== void 0) {
109
- let e = O;
110
- O = void 0, $e(e);
112
+ compositionstart: () => (O = !0, k !== void 0 && clearTimeout(k), !1),
113
+ compositionend: () => (O = !1, k = setTimeout(() => {
114
+ if (k = void 0, !(j || L())) {
115
+ if (A !== void 0) {
116
+ let e = A;
117
+ A = void 0, dt(e);
111
118
  }
112
- S("page-update", J()), S("composition-end", x.page.id);
119
+ w("page-update", K()), w("composition-end", C.page.id);
113
120
  }
114
121
  }, 0), !1),
115
122
  contextmenu: (e, t) => {
116
- if (C.value) return !1;
117
- let n = Je(e, t.target);
118
- if (n) return t.preventDefault(), B({
119
- pageId: x.page.id,
123
+ if (T.value) return !1;
124
+ let n = rt(e, t.target);
125
+ if (n) return t.preventDefault(), V({
126
+ pageId: C.page.id,
120
127
  clientX: t.clientX,
121
128
  clientY: t.clientY
122
129
  }, n), !0;
123
- let r = N.value?.state.selection, i = r instanceof v, a = t.target instanceof HTMLElement ? !!t.target.closest("td, th") : !1, o = oe({
130
+ let r = R.value?.state.selection, i = r instanceof b, a = t.target instanceof HTMLElement ? !!t.target.closest("td, th") : !1, o = f({
124
131
  isCellSelection: i,
125
132
  selectionEmpty: !r || r.empty,
126
133
  inTable: a
127
134
  });
128
- return t.preventDefault(), o === "table" && (i || Ge(t.clientX, t.clientY, t.target)) ? (U({
129
- pageId: x.page.id,
135
+ return t.preventDefault(), o === "table" && (i || Qe(t.clientX, t.clientY, t.target)) ? (it({
136
+ pageId: C.page.id,
130
137
  clientX: t.clientX,
131
138
  clientY: t.clientY
132
- }), !0) : (z({
133
- pageId: x.page.id,
139
+ }), !0) : (B({
140
+ pageId: C.page.id,
134
141
  clientX: t.clientX,
135
142
  clientY: t.clientY
136
143
  }), !0);
137
144
  },
138
- dragstart: (e, t) => C.value ? (t.preventDefault(), !0) : (t.target instanceof HTMLElement ? t.target : null)?.closest("[data-template-variable]") ? (t.dataTransfer?.setData(b, x.page.id), t.dataTransfer && (t.dataTransfer.effectAllowed = "move"), w.value?.classList.add("is-variable-dragging"), !1) : !1,
139
- dragend: () => (w.value?.classList.remove("is-variable-dragging"), !1),
145
+ dragstart: (e, t) => T.value ? (t.preventDefault(), !0) : (t.target instanceof HTMLElement ? t.target : null)?.closest("[data-template-variable]") ? (t.dataTransfer?.setData(S, C.page.id), t.dataTransfer && (t.dataTransfer.effectAllowed = "move"), E.value?.classList.add("is-variable-dragging"), !1) : !1,
146
+ dragend: () => (E.value?.classList.remove("is-variable-dragging"), !1),
140
147
  drop: (e, t) => {
141
- if (C.value) return t.preventDefault(), t.stopPropagation(), !0;
142
- let n = t.dataTransfer?.getData(b);
143
- return !n || n === x.page.id ? !1 : (t.preventDefault(), S("variable-move-blocked", x.page.id), !0);
148
+ if (T.value) return t.preventDefault(), t.stopPropagation(), !0;
149
+ let n = t.dataTransfer?.getData(S);
150
+ return !n || n === C.page.id ? !1 : (t.preventDefault(), w("variable-move-blocked", C.page.id), !0);
144
151
  }
145
152
  },
146
153
  handleKeyDown: (e, t) => {
147
- if (C.value || !He(t)) return !1;
148
- let n = N.value;
154
+ if (T.value || !Je(t)) return !1;
155
+ let n = R.value;
149
156
  if (!n) return !1;
150
157
  t.preventDefault();
151
- let r = n.state.selection, i = H();
158
+ let r = n.state.selection, i = U();
152
159
  if (i) {
153
160
  let e = n.view.coordsAtPos(r.from);
154
- return B({
155
- pageId: x.page.id,
161
+ return V({
162
+ pageId: C.page.id,
156
163
  clientX: e.left,
157
164
  clientY: e.bottom
158
165
  }, i), !0;
159
166
  }
160
- let a = r instanceof v;
161
- if (oe({
167
+ let a = r instanceof b;
168
+ if (f({
162
169
  isCellSelection: a,
163
170
  selectionEmpty: r.empty,
164
171
  inTable: n.isActive("table")
165
172
  }) === "table") {
166
173
  if (!a) {
167
- let e = We();
168
- typeof e == "number" && n.view.dispatch(n.state.tr.setSelection(v.create(n.state.doc, e)));
174
+ let e = Ze();
175
+ typeof e == "number" && n.view.dispatch(n.state.tr.setSelection(b.create(n.state.doc, e)));
169
176
  }
170
177
  let e = n.view.coordsAtPos(n.state.selection.from);
171
- return U({
172
- pageId: x.page.id,
178
+ return it({
179
+ pageId: C.page.id,
173
180
  clientX: e.left,
174
181
  clientY: e.bottom
175
182
  }), !0;
176
183
  }
177
184
  let o = n.view.coordsAtPos(n.state.selection.from);
178
- return z({
179
- pageId: x.page.id,
185
+ return B({
186
+ pageId: C.page.id,
180
187
  clientX: o.left,
181
188
  clientY: o.bottom
182
189
  }), !0;
183
- }
190
+ },
191
+ handleScrollToSelection: (e) => le(e, () => C.getScrollContainer?.(), () => E.value)
192
+ },
193
+ onTransaction: ({ transaction: e, appendedTransactions: t }) => {
194
+ [e, ...t].some((e) => e.docChanged && !e.getMeta("preventUpdate")) && (Ne = !0), !M && [e, ...t].some((e) => e.selectionSet || e.storedMarksSet) && (N = !0), [e, ...t].some((e) => e.docChanged || e.selectionSet || e.storedMarksSet || e.getMeta("blur")) && (P += 1);
184
195
  },
185
196
  onUpdate: ({ editor: e }) => {
186
- S("page-update", {
187
- ...x.page,
188
- contentHtml: T.read(e).getHTML(),
189
- contentJson: T.read(e).getJSON()
190
- }), K();
197
+ w("page-update", {
198
+ ...C.page,
199
+ contentHtml: D.read(e).getHTML(),
200
+ contentJson: D.read(e).getJSON()
201
+ }), W();
191
202
  },
192
203
  onFocus: () => {
193
- S("editor-focus", x.page.id), K();
204
+ w("editor-focus", C.page.id), W();
205
+ },
206
+ onBlur: W,
207
+ onSelectionUpdate: W,
208
+ onMount: () => {
209
+ F = P;
194
210
  },
195
- onBlur: K,
196
- onSelectionUpdate: K,
197
211
  onCreate: ({ editor: e }) => {
198
- x.page.contentHtml !== je && x.page.contentHtml !== T.read(e).getHTML() && (E || e.view.composing ? O = x.page.contentHtml : e.commands.setContent(x.page.contentHtml || "<p></p>", { emitUpdate: !1 })), Ae = !0, e.on("contract-word-paste", P), K(), S("editor-ready", x.page.id);
212
+ if (C.page.contentHtml !== Pe && C.page.contentHtml !== D.read(e).getHTML()) if (O || e.view.composing) A = C.page.contentHtml;
213
+ else {
214
+ let t = F === P ? P + 1 : void 0;
215
+ e.commands.setContent(C.page.contentHtml || "<p></p>", { emitUpdate: !1 }), F = t;
216
+ }
217
+ M = !0, e.on("contract-word-paste", He), W(), w("editor-ready", C.page.id);
199
218
  }
200
- }), { findText: Ne, revealSearchMatch: Pe, replaceSearchMatches: Fe, focusHeading: Ie } = ne({
201
- editor: () => N.value,
202
- readonly: () => C.value,
219
+ }), { findText: Re, revealSearchMatch: ze, replaceSearchMatches: Be, focusHeading: Ve } = re({
220
+ editor: () => R.value,
221
+ readonly: () => T.value,
203
222
  search: () => ({
204
- query: x.searchQuery,
205
- matchCase: x.searchMatchCase,
206
- activeMatch: x.activeSearchMatch
223
+ query: C.searchQuery,
224
+ matchCase: C.searchMatchCase,
225
+ activeMatch: C.activeSearchMatch
207
226
  })
208
227
  });
209
- function P(e) {
210
- S("word-paste", e);
228
+ function He(e) {
229
+ w("word-paste", e);
211
230
  }
212
- function Le(e) {
231
+ function Ue(e) {
213
232
  if (typeof e == "number" && Number.isFinite(e)) return e;
214
233
  let t = String(e || "").match(/(\d+(\.\d+)?)/);
215
234
  return t ? Number(t[1]) : void 0;
216
235
  }
217
- function Re() {
218
- if (!N.value) return "";
219
- let { from: e, to: t } = N.value.state.selection;
220
- return N.value.state.doc.textBetween(e, t, "\n");
236
+ function We() {
237
+ if (!R.value) return "";
238
+ let { from: e, to: t } = R.value.state.selection;
239
+ return R.value.state.doc.textBetween(e, t, "\n");
221
240
  }
222
- function ze() {
223
- let e = N.value, t = e?.state.selection;
241
+ function Ge() {
242
+ let e = R.value, t = e?.state.selection;
224
243
  if (!(!e || !t || t.empty)) try {
225
244
  let n = e.view.coordsAtPos(t.from), r = e.view.coordsAtPos(t.to, -1);
226
- if (Math.abs(r.top - n.top) > De) return;
227
- let i = Math.abs(r.left - n.left) / q.value;
245
+ if (Math.abs(r.top - n.top) > Ae) return;
246
+ let i = Math.abs(r.left - n.left) / G.value;
228
247
  return Number.isFinite(i) && i > 0 ? i : void 0;
229
248
  } catch {
230
249
  return;
231
250
  }
232
251
  }
233
- function Be() {
234
- let e = N.value, t = e?.state.selection;
235
- if (!(!e || !t || t.empty) && !(t instanceof v || t instanceof y)) try {
252
+ function Ke() {
253
+ let e = R.value, t = e?.state.selection;
254
+ if (!(!e || !t || t.empty) && !(t instanceof b || t instanceof x)) try {
236
255
  let n = e.view.coordsAtPos(t.from), r = e.view.coordsAtPos(t.to, -1);
237
256
  return {
238
257
  top: Math.min(n.top, r.top),
@@ -244,8 +263,8 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
244
263
  return;
245
264
  }
246
265
  }
247
- function Ve() {
248
- let e = N.value;
266
+ function qe() {
267
+ let e = R.value;
249
268
  if (!e) return "";
250
269
  let t = e.state.selection.$from, n = t.pos;
251
270
  for (let e = t.depth; e > 0; --e) {
@@ -257,35 +276,35 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
257
276
  }
258
277
  return e.state.doc.textBetween(n, e.state.selection.from, "");
259
278
  }
260
- function He(e) {
279
+ function Je(e) {
261
280
  return e.key === "ContextMenu" || e.shiftKey && e.key === "F10";
262
281
  }
263
- function F(e) {
282
+ function Ye(e) {
264
283
  for (let t = e.depth; t > 0; --t) {
265
284
  let n = e.node(t).type.spec.tableRole;
266
285
  if (n === "cell" || n === "header_cell") return e.before(t);
267
286
  }
268
287
  }
269
- function Ue(e, t) {
270
- let n = N.value, r = n?.view.posAtCoords({
288
+ function Xe(e, t) {
289
+ let n = R.value, r = n?.view.posAtCoords({
271
290
  left: e,
272
291
  top: t
273
292
  })?.pos;
274
- if (!(!n || typeof r != "number")) return F(n.state.doc.resolve(r));
293
+ if (!(!n || typeof r != "number")) return Ye(n.state.doc.resolve(r));
275
294
  }
276
- function We() {
277
- let e = N.value;
278
- if (e) return F(e.state.selection.$from);
295
+ function Ze() {
296
+ let e = R.value;
297
+ if (e) return Ye(e.state.selection.$from);
279
298
  }
280
- function Ge(e, t, n) {
281
- let r = N.value, i = n instanceof HTMLElement ? n : null;
299
+ function Qe(e, t, n) {
300
+ let r = R.value, i = n instanceof HTMLElement ? n : null;
282
301
  if (!r || !i?.closest("td,th")) return !1;
283
- if (r.state.selection instanceof v && i.closest("td.selectedCell,th.selectedCell")) return !0;
284
- let a = Ue(e, t);
285
- return typeof a == "number" ? (r.view.dispatch(r.state.tr.setSelection(v.create(r.state.doc, a))), !0) : !1;
302
+ if (r.state.selection instanceof b && i.closest("td.selectedCell,th.selectedCell")) return !0;
303
+ let a = Xe(e, t);
304
+ return typeof a == "number" ? (r.view.dispatch(r.state.tr.setSelection(b.create(r.state.doc, a))), !0) : !1;
286
305
  }
287
- function I() {
288
- let e = N.value, t = e?.isActive("table") ? e.can() : void 0, n = (e) => !!(t && e(t));
306
+ function $e() {
307
+ let e = R.value, t = e?.isActive("table") ? e.can() : void 0, n = (e) => !!(t && e(t));
289
308
  return {
290
309
  addRowBefore: n((e) => e.addRowBefore()),
291
310
  addRowAfter: n((e) => e.addRowAfter()),
@@ -303,97 +322,97 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
303
322
  deleteTable: n((e) => e.deleteTable())
304
323
  };
305
324
  }
306
- function Ke() {
307
- let e = N.value, t = e?.state.selection;
308
- if (!e || !(t instanceof v)) return "left";
325
+ function et() {
326
+ let e = R.value, t = e?.state.selection;
327
+ if (!e || !(t instanceof b)) return "left";
309
328
  let n = /* @__PURE__ */ new Set();
310
329
  return t.forEachCell((e) => {
311
330
  let t = e.attrs.textAlign;
312
331
  n.add(t === "center" || t === "right" ? t : "left");
313
332
  }), n.size === 1 ? n.values().next().value ?? "left" : "mixed";
314
333
  }
315
- function L(e = N.value?.state.doc) {
334
+ function tt(e = R.value?.state.doc) {
316
335
  let t = 0;
317
336
  return e?.descendants((e) => {
318
337
  e.type.name === "templateVariable" && (t += 1);
319
338
  }), t;
320
339
  }
321
- function R(e) {
322
- let t = N.value;
340
+ function z(e) {
341
+ let t = R.value;
323
342
  if (!t) return 0;
324
- let n = L(t.state.doc), r = n, i = (e) => {
325
- r = L(e.doc);
343
+ let n = tt(t.state.doc), r = n, i = (e) => {
344
+ r = tt(e.doc);
326
345
  };
327
- return e === "delete-table-row" ? we(t.state, i) : e === "delete-table-column" ? Ce(t.state, i) : Te(t.state, i), Math.max(0, n - r);
346
+ return e === "delete-table-row" ? Ee(t.state, i) : e === "delete-table-column" ? Te(t.state, i) : De(t.state, i), Math.max(0, n - r);
328
347
  }
329
- function z(e) {
330
- let t = N.value?.state.selection, n = !!(t && !t.empty);
331
- S("editor-context-menu", {
348
+ function B(e) {
349
+ let t = R.value?.state.selection, n = !!(t && !t.empty);
350
+ w("editor-context-menu", {
332
351
  type: "text",
333
352
  ...e,
334
353
  hasSelection: n,
335
- selectionWidth: n ? ze() : void 0,
336
- leadingText: Ve()
354
+ selectionWidth: n ? Ge() : void 0,
355
+ leadingText: qe()
337
356
  });
338
357
  }
339
- function qe(e, t) {
340
- z({
341
- pageId: x.page.id,
358
+ function nt(e, t) {
359
+ B({
360
+ pageId: C.page.id,
342
361
  clientX: e,
343
362
  clientY: t
344
363
  });
345
364
  }
346
- function B(e, t) {
347
- S("editor-context-menu", {
365
+ function V(e, t) {
366
+ w("editor-context-menu", {
348
367
  type: "image",
349
368
  ...e,
350
369
  image: t
351
370
  });
352
371
  }
353
- function V(e, t) {
372
+ function H(e, t) {
354
373
  if (!(e.type.name !== "image" || typeof e.attrs.src != "string" || !e.attrs.src)) return {
355
374
  position: t,
356
375
  src: e.attrs.src,
357
376
  alt: typeof e.attrs.alt == "string" ? e.attrs.alt : void 0,
358
377
  title: typeof e.attrs.title == "string" ? e.attrs.title : void 0,
359
- width: l(e.attrs.width),
360
- height: l(e.attrs.height)
378
+ width: u(e.attrs.width),
379
+ height: u(e.attrs.height)
361
380
  };
362
381
  }
363
- function H() {
364
- let e = N.value?.state.selection;
365
- if (e instanceof y) return V(e.node, e.from);
382
+ function U() {
383
+ let e = R.value?.state.selection;
384
+ if (e instanceof x) return H(e.node, e.from);
366
385
  }
367
- function Je(e, t) {
386
+ function rt(e, t) {
368
387
  let n = t instanceof HTMLElement ? t.closest("[data-template-variable], img[src]") : null;
369
388
  if (n) try {
370
389
  let t = e.posAtDOM(n, 0), r = e.state.doc.nodeAt(t);
371
- return !r || r.type.name !== "templateVariable" && r.type.name !== "image" ? void 0 : (r.type.name === "templateVariable" && typeof r.attrs.key == "string" && S("variable-select", r.attrs.key), (!(e.state.selection instanceof y) || e.state.selection.from !== t) && e.dispatch(e.state.tr.setSelection(y.create(e.state.doc, t))), V(r, t));
390
+ return !r || r.type.name !== "templateVariable" && r.type.name !== "image" ? void 0 : (r.type.name === "templateVariable" && typeof r.attrs.key == "string" && w("variable-select", r.attrs.key), (!(e.state.selection instanceof x) || e.state.selection.from !== t) && e.dispatch(e.state.tr.setSelection(x.create(e.state.doc, t))), H(r, t));
372
391
  } catch {
373
392
  return;
374
393
  }
375
394
  }
376
- function U(e) {
377
- S("editor-context-menu", {
395
+ function it(e) {
396
+ w("editor-context-menu", {
378
397
  type: "table",
379
398
  ...e,
380
- capabilities: I(),
381
- activeAlignment: Ke(),
399
+ capabilities: $e(),
400
+ activeAlignment: et(),
382
401
  affectedVariableCounts: {
383
- deleteRow: R("delete-table-row"),
384
- deleteColumn: R("delete-table-column"),
385
- deleteTable: R("delete-table")
402
+ deleteRow: z("delete-table-row"),
403
+ deleteColumn: z("delete-table-column"),
404
+ deleteTable: z("delete-table")
386
405
  }
387
406
  });
388
407
  }
389
- function Ye(e) {
408
+ function at(e) {
390
409
  return typeof e == "number" && Number.isInteger(e) && e >= 1 && e <= 6;
391
410
  }
392
- function W() {
393
- let e = N.value;
411
+ function ot() {
412
+ let e = R.value;
394
413
  if (!e) return [];
395
414
  let { doc: t, selection: n } = e.state, r = [], i = (e) => {
396
- e.type.name === "paragraph" ? r.push("paragraph") : e.type.name === "heading" && Ye(e.attrs.level) && r.push(e.attrs.level);
415
+ e.type.name === "paragraph" ? r.push("paragraph") : e.type.name === "heading" && at(e.attrs.level) && r.push(e.attrs.level);
397
416
  };
398
417
  if (n.empty) for (let e = n.$from.depth; e > 0; e--) {
399
418
  let t = n.$from.node(e);
@@ -405,18 +424,18 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
405
424
  else t.nodesBetween(n.from, n.to, (e) => (i(e), !0));
406
425
  return Array.from(new Set(r));
407
426
  }
408
- function Xe() {
409
- let e = W();
427
+ function st() {
428
+ let e = ot();
410
429
  return e.length === 1 && e[0] !== "paragraph" ? e[0] : void 0;
411
430
  }
412
- function Ze() {
413
- return W().length > 1;
431
+ function ct() {
432
+ return ot().length > 1;
414
433
  }
415
- function Qe() {
416
- return ["center", "right"].find((e) => N.value?.isActive("heading", { textAlign: e }) || N.value?.isActive("paragraph", { textAlign: e })) ?? "left";
434
+ function lt() {
435
+ return ["center", "right"].find((e) => R.value?.isActive("heading", { textAlign: e }) || R.value?.isActive("paragraph", { textAlign: e })) ?? "left";
417
436
  }
418
- function G() {
419
- let e = N.value, t = (t) => !!e?.isActive(t), n = e?.getAttributes("textStyle") ?? {};
437
+ function ut() {
438
+ let e = R.value, t = (t) => !!e?.isActive(t), n = e?.getAttributes("textStyle") ?? {};
420
439
  return {
421
440
  isFocused: !!e?.isFocused,
422
441
  canUndo: !!e?.can().undo(),
@@ -427,107 +446,107 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
427
446
  isBulletList: t("bulletList"),
428
447
  isOrderedList: t("orderedList"),
429
448
  isTableActive: t("table"),
430
- currentHeadingLevel: Xe(),
431
- hasMixedBlockFormats: Ze(),
432
- textAlign: Qe(),
449
+ currentHeadingLevel: st(),
450
+ hasMixedBlockFormats: ct(),
451
+ textAlign: lt(),
433
452
  fontFamily: typeof n.fontFamily == "string" ? n.fontFamily : void 0,
434
- fontSize: Le(n.fontSize),
453
+ fontSize: Ue(n.fontSize),
435
454
  textColor: typeof n.color == "string" ? n.color : void 0,
436
- selectionText: Re(),
437
- selectedContentImage: H()
455
+ selectionText: We(),
456
+ selectedContentImage: U()
438
457
  };
439
458
  }
440
- function K() {
441
- S("editor-state-change", x.page.id, G());
459
+ function W() {
460
+ w("editor-state-change", C.page.id, ut());
442
461
  }
443
- _(C, (e) => {
444
- N.value?.setEditable(!e), K();
445
- }), _(() => x.page.contentHtml, (e) => {
446
- $e(e);
462
+ y(T, (e) => {
463
+ R.value?.setEditable(!e), W();
464
+ }), y(() => C.page.contentHtml, (e) => {
465
+ dt(e);
447
466
  });
448
- function $e(e) {
449
- if (!N.value || e === $()) {
450
- O = void 0;
467
+ function dt(e) {
468
+ if (!R.value || e === $()) {
469
+ A = void 0;
451
470
  return;
452
471
  }
453
- if (j()) {
454
- O = e;
472
+ if (L()) {
473
+ A = e;
455
474
  return;
456
475
  }
457
- N.value.commands.setContent(e || "<p></p>", { emitUpdate: !1 }), K();
476
+ R.value.commands.setContent(e || "<p></p>", { emitUpdate: !1 }), W();
458
477
  }
459
- let et = d(() => {
460
- let e = o(x.pageDecorations), t = x.pageIndex + 1, s = a(e, t) ? r(e.header) : n.top, c = i(e, t) ? r(e.footer) : n.bottom;
478
+ let ft = p(() => {
479
+ let e = o(C.pageDecorations), t = C.pageIndex + 1, s = a(e, t) ? r(e.header) : n.top, c = i(e, t) ? r(e.footer) : n.bottom;
461
480
  return {
462
- width: `${x.pageSize.width}px`,
463
- height: `${x.pageSize.height}px`,
481
+ width: `${C.pageSize.width}px`,
482
+ height: `${C.pageSize.height}px`,
464
483
  paddingTop: `${s}px`,
465
484
  paddingBottom: `${c}px`,
466
- "--gd-contract-page-content-height": `${Math.max(120, x.pageSize.height - s - c)}px`
485
+ "--gd-contract-page-content-height": `${Math.max(120, C.pageSize.height - s - c)}px`
467
486
  };
468
- }), q = d(() => Math.max(.1, x.zoom || 1)), tt = d(() => ({
469
- width: `${Math.ceil((x.pageSize.width + 10) * q.value)}px`,
470
- height: `${Math.ceil((x.pageSize.height + 40) * q.value)}px`
471
- })), nt = d(() => ({ "--gd-contract-page-zoom": String(q.value) })), rt = d(() => c(x.pageSize));
472
- function it(e) {
473
- if (x.readonly || x.disabled) {
487
+ }), G = p(() => Math.max(.1, C.zoom || 1)), pt = p(() => ({
488
+ width: `${Math.ceil((C.pageSize.width + 10) * G.value)}px`,
489
+ height: `${Math.ceil((C.pageSize.height + 40) * G.value)}px`
490
+ })), mt = p(() => ({ "--gd-contract-page-zoom": String(G.value) })), ht = p(() => c(C.pageSize));
491
+ function gt(e) {
492
+ if (C.readonly || C.disabled) {
474
493
  e.preventDefault(), e.stopPropagation();
475
494
  return;
476
495
  }
477
496
  let t = e.dataTransfer?.getData("application/x-gd-contract-variable");
478
497
  if (t) {
479
- e.preventDefault(), e.stopPropagation(), S("variable-drop", x.page.id, t, e.clientX, e.clientY);
498
+ e.preventDefault(), e.stopPropagation(), w("variable-drop", C.page.id, t, e.clientX, e.clientY);
480
499
  return;
481
500
  }
482
- let n = e.dataTransfer?.getData(b);
483
- n && n !== x.page.id && (e.preventDefault(), e.stopPropagation(), S("variable-move-blocked", x.page.id));
501
+ let n = e.dataTransfer?.getData(S);
502
+ n && n !== C.page.id && (e.preventDefault(), e.stopPropagation(), w("variable-move-blocked", C.page.id));
484
503
  }
485
- function at(e, t) {
486
- let n = N.value;
487
- return n ? (ie(n, e, t ? n.view.posAtCoords(t)?.pos : void 0), Z(), J()) : void 0;
504
+ function _t(e, t) {
505
+ let n = R.value;
506
+ return n ? (ae(n, e, t ? n.view.posAtCoords(t)?.pos : void 0), Z(), K()) : void 0;
488
507
  }
489
- function ot(e, t) {
490
- let n = N.value;
491
- if (n) return u(n, {
508
+ function vt(e, t) {
509
+ let n = R.value;
510
+ if (n) return d(n, {
492
511
  type: "insert-content-image",
493
512
  image: e,
494
513
  position: t
495
- }), J();
514
+ }), K();
496
515
  }
497
- function st(e) {
498
- let t = N.value, n = t?.state.selection;
499
- if (!t || !(n instanceof y) || n.node.type.name !== "image") return;
516
+ function yt(e) {
517
+ let t = R.value, n = t?.state.selection;
518
+ if (!t || !(n instanceof x) || n.node.type.name !== "image") return;
500
519
  let r = { ...n.node.attrs }, i = !1;
501
520
  if (["width", "height"].forEach((t) => {
502
521
  if (!Object.prototype.hasOwnProperty.call(e, t)) return;
503
- let n = e[t] === void 0 ? null : l(e[t]) ?? null;
522
+ let n = e[t] === void 0 ? null : u(e[t]) ?? null;
504
523
  r[t] !== n && (r[t] = n, i = !0);
505
524
  }), !i) return;
506
525
  let a = t.state.tr.setNodeMarkup(n.from, void 0, r);
507
- return a.setSelection(y.create(a.doc, n.from)), t.view.dispatch(a), J();
526
+ return a.setSelection(x.create(a.doc, n.from)), t.view.dispatch(a), K();
508
527
  }
509
- function ct() {
510
- let e = N.value?.state.selection;
528
+ function bt() {
529
+ let e = R.value?.state.selection;
511
530
  return e ? {
512
531
  from: e.from,
513
532
  to: e.to
514
533
  } : void 0;
515
534
  }
516
- function J() {
535
+ function K() {
517
536
  return {
518
- ...x.page,
519
- pageSize: rt.value,
537
+ ...C.page,
538
+ pageSize: ht.value,
520
539
  contentHtml: $(),
521
- contentJson: Q() ?? x.page.contentJson
540
+ contentJson: Q() ?? C.page.contentJson
522
541
  };
523
542
  }
524
- function lt(e) {
525
- if (!A()) return {
543
+ function xt(e) {
544
+ if (!I()) return {
526
545
  contentHtml: e.contentHtml,
527
546
  contentJson: e.contentJson
528
547
  };
529
548
  let t = $();
530
- return !j() && e.contentHtml !== x.page.contentHtml && e.contentHtml !== t ? {
549
+ return !L() && e.contentHtml !== C.page.contentHtml && e.contentHtml !== t ? {
531
550
  contentHtml: e.contentHtml,
532
551
  contentJson: e.contentJson
533
552
  } : {
@@ -535,32 +554,32 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
535
554
  contentJson: Q()
536
555
  };
537
556
  }
538
- function Y(e) {
557
+ function q(e) {
539
558
  return {
540
559
  type: "doc",
541
560
  content: e.length ? e : [{ type: "paragraph" }]
542
561
  };
543
562
  }
544
- function ut(e) {
563
+ function St(e) {
545
564
  return e?.length ? e.length === 1 && e[0].type === "paragraph" && !e[0].content?.length : !0;
546
565
  }
547
- function dt(e) {
548
- return Se(Y(e), M);
566
+ function Ct(e) {
567
+ return we(q(e), Le);
549
568
  }
550
- function ft() {
551
- if (x.pageDecorations) {
552
- let e = o(x.pageDecorations), t = x.pageIndex + 1, s = a(e, t) ? r(e.header) : n.top, c = i(e, t) ? r(e.footer) : n.bottom;
553
- return Math.max(120, x.pageSize.height - s - c);
569
+ function wt() {
570
+ if (C.pageDecorations) {
571
+ let e = o(C.pageDecorations), t = C.pageIndex + 1, s = a(e, t) ? r(e.header) : n.top, c = i(e, t) ? r(e.footer) : n.bottom;
572
+ return Math.max(120, C.pageSize.height - s - c);
554
573
  }
555
- let e = w.value;
556
- if (!e) return x.pageSize.height - 108;
574
+ let e = E.value;
575
+ if (!e) return C.pageSize.height - 108;
557
576
  let t = window.getComputedStyle(e), s = Number.parseFloat(t.paddingTop) || 0, c = Number.parseFloat(t.paddingBottom) || 0;
558
- return Math.max(120, x.pageSize.height - s - c);
577
+ return Math.max(120, C.pageSize.height - s - c);
559
578
  }
560
- function pt() {
561
- let e = w.value?.querySelector(".gd-contract-template-designer__editor-prose");
579
+ function Tt() {
580
+ let e = E.value?.querySelector(".gd-contract-template-designer__editor-prose");
562
581
  if (!e) return [];
563
- let t = e.getBoundingClientRect(), n = q.value;
582
+ let t = e.getBoundingClientRect(), n = G.value;
564
583
  return Array.from(e.children).map((r) => {
565
584
  let i = r.getBoundingClientRect(), a = r instanceof HTMLTableElement ? r : r.querySelector(":scope > table"), o = a ? Array.from(a.rows).map((e) => {
566
585
  let r = e.getBoundingClientRect();
@@ -579,29 +598,77 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
579
598
  };
580
599
  });
581
600
  }
582
- function mt() {
583
- if (!N.value) return;
584
- let e = pt(), t = ft();
585
- if (e.some((e) => e.top + e.height > t + 1)) return ee(Q()?.content, e, t);
601
+ function J() {
602
+ if (!R.value) return;
603
+ let e = Tt(), t = wt();
604
+ if (e.some((e) => e.top + e.height > t + 1)) return l(Q()?.content, e, t);
586
605
  }
587
- function ht() {
588
- return !!mt();
606
+ function Et() {
607
+ return !!J();
589
608
  }
590
- function gt() {
591
- if (!N.value || !A() || j()) return;
592
- let e = mt();
593
- if (e) return N.value.commands.setContent(Y(e.currentContent), { emitUpdate: !1 }), {
594
- page: J(),
609
+ function Dt() {
610
+ let e = R.value;
611
+ if (!e || !I() || L() || !e.view.hasFocus()) return !1;
612
+ let t = J();
613
+ if (!t) return !1;
614
+ let n = 0;
615
+ for (let r = 0; r < t.splitIndex; r++) n += e.state.doc.child(r).nodeSize;
616
+ if (t.currentContent.length > t.splitIndex) {
617
+ let r = e.state.doc.child(t.splitIndex), i = t.currentContent[t.splitIndex].content.length;
618
+ for (let e = 0; e < i; e++) n += r.child(e).nodeSize;
619
+ n += 1;
620
+ }
621
+ return e.state.selection.ranges.every((e) => e.$from.pos >= n);
622
+ }
623
+ function Ot(e) {
624
+ return (!e || ye(e) === Fe) && !Ne && !L() && !R.value?.view.hasFocus() && St(Q()?.content);
625
+ }
626
+ function kt() {
627
+ if (!R.value || !I() || L()) return;
628
+ let e = J();
629
+ if (!e) return;
630
+ let t = R.value, { doc: n, selection: r, storedMarks: i } = t.state, a = t.state.tr, o = 0;
631
+ for (let t = 0; t < e.splitIndex; t++) o += n.child(t).nodeSize;
632
+ let s = o, c = o;
633
+ if (e.currentContent.length > e.splitIndex) {
634
+ let t = n.child(e.splitIndex), r = e.currentContent[e.splitIndex].content.length;
635
+ for (let e = 0; e < r; e++) s += t.child(e).nodeSize;
636
+ c = s + 1, a.delete(c, o + t.nodeSize - 1), a.delete(s + 2, a.doc.content.size);
637
+ } else a.delete(o, n.content.size);
638
+ let l = t.view.hasFocus() && r.ranges.every((e) => e.$from.pos >= c) ? r.map(t.schema.nodeFromJSON(q(e.overflowContent)), new te([new ne([
639
+ 0,
640
+ s,
641
+ 0
642
+ ])])) : void 0;
643
+ a.setMeta("preventUpdate", !0).setMeta("addToHistory", !1).setStoredMarks(i);
644
+ let ee = P + 1;
645
+ t.view.dispatch(a);
646
+ let re = l && {
647
+ selection: l,
648
+ storedMarks: i,
649
+ isCurrent: () => !j && R.value === t && !t.isDestroyed && !T.value && !L() && t.view.hasFocus() && P === ee
650
+ };
651
+ return {
652
+ page: K(),
595
653
  overflowContent: e.overflowContent,
596
- overflowHtml: dt(e.overflowContent)
654
+ overflowHtml: Ct(e.overflowContent),
655
+ selection: re
597
656
  };
598
657
  }
599
- function _t(e) {
600
- if (!N.value || !A() || j() || !e.length) return;
601
- let t = Q()?.content, n = [...e, ...ut(t) ? [] : t ?? []];
602
- return N.value.commands.setContent(Y(n), { emitUpdate: !1 }), J();
658
+ function At(e) {
659
+ if (!R.value || !I() || L() || !e.length) return;
660
+ let t = R.value, n = t.schema.nodeFromJSON(q(e)).content, { doc: r, storedMarks: i } = t.state, a = t.state.tr;
661
+ St(Q()?.content) ? a.replaceWith(0, r.content.size, n) : a.insert(0, n), a.setMeta("preventUpdate", !0).setMeta("addToHistory", !1).setStoredMarks(i);
662
+ let o = P + 1;
663
+ return t.view.dispatch(a), F = N ? void 0 : o, N = !1, K();
603
664
  }
604
- function vt(e, t) {
665
+ function jt(e, t) {
666
+ let n = R.value, r = F;
667
+ if (F = void 0, !n || !I() || T.value || L() || r !== P || !e.isCurrent() || $() !== t) return;
668
+ let i = Oe.fromJSON(n.state.doc, e.selection.toJSON()), a = P + 1;
669
+ n.view.dispatch(n.state.tr.setSelection(i).setStoredMarks(e.storedMarks?.map((e) => n.schema.markFromJSON(e.toJSON())) ?? null).setMeta("addToHistory", !1)), !(!e.isCurrent() || P !== a) && (n.view.focus(), n.view.hasFocus() && P === a && n.commands.scrollIntoView());
670
+ }
671
+ function Y(e, t) {
605
672
  let n = [];
606
673
  return e.descendants((e, r) => {
607
674
  e.type.name === "templateVariable" && e.attrs.key === t && n.push({
@@ -610,145 +677,148 @@ var Ee = { class: "gd-contract-template-designer__page-title" }, b = "applicatio
610
677
  });
611
678
  }), n;
612
679
  }
613
- function yt(e, t = e.key) {
614
- if (!N.value) return;
615
- let n = re(e), r = !1;
616
- return N.value.commands.command(({ tr: e, state: i, dispatch: a }) => (vt(i.doc, t).forEach(({ node: t, pos: i }) => {
680
+ function Mt(e, t = e.key) {
681
+ if (!R.value) return;
682
+ let n = ie(e), r = !1;
683
+ return R.value.commands.command(({ tr: e, state: i, dispatch: a }) => (Y(i.doc, t).forEach(({ node: t, pos: i }) => {
617
684
  e.setNodeMarkup(i, void 0, {
618
685
  ...t.attrs,
619
686
  ...n
620
687
  }), r = !0;
621
- }), r && a?.(e), r)), Z(), r ? J() : void 0;
688
+ }), r && a?.(e), r)), Z(), r ? K() : void 0;
622
689
  }
623
- function bt(e) {
624
- if (!N.value) return;
690
+ function Nt(e) {
691
+ if (!R.value) return;
625
692
  let t = 0;
626
- return N.value.commands.command(({ tr: n, state: r, dispatch: i }) => {
627
- let a = vt(r.doc, e).map(({ node: e, pos: t }) => ({
693
+ return R.value.commands.command(({ tr: n, state: r, dispatch: i }) => {
694
+ let a = Y(r.doc, e).map(({ node: e, pos: t }) => ({
628
695
  from: t,
629
696
  to: t + e.nodeSize
630
697
  })).sort((e, t) => t.from - e.from);
631
698
  return a.forEach((e) => n.delete(e.from, e.to)), t = a.length, t && i?.(n), t > 0;
632
- }), t ? J() : void 0;
699
+ }), t ? K() : void 0;
633
700
  }
634
- function xt() {
635
- w.value?.querySelectorAll(".gd-contract-template-variable.is-active").forEach((e) => e.classList.remove("is-active"));
701
+ function Pt() {
702
+ E.value?.querySelectorAll(".gd-contract-template-variable.is-active").forEach((e) => e.classList.remove("is-active"));
636
703
  }
637
704
  function X(e) {
638
- if (e) return Array.from(w.value?.querySelectorAll("[data-template-variable]") ?? []).find((t) => t.dataset.key === e);
705
+ if (e) return Array.from(E.value?.querySelectorAll("[data-template-variable]") ?? []).find((t) => t.dataset.key === e);
639
706
  }
640
- function St(e) {
641
- xt();
707
+ function Ft(e) {
708
+ Pt();
642
709
  let t = X(e);
643
710
  return t ? (t.classList.add("is-active"), t.scrollIntoView({
644
711
  behavior: "smooth",
645
712
  block: "center",
646
713
  inline: "center"
647
- }), N.value?.commands.focus(), !0) : !1;
714
+ }), R.value?.commands.focus(), !0) : !1;
648
715
  }
649
716
  function Z() {
650
- xt(), X(x.selectedVariableKey)?.classList.add("is-active");
717
+ Pt(), X(C.selectedVariableKey)?.classList.add("is-active");
651
718
  }
652
- function Ct(n) {
653
- let r = e.find((e) => e.key === n), i = N.value;
719
+ function It(n) {
720
+ let r = e.find((e) => e.key === n), i = R.value;
654
721
  if (!r || !i) return;
655
722
  let a = i.chain().focus().clearNodes();
656
723
  r.headingLevel ? a.setHeading({ level: r.headingLevel }) : a.setParagraph(), a.unsetAllMarks().unsetTextAlign().unsetFontSize().unsetFontFamily().unsetColor().setTextAlign(r.textAlign).setFontSize(`${r.fontSize}px`).setFontFamily(r.fontFamily || t).setColor(s.color || "#1f2937"), r.bold ? a.setBold() : a.unsetBold(), r.italic ? a.setItalic() : a.unsetItalic(), r.underline ? a.setUnderline() : a.unsetUnderline(), a.run();
657
724
  }
658
- _([() => x.selectedVariableKey, () => x.variables], () => {
659
- pe(Z);
725
+ y([() => C.selectedVariableKey, () => C.variables], () => {
726
+ me(Z);
660
727
  }, {
661
728
  deep: !0,
662
729
  flush: "post"
663
730
  });
664
- function wt(e) {
665
- C.value || (e.type === "apply-block-style" ? N.value && se(N.value, e.format) : e.type === "apply-text-style-preset" ? Ct(e.preset) : u(N.value, e), K());
731
+ function Lt(e) {
732
+ T.value || (e.type === "apply-block-style" ? R.value && se(R.value, e.format) : e.type === "apply-text-style-preset" ? It(e.preset) : d(R.value, e), W());
666
733
  }
667
- function Tt() {
668
- N.value?.commands.focus();
734
+ function Rt() {
735
+ R.value?.commands.focus();
669
736
  }
670
737
  function Q() {
671
- return N.value ? T.read(N.value).getJSON() : x.page.contentJson;
738
+ return R.value ? D.read(R.value).getJSON() : C.page.contentJson;
672
739
  }
673
740
  function $() {
674
- return N.value ? T.read(N.value).getHTML() : x.page.contentHtml;
741
+ return R.value ? D.read(R.value).getHTML() : C.page.contentHtml;
675
742
  }
676
- function Et(e) {
677
- let t = x.variables.find((t) => t.id === e || t.key === e), n = t ? X(t.key) : void 0;
743
+ function zt(e) {
744
+ let t = C.variables.find((t) => t.id === e || t.key === e), n = t ? X(t.key) : void 0;
678
745
  Z(), n?.scrollIntoView({
679
746
  behavior: "smooth",
680
747
  block: "center"
681
748
  });
682
749
  }
683
- function Dt() {
684
- w.value?.scrollIntoView({
750
+ function Bt() {
751
+ E.value?.scrollIntoView({
685
752
  behavior: "smooth",
686
753
  block: "start",
687
754
  inline: "center"
688
755
  });
689
756
  }
690
- return he(() => {
691
- k = !0, D !== void 0 && clearTimeout(D), N.value?.off("contract-word-paste", P), N.value?.destroy();
692
- }), Oe({
693
- findText: Ne,
694
- revealSearchMatch: Pe,
695
- replaceSearchMatches: Fe,
696
- focusHeading: Ie,
697
- focus: Tt,
757
+ return ge(() => {
758
+ j = !0, k !== void 0 && clearTimeout(k), R.value?.off("contract-word-paste", He), R.value?.destroy();
759
+ }), je({
760
+ findText: Re,
761
+ revealSearchMatch: ze,
762
+ replaceSearchMatches: Be,
763
+ focusHeading: Ve,
764
+ focus: Rt,
698
765
  getHTML: $,
699
766
  getJSON: Q,
700
- getContentSnapshot: lt,
701
- getEditorState: G,
702
- getTableCommandCapabilities: I,
703
- getAffectedVariableCount: R,
704
- insertVariable: at,
705
- insertContentImage: ot,
706
- updateSelectedContentImage: st,
707
- getSelectionRange: ct,
708
- getSelectionViewportRect: Be,
709
- requestTextContextMenu: qe,
710
- isReady: A,
711
- isComposing: j,
712
- hasOverflowContent: ht,
713
- updateVariable: yt,
714
- removeVariable: bt,
715
- splitOverflowContent: gt,
716
- prependContent: _t,
717
- runCommand: wt,
718
- scrollIntoField: Et,
719
- scrollIntoVariable: St,
720
- scrollIntoPage: Dt
721
- }), (e, t) => (ge(), de("section", {
767
+ getContentSnapshot: xt,
768
+ getEditorState: ut,
769
+ getTableCommandCapabilities: $e,
770
+ getAffectedVariableCount: z,
771
+ insertVariable: _t,
772
+ insertContentImage: vt,
773
+ updateSelectedContentImage: yt,
774
+ getSelectionRange: bt,
775
+ getSelectionViewportRect: Ke,
776
+ requestTextContextMenu: nt,
777
+ isReady: I,
778
+ isComposing: L,
779
+ hasOverflowContent: Et,
780
+ hasOverflowSelection: Dt,
781
+ isUntouchedPaginationBlank: Ot,
782
+ updateVariable: Mt,
783
+ removeVariable: Nt,
784
+ splitOverflowContent: kt,
785
+ prependContent: At,
786
+ restorePaginationSelection: jt,
787
+ runCommand: Lt,
788
+ scrollIntoField: zt,
789
+ scrollIntoVariable: Ft,
790
+ scrollIntoPage: Bt
791
+ }), (e, t) => (_e(), fe("section", {
722
792
  class: "gd-contract-template-designer__page-shell",
723
- style: m(tt.value)
724
- }, [f("div", {
725
- class: me(["gd-contract-template-designer__page-zoom", { "is-active": p.active }]),
726
- style: m(nt.value)
727
- }, [f("header", Ee, [f("span", null, h(p.page.title || `第 ${p.pageIndex + 1} 页`), 1), f("span", null, "第 " + h(p.pageIndex + 1) + " 页 · " + h(p.pageSize.label || "A4") + " · " + h(p.pageSize.width) + " × " + h(p.pageSize.height), 1)]), f("div", {
793
+ style: g(pt.value)
794
+ }, [m("div", {
795
+ class: he(["gd-contract-template-designer__page-zoom", { "is-active": h.active }]),
796
+ style: g(mt.value)
797
+ }, [m("header", ke, [m("span", null, _(h.page.title || `第 ${h.pageIndex + 1} 页`), 1), m("span", null, "第 " + _(h.pageIndex + 1) + " 页 · " + _(h.pageSize.label || "A4") + " · " + _(h.pageSize.width) + " × " + _(h.pageSize.height), 1)]), m("div", {
728
798
  ref_key: "pageElement",
729
- ref: w,
799
+ ref: E,
730
800
  class: "gd-contract-template-designer__page",
731
- style: m(et.value),
732
- onLoadCapture: t[0] ||= (e) => S("page-layout-change", p.page.id),
733
- onDragover: t[1] ||= ve(() => {}, ["prevent"]),
734
- onDrop: it,
735
- onClick: t[2] ||= (e) => S("editor-focus", p.page.id)
736
- }, [fe(ce, {
737
- decorations: p.pageDecorations,
738
- "page-number": p.pageIndex + 1,
739
- "total-pages": p.totalPages,
740
- variables: p.variables
801
+ style: g(ft.value),
802
+ onLoadCapture: t[0] ||= (e) => w("page-layout-change", h.page.id),
803
+ onDragover: t[1] ||= be(() => {}, ["prevent"]),
804
+ onDrop: gt,
805
+ onClick: t[2] ||= (e) => w("editor-focus", h.page.id)
806
+ }, [pe(ce, {
807
+ decorations: h.pageDecorations,
808
+ "page-number": h.pageIndex + 1,
809
+ "total-pages": h.totalPages,
810
+ variables: h.variables
741
811
  }, null, 8, [
742
812
  "decorations",
743
813
  "page-number",
744
814
  "total-pages",
745
815
  "variables"
746
- ]), g(N) ? (ge(), le(g(be), {
816
+ ]), v(R) ? (_e(), ue(v(Se), {
747
817
  key: 0,
748
818
  class: "gd-contract-template-page__content",
749
- editor: g(N)
750
- }, null, 8, ["editor"])) : ue("", !0)], 36)], 6)], 4));
819
+ editor: v(R)
820
+ }, null, 8, ["editor"])) : de("", !0)], 36)], 6)], 4));
751
821
  }
752
822
  });
753
823
  //#endregion
754
- export { Oe as default };
824
+ export { je as default };