@guodun/antdv 1.7.12 → 1.7.14
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.
- package/dist/es/components/contract-signing-location/src/ContractSigningLocation.vue.mjs +373 -295
- package/dist/es/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.mjs +219 -202
- package/dist/es/components/contract-signing-location/src/ContractSigningTemplatePage.vue.mjs +18 -18
- package/dist/es/components/contract-signing-location/src/template-source.mjs +62 -49
- package/dist/es/components/index.mjs +1 -0
- package/dist/es/components/pro-contract-template-designer/index.mjs +1 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.mjs +37 -42
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererPage.vue.mjs +69 -55
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.mjs +278 -270
- package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +344 -343
- package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +1025 -964
- package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.mjs +120 -74
- package/dist/es/components/pro-contract-template-designer/src/SigningLayoutCustomModal.vue.mjs +72 -59
- package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +133 -132
- package/dist/es/components/pro-contract-template-designer/src/utils/contract-layout-check.mjs +239 -0
- package/dist/es/components/pro-contract-template-designer/src/utils/contract-print-document.mjs +95 -71
- package/dist/es/components/pro-contract-template-designer/src/utils/page-decorations.mjs +67 -76
- package/dist/es/components/pro-contract-template-designer/src/utils/signing-layout-presets.mjs +77 -61
- package/dist/es/components/pro-contract-template-designer/src/utils/template-renderer.mjs +96 -83
- package/dist/es/components/pro-contract-template-designer/src/utils/template-variable-render.mjs +23 -15
- package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
- package/dist/es/contract-print-css/index.mjs +134 -30
- package/dist/es/contract-print.mjs +2 -0
- package/dist/es/index.mjs +21 -20
- package/dist/lib/components/contract-signing-location/src/ContractSigningLocation.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/ContractSigningTemplatePage.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/template-source.cjs +1 -1
- package/dist/lib/components/index.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/index.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererPage.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/DesignerPage.vue.cjs +2 -2
- package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/SigningLayoutCustomModal.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +4 -4
- package/dist/lib/components/pro-contract-template-designer/src/utils/contract-layout-check.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/utils/contract-print-document.cjs +50 -28
- package/dist/lib/components/pro-contract-template-designer/src/utils/page-decorations.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/utils/signing-layout-presets.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/utils/template-renderer.cjs +5 -5
- package/dist/lib/components/pro-contract-template-designer/src/utils/template-variable-render.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
- package/dist/lib/contract-print-css/index.cjs +74 -23
- package/dist/lib/contract-print.cjs +1 -0
- package/dist/lib/index.cjs +1 -1
- package/dist/theme/icon.css +1 -1
- package/dist/theme/index.css +1 -1
- package/dist/types/components/contract-signing-location/src/ContractSigningLocation.vue.d.ts +9 -0
- package/dist/types/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.d.ts +7 -0
- package/dist/types/components/contract-signing-location/src/template-source.d.ts +6 -0
- package/dist/types/components/pro-contract-template-designer/index.d.ts +1 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.d.ts +2 -0
- package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.d.ts +5 -1
- package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.d.ts +7 -2
- package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +2 -2
- package/dist/types/components/pro-contract-template-designer/src/types.d.ts +36 -0
- package/dist/types/components/pro-contract-template-designer/src/utils/contract-layout-check.d.ts +104 -0
- package/dist/types/components/pro-contract-template-designer/src/utils/contract-print-document.d.ts +4 -1
- package/dist/types/components/pro-contract-template-designer/src/utils/page-decorations.d.ts +2 -8
- package/dist/types/components/pro-contract-template-designer/src/utils/signing-layout-presets.d.ts +9 -0
- package/dist/types/components/pro-contract-template-designer/src/utils/template-renderer.d.ts +6 -1
- package/dist/types/contract-print-css/index.d.ts +70 -0
- package/dist/types/contract-print.d.ts +2 -0
- package/package.json +14 -2
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
|
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
|
|
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
|
|
13
|
-
import
|
|
14
|
-
import { scrollCaretIntoCanvas as
|
|
15
|
-
import { computed as p, createBlock as
|
|
16
|
-
import { Modal as
|
|
17
|
-
import { EditorContent as
|
|
18
|
-
import { generateHTML as
|
|
19
|
-
import { CellSelection as b, deleteColumn as
|
|
20
|
-
import { NodeSelection as x, Selection as
|
|
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
|
|
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:
|
|
75
|
-
let
|
|
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
|
|
78
|
+
return N && !M;
|
|
79
|
+
}
|
|
80
|
+
function R() {
|
|
81
|
+
return k || !!B.value?.view.composing;
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function Me(e) {
|
|
83
84
|
let t = e.filter(Boolean).join("、");
|
|
84
85
|
return typeof window > "u" ? !1 : new Promise((e) => {
|
|
85
|
-
|
|
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
|
|
96
|
-
processImageFile:
|
|
97
|
-
confirmExternalFontPaste:
|
|
98
|
-
getZoom: () => Math.max(.1,
|
|
99
|
-
}),
|
|
100
|
-
content:
|
|
101
|
-
editable: !
|
|
102
|
-
extensions:
|
|
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 =
|
|
109
|
-
return i &&
|
|
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: () => (
|
|
113
|
-
compositionend: () => (
|
|
114
|
-
if (
|
|
115
|
-
if (
|
|
116
|
-
let e =
|
|
117
|
-
|
|
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
|
-
|
|
120
|
+
T("page-update", q()), T("composition-end", w.page.id);
|
|
120
121
|
}
|
|
121
122
|
}, 0), !1),
|
|
122
123
|
contextmenu: (e, t) => {
|
|
123
|
-
if (
|
|
124
|
-
let n =
|
|
125
|
-
if (n) return t.preventDefault(),
|
|
126
|
-
pageId:
|
|
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 =
|
|
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 ||
|
|
136
|
-
pageId:
|
|
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) : (
|
|
140
|
-
pageId:
|
|
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) =>
|
|
146
|
-
dragend: () => (
|
|
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 (
|
|
149
|
+
if (E.value) return t.preventDefault(), t.stopPropagation(), !0;
|
|
149
150
|
let n = t.dataTransfer?.getData(S);
|
|
150
|
-
return !n || n ===
|
|
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 (
|
|
155
|
-
let n =
|
|
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 =
|
|
159
|
+
let r = n.state.selection, i = Qe();
|
|
159
160
|
if (i) {
|
|
160
161
|
let e = n.view.coordsAtPos(r.from);
|
|
161
|
-
return
|
|
162
|
-
pageId:
|
|
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 =
|
|
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
|
|
179
|
-
pageId:
|
|
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
|
|
186
|
-
pageId:
|
|
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) =>
|
|
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")) && (
|
|
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
|
-
|
|
198
|
-
...
|
|
199
|
-
contentHtml:
|
|
200
|
-
contentJson:
|
|
201
|
-
}),
|
|
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
|
-
|
|
205
|
+
T("editor-focus", w.page.id), G();
|
|
205
206
|
},
|
|
206
|
-
onBlur:
|
|
207
|
-
onSelectionUpdate:
|
|
207
|
+
onBlur: G,
|
|
208
|
+
onSelectionUpdate: G,
|
|
208
209
|
onMount: () => {
|
|
209
|
-
|
|
210
|
+
I = F;
|
|
210
211
|
},
|
|
211
212
|
onCreate: ({ editor: e }) => {
|
|
212
|
-
if (
|
|
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 =
|
|
215
|
-
e.commands.setContent(
|
|
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
|
-
|
|
218
|
+
N = !0, e.on("contract-word-paste", V), G(), T("editor-ready", w.page.id);
|
|
218
219
|
}
|
|
219
|
-
}), { findText:
|
|
220
|
-
editor: () =>
|
|
221
|
-
readonly: () =>
|
|
220
|
+
}), { findText: Ne, revealSearchMatch: Pe, replaceSearchMatches: Fe, focusHeading: Ie } = c({
|
|
221
|
+
editor: () => B.value,
|
|
222
|
+
readonly: () => E.value,
|
|
222
223
|
search: () => ({
|
|
223
|
-
query:
|
|
224
|
-
matchCase:
|
|
225
|
-
activeMatch:
|
|
224
|
+
query: w.searchQuery,
|
|
225
|
+
matchCase: w.searchMatchCase,
|
|
226
|
+
activeMatch: w.activeSearchMatch
|
|
226
227
|
})
|
|
227
228
|
});
|
|
228
|
-
function
|
|
229
|
-
|
|
229
|
+
function V(e) {
|
|
230
|
+
T("word-paste", e);
|
|
230
231
|
}
|
|
231
|
-
function
|
|
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
|
|
237
|
-
if (!
|
|
238
|
-
let { from: e, to: t } =
|
|
239
|
-
return
|
|
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
|
|
242
|
-
let e =
|
|
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) >
|
|
246
|
-
let i = Math.abs(r.left - n.left) /
|
|
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
|
|
253
|
-
let e =
|
|
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
|
|
267
|
-
let e =
|
|
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
|
|
280
|
+
function He(e) {
|
|
280
281
|
return e.key === "ContextMenu" || e.shiftKey && e.key === "F10";
|
|
281
282
|
}
|
|
282
|
-
function
|
|
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
|
|
289
|
-
let n =
|
|
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
|
|
294
|
+
if (!(!n || typeof r != "number")) return H(n.state.doc.resolve(r));
|
|
294
295
|
}
|
|
295
|
-
function
|
|
296
|
-
let e =
|
|
297
|
-
if (e) return
|
|
296
|
+
function We() {
|
|
297
|
+
let e = B.value;
|
|
298
|
+
if (e) return H(e.state.selection.$from);
|
|
298
299
|
}
|
|
299
|
-
function
|
|
300
|
-
let r =
|
|
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 =
|
|
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
|
|
307
|
-
let e =
|
|
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
|
|
326
|
-
let e =
|
|
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
|
|
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
|
|
341
|
-
let t =
|
|
341
|
+
function U(e) {
|
|
342
|
+
let t = B.value;
|
|
342
343
|
if (!t) return 0;
|
|
343
|
-
let n =
|
|
344
|
-
r =
|
|
344
|
+
let n = Je(t.state.doc), r = n, i = (e) => {
|
|
345
|
+
r = Je(e.doc);
|
|
345
346
|
};
|
|
346
|
-
return e === "delete-table-row" ?
|
|
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
|
|
349
|
-
let t =
|
|
350
|
-
|
|
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 ?
|
|
355
|
-
leadingText:
|
|
355
|
+
selectionWidth: n ? ze() : void 0,
|
|
356
|
+
leadingText: Ve()
|
|
356
357
|
});
|
|
357
358
|
}
|
|
358
|
-
function
|
|
359
|
-
|
|
360
|
-
pageId:
|
|
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
|
|
366
|
-
|
|
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
|
|
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
|
|
383
|
-
let e =
|
|
384
|
-
if (e instanceof x) return
|
|
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
|
|
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" &&
|
|
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
|
|
396
|
-
|
|
396
|
+
function et(e) {
|
|
397
|
+
T("editor-context-menu", {
|
|
397
398
|
type: "table",
|
|
398
399
|
...e,
|
|
399
|
-
capabilities:
|
|
400
|
-
activeAlignment:
|
|
400
|
+
capabilities: Ke(),
|
|
401
|
+
activeAlignment: qe(),
|
|
401
402
|
affectedVariableCounts: {
|
|
402
|
-
deleteRow:
|
|
403
|
-
deleteColumn:
|
|
404
|
-
deleteTable:
|
|
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
|
|
409
|
+
function tt(e) {
|
|
409
410
|
return typeof e == "number" && Number.isInteger(e) && e >= 1 && e <= 6;
|
|
410
411
|
}
|
|
411
|
-
function
|
|
412
|
-
let e =
|
|
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" &&
|
|
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
|
|
428
|
-
let e =
|
|
428
|
+
function rt() {
|
|
429
|
+
let e = nt();
|
|
429
430
|
return e.length === 1 && e[0] !== "paragraph" ? e[0] : void 0;
|
|
430
431
|
}
|
|
431
|
-
function
|
|
432
|
-
return
|
|
432
|
+
function it() {
|
|
433
|
+
return nt().length > 1;
|
|
433
434
|
}
|
|
434
|
-
function
|
|
435
|
-
return ["center", "right"].find((e) =>
|
|
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
|
|
438
|
-
let e =
|
|
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:
|
|
450
|
-
hasMixedBlockFormats:
|
|
451
|
-
textAlign:
|
|
450
|
+
currentHeadingLevel: rt(),
|
|
451
|
+
hasMixedBlockFormats: it(),
|
|
452
|
+
textAlign: at(),
|
|
452
453
|
fontFamily: typeof n.fontFamily == "string" ? n.fontFamily : void 0,
|
|
453
|
-
fontSize:
|
|
454
|
+
fontSize: Le(n.fontSize),
|
|
454
455
|
textColor: typeof n.color == "string" ? n.color : void 0,
|
|
455
|
-
selectionText:
|
|
456
|
-
selectedContentImage:
|
|
456
|
+
selectionText: Re(),
|
|
457
|
+
selectedContentImage: Qe()
|
|
457
458
|
};
|
|
458
459
|
}
|
|
459
|
-
function
|
|
460
|
-
|
|
460
|
+
function G() {
|
|
461
|
+
T("editor-state-change", w.page.id, ot());
|
|
461
462
|
}
|
|
462
|
-
y(
|
|
463
|
-
|
|
464
|
-
}), y(() =>
|
|
465
|
-
|
|
463
|
+
y(E, (e) => {
|
|
464
|
+
B.value?.setEditable(!e), G();
|
|
465
|
+
}), y(() => w.page.contentHtml, (e) => {
|
|
466
|
+
st(e);
|
|
466
467
|
});
|
|
467
|
-
function
|
|
468
|
-
if (!
|
|
469
|
-
|
|
468
|
+
function st(e) {
|
|
469
|
+
if (!B.value || e === $()) {
|
|
470
|
+
j = void 0;
|
|
470
471
|
return;
|
|
471
472
|
}
|
|
472
|
-
if (
|
|
473
|
-
|
|
473
|
+
if (R()) {
|
|
474
|
+
j = e;
|
|
474
475
|
return;
|
|
475
476
|
}
|
|
476
|
-
|
|
477
|
+
B.value.commands.setContent(e || "<p></p>", { emitUpdate: !1 }), G();
|
|
477
478
|
}
|
|
478
|
-
let
|
|
479
|
-
let
|
|
479
|
+
let ct = p(() => {
|
|
480
|
+
let { top: t, bottom: n } = e(r(w.pageDecorations), w.pageIndex + 1);
|
|
480
481
|
return {
|
|
481
|
-
width: `${
|
|
482
|
-
height: `${
|
|
483
|
-
paddingTop: `${
|
|
484
|
-
paddingBottom: `${
|
|
485
|
-
"--gd-contract-page-content-height": `${Math.max(120,
|
|
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
|
-
}),
|
|
488
|
-
width: `${Math.ceil((
|
|
489
|
-
height: `${Math.ceil((
|
|
490
|
-
})),
|
|
491
|
-
function
|
|
492
|
-
if (
|
|
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(),
|
|
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 !==
|
|
503
|
+
n && n !== w.page.id && (e.preventDefault(), e.stopPropagation(), T("variable-move-blocked", w.page.id));
|
|
503
504
|
}
|
|
504
|
-
function
|
|
505
|
-
let n =
|
|
506
|
-
return n ? (
|
|
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
|
|
509
|
-
let n =
|
|
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
|
-
}),
|
|
515
|
+
}), q();
|
|
515
516
|
}
|
|
516
|
-
function
|
|
517
|
-
let t =
|
|
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),
|
|
527
|
+
return a.setSelection(x.create(a.doc, n.from)), t.view.dispatch(a), q();
|
|
527
528
|
}
|
|
528
|
-
function
|
|
529
|
-
let e =
|
|
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
|
|
536
|
+
function q() {
|
|
536
537
|
return {
|
|
537
|
-
...
|
|
538
|
-
pageSize:
|
|
538
|
+
...w.page,
|
|
539
|
+
pageSize: dt.value,
|
|
539
540
|
contentHtml: $(),
|
|
540
|
-
contentJson: Q() ??
|
|
541
|
+
contentJson: Q() ?? w.page.contentJson
|
|
541
542
|
};
|
|
542
543
|
}
|
|
543
|
-
function
|
|
544
|
-
if (!
|
|
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 !
|
|
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
|
|
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
|
|
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
|
|
567
|
-
return
|
|
567
|
+
function yt(e) {
|
|
568
|
+
return xe(J(e), z);
|
|
568
569
|
}
|
|
569
|
-
function
|
|
570
|
-
if (
|
|
571
|
-
let
|
|
572
|
-
return Math.max(120,
|
|
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
|
|
575
|
-
if (!
|
|
576
|
-
let
|
|
577
|
-
return Math.max(120,
|
|
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
|
|
580
|
-
let e =
|
|
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 =
|
|
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
|
|
602
|
-
if (!
|
|
603
|
-
let e =
|
|
604
|
-
if (e.some((e) => e.top + e.height > t + 1)) return
|
|
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
|
|
607
|
-
return !!
|
|
607
|
+
function St() {
|
|
608
|
+
return !!Y();
|
|
608
609
|
}
|
|
609
|
-
function
|
|
610
|
-
let e =
|
|
611
|
-
if (!e || !
|
|
612
|
-
let t =
|
|
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
|
|
624
|
-
return (!e ||
|
|
624
|
+
function wt(e) {
|
|
625
|
+
return (!e || ge(e) === je) && !ke && !R() && !B.value?.view.hasFocus() && vt(Q()?.content);
|
|
625
626
|
}
|
|
626
|
-
function
|
|
627
|
-
if (!
|
|
628
|
-
let e =
|
|
627
|
+
function Tt() {
|
|
628
|
+
if (!B.value || !L() || R()) return;
|
|
629
|
+
let e = Y();
|
|
629
630
|
if (!e) return;
|
|
630
|
-
let t =
|
|
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(
|
|
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
|
|
645
|
+
let ne = F + 1;
|
|
645
646
|
t.view.dispatch(a);
|
|
646
|
-
let
|
|
647
|
+
let u = l && {
|
|
647
648
|
selection: l,
|
|
648
649
|
storedMarks: i,
|
|
649
|
-
isCurrent: () => !
|
|
650
|
+
isCurrent: () => !M && B.value === t && !t.isDestroyed && !E.value && !R() && t.view.hasFocus() && F === ne
|
|
650
651
|
};
|
|
651
652
|
return {
|
|
652
|
-
page:
|
|
653
|
+
page: q(),
|
|
653
654
|
overflowContent: e.overflowContent,
|
|
654
|
-
overflowHtml:
|
|
655
|
-
selection:
|
|
655
|
+
overflowHtml: yt(e.overflowContent),
|
|
656
|
+
selection: u
|
|
656
657
|
};
|
|
657
658
|
}
|
|
658
|
-
function
|
|
659
|
-
if (!
|
|
660
|
-
let t =
|
|
661
|
-
|
|
662
|
-
let o =
|
|
663
|
-
return t.view.dispatch(a),
|
|
664
|
-
}
|
|
665
|
-
function
|
|
666
|
-
let n =
|
|
667
|
-
if (
|
|
668
|
-
let i =
|
|
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() ||
|
|
670
|
-
}
|
|
671
|
-
function
|
|
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
|
|
681
|
-
if (!
|
|
682
|
-
let n =
|
|
683
|
-
return
|
|
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 ?
|
|
689
|
+
}), r && a?.(e), r)), Z(), r ? q() : void 0;
|
|
689
690
|
}
|
|
690
|
-
function
|
|
691
|
-
if (!
|
|
691
|
+
function At(e) {
|
|
692
|
+
if (!B.value) return;
|
|
692
693
|
let t = 0;
|
|
693
|
-
return
|
|
694
|
-
let a =
|
|
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 ?
|
|
700
|
+
}), t ? q() : void 0;
|
|
700
701
|
}
|
|
701
|
-
function
|
|
702
|
-
|
|
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(
|
|
706
|
+
if (e) return Array.from(D.value?.querySelectorAll("[data-template-variable]") ?? []).find((t) => t.dataset.key === e);
|
|
706
707
|
}
|
|
707
|
-
function
|
|
708
|
-
|
|
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
|
-
}),
|
|
715
|
+
}), B.value?.commands.focus(), !0) : !1;
|
|
715
716
|
}
|
|
716
717
|
function Z() {
|
|
717
|
-
|
|
718
|
+
jt(), X(w.selectedVariableKey)?.classList.add("is-active");
|
|
718
719
|
}
|
|
719
|
-
function
|
|
720
|
-
let r =
|
|
721
|
-
if (!r || !
|
|
722
|
-
let
|
|
723
|
-
r.headingLevel ?
|
|
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([() =>
|
|
726
|
-
|
|
726
|
+
y([() => w.selectedVariableKey, () => w.variables], () => {
|
|
727
|
+
de(Z);
|
|
727
728
|
}, {
|
|
728
729
|
deep: !0,
|
|
729
730
|
flush: "post"
|
|
730
731
|
});
|
|
731
|
-
function
|
|
732
|
-
|
|
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
|
|
735
|
-
|
|
735
|
+
function Ft() {
|
|
736
|
+
B.value?.commands.focus();
|
|
736
737
|
}
|
|
737
738
|
function Q() {
|
|
738
|
-
return
|
|
739
|
+
return B.value ? O.read(B.value).getJSON() : w.page.contentJson;
|
|
739
740
|
}
|
|
740
741
|
function $() {
|
|
741
|
-
return
|
|
742
|
+
return B.value ? O.read(B.value).getHTML() : w.page.contentHtml;
|
|
742
743
|
}
|
|
743
|
-
function
|
|
744
|
-
let t =
|
|
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
|
|
751
|
-
|
|
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
|
|
758
|
-
|
|
759
|
-
}),
|
|
760
|
-
findText:
|
|
761
|
-
revealSearchMatch:
|
|
762
|
-
replaceSearchMatches:
|
|
763
|
-
focusHeading:
|
|
764
|
-
focus:
|
|
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:
|
|
768
|
-
getEditorState:
|
|
769
|
-
getTableCommandCapabilities:
|
|
770
|
-
getAffectedVariableCount:
|
|
771
|
-
insertVariable:
|
|
772
|
-
insertContentImage:
|
|
773
|
-
updateSelectedContentImage:
|
|
774
|
-
getSelectionRange:
|
|
775
|
-
getSelectionViewportRect:
|
|
776
|
-
requestTextContextMenu:
|
|
777
|
-
isReady:
|
|
778
|
-
isComposing:
|
|
779
|
-
hasOverflowContent:
|
|
780
|
-
hasOverflowSelection:
|
|
781
|
-
isUntouchedPaginationBlank:
|
|
782
|
-
updateVariable:
|
|
783
|
-
removeVariable:
|
|
784
|
-
splitOverflowContent:
|
|
785
|
-
prependContent:
|
|
786
|
-
restorePaginationSelection:
|
|
787
|
-
runCommand:
|
|
788
|
-
scrollIntoField:
|
|
789
|
-
scrollIntoVariable:
|
|
790
|
-
scrollIntoPage:
|
|
791
|
-
}), (e, t) => (
|
|
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(
|
|
794
|
+
style: g(lt.value)
|
|
794
795
|
}, [m("div", {
|
|
795
|
-
class:
|
|
796
|
-
style: g(
|
|
797
|
-
}, [m("header",
|
|
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:
|
|
800
|
+
ref: D,
|
|
800
801
|
class: "gd-contract-template-designer__page",
|
|
801
|
-
style: g(
|
|
802
|
-
onLoadCapture: t[0] ||= (e) =>
|
|
803
|
-
onDragover: t[1] ||=
|
|
804
|
-
onDrop:
|
|
805
|
-
onClick: t[2] ||= (e) =>
|
|
806
|
-
}, [
|
|
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(
|
|
817
|
+
]), v(B) ? (me(), se(v(ye), {
|
|
817
818
|
key: 0,
|
|
818
819
|
class: "gd-contract-template-page__content",
|
|
819
|
-
editor: v(
|
|
820
|
-
}, null, 8, ["editor"])) :
|
|
820
|
+
editor: v(B)
|
|
821
|
+
}, null, 8, ["editor"])) : ce("", !0)], 36)], 6)], 4));
|
|
821
822
|
}
|
|
822
823
|
});
|
|
823
824
|
//#endregion
|
|
824
|
-
export {
|
|
825
|
+
export { C as default };
|