@guodun/antdv 1.7.12 → 1.7.13

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