@guodun/antdv 1.7.5 → 1.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.mjs +152 -146
  2. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererHeader.vue.mjs +45 -37
  3. package/dist/es/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.mjs +266 -264
  4. package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +351 -301
  5. package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +939 -914
  6. package/dist/es/components/pro-contract-template-designer/src/composables/use-auto-pagination.mjs +82 -47
  7. package/dist/es/components/pro-contract-template-designer/src/composables/use-draft-cache-session.mjs +1 -1
  8. package/dist/es/components/pro-contract-template-designer/src/composables/use-page-authoring.mjs +22 -21
  9. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-authoring.mjs +37 -36
  10. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +125 -75
  11. package/dist/es/components/pro-contract-template-designer/src/utils/authoring-search.mjs +34 -13
  12. package/dist/es/components/pro-contract-template-designer/src/utils/document-outline.mjs +24 -1
  13. package/dist/es/components/pro-contract-template-designer/src/utils/editor-snapshot-cache.mjs +15 -0
  14. package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
  15. package/dist/es/index.mjs +21 -21
  16. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.cjs +1 -1
  17. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererHeader.vue.cjs +1 -1
  18. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateSingleRenderer.vue.cjs +1 -1
  19. package/dist/lib/components/pro-contract-template-designer/src/DesignerPage.vue.cjs +2 -2
  20. package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
  21. package/dist/lib/components/pro-contract-template-designer/src/composables/use-auto-pagination.cjs +1 -1
  22. package/dist/lib/components/pro-contract-template-designer/src/composables/use-draft-cache-session.cjs +1 -1
  23. package/dist/lib/components/pro-contract-template-designer/src/composables/use-page-authoring.cjs +1 -1
  24. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-authoring.cjs +1 -1
  25. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +4 -4
  26. package/dist/lib/components/pro-contract-template-designer/src/utils/authoring-search.cjs +1 -1
  27. package/dist/lib/components/pro-contract-template-designer/src/utils/document-outline.cjs +1 -1
  28. package/dist/lib/components/pro-contract-template-designer/src/utils/editor-snapshot-cache.cjs +1 -0
  29. package/dist/lib/components/pro-contract-template-designer/style/index.css +1 -1
  30. package/dist/lib/index.cjs +1 -1
  31. package/dist/theme/icon.css +1 -1
  32. package/dist/theme/index.css +1 -1
  33. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.d.ts +1 -0
  34. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateRendererHeader.vue.d.ts +1 -0
  35. package/dist/types/components/pro-contract-template-designer/src/DesignerPage.vue.d.ts +14 -0
  36. package/dist/types/components/pro-contract-template-designer/src/composables/use-auto-pagination.d.ts +8 -2
  37. package/dist/types/components/pro-contract-template-designer/src/composables/use-draft-cache-session.d.ts +1 -1
  38. package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +10 -1
  39. package/dist/types/components/pro-contract-template-designer/src/utils/authoring-search.d.ts +5 -0
  40. package/dist/types/components/pro-contract-template-designer/src/utils/document-outline.d.ts +6 -0
  41. package/dist/types/components/pro-contract-template-designer/src/utils/editor-snapshot-cache.d.ts +16 -0
  42. package/package.json +1 -1
@@ -1,71 +1,106 @@
1
1
  import { createBlankPage as e } from "./use-template-designer.mjs";
2
- import { nextTick as t } from "vue";
2
+ import { nextTick as t, watch as n } from "vue";
3
3
  //#region src/components/pro-contract-template-designer/src/composables/use-auto-pagination.ts
