@guodun/antdv 1.4.1 → 1.4.3

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 (135) hide show
  1. package/dist/es/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.mjs +304 -293
  2. package/dist/es/components/contract-signing-location/src/coordinates.mjs +23 -23
  3. package/dist/es/components/contract-signing-location/src/location-rules.mjs +20 -10
  4. package/dist/es/components/contract-signing-location/src/page-layout.mjs +12 -9
  5. package/dist/es/components/contract-signing-location/src/template-source.mjs +2 -0
  6. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.mjs +208 -180
  7. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.mjs +2 -1
  8. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerToolbar.mjs +5 -0
  9. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerToolbar.vue.mjs +690 -0
  10. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerWorkspaceHeader.mjs +5 -0
  11. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerWorkspaceHeader.vue.mjs +253 -0
  12. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateImageContextMenu.mjs +5 -0
  13. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateImageContextMenu.vue.mjs +87 -0
  14. package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePageDecorations.mjs +5 -0
  15. package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePageDecorations.vue.mjs +98 -0
  16. package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePageDecorationsInspector.mjs +5 -0
  17. package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePageDecorationsInspector.vue.mjs +550 -0
  18. package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePageDecorationsStudio.mjs +5 -0
  19. package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePageDecorationsStudio.vue.mjs +117 -0
  20. package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePreviewModal.mjs +5 -0
  21. package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePreviewModal.vue.mjs +96 -0
  22. package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.mjs +51 -26
  23. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererPage.vue.mjs +56 -33
  24. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateSubmitDataModal.mjs +5 -0
  25. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateSubmitDataModal.vue.mjs +29 -0
  26. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateTextBubbleMenu.mjs +5 -0
  27. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateTextBubbleMenu.vue.mjs +179 -0
  28. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateTextContextMenu.mjs +5 -0
  29. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateTextContextMenu.vue.mjs +390 -0
  30. package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +332 -263
  31. package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +1442 -2287
  32. package/dist/es/components/pro-contract-template-designer/src/composables/use-auto-pagination.mjs +71 -0
  33. package/dist/es/components/pro-contract-template-designer/src/composables/use-designer-files.mjs +11 -0
  34. package/dist/es/components/pro-contract-template-designer/src/composables/use-draft-cache-session.mjs +111 -0
  35. package/dist/es/components/pro-contract-template-designer/src/composables/use-signing-placement-editor.mjs +79 -0
  36. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +189 -160
  37. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-files.mjs +35 -22
  38. package/dist/es/components/pro-contract-template-designer/src/composables/use-toolbar-overflow.mjs +71 -0
  39. package/dist/es/components/pro-contract-template-designer/src/constants.mjs +71 -10
  40. package/dist/es/components/pro-contract-template-designer/src/extensions/editor-extensions.mjs +1 -0
  41. package/dist/es/components/pro-contract-template-designer/src/utils/block-style.mjs +43 -0
  42. package/dist/es/components/pro-contract-template-designer/src/utils/context-menu-viewport.mjs +13 -0
  43. package/dist/es/components/pro-contract-template-designer/src/utils/editor-state.mjs +7 -0
  44. package/dist/es/components/pro-contract-template-designer/src/utils/page-decorations.mjs +398 -0
  45. package/dist/es/components/pro-contract-template-designer/src/utils/serialize-fingerprint.mjs +6 -0
  46. package/dist/es/components/pro-contract-template-designer/src/utils/template-renderer.mjs +88 -72
  47. package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
  48. package/dist/es/index.mjs +20 -20
  49. package/dist/lib/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.cjs +1 -1
  50. package/dist/lib/components/contract-signing-location/src/coordinates.cjs +1 -1
  51. package/dist/lib/components/contract-signing-location/src/location-rules.cjs +1 -1
  52. package/dist/lib/components/contract-signing-location/src/page-layout.cjs +1 -1
  53. package/dist/lib/components/contract-signing-location/src/template-source.cjs +1 -1
  54. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.cjs +1 -1
  55. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.cjs +1 -1
  56. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerToolbar.cjs +1 -0
  57. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerToolbar.vue.cjs +1 -0
  58. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerWorkspaceHeader.cjs +1 -0
  59. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerWorkspaceHeader.vue.cjs +1 -0
  60. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateImageContextMenu.cjs +1 -0
  61. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateImageContextMenu.vue.cjs +1 -0
  62. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePageDecorations.cjs +1 -0
  63. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePageDecorations.vue.cjs +1 -0
  64. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePageDecorationsInspector.cjs +1 -0
  65. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePageDecorationsInspector.vue.cjs +1 -0
  66. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePageDecorationsStudio.cjs +1 -0
  67. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePageDecorationsStudio.vue.cjs +1 -0
  68. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePreviewModal.cjs +1 -0
  69. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePreviewModal.vue.cjs +1 -0
  70. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.cjs +1 -1
  71. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererPage.vue.cjs +1 -1
  72. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateSubmitDataModal.cjs +1 -0
  73. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateSubmitDataModal.vue.cjs +1 -0
  74. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateTextBubbleMenu.cjs +1 -0
  75. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateTextBubbleMenu.vue.cjs +1 -0
  76. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateTextContextMenu.cjs +1 -0
  77. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateTextContextMenu.vue.cjs +1 -0
  78. package/dist/lib/components/pro-contract-template-designer/src/DesignerPage.vue.cjs +2 -2
  79. package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
  80. package/dist/lib/components/pro-contract-template-designer/src/composables/use-auto-pagination.cjs +1 -0
  81. package/dist/lib/components/pro-contract-template-designer/src/composables/use-designer-files.cjs +1 -0
  82. package/dist/lib/components/pro-contract-template-designer/src/composables/use-draft-cache-session.cjs +1 -0
  83. package/dist/lib/components/pro-contract-template-designer/src/composables/use-signing-placement-editor.cjs +1 -0
  84. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +4 -4
  85. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-files.cjs +2 -2
  86. package/dist/lib/components/pro-contract-template-designer/src/composables/use-toolbar-overflow.cjs +1 -0
  87. package/dist/lib/components/pro-contract-template-designer/src/constants.cjs +1 -1
  88. package/dist/lib/components/pro-contract-template-designer/src/extensions/editor-extensions.cjs +1 -1
  89. package/dist/lib/components/pro-contract-template-designer/src/utils/block-style.cjs +1 -0
  90. package/dist/lib/components/pro-contract-template-designer/src/utils/context-menu-viewport.cjs +1 -0
  91. package/dist/lib/components/pro-contract-template-designer/src/utils/editor-state.cjs +1 -0
  92. package/dist/lib/components/pro-contract-template-designer/src/utils/page-decorations.cjs +1 -0
  93. package/dist/lib/components/pro-contract-template-designer/src/utils/serialize-fingerprint.cjs +1 -0
  94. package/dist/lib/components/pro-contract-template-designer/src/utils/template-renderer.cjs +3 -3
  95. package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
  96. package/dist/lib/index.cjs +1 -1
  97. package/dist/theme/icon.css +1 -1
  98. package/dist/theme/index.css +1 -1
  99. package/dist/types/components/contract-signing-location/src/coordinates.d.ts +2 -2
  100. package/dist/types/components/contract-signing-location/src/page-layout.d.ts +2 -2
  101. package/dist/types/components/contract-signing-location/src/template-source.d.ts +2 -0
  102. package/dist/types/components/contract-signing-location/src/types.d.ts +3 -0
  103. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.d.ts +3 -0
  104. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.d.ts +1 -0
  105. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerToolbar.vue.d.ts +104 -0
  106. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerWorkspaceHeader.vue.d.ts +60 -0
  107. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateImageContextMenu.vue.d.ts +27 -0
  108. package/dist/types/components/pro-contract-template-designer/src/ContractTemplatePageDecorations.vue.d.ts +13 -0
  109. package/dist/types/components/pro-contract-template-designer/src/ContractTemplatePageDecorationsInspector.vue.d.ts +28 -0
  110. package/dist/types/components/pro-contract-template-designer/src/ContractTemplatePageDecorationsStudio.vue.d.ts +77 -0
  111. package/dist/types/components/pro-contract-template-designer/src/ContractTemplatePreviewModal.vue.d.ts +36 -0
  112. package/dist/types/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.d.ts +5 -1
  113. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateRendererHeader.vue.d.ts +4 -4
  114. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateRendererToolbar.vue.d.ts +4 -4
  115. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateSubmitDataModal.vue.d.ts +12 -0
  116. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateTextBubbleMenu.vue.d.ts +43 -0
  117. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateTextContextMenu.vue.d.ts +77 -0
  118. package/dist/types/components/pro-contract-template-designer/src/DesignerPage.vue.d.ts +30 -32
  119. package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.d.ts +456 -12
  120. package/dist/types/components/pro-contract-template-designer/src/composables/use-auto-pagination.d.ts +43 -0
  121. package/dist/types/components/pro-contract-template-designer/src/composables/use-designer-files.d.ts +22 -0
  122. package/dist/types/components/pro-contract-template-designer/src/composables/use-draft-cache-session.d.ts +41 -0
  123. package/dist/types/components/pro-contract-template-designer/src/composables/use-signing-placement-editor.d.ts +49 -0
  124. package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +15 -1
  125. package/dist/types/components/pro-contract-template-designer/src/composables/use-template-files.d.ts +13 -0
  126. package/dist/types/components/pro-contract-template-designer/src/composables/use-toolbar-overflow.d.ts +19 -0
  127. package/dist/types/components/pro-contract-template-designer/src/constants.d.ts +7 -1
  128. package/dist/types/components/pro-contract-template-designer/src/types.d.ts +89 -0
  129. package/dist/types/components/pro-contract-template-designer/src/utils/block-style.d.ts +4 -0
  130. package/dist/types/components/pro-contract-template-designer/src/utils/context-menu-viewport.d.ts +25 -0
  131. package/dist/types/components/pro-contract-template-designer/src/utils/editor-state.d.ts +8 -0
  132. package/dist/types/components/pro-contract-template-designer/src/utils/page-decorations.d.ts +90 -0
  133. package/dist/types/components/pro-contract-template-designer/src/utils/serialize-fingerprint.d.ts +8 -0
  134. package/dist/types/components/pro-contract-template-designer/src/utils/template-renderer.d.ts +4 -1
  135. package/package.json +3 -3
