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