@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
package/dist/es/components/pro-contract-template-designer/src/composables/use-auto-pagination.mjs
CHANGED
|
@@ -1,106 +1,165 @@
|
|
|
1
1
|
import { createBlankPage as e } from "./use-template-designer.mjs";
|
|
2
|
-
import { nextTick as t,
|
|
2
|
+
import { nextTick as t, toRaw as n, watch as r } from "vue";
|
|
3
3
|
//#region src/components/pro-contract-template-designer/src/composables/use-auto-pagination.ts
|
|
4
|
-
function
|
|
4
|
+
function i(e) {
|
|
5
5
|
return {
|
|
6
6
|
type: "doc",
|
|
7
7
|
content: e.length ? e : [{ type: "paragraph" }]
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function a(e) {
|
|
11
11
|
return e.replace(/<p>\s*(<br>)?\s*<\/p>/gi, "").trim().length === 0;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
let
|
|
13
|
+
function o(e, t, n) {
|
|
14
|
+
let r = e.contentJson?.content, o = [...t, ...r?.length ? r : []], s = a(e.contentHtml || "") ? "" : e.contentHtml;
|
|
15
15
|
return {
|
|
16
16
|
...e,
|
|
17
17
|
contentHtml: `${n}${s}`,
|
|
18
|
-
contentJson:
|
|
18
|
+
contentJson: i(o)
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
let
|
|
23
|
-
e &&
|
|
21
|
+
function s(s) {
|
|
22
|
+
let c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = !1, p = !1, m = 0, h, g, _ = r(s.readonlyState, (e) => {
|
|
23
|
+
e && T();
|
|
24
24
|
}, { flush: "sync" });
|
|
25
|
-
function
|
|
26
|
-
|
|
25
|
+
function v(e) {
|
|
26
|
+
let t = /* @__PURE__ */ new Set();
|
|
27
|
+
for (let [r, i] of Array.from(d)) {
|
|
28
|
+
if (e && i.sourceId !== e) continue;
|
|
29
|
+
d.delete(r);
|
|
30
|
+
let o = s.templateValue.value.pages.find((e) => e.id === r), c = o?.contentJson?.content, l = !c?.length || c.length === 1 && c[0].type === "paragraph" && !c[0].content?.length, u = s.pageRefs.get(r), f = u?.isUntouchedPaginationBlank?.(i.page);
|
|
31
|
+
i.generation === m && o && (n(o) === i.page || f === !0) && l && a(o.contentHtml || "") && !u?.isComposing?.() && f !== !1 && t.add(r);
|
|
32
|
+
}
|
|
33
|
+
let r = s.templateValue.value.pages;
|
|
34
|
+
if (r.length && r.every((e) => t.has(e.id)) && t.delete(r[0].id), t.size) {
|
|
35
|
+
for (let e of Array.from(t)) c.delete(e), l.delete(e), u.delete(e);
|
|
36
|
+
s.applyPagesChange(s.templateValue.value.pages.filter((e) => !t.has(e.id))), y();
|
|
37
|
+
}
|
|
38
|
+
return t;
|
|
27
39
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
function y() {
|
|
41
|
+
s.pendingPaginationPageId.value = c.values().next().value ?? l.values().next().value ?? "";
|
|
42
|
+
}
|
|
43
|
+
function b() {
|
|
44
|
+
f || p || s.isAutoPaginating.value || s.readonlyState.value || (f = !0, t(() => {
|
|
45
|
+
f = !1, p || w();
|
|
31
46
|
}));
|
|
32
47
|
}
|
|
33
|
-
function
|
|
34
|
-
if (!(
|
|
35
|
-
|
|
36
|
-
for (let t of Array.from(
|
|
37
|
-
let n =
|
|
38
|
-
|
|
48
|
+
function x(e = s.activePageId.value) {
|
|
49
|
+
if (!(p || s.readonlyState.value || !e)) {
|
|
50
|
+
l.delete(e);
|
|
51
|
+
for (let t of Array.from(l)) {
|
|
52
|
+
let n = s.templateValue.value.pages.findIndex((e) => e.id === t);
|
|
53
|
+
s.templateValue.value.pages[n + 1]?.id === e && (l.delete(t), c.add(t));
|
|
39
54
|
}
|
|
40
|
-
|
|
55
|
+
c.add(e), y(), b();
|
|
41
56
|
}
|
|
42
57
|
}
|
|
43
|
-
function
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
function S() {
|
|
59
|
+
if (p || s.readonlyState.value) return;
|
|
60
|
+
let e = m, t = new Set(s.templateValue.value.pages.map((e) => e.id));
|
|
61
|
+
for (let n of Array.from(d.values())) if (t.has(n.sourceId) || v(n.sourceId), p || e !== m || s.readonlyState.value) return;
|
|
62
|
+
c.clear(), l.clear();
|
|
63
|
+
let n = new Set(s.templateValue.value.pages.map((e) => e.id));
|
|
64
|
+
for (let e of Array.from(u.keys())) n.has(e) || u.delete(e);
|
|
65
|
+
for (let e of Array.from(n)) c.add(e);
|
|
66
|
+
y(), b();
|
|
49
67
|
}
|
|
50
|
-
function
|
|
68
|
+
function C() {
|
|
51
69
|
return new Promise((e) => {
|
|
52
|
-
|
|
53
|
-
|
|
70
|
+
g = e, h = setTimeout(() => {
|
|
71
|
+
h = void 0, g = void 0, e();
|
|
54
72
|
}, 0);
|
|
55
73
|
});
|
|
56
74
|
}
|
|
57
|
-
async function
|
|
58
|
-
if (
|
|
59
|
-
let n =
|
|
60
|
-
|
|
61
|
-
let
|
|
75
|
+
async function w() {
|
|
76
|
+
if (p || s.readonlyState.value || s.isAutoPaginating.value) return;
|
|
77
|
+
let n = m;
|
|
78
|
+
s.isAutoPaginating.value = !0;
|
|
79
|
+
let r = performance.now();
|
|
62
80
|
try {
|
|
63
|
-
for (;
|
|
64
|
-
let t =
|
|
65
|
-
|
|
66
|
-
let
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
81
|
+
for (; c.size && !p && n === m && !s.readonlyState.value && (await t(), !(p || n !== m || s.readonlyState.value));) {
|
|
82
|
+
let t = c.values().next().value;
|
|
83
|
+
c.delete(t);
|
|
84
|
+
let a = s.templateValue.value.pages, f = a.findIndex((e) => e.id === t), h = s.pageRefs.get(t), g = a[f + 1], _ = g && s.pageRefs.get(g.id);
|
|
85
|
+
if (f < 0) {
|
|
86
|
+
u.delete(t), v(t);
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (!h || h.isReady?.() === !1 || h.isComposing?.() || _?.isComposing?.()) {
|
|
90
|
+
l.add(t);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
let b = u.get(t);
|
|
94
|
+
if (b && (u.delete(t), h.restorePaginationSelection?.(b.selection, b.contentHtml), p || n !== m || s.readonlyState.value)) break;
|
|
95
|
+
if (g && d.get(g.id)?.sourceId === t && a.length > s.normalizedMaxPages.value) {
|
|
96
|
+
let e = v(t);
|
|
97
|
+
if (p || n !== m || s.readonlyState.value) break;
|
|
98
|
+
if (e.has(g.id)) {
|
|
99
|
+
c.add(t), y();
|
|
70
100
|
continue;
|
|
71
101
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
102
|
+
}
|
|
103
|
+
if ((!_ || _.isReady?.() === !1) && (g || a.length < s.normalizedMaxPages.value) && h.hasOverflowSelection?.() === !0) {
|
|
104
|
+
if (l.add(t), !g) {
|
|
105
|
+
let r = e(a.length + 1, s.getPageSize(a[f]));
|
|
106
|
+
d.set(r.id, {
|
|
107
|
+
sourceId: t,
|
|
108
|
+
generation: n,
|
|
109
|
+
page: r
|
|
110
|
+
}), s.applyPagesChange([...s.templateValue.value.pages, r]);
|
|
111
|
+
}
|
|
112
|
+
y();
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (Array.from(d.values()).some((e) => e.sourceId === t) && !h.hasOverflowContent()) {
|
|
116
|
+
if (v(t), p || n !== m || s.readonlyState.value) break;
|
|
117
|
+
y();
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (!g && a.length >= s.normalizedMaxPages.value) h.hasOverflowContent() && s.notifyPageLimit("auto-pagination");
|
|
121
|
+
else {
|
|
122
|
+
let t = s.captureViewport?.();
|
|
123
|
+
try {
|
|
124
|
+
let t = h.splitOverflowContent();
|
|
75
125
|
if (t) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
let
|
|
79
|
-
s.
|
|
126
|
+
if (p || n !== m || s.readonlyState.value) break;
|
|
127
|
+
g && d.delete(g.id);
|
|
128
|
+
let r = g ? _?.prependContent(t.overflowContent) ?? o(g, t.overflowContent, t.overflowHtml) : e(a.length + 1, s.getPageSize(t.page), t.overflowHtml, i(t.overflowContent));
|
|
129
|
+
if (p || n !== m || s.readonlyState.value) break;
|
|
130
|
+
let h = s.templateValue.value.pages.slice(), v = h[f];
|
|
131
|
+
if (v.contentHtml === a[f].contentHtml && v.contentJson === a[f].contentJson && (h[f] = t.page), g ? h[f + 1] = r : h.push(r), s.applyPagesChange(h), p || n !== m || s.readonlyState.value || (t.selection && (_?.isReady?.() !== !1 && _?.restorePaginationSelection ? _.restorePaginationSelection(t.selection, r.contentHtml) : u.set(r.id, {
|
|
132
|
+
selection: t.selection,
|
|
133
|
+
contentHtml: r.contentHtml
|
|
134
|
+
})), p || n !== m || s.readonlyState.value)) break;
|
|
135
|
+
let y = r.id;
|
|
136
|
+
l.delete(y), c.add(y);
|
|
80
137
|
}
|
|
138
|
+
} finally {
|
|
139
|
+
t?.();
|
|
81
140
|
}
|
|
82
|
-
m(), o.size && performance.now() - c >= (i.timeBudgetMs ?? 8) && (await v(), c = performance.now());
|
|
83
141
|
}
|
|
142
|
+
y(), c.size && performance.now() - r >= (s.timeBudgetMs ?? 8) && (await C(), r = performance.now());
|
|
84
143
|
}
|
|
85
144
|
} finally {
|
|
86
|
-
|
|
145
|
+
s.isAutoPaginating.value = !1, y(), c.size && b();
|
|
87
146
|
}
|
|
88
147
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
148
|
+
function T() {
|
|
149
|
+
v(), m += 1, u.clear(), c.clear(), l.clear(), h !== void 0 && clearTimeout(h), h = void 0, g?.(), g = void 0, y();
|
|
91
150
|
}
|
|
92
|
-
function
|
|
93
|
-
|
|
151
|
+
function E() {
|
|
152
|
+
_(), p = !0, T();
|
|
94
153
|
}
|
|
95
154
|
return {
|
|
96
|
-
scheduleAutoPaginate:
|
|
97
|
-
scheduleFullPagination:
|
|
98
|
-
runAutoPagination:
|
|
99
|
-
resetPagination:
|
|
100
|
-
disposePagination:
|
|
101
|
-
createDocContent:
|
|
102
|
-
prependOverflowToPageData:
|
|
155
|
+
scheduleAutoPaginate: x,
|
|
156
|
+
scheduleFullPagination: S,
|
|
157
|
+
runAutoPagination: w,
|
|
158
|
+
resetPagination: T,
|
|
159
|
+
disposePagination: E,
|
|
160
|
+
createDocContent: i,
|
|
161
|
+
prependOverflowToPageData: o
|
|
103
162
|
};
|
|
104
163
|
}
|
|
105
164
|
//#endregion
|
|
106
|
-
export {
|
|
165
|
+
export { s as useAutoPagination };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { NodeSelection as e } from "@tiptap/pm/state";
|
|
2
|
+
var t = ".gd-contract-template-designer__editor-prose";
|
|
3
|
+
function n(t, n, r) {
|
|
4
|
+
let i = n();
|
|
5
|
+
if (!i) return !1;
|
|
6
|
+
let a;
|
|
7
|
+
try {
|
|
8
|
+
let { selection: n } = t.state;
|
|
9
|
+
if (n instanceof e) {
|
|
10
|
+
let e = t.nodeDOM(n.from);
|
|
11
|
+
if (!(e instanceof HTMLElement)) return !1;
|
|
12
|
+
a = e.getBoundingClientRect();
|
|
13
|
+
} else a = t.coordsAtPos(n.head, 1);
|
|
14
|
+
} catch {
|
|
15
|
+
return !1;
|
|
16
|
+
}
|
|
17
|
+
let o = r()?.getBoundingClientRect(), s = o ? Math.min(a.top, o.bottom) : a.top, c = o ? Math.min(a.bottom, o.bottom) : a.bottom, l = i.getBoundingClientRect();
|
|
18
|
+
return s < l.top + 48 ? i.scrollTop -= l.top + 48 - s : c > l.bottom - 48 && (i.scrollTop += c - (l.bottom - 48)), a.left < l.left ? i.scrollLeft -= l.left - a.left : a.right > l.right && (i.scrollLeft += a.right - l.right), !0;
|
|
19
|
+
}
|
|
20
|
+
function r() {
|
|
21
|
+
let e = window.getSelection();
|
|
22
|
+
if (!e?.rangeCount) return;
|
|
23
|
+
let t = e.getRangeAt(0).getBoundingClientRect();
|
|
24
|
+
return t.top || t.bottom ? t.top : (e.focusNode instanceof Element ? e.focusNode : e.focusNode?.parentElement)?.getBoundingClientRect().top;
|
|
25
|
+
}
|
|
26
|
+
function i(e, n = () => !0) {
|
|
27
|
+
if (typeof window > "u" || !e || !n()) return;
|
|
28
|
+
let i = window.getSelection();
|
|
29
|
+
if (!i?.rangeCount || !e.contains(i.focusNode)) return;
|
|
30
|
+
let a = (i.focusNode instanceof Element ? i.focusNode : i.focusNode?.parentElement)?.closest(t), o = r();
|
|
31
|
+
if (o !== void 0) return () => {
|
|
32
|
+
if (n()) try {
|
|
33
|
+
let n = window.getSelection()?.focusNode, i = n instanceof Element ? n : n?.parentElement;
|
|
34
|
+
if (!i || i.closest(t) !== a) return;
|
|
35
|
+
let s = r();
|
|
36
|
+
s !== void 0 && Math.abs(s - o) > .5 && (e.scrollTop += s - o);
|
|
37
|
+
} catch {}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { i as captureCaretViewport, n as scrollCaretIntoCanvas };
|