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