4
- function n(e) {
4
+ function r(e) {
5
5
  return {
6
6
  type: "doc",
7
7
  content: e.length ? e : [{ type: "paragraph" }]
8
8
  };
9
9
  }
10
- function r(e) {
10
+ function i(e) {
11
11
  return e.replace(/<p>\s*(<br>)?\s*<\/p>/gi, "").trim().length === 0;
12
12
  }
13
- function i(e, t, i) {
14
- let a = e.contentJson?.content, o = [...t, ...a?.length ? a : []], s = r(e.contentHtml || "") ? "" : e.contentHtml;
13
+ function a(e, t, n) {
14
+ let a = e.contentJson?.content, o = [...t, ...a?.length ? a : []], s = i(e.contentHtml || "") ? "" : e.contentHtml;
15
15
  return {
16
16
  ...e,
17
- contentHtml: `${i}${s}`,
18
- contentJson: n(o)
17
+ contentHtml: `${n}${s}`,
18
+ contentJson: r(o)
19
19
  };
20
20
  }
21
- function a(r) {
22
- function a(e = r.activePageId.value) {
23
- if (r.readonlyState.value) return;
24
- let n = r.templateValue.value.pages.findIndex((e) => e.id === r.pendingPaginationPageId.value), i = r.templateValue.value.pages.findIndex((t) => t.id === e);
25
- (!r.pendingPaginationPageId.value || n < 0 || i >= 0 && i < n) && (r.pendingPaginationPageId.value = e), !r.isAutoPaginating.value && t(() => o());
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();
24
+ }, { flush: "sync" });
25
+ function m() {
26
+ i.pendingPaginationPageId.value = o.values().next().value ?? s.values().next().value ?? "";
27
+ }
28
+ function h() {
29
+ c || l || i.isAutoPaginating.value || i.readonlyState.value || (c = !0, t(() => {
30
+ c = !1, l || y();
31
+ }));
32
+ }
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));
39
+ }
40
+ o.add(e), m(), h();
41
+ }
26
42
  }
27
- async function o() {
28
- if (!r.isAutoPaginating.value) {
29
- r.isAutoPaginating.value = !0;
30
- try {
31
- let a = r.pendingPaginationPageId.value;
32
- r.pendingPaginationPageId.value = "";
33
- let o = 0, s = Math.max(40, r.normalizedMaxPages.value + 1);
34
- for (; o < s;) {
35
- await t();
36
- let s = r.syncPageEditors().pages, c = Math.max(0, s.findIndex((e) => e.id === a)), l = !1;
37
- for (let t = c; t < s.length; t += 1) {
38
- let o = s[t];
39
- if (t === s.length - 1 && s.length >= r.normalizedMaxPages.value && r.pageRefs.get(o.id)?.hasOverflowContent()) {
40
- r.notifyPageLimit("auto-pagination");
41
- break;
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
+ }
49
+ }
50
+ function v() {
51
+ return new Promise((e) => {
52
+ f = e, d = setTimeout(() => {
53
+ d = void 0, f = void 0, e();
54
+ }, 0);
55
+ });
56
+ }
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();
62
+ 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);
70
+ continue;
71
+ }
72
+ if (!d && n.length >= i.normalizedMaxPages.value) u.hasOverflowContent() && i.notifyPageLimit("auto-pagination");
73
+ else {
74
+ let t = u.splitOverflowContent();
75
+ 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);
42
80
  }
43
- let c = r.pageRefs.get(o.id)?.splitOverflowContent();
44
- if (!c) continue;
45
- let u = r.syncPageEditors().pages, d = u.findIndex((e) => e.id === o.id);
46
- if (d < 0) break;
47
- u[d] = c.page;
48
- let f = u[d + 1];
49
- f ? u[d + 1] = r.pageRefs.get(f.id)?.prependContent(c.overflowContent) ?? i(f, c.overflowContent, c.overflowHtml) : u.push(e(u.length + 1, r.getPageSize(c.page), c.overflowHtml, n(c.overflowContent))), r.commitBodyChange({
50
- ...r.templateValue.value,
51
- pages: u
52
- }), a = u[d + 1]?.id ?? c.page.id, l = !0;
53
- break;
54
81
  }
55
- if (!l) break;
56
- o += 1;
82
+ m(), o.size && performance.now() - c >= (i.timeBudgetMs ?? 8) && (await v(), c = performance.now());
57
83
  }
58
- } finally {
59
- r.isAutoPaginating.value = !1, r.pendingPaginationPageId.value && t(() => o());
60
84
  }
85
+ } finally {
86
+ i.isAutoPaginating.value = !1, m(), o.size && h();
61
87
  }
62
88
  }