@@ -1,24 +1,29 @@
1
1
  import { SIGNING_PLACEMENT_MIME as e, canMutateSigningPlacements as t, getSigningPlacementDefaultSize as n, parseSigningPlacementDragPayload as r } from "./utils/signing-placement.mjs";
2
2
  import { CONTRACT_TEXT_STYLE_PRESETS as i } from "./constants.mjs";
3
- import { DEFAULT_FIELD_STYLE as a, resolvePageSize as o, splitPageContentByMeasurements as s } from "./composables/use-template-designer.mjs";
4
- import { buildTemplateVariableAttrs as c, insertTemplateVariableNode as l } from "./extensions/template-variable.mjs";
3
+ import { CONTRACT_PAGE_BASE_PADDING as a, getPageDecorationSafePadding as o, hasEnabledPageFooter as s, hasEnabledPageHeader as c, normalizePageDecorations as l } from "./utils/page-decorations.mjs";
4
+ import { DEFAULT_FIELD_STYLE as ee, resolvePageSize as te, splitPageContentByMeasurements as ne } from "./composables/use-template-designer.mjs";
5
+ import { buildTemplateVariableAttrs as re, insertTemplateVariableNode as ie } from "./extensions/template-variable.mjs";
5
6
  import { normalizeContractImageDimension as u } from "./utils/content-image.mjs";
6
- import { createEditorExtensions as ee, runContractTemplateEditorCommand as d } from "./extensions/editor-extensions.mjs";
7
+ import { createEditorExtensions as ae, runContractTemplateEditorCommand as d } from "./extensions/editor-extensions.mjs";
7
8
  import { resolveEditorContextMenuKind as f } from "./utils/context-variable.mjs";
8
- import te from "./SigningPlacementLayer.mjs";
9
- import { computed as p, createBlock as ne, createCommentVNode as re, createElementBlock as ie, createElementVNode as m, createVNode as ae, defineComponent as h, nextTick as oe, normalizeClass as se, normalizeStyle as g, onBeforeUnmount as ce, openBlock as _, ref as le, toDisplayString as v, unref as y, watch as b, withModifiers as ue } from "vue";
10
- import { EditorContent as de, useEditor as fe } from "@tiptap/vue-3";
11
- import { generateHTML as pe } from "@tiptap/core";
12
- import { CellSelection as x, deleteColumn as me, deleteRow as he, deleteTable as ge } from "@tiptap/pm/tables";
13
- import { NodeSelection as S } from "@tiptap/pm/state";
9
+ import { applyContractTemplateBlockStyle as oe } from "./utils/block-style.mjs";
10
+ import se from "./SigningPlacementLayer.mjs";
11
+ import ce from "./ContractTemplatePageDecorations.mjs";
12
+ import { computed as p, createBlock as le, createCommentVNode as ue, createElementBlock as de, createElementVNode as m, createVNode as h, defineComponent as g, nextTick as fe, normalizeClass as pe, normalizeStyle as _, onBeforeUnmount as me, openBlock as v, ref as he, toDisplayString as y, unref as b, watch as x, withModifiers as ge } from "vue";
13
+ import { EditorContent as _e, useEditor as ve } from "@tiptap/vue-3";
14
+ import { generateHTML as ye } from "@tiptap/core";
15
+ import { CellSelection as S, deleteColumn as be, deleteRow as xe, deleteTable as Se } from "@tiptap/pm/tables";
16
+ import { NodeSelection as C } from "@tiptap/pm/state";
14
17
  //#region src/components/pro-contract-template-designer/src/DesignerPage.vue?vue&type=script&setup=true&lang.ts
