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