89
+ function b() {
90
+ u += 1, o.clear(), s.clear(), d !== void 0 && clearTimeout(d), d = void 0, f?.(), f = void 0, m();
91
+ }
92
+ function x() {
93
+ p(), l = !0, b();
94
+ }
63
95
  return {
64
- scheduleAutoPaginate: a,
65
- runAutoPagination: o,
66
- createDocContent: n,
67
- prependOverflowToPageData: i
96
+ scheduleAutoPaginate: g,
97
+ scheduleFullPagination: _,
98
+ runAutoPagination: y,
99
+ resetPagination: b,
100
+ disposePagination: x,
101
+ createDocContent: r,
102
+ prependOverflowToPageData: a
68
103
  };
69
104
  }
70
105
  //#endregion
71
- export { a as useAutoPagination };
106
+ export { o as useAutoPagination };
@@ -76,7 +76,7 @@ function g(g) {
76
76
  let e = s(i(), y());
77
77
  if (e.valueSerialized && (_ = e.valueSerialized), e.value) {
78
78
  let n = g.commit(t(e.value, g.pageSize()));
79
- g.activePageId.value = n.pages[0]?.id ?? "", g.selectedVariableKey.value = "", g.scheduleAutoPaginate(g.activePageId.value), g.updateDraftCacheStatus(e.status);
79
+ g.activePageId.value = n.pages[0]?.id ?? "", g.selectedVariableKey.value = "", g.scheduleFullPagination(), g.updateDraftCacheStatus(e.status);
80
80
  return;
81
81
  }
82
82
  e.status.type !== "idle" && e.status.type !== "invalid" && g.updateDraftCacheStatus(e.status);
@@ -1,29 +1,30 @@
1
- import { findContractHeadingPosition as e, findContractTextMatches as t, replaceContractTextMatches as n } from "../utils/authoring-search.mjs";
1
+ import { createContractTextMatchCache as e, findContractHeadingPosition as t, replaceContractTextMatches as n } from "../utils/authoring-search.mjs";
2
2
  import { createContractTextSearchPlugin as r, updateContractTextSearch as i } from "../extensions/authoring-search.mjs";
3
- import { watch as a } from "vue";
3
+ import { onScopeDispose as a, watch as o } from "vue";
4
4
  //#region src/components/pro-contract-template-designer/src/composables/use-page-authoring.ts
5
- function o(o) {
6
- a(o.editor, (e) => {
7
- !e || e.isDestroyed || (e.registerPlugin(r()), i(e, o.search()));
8
- }, { immediate: !0 }), a(o.search, (e) => {
9
- let t = o.editor();
5
+ function s(s) {
6
+ let c = e();
7
+ a(() => c.clear()), o(s.editor, (e) => {
8
+ c.clear(), !(!e || e.isDestroyed) && (e.registerPlugin(r()), i(e, s.search()));
9
+ }, { immediate: !0 }), o(s.search, (e) => {
10
+ let t = s.editor();
10
11
  t && !t.isDestroyed && i(t, e);
11
12
  }, { deep: !0 });
12
- function s(e, n) {
13
- let r = o.editor();
14
- return r ? t(r.view.state.doc, e, n) : [];
13
+ function l(e, t) {
14
+ let n = s.editor();
15
+ return n && !n.isDestroyed ? c.read(n.view.state.doc, e, t) : [];
15
16
  }
16
- function c(e) {
17
- let t = o.editor();
17
+ function u(e) {
18
+ let t = s.editor();
18
19
  if (!t || e.from < 1 || e.to > t.state.doc.content.size) return !1;
19
20
  let n = t.view.state.selection;
20
21
  return (n.from !== e.from || n.to !== e.to) && t.commands.setTextSelection(e), t.commands.scrollIntoView(), !0;
21
22
  }
22
- function l(e, t, r) {
23
- return n(o.editor(), o.readonly(), e, t, r);
23
+ function d(e, t, r) {
24
+ return n(s.editor(), s.readonly(), e, t, r);
24
25
  }
25
- function u(t) {
26
- let n = o.editor(), r = n && e(n.state.doc, t);
26
+ function f(e) {
27
+ let n = s.editor(), r = n && t(n.state.doc, e);
27
28
  if (!n || r === void 0) return !1;
28
29
  n.chain().setTextSelection(r).focus(void 0, { scrollIntoView: !1 }).run();
29
30
  let i = n.view.nodeDOM(r - 1);
@@ -33,11 +34,11 @@ function o(o) {
33
34
  }), !0;
34
35
  }
35
36
  return {
36
- findText: s,
37
- revealSearchMatch: c,
38
- replaceSearchMatches: l,
39
- focusHeading: u
37
+ findText: l,
38
+ revealSearchMatch: u,
39
+ replaceSearchMatches: d,
40
+ focusHeading: f
40
41
  };
41
42
  }
42
43
  //#endregion
43
- export { o as usePageAuthoring };
44
+ export { s as usePageAuthoring };
@@ -2,56 +2,57 @@ import { resolveContractAuthoringShortcut as e } from "../utils/authoring-shortc
2
2
  import { computed as t, nextTick as n, shallowRef as r, watch as i } from "vue";
3
3
  //#region src/components/pro-contract-template-designer/src/composables/use-template-authoring.ts
4
4
  function a(a) {
5
- let o = r(), s = r(""), c = r(""), l = r(!1), u = r(0), d = r(""), f = t(() => o.value === "find" || o.value === "replace"), p = !1, m = r(0);
5
+ let o = r(), s = r(""), c = r(""), l = r(!1), u = r(0), d = r(""), f = t(() => o.value === "find" || o.value === "replace"), p = !1, m, h = r(0);
6
6
  i([a.fileId, () => JSON.stringify(a.pages().map((e) => e.id))], async () => {
7
- await n(), m.value += 1;
7
+ await n(), h.value += 1;
8
8
  }, { flush: "post" });
9
- let h = t(() => (a.fileId(), m.value, a.pages().flatMap((e, t) => (e.contentHtml, s.value ? (a.pageRefs.get(e.id)?.findText(s.value, l.value) ?? []).map((n) => ({
9
+ let g = t(() => !f.value || !s.value ? [] : (a.fileId(), h.value, a.pages().flatMap((e, t) => (e.contentHtml, (a.pageRefs.get(e.id)?.findText(s.value, l.value) ?? []).map((n) => ({
10
10
  ...n,
11
11
  pageId: e.id,
12
12
  pageIndex: t
13
- })) : [])))), g = t(() => h.value[u.value]), _ = t(() => f.value ? s.value : "");
14
- function v() {
15
- let e = g.value;
16
- !f.value || !e || (a.activatePage(e.pageId, !1), a.pageRefs.get(e.pageId)?.revealSearchMatch(e));
13
+ })))))), _ = t(() => g.value[u.value]), v = t(() => f.value ? s.value : "");
14
+ function y() {
15
+ let e = _.value;
16
+ !f.value || !e || (m = e, a.activatePage(e.pageId, !1), a.pageRefs.get(e.pageId)?.revealSearchMatch(e));
17
17
  }
18
18
  i([
19
19
  s,
20
20
  l,
21
21
  a.fileId
22
22
  ], () => {
23
- p = !0, u.value = 0, d.value = "";
24
- }, { flush: "sync" }), i(h, (e, t) => {
25
- let n = t[u.value], r = !p && n ? e.findIndex((e) => e.pageId === n.pageId && e.from === n.from && e.to === n.to) : -1;
26
- u.value = p ? 0 : r >= 0 ? r : Math.min(u.value, Math.max(0, e.length - 1)), p = !1, v();
23
+ p = !0, m = void 0, u.value = 0, d.value = "";
24
+ }, { flush: "sync" }), i(g, (e, t) => {
25
+ if (!f.value) return;
26
+ let n = t[u.value] ?? m, r = !p && n ? e.findIndex((e) => e.pageId === n.pageId && e.from === n.from && e.to === n.to) : -1;
27
+ u.value = p ? 0 : r >= 0 ? r : Math.min(u.value, Math.max(0, e.length - 1)), p = !1, y();
27
28
  }, { flush: "post" });
28
- async function y(e) {
29
- a.beforeOpen(), o.value = e, await n(), v(), a.focusPanel();
29
+ async function b(e) {
30
+ a.beforeOpen(), o.value = e, await n(), y(), a.focusPanel();
30
31
  }
31
- function b(e = !0) {
32
+ function x(e = !0) {
32
33
  let t = o.value;
33
- o.value = void 0, e && t && n(() => a.focusTrigger(t));
34
+ f.value && (m = _.value), o.value = void 0, e && t && n(() => a.focusTrigger(t));
34
35
  }
35
- function x(e) {
36
- h.value.length && (u.value = (u.value + e + h.value.length) % h.value.length, v());
36
+ function S(e) {
37
+ g.value.length && (u.value = (u.value + e + g.value.length) % g.value.length, y());
37
38
  }
38
- async function S() {
39
- let e = g.value;
39
+ async function C() {
40
+ let e = _.value;
40
41
  if (a.readonly() || !e) return;
41
42
  let t = a.pageRefs.get(e.pageId)?.replaceSearchMatches({
42
43
  query: s.value,
43
44
  matchCase: l.value
44
45
  }, c.value, [e]) ?? 0;
45
46
  if (d.value = t ? "已替换 1 处,可在该页撤销" : "未修改正文:内容已变化或替换文字相同", await n(), t) {
46
- let t = h.value.findIndex((t) => t.pageIndex > e.pageIndex || t.pageId === e.pageId && t.from >= e.from + c.value.length);
47
+ let t = g.value.findIndex((t) => t.pageIndex > e.pageIndex || t.pageId === e.pageId && t.from >= e.from + c.value.length);
47
48
  u.value = Math.max(0, t);
48
49
  }
49
- v();
50
+ y();
50
51
  }
51
- async function C() {
52
- if (a.readonly() || !h.value.length) return;
52
+ async function w() {
53
+ if (a.readonly() || !g.value.length) return;
53
54
  let e = /* @__PURE__ */ new Map();
54
- for (let t of h.value) {
55
+ for (let t of g.value) {
55
56
  let n = e.get(t.pageId) ?? [];
56
57
  n.push(t), e.set(t.pageId, n);
57
58
  }
@@ -63,29 +64,29 @@ function a(a) {
63
64
  }, c.value, i) ?? 0;
64
65
  t += e, e && (r += 1);
65
66
  }
66
- d.value = t ? `已在本文件 ${r} 页替换 ${t} 处,可逐页撤销` : "未修改正文:内容已变化或替换文字相同", u.value = 0, await n(), v();
67
+ d.value = t ? `已在本文件 ${r} 页替换 ${t} 处,可逐页撤销` : "未修改正文:内容已变化或替换文字相同", u.value = 0, await n(), y();
67
68
  }
68
- function w(t) {
69
+ function T(t) {
69
70
  let n = e(t, a.root());
70
- !n || (n === "next" || n === "previous") && !f.value || (t.preventDefault(), t.stopPropagation(), n === "next" || n === "previous" ? x(n === "next" ? 1 : -1) : y(n));
71
+ !n || (n === "next" || n === "previous") && !f.value || (t.preventDefault(), t.stopPropagation(), n === "next" || n === "previous" ? S(n === "next" ? 1 : -1) : b(n));
71
72
  }
72
73
  return {
73
74
  panel: o,
74
75
  query: s,
75
76
  replacement: c,
76
77
  matchCase: l,
77
- matches: h,
78
+ matches: g,
78
79
  currentIndex: u,
79
- currentMatch: g,
80
+ currentMatch: _,
80
81
  feedback: d,
81
- highlightQuery: _,
82
+ highlightQuery: v,
82
83
  searchOpen: f,
83
- open: y,
84
- close: b,
85
- navigate: x,
86
- replaceCurrent: S,
87
- replaceAll: C,
88
- handleKeydown: w
84
+ open: b,
85
+ close: x,
86
+ navigate: S,
87
+ replaceCurrent: C,
88
+ replaceAll: w,
89
+ handleKeydown: T
89
90
  };
90
91
  }
91
92
  //#endregion