@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.
Files changed (23) hide show
  1. package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +395 -325
  2. package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +851 -829
  3. package/dist/es/components/pro-contract-template-designer/src/composables/use-auto-pagination.mjs +122 -63
  4. package/dist/es/components/pro-contract-template-designer/src/utils/caret-viewport.mjs +41 -0
  5. package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
  6. package/dist/es/node_modules/@tiptap/pm/dist/transform/index.mjs +1 -0
  7. package/dist/es/node_modules/prosemirror-transform/dist/index.mjs +161 -67
  8. package/dist/lib/components/pro-contract-template-designer/src/DesignerPage.vue.cjs +2 -2
  9. package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
  10. package/dist/lib/components/pro-contract-template-designer/src/composables/use-auto-pagination.cjs +1 -1
  11. package/dist/lib/components/pro-contract-template-designer/src/utils/caret-viewport.cjs +1 -0
  12. package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
  13. package/dist/lib/node_modules/@tiptap/pm/dist/transform/index.cjs +1 -0
  14. package/dist/lib/node_modules/prosemirror-transform/dist/index.cjs +2 -2
  15. package/dist/theme/icon.css +1 -1
  16. package/dist/theme/index.css +1 -1
  17. package/dist/types/components/pro-contract-template-designer/src/DesignerPage.vue.d.ts +14 -0
  18. package/dist/types/components/pro-contract-template-designer/src/composables/use-auto-pagination.d.ts +17 -0
  19. package/dist/types/components/pro-contract-template-designer/src/utils/caret-viewport.d.ts +18 -0
  20. package/package.json +1 -1
  21. package/dist/theme/dept-selector.css +0 -1
  22. package/dist/theme/pro-selector-group.css +0 -1
  23. package/dist/theme/role-selector.css +0 -1
@@ -1,106 +1,165 @@
1
1
  import { createBlankPage as e } from "./use-template-designer.mjs";
2
- import { nextTick as t, watch as n } from "vue";
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 r(e) {
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 i(e) {
10
+ function a(e) {
11
11
  return e.replace(/<p>\s*(<br>)?\s*<\/p>/gi, "").trim().length === 0;
12
12
  }
13
- function a(e, t, n) {
14
- let a = e.contentJson?.content, o = [...t, ...a?.length ? a : []], s = i(e.contentHtml || "") ? "" : e.contentHtml;
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: r(o)
18
+ contentJson: i(o)
19
19
  };
20
20
  }
21
- function o(i) {
22
- let o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = !1, l = !1, u = 0, d, f, p = n(i.readonlyState, (e) => {
23
- e && b();
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 m() {
26
- i.pendingPaginationPageId.value = o.values().next().value ?? s.values().next().value ?? "";
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 h() {
29
- c || l || i.isAutoPaginating.value || i.readonlyState.value || (c = !0, t(() => {
30
- c = !1, l || y();
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 g(e = i.activePageId.value) {
34
- if (!(l || i.readonlyState.value || !e)) {
35
- s.delete(e);
36
- for (let t of Array.from(s)) {
37
- let n = i.templateValue.value.pages.findIndex((e) => e.id === t);
38
- i.templateValue.value.pages[n + 1]?.id === e && (s.delete(t), o.add(t));
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
- o.add(e), m(), h();
55
+ c.add(e), y(), b();
41
56
  }
42
57
  }
43
- function _() {
44
- if (!(l || i.readonlyState.value)) {
45
- o.clear(), s.clear();
46
- for (let e of i.templateValue.value.pages) o.add(e.id);
47
- m(), h();
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 v() {
68
+ function C() {
51
69
  return new Promise((e) => {
52
- f = e, d = setTimeout(() => {
53
- d = void 0, f = void 0, e();
70
+ g = e, h = setTimeout(() => {
71
+ h = void 0, g = void 0, e();
54
72
  }, 0);
55
73
  });
56
74
  }
57
- async function y() {
58
- if (l || i.readonlyState.value || i.isAutoPaginating.value) return;
59
- let n = u;
60
- i.isAutoPaginating.value = !0;
61
- let c = performance.now();
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 (; o.size && !l && n === u && !i.readonlyState.value && (await t(), !(l || n !== u || i.readonlyState.value));) {
64
- let t = o.values().next().value;
65
- o.delete(t);
66
- let n = i.templateValue.value.pages, l = n.findIndex((e) => e.id === t), u = i.pageRefs.get(t), d = n[l + 1], f = d && i.pageRefs.get(d.id);
67
- if (!(l < 0)) {
68
- if (!u || u.isReady?.() === !1 || u.isComposing?.() || f?.isComposing?.()) {
69
- s.add(t);
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
- if (!d && n.length >= i.normalizedMaxPages.value) u.hasOverflowContent() && i.notifyPageLimit("auto-pagination");
73
- else {
74
- let t = u.splitOverflowContent();
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
- let c = n.slice();
77
- c[l] = t.page, d ? c[l + 1] = f?.prependContent(t.overflowContent) ?? a(d, t.overflowContent, t.overflowHtml) : c.push(e(c.length + 1, i.getPageSize(t.page), t.overflowHtml, r(t.overflowContent))), i.applyPagesChange(c);
78
- let u = c[l + 1].id;
79
- s.delete(u), o.add(u);
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
- i.isAutoPaginating.value = !1, m(), o.size && h();
145
+ s.isAutoPaginating.value = !1, y(), c.size && b();
87
146
  }
88
147
  }
89
- function b() {
90
- u += 1, o.clear(), s.clear(), d !== void 0 && clearTimeout(d), d = void 0, f?.(), f = void 0, m();
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 x() {
93
- p(), l = !0, b();
151
+ function E() {
152
+ _(), p = !0, T();
94
153
  }
95
154
  return {
96
- scheduleAutoPaginate: g,
97
- scheduleFullPagination: _,
98
- runAutoPagination: y,
99
- resetPagination: b,
100
- disposePagination: x,
101
- createDocContent: r,
102
- prependOverflowToPageData: a
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 { o as useAutoPagination };
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 };