15
- var _e = { class: "gd-contract-template-designer__page-title" }, C = "application/x-gd-contract-variable-move", ve = 8, w = /* @__PURE__ */ h({
18
+ var Ce = { class: "gd-contract-template-designer__page-title" }, w = "application/x-gd-contract-variable-move", we = 8, T = /* @__PURE__ */ g({
16
19
  name: "ProContractTemplateDesignerPage",
17
20
  __name: "DesignerPage",
18
21
  props: {
19
22
  page: {},
20
23
  pageIndex: {},
21
24
  pageSize: {},
25
+ pageDecorations: { default: void 0 },
26
+ totalPages: { default: 1 },
22
27
  variables: {},
23
28
  selectedVariableKey: { default: "" },
24
29
  active: {
@@ -54,130 +59,144 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
54
59
  "editor-state-change",
55
60
  "editor-context-menu"
56
61
  ],
57
- setup(h, { expose: w, emit: ye }) {
58
- let T = h, E = ye, D = p(() => T.readonly || T.disabled), O = le(), k = ee("请输入合同正文,或从 WPS / Word 粘贴合同内容", {
59
- processImageFile: T.processImageFile,
60
- getZoom: () => Math.max(.1, T.zoom || 1)
61
- }), A = fe({
62
- content: T.page.contentHtml,
63
- editable: !D.value,
64
- extensions: k,
62
+ setup(g, { expose: T, emit: Te }) {
63
+ let E = g, D = Te, O = p(() => E.readonly || E.disabled), k = he(), A = ae("请输入合同正文,或从 WPS / Word 粘贴合同内容", {
64
+ processImageFile: E.processImageFile,
65
+ getZoom: () => Math.max(.1, E.zoom || 1)
66
+ }), j = ve({
67
+ content: E.page.contentHtml,
68
+ editable: !O.value,
69
+ extensions: A,
65
70
  editorProps: {
66
71
  attributes: { class: "gd-contract-template-designer__editor-prose" },
67
72
  handleClick: (e, t, n) => {
68
73
  let r = (n.target instanceof HTMLElement ? n.target.closest("[data-template-variable]") : void 0)?.dataset.key;
69
74
  if (!r) return !1;
70
- let i = T.variables.find((e) => e.key === r);
71
- return i && E("variable-select", i.key), !1;
75
+ let i = E.variables.find((e) => e.key === r);
76
+ return i && D("variable-select", i.key), !1;
72
77
  },
73
78
  handleDOMEvents: {
74
79
  contextmenu: (e, t) => {
75
- if (D.value) return !1;
76
- let n = Oe(e, t.target);
80
+ if (O.value) return !1;
81
+ let n = Le(e, t.target);
77
82
  if (n) return t.preventDefault(), L({
78
- pageId: T.page.id,
83
+ pageId: E.page.id,
79
84
  clientX: t.clientX,
80
85
  clientY: t.clientY
81
86
  }, n), !0;
82
- let r = A.value?.state.selection, i = r instanceof x, a = t.target instanceof HTMLElement ? !!t.target.closest("td, th") : !1, o = f({
87
+ let r = j.value?.state.selection, i = r instanceof S, a = t.target instanceof HTMLElement ? !!t.target.closest("td, th") : !1, o = f({
83
88
  isCellSelection: i,
84
89
  selectionEmpty: !r || r.empty,
85
90
  inTable: a
86
91
  });
87
- return t.preventDefault(), o === "table" && (i || Ee(t.clientX, t.clientY, t.target)) ? (B({
88
- pageId: T.page.id,
92
+ return t.preventDefault(), o === "table" && (i || Pe(t.clientX, t.clientY, t.target)) ? (B({
93
+ pageId: E.page.id,
89
94
  clientX: t.clientX,
90
95
  clientY: t.clientY
91
96
  }), !0) : (I({
92
- pageId: T.page.id,
97
+ pageId: E.page.id,
93
98
  clientX: t.clientX,
94
99
  clientY: t.clientY
95
100
  }), !0);
96
101
  },
97
- dragstart: (e, t) => D.value ? (t.preventDefault(), !0) : (t.target instanceof HTMLElement ? t.target : null)?.closest("[data-template-variable]") ? (t.dataTransfer?.setData(C, T.page.id), t.dataTransfer && (t.dataTransfer.effectAllowed = "move"), O.value?.classList.add("is-variable-dragging"), !1) : !1,
98
- dragend: () => (O.value?.classList.remove("is-variable-dragging"), !1),
102
+ dragstart: (e, t) => O.value ? (t.preventDefault(), !0) : (t.target instanceof HTMLElement ? t.target : null)?.closest("[data-template-variable]") ? (t.dataTransfer?.setData(w, E.page.id), t.dataTransfer && (t.dataTransfer.effectAllowed = "move"), k.value?.classList.add("is-variable-dragging"), !1) : !1,
103
+ dragend: () => (k.value?.classList.remove("is-variable-dragging"), !1),
99
104
  drop: (e, t) => {
100
- if (D.value) return t.preventDefault(), t.stopPropagation(), !0;
101
- let n = t.dataTransfer?.getData(C);
102
- return !n || n === T.page.id ? !1 : (t.preventDefault(), E("variable-move-blocked", T.page.id), !0);
105
+ if (O.value) return t.preventDefault(), t.stopPropagation(), !0;
106
+ let n = t.dataTransfer?.getData(w);
107
+ return !n || n === E.page.id ? !1 : (t.preventDefault(), D("variable-move-blocked", E.page.id), !0);
103
108
  }
104
109
  },
105
110
  handleKeyDown: (e, t) => {
106
- if (D.value || !Ce(t)) return !1;
107
- let n = A.value;
111
+ if (O.value || !je(t)) return !1;
112
+ let n = j.value;
108
113
  if (!n) return !1;
109
114
  t.preventDefault();
110
115
  let r = n.state.selection, i = z();
111
116
  if (i) {
112
117
  let e = n.view.coordsAtPos(r.from);
113
118
  return L({
114
- pageId: T.page.id,
119
+ pageId: E.page.id,
115
120
  clientX: e.left,
116
121
  clientY: e.bottom
117
122
  }, i), !0;
118
123
  }
119
- let a = r instanceof x;
124
+ let a = r instanceof S;
120
125
  if (f({
121
126
  isCellSelection: a,
122
127
  selectionEmpty: r.empty,
123
128
  inTable: n.isActive("table")
124
129
  }) === "table") {
125
130
  if (!a) {
126
- let e = Te();
127
- typeof e == "number" && n.view.dispatch(n.state.tr.setSelection(x.create(n.state.doc, e)));
131
+ let e = Ne();
132
+ typeof e == "number" && n.view.dispatch(n.state.tr.setSelection(S.create(n.state.doc, e)));
128
133
  }
129
134
  let e = n.view.coordsAtPos(n.state.selection.from);
130
135
  return B({
131
- pageId: T.page.id,
136
+ pageId: E.page.id,
132
137
  clientX: e.left,
133
138
  clientY: e.bottom
134
139
  }), !0;
135
140
  }
136
141
  let o = n.view.coordsAtPos(n.state.selection.from);
137
142
  return I({
138
- pageId: T.page.id,
143
+ pageId: E.page.id,
139
144
  clientX: o.left,
140
145
  clientY: o.bottom
141
146
  }), !0;
142
147
  }
143
148
  },
144
149
  onUpdate: ({ editor: e }) => {
145
- E("page-update", {
146
- ...T.page,
150
+ D("page-update", {
151
+ ...E.page,
147
152
  contentHtml: e.getHTML(),
148
153
  contentJson: e.getJSON()
149
- }), H();
154
+ }), U();
150
155
  },
151
156
  onFocus: () => {
152
- E("editor-focus", T.page.id), H();
157
+ D("editor-focus", E.page.id), U();
153
158
  },
154
- onBlur: H,
155
- onSelectionUpdate: H,
156
- onCreate: H
159
+ onBlur: U,
160
+ onSelectionUpdate: U,
161
+ onCreate: U
157
162
  });
158
- function be(e) {
163
+ function Ee(e) {
159
164
  if (typeof e == "number" && Number.isFinite(e)) return e;
160
165
  let t = String(e || "").match(/(\d+(\.\d+)?)/);
161
166
  return t ? Number(t[1]) : void 0;
162
167
  }
163
- function xe() {
164
- if (!A.value) return "";
165
- let { from: e, to: t } = A.value.state.selection;
166
- return A.value.state.doc.textBetween(e, t, "\n");
168
+ function De() {
169
+ if (!j.value) return "";
170
+ let { from: e, to: t } = j.value.state.selection;
171
+ return j.value.state.doc.textBetween(e, t, "\n");
167
172
  }
168
- function Se() {
169
- let e = A.value, t = e?.state.selection;
173
+ function Oe() {
174
+ let e = j.value, t = e?.state.selection;
170
175
  if (!(!e || !t || t.empty)) try {
171
176
  let n = e.view.coordsAtPos(t.from), r = e.view.coordsAtPos(t.to, -1);
172
- if (Math.abs(r.top - n.top) > ve) return;
173
- let i = Math.abs(r.left - n.left) / U.value;
177
+ if (Math.abs(r.top - n.top) > we) return;
178
+ let i = Math.abs(r.left - n.left) / W.value;
174
179
  return Number.isFinite(i) && i > 0 ? i : void 0;
175
180
  } catch {
176
181
  return;
177
182
  }
178
183
  }
179
- function j() {
180
- let e = A.value;
184
+ function ke() {
185
+ let e = j.value, t = e?.state.selection;
186
+ if (!(!e || !t || t.empty) && !(t instanceof S || t instanceof C)) try {
187
+ let n = e.view.coordsAtPos(t.from), r = e.view.coordsAtPos(t.to, -1);
188
+ return {
189
+ top: Math.min(n.top, r.top),
190
+ bottom: Math.max(n.bottom, r.bottom),
191
+ left: Math.min(n.left, r.left),
192
+ right: Math.max(n.left, r.right)
193
+ };
194
+ } catch {
195
+ return;
196
+ }
197
+ }
198
+ function Ae() {
199
+ let e = j.value;
181
200
  if (!e) return "";
182
201
  let t = e.state.selection.$from, n = t.pos;
183
202
  for (let e = t.depth; e > 0; --e) {
@@ -189,7 +208,7 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
189
208
  }
190
209
  return e.state.doc.textBetween(n, e.state.selection.from, "");
191
210
  }
192
- function Ce(e) {
211
+ function je(e) {
193
212
  return e.key === "ContextMenu" || e.shiftKey && e.key === "F10";
194
213
  }
195
214
  function M(e) {
@@ -198,26 +217,26 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
198
217
  if (n === "cell" || n === "header_cell") return e.before(t);
199
218
  }
200
219
  }
201
- function we(e, t) {
202
- let n = A.value, r = n?.view.posAtCoords({
220
+ function Me(e, t) {
221
+ let n = j.value, r = n?.view.posAtCoords({
203
222
  left: e,
204
223
  top: t
205
224
  })?.pos;
206
225
  if (!(!n || typeof r != "number")) return M(n.state.doc.resolve(r));
207
226
  }
208
- function Te() {
209
- let e = A.value;
227
+ function Ne() {
228
+ let e = j.value;
210
229
  if (e) return M(e.state.selection.$from);
211
230
  }
212
- function Ee(e, t, n) {
213
- let r = A.value, i = n instanceof HTMLElement ? n : null;
231
+ function Pe(e, t, n) {
232
+ let r = j.value, i = n instanceof HTMLElement ? n : null;
214
233
  if (!r || !i?.closest("td,th")) return !1;
215
- if (r.state.selection instanceof x && i.closest("td.selectedCell,th.selectedCell")) return !0;
216
- let a = we(e, t);
217
- return typeof a == "number" ? (r.view.dispatch(r.state.tr.setSelection(x.create(r.state.doc, a))), !0) : !1;
234
+ if (r.state.selection instanceof S && i.closest("td.selectedCell,th.selectedCell")) return !0;
235
+ let a = Me(e, t);
236
+ return typeof a == "number" ? (r.view.dispatch(r.state.tr.setSelection(S.create(r.state.doc, a))), !0) : !1;
218
237
  }
219
238
  function N() {
220
- let e = A.value, t = e?.isActive("table") ? e.can() : void 0, n = (e) => !!(t && e(t));
239
+ let e = j.value, t = e?.isActive("table") ? e.can() : void 0, n = (e) => !!(t && e(t));
221
240
  return {
222
241
  addRowBefore: n((e) => e.addRowBefore()),
223
242
  addRowAfter: n((e) => e.addRowAfter()),
@@ -235,41 +254,48 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
235
254
  deleteTable: n((e) => e.deleteTable())
236
255
  };
237
256
  }
238
- function De() {
239
- let e = A.value, t = e?.state.selection;
240
- if (!e || !(t instanceof x)) return "left";
257
+ function Fe() {
258
+ let e = j.value, t = e?.state.selection;
259
+ if (!e || !(t instanceof S)) return "left";
241
260
  let n = /* @__PURE__ */ new Set();
242
261
  return t.forEachCell((e) => {
243
262
  let t = e.attrs.textAlign;
244
263
  n.add(t === "center" || t === "right" ? t : "left");
245
264
  }), n.size === 1 ? n.values().next().value ?? "left" : "mixed";
246
265
  }
247
- function P(e = A.value?.state.doc) {
266
+ function P(e = j.value?.state.doc) {
248
267
  let t = 0;
249
268
  return e?.descendants((e) => {
250
269
  e.type.name === "templateVariable" && (t += 1);
251
270
  }), t;
252
271
  }
253
272
  function F(e) {
254
- let t = A.value;
273
+ let t = j.value;
255
274
  if (!t) return 0;
256
275
  let n = P(t.state.doc), r = n, i = (e) => {
257
276
  r = P(e.doc);
258
277
  };
259
- return e === "delete-table-row" ? he(t.state, i) : e === "delete-table-column" ? me(t.state, i) : ge(t.state, i), Math.max(0, n - r);
278
+ return e === "delete-table-row" ? xe(t.state, i) : e === "delete-table-column" ? be(t.state, i) : Se(t.state, i), Math.max(0, n - r);
260
279
  }
261
280
  function I(e) {
262
- let t = A.value?.state.selection, n = !!(t && !t.empty);
263
- E("editor-context-menu", {
281
+ let t = j.value?.state.selection, n = !!(t && !t.empty);
282
+ D("editor-context-menu", {
264
283
  type: "text",
265
284
  ...e,
266
285
  hasSelection: n,
267
- selectionWidth: n ? Se() : void 0,
268
- leadingText: j()
286
+ selectionWidth: n ? Oe() : void 0,
287
+ leadingText: Ae()
288
+ });
289
+ }
290
+ function Ie(e, t) {
291
+ I({
292
+ pageId: E.page.id,
293
+ clientX: e,
294
+ clientY: t
269
295
  });
270
296
  }
271
297
  function L(e, t) {
272
- E("editor-context-menu", {
298
+ D("editor-context-menu", {
273
299
  type: "image",
274
300
  ...e,
275
301
  image: t
@@ -286,24 +312,24 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
286
312
  };
287
313
  }
288
314
  function z() {
289
- let e = A.value?.state.selection;
290
- if (e instanceof S) return R(e.node, e.from);
315
+ let e = j.value?.state.selection;
316
+ if (e instanceof C) return R(e.node, e.from);
291
317
  }
292
- function Oe(e, t) {
318
+ function Le(e, t) {
293
319
  let n = t instanceof HTMLElement ? t.closest("[data-template-variable], img[src]") : null;
294
320
  if (n) try {
295
321
  let t = e.posAtDOM(n, 0), r = e.state.doc.nodeAt(t);
296
- return !r || r.type.name !== "templateVariable" && r.type.name !== "image" ? void 0 : (r.type.name === "templateVariable" && typeof r.attrs.key == "string" && E("variable-select", r.attrs.key), (!(e.state.selection instanceof S) || e.state.selection.from !== t) && e.dispatch(e.state.tr.setSelection(S.create(e.state.doc, t))), R(r, t));
322
+ return !r || r.type.name !== "templateVariable" && r.type.name !== "image" ? void 0 : (r.type.name === "templateVariable" && typeof r.attrs.key == "string" && D("variable-select", r.attrs.key), (!(e.state.selection instanceof C) || e.state.selection.from !== t) && e.dispatch(e.state.tr.setSelection(C.create(e.state.doc, t))), R(r, t));
297
323
  } catch {
298
324
  return;
299
325
  }
300
326
  }
301
327
  function B(e) {
302
- E("editor-context-menu", {
328
+ D("editor-context-menu", {
303
329
  type: "table",
304
330
  ...e,
305
331
  capabilities: N(),
306
- activeAlignment: De(),
332
+ activeAlignment: Fe(),
307
333
  affectedVariableCounts: {
308
334
  deleteRow: F("delete-table-row"),
309
335
  deleteColumn: F("delete-table-column"),
@@ -311,21 +337,37 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
311
337
  }
312
338
  });
313
339
  }
314
- function ke() {
315
- return A.value ? [
316
- 1,
317
- 2,
318
- 3,
319
- 4,
320
- 5,
321
- 6
322
- ].find((e) => A.value?.isActive("heading", { level: e })) : void 0;
323
- }
324
- function Ae() {
325
- return ["center", "right"].find((e) => A.value?.isActive("heading", { textAlign: e }) || A.value?.isActive("paragraph", { textAlign: e })) ?? "left";
340
+ function Re(e) {
341
+ return typeof e == "number" && Number.isInteger(e) && e >= 1 && e <= 6;
326
342
  }
327
343
  function V() {
328
- let e = A.value, t = (t) => !!e?.isActive(t), n = e?.getAttributes("textStyle") ?? {};
344
+ let e = j.value;
345
+ if (!e) return [];
346
+ let { doc: t, selection: n } = e.state, r = [], i = (e) => {
347
+ e.type.name === "paragraph" ? r.push("paragraph") : e.type.name === "heading" && Re(e.attrs.level) && r.push(e.attrs.level);
348
+ };
349
+ if (n.empty) for (let e = n.$from.depth; e > 0; e--) {
350
+ let t = n.$from.node(e);
351
+ if (t.type.name === "paragraph" || t.type.name === "heading") {
352
+ i(t);
353
+ break;
354
+ }
355
+ }
356
+ else t.nodesBetween(n.from, n.to, (e) => (i(e), !0));
357
+ return Array.from(new Set(r));
358
+ }
359
+ function ze() {
360
+ let e = V();
361
+ return e.length === 1 && e[0] !== "paragraph" ? e[0] : void 0;
362
+ }
363
+ function Be() {
364
+ return V().length > 1;
365
+ }
366
+ function Ve() {
367
+ return ["center", "right"].find((e) => j.value?.isActive("heading", { textAlign: e }) || j.value?.isActive("paragraph", { textAlign: e })) ?? "left";
368
+ }
369
+ function H() {
370
+ let e = j.value, t = (t) => !!e?.isActive(t), n = e?.getAttributes("textStyle") ?? {};
329
371
  return {
330
372
  isFocused: !!e?.isFocused,
331
373
  canUndo: !!e?.can().undo(),
@@ -336,88 +378,94 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
336
378
  isBulletList: t("bulletList"),
337
379
  isOrderedList: t("orderedList"),
338
380
  isTableActive: t("table"),
339
- currentHeadingLevel: ke(),
340
- textAlign: Ae(),
381
+ currentHeadingLevel: ze(),
382
+ hasMixedBlockFormats: Be(),
383
+ textAlign: Ve(),
341
384
  fontFamily: typeof n.fontFamily == "string" ? n.fontFamily : void 0,
342
- fontSize: be(n.fontSize),
385
+ fontSize: Ee(n.fontSize),
343
386
  textColor: typeof n.color == "string" ? n.color : void 0,
344
- selectionText: xe(),
387
+ selectionText: De(),
345
388
  selectedContentImage: z()
346
389
  };
347
390
  }
348
- function H() {
349
- E("editor-state-change", T.page.id, V());
391
+ function U() {
392
+ D("editor-state-change", E.page.id, H());
350
393
  }
351
- b(D, (e) => {
352
- A.value?.setEditable(!e), H();
353
- }), b(() => T.page.contentHtml, (e) => {
354
- !A.value || e === A.value.getHTML() || (A.value.commands.setContent(e || "<p></p>", { emitUpdate: !1 }), H());
394
+ x(O, (e) => {
395
+ j.value?.setEditable(!e), U();
396
+ }), x(() => E.page.contentHtml, (e) => {
397
+ !j.value || e === j.value.getHTML() || (j.value.commands.setContent(e || "<p></p>", { emitUpdate: !1 }), U());
355
398
  });
356
- let je = p(() => ({
357
- width: `${T.pageSize.width}px`,
358
- height: `${T.pageSize.height}px`,
359
- "--gd-contract-page-content-height": `${q()}px`
360
- })), U = p(() => Math.max(.1, T.zoom || 1)), Me = p(() => ({
361
- width: `${Math.ceil((T.pageSize.width + 10) * U.value)}px`,
362
- height: `${Math.ceil((T.pageSize.height + 40) * U.value)}px`
363
- })), Ne = p(() => ({ "--gd-contract-page-zoom": String(U.value) })), Pe = p(() => o(T.pageSize));
364
- function W(e, t) {
365
- let n = O.value?.getBoundingClientRect();
399
+ let He = p(() => {
400
+ let e = l(E.pageDecorations), t = E.pageIndex + 1, n = c(e, t) ? o(e.header) : a.top, r = s(e, t) ? o(e.footer) : a.bottom;
401
+ return {
402
+ width: `${E.pageSize.width}px`,
403
+ height: `${E.pageSize.height}px`,
404
+ paddingTop: `${n}px`,
405
+ paddingBottom: `${r}px`,
406
+ "--gd-contract-page-content-height": `${Math.max(120, E.pageSize.height - n - r)}px`
407
+ };
408
+ }), W = p(() => Math.max(.1, E.zoom || 1)), Ue = p(() => ({
409
+ width: `${Math.ceil((E.pageSize.width + 10) * W.value)}px`,
410
+ height: `${Math.ceil((E.pageSize.height + 40) * W.value)}px`
411
+ })), We = p(() => ({ "--gd-contract-page-zoom": String(W.value) })), Ge = p(() => te(E.pageSize));
412
+ function G(e, t) {
413
+ let n = k.value?.getBoundingClientRect();
366
414
  return n ? {
367
- x: Math.min(T.pageSize.width, Math.max(0, (e - n.left) / U.value)),
368
- y: Math.min(T.pageSize.height, Math.max(0, (t - n.top) / U.value))
415
+ x: Math.min(E.pageSize.width, Math.max(0, (e - n.left) / W.value)),
416
+ y: Math.min(E.pageSize.height, Math.max(0, (t - n.top) / W.value))
369
417
  } : {
370
- x: T.pageSize.width / 2,
371
- y: T.pageSize.height / 2
418
+ x: E.pageSize.width / 2,
419
+ y: E.pageSize.height / 2
372
420
  };
373
421
  }
374
- function Fe(e) {
375
- let t = O.value?.getBoundingClientRect(), r = O.value?.closest(".gd-contract-template-designer__canvas")?.getBoundingClientRect(), i = n(e);
422
+ function Ke(e) {
423
+ let t = k.value?.getBoundingClientRect(), r = k.value?.closest(".gd-contract-template-designer__canvas")?.getBoundingClientRect(), i = n(e);
376
424
  if (!t || !r) return {
377
- x: Math.max(0, (T.pageSize.width - i.width) / 2),
378
- y: Math.max(0, (T.pageSize.height - i.height) / 2)
425
+ x: Math.max(0, (E.pageSize.width - i.width) / 2),
426
+ y: Math.max(0, (E.pageSize.height - i.height) / 2)
379
427
  };
380
- let a = Math.max(t.left, r.left), o = Math.max(t.top, r.top), s = Math.min(t.right, r.right), c = Math.min(t.bottom, r.bottom), l = W(s > a ? (a + s) / 2 : (t.left + t.right) / 2, c > o ? (o + c) / 2 : (t.top + t.bottom) / 2);
428
+ let a = Math.max(t.left, r.left), o = Math.max(t.top, r.top), s = Math.min(t.right, r.right), c = Math.min(t.bottom, r.bottom), l = G(s > a ? (a + s) / 2 : (t.left + t.right) / 2, c > o ? (o + c) / 2 : (t.top + t.bottom) / 2);
381
429
  return {
382
430
  x: l.x - i.width / 2,
383
431
  y: l.y - i.height / 2
384
432
  };
385
433
  }
386
- function Ie(n) {
387
- if (!t(T.readonly, T.disabled)) {
434
+ function qe(n) {
435
+ if (!t(E.readonly, E.disabled)) {
388
436
  n.preventDefault(), n.stopPropagation();
389
437
  return;
390
438
  }
391
439
  let i = r(n.dataTransfer?.getData(e));
392
440
  if (i) {
393
441
  n.preventDefault(), n.stopPropagation();
394
- let e = W(n.clientX, n.clientY);
395
- E("signing-placement-drop", T.page.id, i, e.x, e.y);
442
+ let e = G(n.clientX, n.clientY);
443
+ D("signing-placement-drop", E.page.id, i, e.x, e.y);
396
444
  return;
397
445
  }
398
446
  let a = n.dataTransfer?.getData("application/x-gd-contract-variable");
399
447
  if (a) {
400
- n.preventDefault(), n.stopPropagation(), E("variable-drop", T.page.id, a, n.clientX, n.clientY);
448
+ n.preventDefault(), n.stopPropagation(), D("variable-drop", E.page.id, a, n.clientX, n.clientY);
401
449
  return;
402
450
  }
403
- let o = n.dataTransfer?.getData(C);
404
- o && o !== T.page.id && (n.preventDefault(), n.stopPropagation(), E("variable-move-blocked", T.page.id));
451
+ let o = n.dataTransfer?.getData(w);
452
+ o && o !== E.page.id && (n.preventDefault(), n.stopPropagation(), D("variable-move-blocked", E.page.id));
405
453
  }
406
- function Le(e, t) {
407
- let n = A.value;
408
- return n ? (l(n, e, t ? n.view.posAtCoords(t)?.pos : void 0), $(), G()) : void 0;
454
+ function Je(e, t) {
455
+ let n = j.value;
456
+ return n ? (ie(n, e, t ? n.view.posAtCoords(t)?.pos : void 0), $(), K()) : void 0;
409
457
  }
410
- function Re(e, t) {
411
- let n = A.value;
458
+ function Ye(e, t) {
459
+ let n = j.value;
412
460
  if (n) return d(n, {
413
461
  type: "insert-content-image",
414
462
  image: e,
415
463
  position: t
416
- }), G();
464
+ }), K();
417
465
  }
418
- function ze(e) {
419
- let t = A.value, n = t?.state.selection;
420
- if (!t || !(n instanceof S) || n.node.type.name !== "image") return;
466
+ function Xe(e) {
467
+ let t = j.value, n = t?.state.selection;
468
+ if (!t || !(n instanceof C) || n.node.type.name !== "image") return;
421
469
  let r = { ...n.node.attrs }, i = !1;
422
470
  if (["width", "height"].forEach((t) => {
423
471
  if (!Object.prototype.hasOwnProperty.call(e, t)) return;
@@ -425,45 +473,49 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
425
473
  r[t] !== n && (r[t] = n, i = !0);
426
474
  }), !i) return;
427
475
  let a = t.state.tr.setNodeMarkup(n.from, void 0, r);
428
- return a.setSelection(S.create(a.doc, n.from)), t.view.dispatch(a), G();
476
+ return a.setSelection(C.create(a.doc, n.from)), t.view.dispatch(a), K();
429
477
  }
430
- function Be() {
431
- let e = A.value?.state.selection;
478
+ function Ze() {
479
+ let e = j.value?.state.selection;
432
480
  return e ? {
433
481
  from: e.from,
434
482
  to: e.to
435
483
  } : void 0;
436
484
  }
437
- function G() {
485
+ function K() {
438
486
  return {
439
- ...T.page,
440
- pageSize: Pe.value,
441
- contentHtml: A.value?.getHTML() ?? T.page.contentHtml,
442
- contentJson: A.value?.getJSON() ?? T.page.contentJson
487
+ ...E.page,
488
+ pageSize: Ge.value,
489
+ contentHtml: j.value?.getHTML() ?? E.page.contentHtml,
490
+ contentJson: j.value?.getJSON() ?? E.page.contentJson
443
491
  };
444
492
  }
445
- function K(e) {
493
+ function q(e) {
446
494
  return {
447
495
  type: "doc",
448
496
  content: e.length ? e : [{ type: "paragraph" }]
449
497
  };
450
498
  }
451
- function Ve(e) {
499
+ function Qe(e) {
452
500
  return e?.length ? e.length === 1 && e[0].type === "paragraph" && !e[0].content?.length : !0;
453
501
  }
454
- function He(e) {
455
- return pe(K(e), k);
502
+ function $e(e) {
503
+ return ye(q(e), A);
456
504
  }
457
- function q() {
458
- let e = O.value;
459
- if (!e) return T.pageSize.height - 108;
505
+ function et() {
506
+ if (E.pageDecorations) {
507
+ let e = l(E.pageDecorations), t = E.pageIndex + 1, n = c(e, t) ? o(e.header) : a.top, r = s(e, t) ? o(e.footer) : a.bottom;
508
+ return Math.max(120, E.pageSize.height - n - r);
509
+ }
510
+ let e = k.value;
511
+ if (!e) return E.pageSize.height - 108;
460
512
  let t = window.getComputedStyle(e), n = Number.parseFloat(t.paddingTop) || 0, r = Number.parseFloat(t.paddingBottom) || 0;
461
- return Math.max(120, T.pageSize.height - n - r);
513
+ return Math.max(120, E.pageSize.height - n - r);
462
514
  }
463
- function Ue() {
464
- let e = O.value?.querySelector(".gd-contract-template-designer__editor-prose");
515
+ function tt() {
516
+ let e = k.value?.querySelector(".gd-contract-template-designer__editor-prose");
465
517
  if (!e) return [];
466
- let t = e.getBoundingClientRect(), n = U.value;
518
+ let t = e.getBoundingClientRect(), n = W.value;
467
519
  return Array.from(e.children).map((e) => {
468
520
  let r = e.getBoundingClientRect();
469
521
  return {
@@ -473,26 +525,26 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
473
525
  });
474
526
  }
475
527
  function J() {
476
- return A.value ? s(A.value.getJSON().content, Ue(), q()) : void 0;
528
+ return j.value ? ne(j.value.getJSON().content, tt(), et()) : void 0;
477
529
  }
478
- function We() {
530
+ function nt() {
479
531
  return !!J();
480
532
  }
481
- function Ge() {
482
- if (!A.value) return;
533
+ function rt() {
534
+ if (!j.value) return;
483
535
  let e = J();
484
- if (e) return A.value.commands.setContent(K(e.currentContent), { emitUpdate: !1 }), {
485
- page: G(),
536
+ if (e) return j.value.commands.setContent(q(e.currentContent), { emitUpdate: !1 }), {
537
+ page: K(),
486
538
  overflowContent: e.overflowContent,
487
- overflowHtml: He(e.overflowContent)
539
+ overflowHtml: $e(e.overflowContent)
488
540
  };
489
541
  }
490
- function Y(e) {
491
- if (!A.value || !e.length) return;
492
- let t = A.value.getJSON().content, n = [...e, ...Ve(t) ? [] : t ?? []];
493
- return A.value.commands.setContent(K(n), { emitUpdate: !1 }), G();
542
+ function it(e) {
543
+ if (!j.value || !e.length) return;
544
+ let t = j.value.getJSON().content, n = [...e, ...Qe(t) ? [] : t ?? []];
545
+ return j.value.commands.setContent(q(n), { emitUpdate: !1 }), K();
494
546
  }
495
- function X(e, t) {
547
+ function Y(e, t) {
496
548
  let n = [];
497
549
  return e.descendants((e, r) => {
498
550
  e.type.name === "templateVariable" && e.attrs.key === t && n.push({
@@ -501,44 +553,44 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
501
553
  });
502
554
  }), n;
503
555
  }
504
- function Ke(e, t = e.key) {
505
- if (!A.value) return;
506
- let n = c(e), r = !1;
507
- return A.value.commands.command(({ tr: e, state: i, dispatch: a }) => (X(i.doc, t).forEach(({ node: t, pos: i }) => {
556
+ function X(e, t = e.key) {
557
+ if (!j.value) return;
558
+ let n = re(e), r = !1;
559
+ return j.value.commands.command(({ tr: e, state: i, dispatch: a }) => (Y(i.doc, t).forEach(({ node: t, pos: i }) => {
508
560
  e.setNodeMarkup(i, void 0, {
509
561
  ...t.attrs,
510
562
  ...n
511
563
  }), r = !0;
512
- }), r && a?.(e), r)), $(), r ? G() : void 0;
564
+ }), r && a?.(e), r)), $(), r ? K() : void 0;
513
565
  }
514
- function qe(e) {
515
- if (!A.value) return;
566
+ function at(e) {
567
+ if (!j.value) return;
516
568
  let t = 0;
517
- return A.value.commands.command(({ tr: n, state: r, dispatch: i }) => {
518
- let a = X(r.doc, e).map(({ node: e, pos: t }) => ({
569
+ return j.value.commands.command(({ tr: n, state: r, dispatch: i }) => {
570
+ let a = Y(r.doc, e).map(({ node: e, pos: t }) => ({
519
571
  from: t,
520
572
  to: t + e.nodeSize
521
573
  })).sort((e, t) => t.from - e.from);
522
574
  return a.forEach((e) => n.delete(e.from, e.to)), t = a.length, t && i?.(n), t > 0;
523
- }), t ? G() : void 0;
575
+ }), t ? K() : void 0;
524
576
  }
525
577
  function Z() {
526
- O.value?.querySelectorAll(".gd-contract-template-variable.is-active").forEach((e) => e.classList.remove("is-active"));
578
+ k.value?.querySelectorAll(".gd-contract-template-variable.is-active").forEach((e) => e.classList.remove("is-active"));
527
579
  }
528
580
  function Q(e) {
529
- if (e) return Array.from(O.value?.querySelectorAll("[data-template-variable]") ?? []).find((t) => t.dataset.key === e);
581
+ if (e) return Array.from(k.value?.querySelectorAll("[data-template-variable]") ?? []).find((t) => t.dataset.key === e);
530
582
  }
531
- function Je(e) {
583
+ function ot(e) {
532
584
  Z();
533
585
  let t = Q(e);
534
586
  return t ? (t.classList.add("is-active"), t.scrollIntoView({
535
587
  behavior: "smooth",
536
588
  block: "center",
537
589
  inline: "center"
538
- }), A.value?.commands.focus(), !0) : !1;
590
+ }), j.value?.commands.focus(), !0) : !1;
539
591
  }
540
- function Ye(e) {
541
- let t = Array.from(O.value?.querySelectorAll("[data-signing-placement-id]") ?? []).find((t) => t.dataset.signingPlacementId === e);
592
+ function st(e) {
593
+ let t = Array.from(k.value?.querySelectorAll("[data-signing-placement-id]") ?? []).find((t) => t.dataset.signingPlacementId === e);
542
594
  return t?.scrollIntoView({
543
595
  behavior: "smooth",
544
596
  block: "center",
@@ -546,106 +598,123 @@ var _e = { class: "gd-contract-template-designer__page-title" }, C = "applicatio
546
598
  }), !!t;
547
599
  }
548
600
  function $() {
549
- Z(), Q(T.selectedVariableKey)?.classList.add("is-active");
601
+ Z(), Q(E.selectedVariableKey)?.classList.add("is-active");
550
602
  }
551
- function Xe(e) {
552
- let t = i.find((t) => t.key === e), n = A.value;
603
+ function ct(e) {
604
+ let t = i.find((t) => t.key === e), n = j.value;
553
605
  if (!t || !n) return;
554
606
  let r = n.chain().focus().clearNodes();
555
- t.headingLevel ? r.setHeading({ level: t.headingLevel }) : r.setParagraph(), r.unsetAllMarks().unsetTextAlign().unsetFontSize().unsetFontFamily().unsetColor().setTextAlign(t.textAlign).setFontSize(`${t.fontSize}px`).setFontFamily(t.fontFamily || "Noto Serif SC, Source Han Serif SC, Songti SC, STSong, SimSun, serif").setColor(a.color || "#1f2937"), t.bold ? r.setBold() : r.unsetBold(), t.italic ? r.setItalic() : r.unsetItalic(), t.underline ? r.setUnderline() : r.unsetUnderline(), r.run();
607
+ t.headingLevel ? r.setHeading({ level: t.headingLevel }) : r.setParagraph(), r.unsetAllMarks().unsetTextAlign().unsetFontSize().unsetFontFamily().unsetColor().setTextAlign(t.textAlign).setFontSize(`${t.fontSize}px`).setFontFamily(t.fontFamily || "Noto Serif SC, Source Han Serif SC, Songti SC, STSong, SimSun, serif").setColor(ee.color || "#1f2937"), t.bold ? r.setBold() : r.unsetBold(), t.italic ? r.setItalic() : r.unsetItalic(), t.underline ? r.setUnderline() : r.unsetUnderline(), r.run();
556
608
  }
557
- b([() => T.selectedVariableKey, () => T.variables], () => {
558
- oe($);
609
+ x([() => E.selectedVariableKey, () => E.variables], () => {
610
+ fe($);
559
611
  }, {
560
612
  deep: !0,
561
613
  flush: "post"
562
614
  });
563
- function Ze(e) {
564
- e.type === "apply-text-style-preset" ? Xe(e.preset) : d(A.value, e), H();
615
+ function lt(e) {
616
+ e.type === "apply-block-style" ? j.value && oe(j.value, e.format) : e.type === "apply-text-style-preset" ? ct(e.preset) : d(j.value, e), U();
565
617
  }
566
- function Qe() {
567
- A.value?.commands.focus();
618
+ function ut() {
619
+ j.value?.commands.focus();
568
620
  }
569
- function $e() {
570
- return A.value?.getJSON();
621
+ function dt() {
622
+ return j.value?.getJSON();
571
623
  }
572
- function et() {
573
- return A.value?.getHTML() ?? T.page.contentHtml;
624
+ function ft() {
625
+ return j.value?.getHTML() ?? E.page.contentHtml;
574
626
  }
575
- function tt(e) {
576
- let t = T.variables.find((t) => t.id === e || t.key === e), n = t ? Q(t.key) : void 0;
627
+ function pt(e) {
628
+ let t = E.variables.find((t) => t.id === e || t.key === e), n = t ? Q(t.key) : void 0;
577
629
  $(), n?.scrollIntoView({
578
630
  behavior: "smooth",
579
631
  block: "center"
580
632
  });
581
633
  }
582
- function nt() {
583
- O.value?.scrollIntoView({
634
+ function mt() {
635
+ k.value?.scrollIntoView({
584
636
  behavior: "smooth",
585
637
  block: "start",
586
638
  inline: "center"
587
639
  });
588
640
  }
589
- return ce(() => {
590
- A.value?.destroy();
591
- }), w({
592
- focus: Qe,
593
- getHTML: et,
594
- getJSON: $e,
595
- getEditorState: V,
641
+ return me(() => {
642
+ j.value?.destroy();
643
+ }), T({
644
+ focus: ut,
645
+ getHTML: ft,
646
+ getJSON: dt,
647
+ getEditorState: H,
596
648
  getTableCommandCapabilities: N,
597
649
  getAffectedVariableCount: F,
598
- getVisibleSigningPlacementPosition: Fe,
599
- insertVariable: Le,
600
- insertContentImage: Re,
601
- updateSelectedContentImage: ze,
602
- getSelectionRange: Be,
603
- hasOverflowContent: We,
604
- updateVariable: Ke,
605
- removeVariable: qe,
606
- splitOverflowContent: Ge,
607
- prependContent: Y,
608
- runCommand: Ze,
609
- scrollIntoField: tt,
610
- scrollIntoVariable: Je,
611
- scrollIntoSigningPlacement: Ye,
612
- scrollIntoPage: nt
613
- }), (e, t) => (_(), ie("section", {
650
+ getVisibleSigningPlacementPosition: Ke,
651
+ insertVariable: Je,
652
+ insertContentImage: Ye,
653
+ updateSelectedContentImage: Xe,
654
+ getSelectionRange: Ze,
655
+ getSelectionViewportRect: ke,
656
+ requestTextContextMenu: Ie,
657
+ hasOverflowContent: nt,
658
+ updateVariable: X,
659
+ removeVariable: at,
660
+ splitOverflowContent: rt,
661
+ prependContent: it,
662
+ runCommand: lt,
663
+ scrollIntoField: pt,
664
+ scrollIntoVariable: ot,
665
+ scrollIntoSigningPlacement: st,
666
+ scrollIntoPage: mt
667
+ }), (e, t) => (v(), de("section", {
614
668
  class: "gd-contract-template-designer__page-shell",
615
- style: g(Me.value)
669
+ style: _(Ue.value)
616
670
  }, [m("div", {
617
- class: se(["gd-contract-template-designer__page-zoom", { "is-active": h.active }]),
618
- style: g(Ne.value)
619
- }, [m("header", _e, [m("span", null, v(h.page.title || `第 ${h.pageIndex + 1} 页`), 1), m("span", null, "第 " + v(h.pageIndex + 1) + " 页 · " + v(h.pageSize.label || "A4") + " · " + v(h.pageSize.width) + " × " + v(h.pageSize.height), 1)]), m("div", {
671
+ class: pe(["gd-contract-template-designer__page-zoom", { "is-active": g.active }]),
672
+ style: _(We.value)
673
+ }, [m("header", Ce, [m("span", null, y(g.page.title || `第 ${g.pageIndex + 1} 页`), 1), m("span", null, "第 " + y(g.pageIndex + 1) + " 页 · " + y(g.pageSize.label || "A4") + " · " + y(g.pageSize.width) + " × " + y(g.pageSize.height), 1)]), m("div", {
620
674
  ref_key: "pageElement",
621
- ref: O,
675
+ ref: k,
622
676
  class: "gd-contract-template-designer__page",
623
- style: g(je.value),
624
- onDragover: t[3] ||= ue(() => {}, ["prevent"]),
625
- onDrop: Ie,
626
- onClick: t[4] ||= (e) => E("editor-focus", h.page.id)
627
- }, [y(A) ? (_(), ne(y(de), {
628
- key: 0,
629
- editor: y(A)
630
- }, null, 8, ["editor"])) : re("", !0), ae(te, {
631
- "page-size": h.pageSize,
632
- placements: h.signingPlacements,
633
- "selected-id": h.selectedSigningPlacementId,
634
- zoom: U.value,
635
- readonly: h.readonly,
636
- disabled: h.disabled,
637
- onSelect: t[0] ||= (e) => E("signing-placement-select", e),
638
- onMove: t[1] ||= (e) => E("signing-placement-move", e),
639
- onRemove: t[2] ||= (e) => E("signing-placement-remove", e)
640
- }, null, 8, [
641
- "page-size",
642
- "placements",
643
- "selected-id",
644
- "zoom",
645
- "readonly",
646
- "disabled"
647
- ])], 36)], 6)], 4));
677
+ style: _(He.value),
678
+ onDragover: t[3] ||= ge(() => {}, ["prevent"]),
679
+ onDrop: qe,
680
+ onClick: t[4] ||= (e) => D("editor-focus", g.page.id)
681
+ }, [
682
+ h(ce, {
683
+ decorations: g.pageDecorations,
684
+ "page-number": g.pageIndex + 1,
685
+ "total-pages": g.totalPages,
686
+ variables: g.variables
687
+ }, null, 8, [
688
+ "decorations",
689
+ "page-number",
690
+ "total-pages",
691
+ "variables"
692
+ ]),
693
+ b(j) ? (v(), le(b(_e), {
694
+ key: 0,
695
+ class: "gd-contract-template-page__content",
696
+ editor: b(j)
697
+ }, null, 8, ["editor"])) : ue("", !0),
698
+ h(se, {
699
+ "page-size": g.pageSize,
700
+ placements: g.signingPlacements,
701
+ "selected-id": g.selectedSigningPlacementId,
702
+ zoom: W.value,
703
+ readonly: g.readonly,
704
+ disabled: g.disabled,
705
+ onSelect: t[0] ||= (e) => D("signing-placement-select", e),
706
+ onMove: t[1] ||= (e) => D("signing-placement-move", e),
707
+ onRemove: t[2] ||= (e) => D("signing-placement-remove", e)
708
+ }, null, 8, [
709
+ "page-size",
710
+ "placements",
711
+ "selected-id",
712
+ "zoom",
713
+ "readonly",
714
+ "disabled"
715
+ ])
716
+ ], 36)], 6)], 4));
648
717
  }
649
718
  });
650
719
  //#endregion
651
- export { w as default };
720
+ export { T as default };