@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.
Files changed (47) 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/DesignerPage.vue.mjs +415 -295
  3. package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +1040 -993
  4. package/dist/es/components/pro-contract-template-designer/src/composables/use-auto-pagination.mjs +141 -47
  5. package/dist/es/components/pro-contract-template-designer/src/composables/use-draft-cache-session.mjs +1 -1
  6. package/dist/es/components/pro-contract-template-designer/src/composables/use-page-authoring.mjs +22 -21
  7. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-authoring.mjs +37 -36
  8. package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +125 -75
  9. package/dist/es/components/pro-contract-template-designer/src/utils/authoring-search.mjs +34 -13
  10. package/dist/es/components/pro-contract-template-designer/src/utils/caret-viewport.mjs +41 -0
  11. package/dist/es/components/pro-contract-template-designer/src/utils/document-outline.mjs +24 -1
  12. package/dist/es/components/pro-contract-template-designer/src/utils/editor-snapshot-cache.mjs +15 -0
  13. package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
  14. package/dist/es/index.mjs +21 -21
  15. package/dist/es/node_modules/@tiptap/pm/dist/transform/index.mjs +1 -0
  16. package/dist/es/node_modules/prosemirror-transform/dist/index.mjs +161 -67
  17. package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.cjs +1 -1
  18. package/dist/lib/components/pro-contract-template-designer/src/DesignerPage.vue.cjs +2 -2
  19. package/dist/lib/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.cjs +1 -1
  20. package/dist/lib/components/pro-contract-template-designer/src/composables/use-auto-pagination.cjs +1 -1
  21. package/dist/lib/components/pro-contract-template-designer/src/composables/use-draft-cache-session.cjs +1 -1
  22. package/dist/lib/components/pro-contract-template-designer/src/composables/use-page-authoring.cjs +1 -1
  23. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-authoring.cjs +1 -1
  24. package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +4 -4
  25. package/dist/lib/components/pro-contract-template-designer/src/utils/authoring-search.cjs +1 -1
  26. package/dist/lib/components/pro-contract-template-designer/src/utils/caret-viewport.cjs +1 -0
  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/lib/node_modules/@tiptap/pm/dist/transform/index.cjs +1 -0
  32. package/dist/lib/node_modules/prosemirror-transform/dist/index.cjs +2 -2
  33. package/dist/theme/icon.css +1 -1
  34. package/dist/theme/index.css +1 -1
  35. package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.d.ts +1 -0
  36. package/dist/types/components/pro-contract-template-designer/src/DesignerPage.vue.d.ts +28 -0
  37. package/dist/types/components/pro-contract-template-designer/src/composables/use-auto-pagination.d.ts +25 -2
  38. package/dist/types/components/pro-contract-template-designer/src/composables/use-draft-cache-session.d.ts +1 -1
  39. package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +10 -1
  40. package/dist/types/components/pro-contract-template-designer/src/utils/authoring-search.d.ts +5 -0
  41. package/dist/types/components/pro-contract-template-designer/src/utils/caret-viewport.d.ts +18 -0
  42. package/dist/types/components/pro-contract-template-designer/src/utils/document-outline.d.ts +6 -0
  43. package/dist/types/components/pro-contract-template-designer/src/utils/editor-snapshot-cache.d.ts +16 -0
  44. package/package.json +3 -3
  45. package/dist/theme/dept-selector.css +0 -1
  46. package/dist/theme/pro-selector-group.css +0 -1
  47. package/dist/theme/role-selector.css +0 -1
@@ -4,6 +4,7 @@ import { resolveTemplateVariablePresentation as ee } from "../utils/template-var
4
4
  import { buildPageDecorationClassNames as te, buildPageDecorationsHtml as d, collectPageDecorationVariableKeys as f, normalizePageDecorations as p, validatePageDecorations as m } from "../utils/page-decorations.mjs";
5
5
  import { isContractTemplateFieldType as ne } from "../types.mjs";
6
6
  import { decodeContractTemplateJsonAttribute as h } from "../utils/advanced-controls.mjs";
7
+ import { toRaw as re } from "vue";
7
8
  //#region src/components/pro-contract-template-designer/src/composables/use-template-designer.ts
8
9
  var g = [
9
10
  {
@@ -64,20 +65,20 @@ var g = [
64
65
  textAlign: "left",
65
66
  borderStyle: "solid",
66
67
  objectFit: "contain"
67
- }, re = 3, ie = 28, ae = "contract-template-renderer-1.0.0", oe = "contract-render-css-1.0.0", se = /^[A-Za-z][A-Za-z0-9_]{1,63}$/, ce = new Set([
68
+ }, ie = 3, ae = 28, oe = "contract-template-renderer-1.0.0", se = "contract-render-css-1.0.0", ce = /^[A-Za-z][A-Za-z0-9_]{1,63}$/, y = new Set([
68
69
  "pageNumber",
69
70
  "totalPages",
70
71
  "rendererVersion"
71
72
  ]);
72
- function y(e, t, n) {
73
+ function b(e, t, n) {
73
74
  let r = typeof e == "string" ? e.trim() : "";
74
- return r ? se.test(r) ? ce.has(r) ? `${r} 是系统保留标识` : t.some((e) => e.id !== n && e.key.trim() === r) ? `变量标识 ${r} 已存在` : "" : "变量标识需以字母开头,仅包含字母、数字和下划线,长度为 2~64 位" : "请输入变量标识";
75
+ return r ? ce.test(r) ? y.has(r) ? `${r} 是系统保留标识` : t.some((e) => e.id !== n && e.key.trim() === r) ? `变量标识 ${r} 已存在` : "" : "变量标识需以字母开头,仅包含字母、数字和下划线,长度为 2~64 位" : "请输入变量标识";
75
76
  }
76
77
  function le(e) {
77
78
  let t = Number(e);
78
79
  return Number.isFinite(t) && t >= 1 ? Math.max(1, Math.floor(t)) : 20;
79
80
  }
80
- var b = [
81
+ var x = [
81
82
  {
82
83
  type: "text",
83
84
  label: "输入框",
@@ -108,7 +109,7 @@ var b = [
108
109
  defaultWidth: 96,
109
110
  defaultHeight: 28
110
111
  }
111
- ], x = [{
112
+ ], S = [{
112
113
  type: "select",
113
114
  label: "下拉框",
114
115
  defaultWidth: 180,
@@ -118,7 +119,7 @@ var b = [
118
119
  label: "单选框",
119
120
  defaultWidth: 220,
120
121
  defaultHeight: 32
121
- }], S = [
122
+ }], ue = [
122
123
  {
123
124
  type: "user-selector",
124
125
  label: "用户选择器",
@@ -149,9 +150,9 @@ var b = [
149
150
  defaultWidth: 200,
150
151
  defaultHeight: 36
151
152
  }], w = [
152
- ...b,
153
153
  ...x,
154
154
  ...S,
155
+ ...ue,
155
156
  ...C
156
157
  ], T = 0;
157
158
  function E(e) {
@@ -213,7 +214,7 @@ function N(e, t) {
213
214
  let n = j(e);
214
215
  return t.find((e) => j(e) === n);
215
216
  }
216
- function ue(e, t) {
217
+ function de(e, t) {
217
218
  let n = M(t), r = n[0], i = A(e.pageSize, r), a = N(i, n) ?? r, o = /* @__PURE__ */ new Map(), s = e.pages.map((e) => {
218
219
  let t = A(e.pageSize, i), a = N(t, n) ?? r;
219
220
  return j(t) !== j(a) && o.set(e.id, {
@@ -259,7 +260,7 @@ function L(e = _) {
259
260
  pageSize: t
260
261
  };
261
262
  }
262
- function de(e = _) {
263
+ function fe(e = _) {
263
264
  let t = A(e);
264
265
  return {
265
266
  pages: [I(1, t, "<p></p>")],
@@ -267,11 +268,11 @@ function de(e = _) {
267
268
  pageSize: t
268
269
  };
269
270
  }
270
- function R(e, t = b) {
271
- return t.find((t) => t.type === e) ?? w.find((t) => t.type === e) ?? b[0];
271
+ function R(e, t = x) {
272
+ return t.find((t) => t.type === e) ?? w.find((t) => t.type === e) ?? x[0];
272
273
  }
273
- function z(e, t = b, n = {}) {
274
- let r = e.type === void 0 ? "text" : e.type, i = R(r, t), a = fe(r);
274
+ function z(e, t = x, n = {}) {
275
+ let r = e.type === void 0 ? "text" : e.type, i = R(r, t), a = pe(r);
275
276
  return {
276
277
  id: e.id ?? E("variable"),
277
278
  key: e.key,
@@ -303,7 +304,7 @@ function z(e, t = b, n = {}) {
303
304
  }
304
305
  };
305
306
  }
306
- function fe(e) {
307
+ function pe(e) {
307
308
  return e === "date" ? {
308
309
  placeholder: "年 月 日",
309
310
  format: "YYYY年MM月DD日",
@@ -362,7 +363,7 @@ function fe(e) {
362
363
  function B(e) {
363
364
  return e !== void 0 && !ne(e);
364
365
  }
365
- function pe(e, t = _) {
366
+ function me(e, t = _) {
366
367
  if (!e) return L(t);
367
368
  let n = A(e.pageSize, t), r = (e.pages?.length ? e.pages : [F(1, n)]).map((e, t) => ({
368
369
  id: e.id || E("page"),
@@ -378,7 +379,7 @@ function pe(e, t = _) {
378
379
  });
379
380
  i.push(t), t.key && a.set(t.key, t);
380
381
  }), r.forEach((e) => {
381
- we(e).forEach((e) => {
382
+ Y(e).forEach((e) => {
382
383
  if (!e.key) return;
383
384
  let t = a.get(e.key);
384
385
  if (!t) {
@@ -403,16 +404,16 @@ function pe(e, t = _) {
403
404
  ...e.pageDecorations ? { pageDecorations: p(e.pageDecorations) } : {}
404
405
  };
405
406
  }
406
- function me(e) {
407
- return e.pages.map((t, n) => K(e, t, n, t.contentHtml, {})).join("\n");
407
+ function he(e) {
408
+ return e.pages.map((t, n) => q(e, t, n, t.contentHtml, {})).join("\n");
408
409
  }
409
410
  function V(e) {
410
- return e.pages.map((t, n) => K(e, t, n, Pe(t.contentHtml))).join("\n");
411
+ return e.pages.map((t, n) => q(e, t, n, Ie(t.contentHtml))).join("\n");
411
412
  }
412
- function he(e) {
413
+ function ge(e) {
413
414
  return H(e).map(({ page: t, contentHtml: n }, r) => {
414
415
  let i = A(t.pageSize, e.pageSize), a = d(e.pageDecorations, r + 1, e.pages.length, e.variables, {});
415
- return `<section ${q(t, e.pageSize, e.pageDecorations, r + 1)} style="width:${i.width}px;min-height:${i.height}px">${a}<div class="gd-contract-template-page__content">${n}</div></section>`;
416
+ return `<section ${J(t, e.pageSize, e.pageDecorations, r + 1)} style="width:${i.width}px;min-height:${i.height}px">${a}<div class="gd-contract-template-page__content">${n}</div></section>`;
416
417
  }).join("\n");
417
418
  }
418
419
  function H(e) {
@@ -422,7 +423,7 @@ function H(e) {
422
423
  ...e,
423
424
  ...e.pageSize ? { pageSize: { ...e.pageSize } } : {}
424
425
  },
425
- contentHtml: Ee(e.contentHtml, t)
426
+ contentHtml: De(e.contentHtml, t)
426
427
  }));
427
428
  }
428
429
  var U = class extends Error {
@@ -430,18 +431,18 @@ var U = class extends Error {
430
431
  super(e[0]?.message || "页面装饰配置无效"), this.errors = e, this.name = "ContractTemplatePageDecorationValidationError";
431
432
  }
432
433
  };
433
- function ge(e) {
434
+ function _e(e) {
434
435
  let t = m(e.pageDecorations, e.variables);
435
436
  if (t.length) throw new U(t);
436
437
  let n = D(e);
437
438
  return n.pageDecorations &&= p(n.pageDecorations), {
438
439
  ...n,
439
- rendererVersion: ae,
440
- styleVersion: oe,
440
+ rendererVersion: oe,
441
+ styleVersion: se,
441
442
  html: V(n)
442
443
  };
443
444
  }
444
- function _e(e, t = {}) {
445
+ function ve(e, t = {}) {
445
446
  let n = [], r = /* @__PURE__ */ new Set();
446
447
  typeof t.maxPages == "number" && e.pages.length > t.maxPages && n.push({
447
448
  type: "page",
@@ -450,7 +451,7 @@ function _e(e, t = {}) {
450
451
  code: "PAGE_LIMIT_EXCEEDED",
451
452
  message: `合同共 ${e.pages.length} 页,超过最多 ${t.maxPages} 页限制`
452
453
  }), e.variables.forEach((t) => {
453
- let i = y(t.key, e.variables, t.id), a = !!t.key?.trim() && e.variables.some((e) => e.id !== t.id && e.key.trim() === t.key.trim());
454
+ let i = b(t.key, e.variables, t.id), a = !!t.key?.trim() && e.variables.some((e) => e.id !== t.id && e.key.trim() === t.key.trim());
454
455
  i && (!a || t.key !== t.key.trim()) && n.push({
455
456
  type: "variable",
456
457
  id: t.id,
@@ -493,7 +494,7 @@ function W(e) {
493
494
  function n(e) {
494
495
  if (!e || typeof e != "object") return;
495
496
  let r = e;
496
- ve(r.type) && r.attrs?.key && t.add(r.attrs.key), r.content?.forEach(n);
497
+ ye(r.type) && r.attrs?.key && t.add(r.attrs.key), r.content?.forEach(n);
497
498
  }
498
499
  n(e.contentJson);
499
500
  let r = e.contentHtml || "", i = /data-template-variable=["']true["'][^>]*data-key=["']([^"']+)["']|data-key=["']([^"']+)["'][^>]*data-template-variable=["']true["']/g, a = i.exec(r);
@@ -503,7 +504,7 @@ function W(e) {
503
504
  }
504
505
  return t;
505
506
  }
506
- function ve(e) {
507
+ function ye(e) {
507
508
  return e === "templateVariable" || e === "templateField";
508
509
  }
509
510
  function G(e) {
@@ -512,14 +513,63 @@ function G(e) {
512
513
  W(e).forEach((e) => t.add(e));
513
514
  }), t;
514
515
  }
515
- function ye(e) {
516
- let t = G(e), n = f(e.pageDecorations);
516
+ function K(e, t = G(e)) {
517
+ let n = f(e.pageDecorations), r = /* @__PURE__ */ new Map();
518
+ for (let t of e.variables) r.set(t.key, (r.get(t.key) ?? 0) + 1);
517
519
  return {
518
520
  ...e,
519
- variables: e.variables.filter((r) => y(r.key, e.variables, r.id) ? !0 : t.has(r.key) || n.has(r.key))
521
+ variables: e.variables.filter((i) => (r.get(i.key) ?? 0) > 1 || b(i.key, e.variables, i.id) ? !0 : t.has(i.key) || n.has(i.key))
522
+ };
523
+ }
524
+ function be() {
525
+ let e = /* @__PURE__ */ new Map();
526
+ function t(t) {
527
+ let n = t.contentJson && re(t.contentJson), r = e.get(t.id);
528
+ return (!r || r.html !== t.contentHtml || r.json !== n) && (r = {
529
+ html: t.contentHtml,
530
+ json: n,
531
+ keys: W(t)
532
+ }, e.set(t.id, r)), r;
533
+ }
534
+ function n(n) {
535
+ let r = new Set(n.pages.map((e) => e.id));
536
+ for (let t of Array.from(e.keys())) r.has(t) || e.delete(t);
537
+ let i = /* @__PURE__ */ new Set();
538
+ for (let e of n.pages) t(e).keys.forEach((e) => i.add(e));
539
+ return i;
540
+ }
541
+ function r(e) {
542
+ let r = n(e), i = e.variables.slice(), a = new Map(i.filter((e) => e.key).map((e) => [e.key, e]));
543
+ for (let n of e.pages) {
544
+ let e = t(n);
545
+ e.variables ??= Y(n);
546
+ for (let t of e.variables) {
547
+ let e = a.get(t.key);
548
+ if (!e) {
549
+ let e = z(t);
550
+ i.push(e), a.set(e.key, e);
551
+ } else if (B(t.type) && e.type !== t.type) {
552
+ let n = z({
553
+ ...e,
554
+ type: t.type
555
+ }), r = i.findIndex((t) => t.id === e.id);
556
+ r >= 0 && (i[r] = n), a.set(n.key, n);
557
+ }
558
+ }
559
+ }
560
+ let o = K({
561
+ ...e,
562
+ variables: i
563
+ }, r);
564
+ return o.variables.length === e.variables.length && o.variables.every((t, n) => t === e.variables[n]) ? e : o;
565
+ }
566
+ return {
567
+ sync: r,
568
+ collectKeys: n,
569
+ clear: () => e.clear()
520
570
  };
521
571
  }
522
- function be(e, t) {
572
+ function xe(e, t) {
523
573
  for (let n = 0; n < t; n += 1) {
524
574
  let r = e[n]?.content ?? [];
525
575
  for (let e of r) {
@@ -529,7 +579,7 @@ function be(e, t) {
529
579
  }
530
580
  return !0;
531
581
  }
532
- function xe(e, t, n) {
582
+ function Se(e, t, n) {
533
583
  let r = e.content ?? [], i = t.tableRows ?? [], a = Math.min(r.length, i.length), o = n - Math.max(0, t.trailingTextBlockHeight ?? 0), s = 0;
534
584
  for (let e = 0; e < a; e += 1) {
535
585
  let t = i[e];
@@ -538,7 +588,7 @@ function xe(e, t, n) {
538
588
  }
539
589
  if (s <= 0 || s >= r.length) return;
540
590
  let c = s;
541
- for (; c > 0 && !be(r, c);) --c;
591
+ for (; c > 0 && !xe(r, c);) --c;
542
592
  if (!(c <= 0 || c >= r.length)) return {
543
593
  currentTable: {
544
594
  ...e,
@@ -550,7 +600,7 @@ function xe(e, t, n) {
550
600
  }
551
601
  };
552
602
  }
553
- function Se(e, t, n) {
603
+ function Ce(e, t, n) {
554
604
  let r = e ?? [];
555
605
  if (!r.length || n <= 0) return;
556
606
  let i = Math.min(r.length, t.length), a = -1;
@@ -562,7 +612,7 @@ function Se(e, t, n) {
562
612
  }
563
613
  }
564
614
  if (a < 0) return;
565
- let o = r[a], s = o?.type === "table" ? xe(o, t[a], n) : void 0;
615
+ let o = r[a], s = o?.type === "table" ? Se(o, t[a], n) : void 0;
566
616
  if (s) return {
567
617
  splitIndex: a,
568
618
  currentContent: [...r.slice(0, a), s.currentTable],
@@ -574,11 +624,11 @@ function Se(e, t, n) {
574
624
  overflowContent: r.slice(a)
575
625
  };
576
626
  }
577
- function K(e, t, n, r, i) {
627
+ function q(e, t, n, r, i) {
578
628
  let a = d(e.pageDecorations, n + 1, e.pages.length, e.variables, i);
579
- return `<section ${q(t, e.pageSize, e.pageDecorations, n + 1)}>${a}<div class="gd-contract-template-page__content">${r}</div></section>`;
629
+ return `<section ${J(t, e.pageSize, e.pageDecorations, n + 1)}>${a}<div class="gd-contract-template-page__content">${r}</div></section>`;
580
630
  }
581
- function q(e, t, n, r = 1) {
631
+ function J(e, t, n, r = 1) {
582
632
  let a = A(e.pageSize, t);
583
633
  return [
584
634
  `class="${te(n, r)}"`,
@@ -589,8 +639,8 @@ function q(e, t, n, r = 1) {
589
639
  `data-page-height="${a.height}"`
590
640
  ].join(" ");
591
641
  }
592
- var Ce = /<span\b[^>]*data-template-variable=["']true["'][^>]*>/g;
593
- function we(e) {
642
+ var we = /<span\b[^>]*data-template-variable=["']true["'][^>]*>/g;
643
+ function Y(e) {
594
644
  let i = /* @__PURE__ */ new Map();
595
645
  function a(e) {
596
646
  if (!e.key) return;
@@ -600,17 +650,17 @@ function we(e) {
600
650
  function s(e) {
601
651
  if (!e || typeof e != "object") return;
602
652
  let t = e;
603
- t.type === "templateVariable" && typeof t.attrs?.key == "string" && a(Te(t.attrs, t.attrs.key)), t.content?.forEach(s);
653
+ t.type === "templateVariable" && typeof t.attrs?.key == "string" && a(Ee(t.attrs, t.attrs.key)), t.content?.forEach(s);
604
654
  }
605
655
  s(e.contentJson);
606
656
  let c = e.contentHtml || "";
607
657
  return t() ? new DOMParser().parseFromString(c, "text/html").querySelectorAll("[data-template-variable]").forEach((e) => {
608
- a(J(n(e)));
609
- }) : o(c, Ce, (e) => {
610
- a(J(r(e)));
658
+ a(Te(n(e)));
659
+ }) : o(c, we, (e) => {
660
+ a(Te(r(e)));
611
661
  }), Array.from(i.values());
612
662
  }
613
- function J(e) {
663
+ function Te(e) {
614
664
  let t = e("data-key") ?? "", n = e("data-variable-type"), r = e("data-precision"), i = e("data-use-grouping");
615
665
  return {
616
666
  key: t,
@@ -649,7 +699,7 @@ function J(e) {
649
699
  }
650
700
  };
651
701
  }
652
- function Te(e, t) {
702
+ function Ee(e, t) {
653
703
  let n = (t) => typeof e[t] == "string" ? e[t] : void 0;
654
704
  return {
655
705
  key: t,
@@ -688,20 +738,20 @@ function Te(e, t) {
688
738
  }
689
739
  };
690
740
  }
691
- function Ee(e, n) {
741
+ function De(e, n) {
692
742
  if (!e) return e;
693
743
  if (t()) {
694
744
  let t = new DOMParser().parseFromString(e, "text/html");
695
- return De(t), t.querySelectorAll("[data-template-variable]").forEach((e) => {
696
- Oe(e, n);
745
+ return Oe(t), t.querySelectorAll("[data-template-variable]").forEach((e) => {
746
+ Ae(e, n);
697
747
  }), t.body.innerHTML;
698
748
  }
699
- return u(Ae(e), (e, t) => {
749
+ return u(Me(e), (e, t) => {
700
750
  let i = r(t);
701
- return i("data-key") ? ke(i, n) : e;
751
+ return i("data-key") ? je(i, n) : e;
702
752
  });
703
753
  }
704
- function De(e) {
754
+ function Oe(e) {
705
755
  e.querySelectorAll("script,style,meta,link").forEach((e) => e.remove()), e.querySelectorAll("*").forEach((e) => {
706
756
  Array.from(e.attributes).forEach((t) => {
707
757
  let n = t.name.toLowerCase(), r = t.value;
@@ -713,12 +763,12 @@ function De(e) {
713
763
  e.removeAttribute(t.name);
714
764
  return;
715
765
  }
716
- n === "style" && Ne(r) && e.removeAttribute(t.name);
766
+ n === "style" && Fe(r) && e.removeAttribute(t.name);
717
767
  });
718
768
  });
719
769
  }
720
- function Y(e, t) {
721
- let n = e("data-key") ?? "", r = t.get(n), i = r?.type ?? e("data-variable-type") ?? "text", a = Me(i, r?.defaultValue ?? e("data-default-value") ?? ""), o = ee({
770
+ function ke(e, t) {
771
+ let n = e("data-key") ?? "", r = t.get(n), i = r?.type ?? e("data-variable-type") ?? "text", a = Pe(i, r?.defaultValue ?? e("data-default-value") ?? ""), o = ee({
722
772
  type: i,
723
773
  width: r?.width ?? e("data-width"),
724
774
  height: r?.height ?? e("data-height"),
@@ -732,7 +782,7 @@ function Y(e, t) {
732
782
  multiline: r?.multiline ?? c(e("data-multiline")) ?? !1,
733
783
  rows: r?.rows ?? e("data-rows"),
734
784
  lineHeight: r?.lineHeight ?? e("data-line-height"),
735
- style: je(r, e)
785
+ style: Ne(r, e)
736
786
  });
737
787
  return {
738
788
  key: n,
@@ -741,18 +791,18 @@ function Y(e, t) {
741
791
  text: o.type === "image" && o.hasDefaultValue ? " " : o.displayText || " "
742
792
  };
743
793
  }
744
- function Oe(e, t) {
745
- let { key: r, label: i, presentation: a, text: o } = Y(n(e), t);
794
+ function Ae(e, t) {
795
+ let { key: r, label: i, presentation: a, text: o } = ke(n(e), t);
746
796
  e.setAttribute("data-template-variable", "true"), e.setAttribute("data-key", r), e.setAttribute("data-label", i), e.setAttribute("data-variable-type", a.type), e.setAttribute("data-width", String(a.width)), e.setAttribute("data-height", String(a.height)), e.setAttribute("data-border", String(a.border)), e.setAttribute("data-underline", String(a.underline)), e.setAttribute("data-color", a.color), e.setAttribute("data-background", a.background), e.setAttribute("data-font-size", String(a.fontSize)), e.setAttribute("data-font-family", a.fontFamily), e.setAttribute("data-placeholder-color", a.placeholderColor), e.setAttribute("data-line-color", a.lineColor), e.setAttribute("data-text-align", a.textAlign), e.setAttribute("data-border-style", a.borderStyle), e.setAttribute("data-object-fit", a.objectFit), e.className = a.classes.join(" "), e.setAttribute("style", a.styleText), e.textContent = o;
747
797
  }
748
- function ke(e, t) {
749
- let { key: n, label: r, presentation: o, text: s } = Y(e, t);
798
+ function je(e, t) {
799
+ let { key: n, label: r, presentation: o, text: s } = ke(e, t);
750
800
  return `<span data-template-variable="true" data-key="${i(n)}" data-label="${i(r)}" data-variable-type="${i(o.type)}" data-width="${o.width}" data-height="${o.height}" data-border="${o.border}" data-underline="${o.underline}" data-font-family="${i(o.fontFamily)}" class="${i(o.classes.join(" "))}" style="${i(o.styleText)}">${a(s)}</span>`;
751
801
  }
752
- function Ae(e) {
753
- return e.replace(/<\s*(script|style|meta|link)\b[\s\S]*?<\s*\/\s*\1\s*>/gi, "").replace(/<\s*(meta|link)\b[^>]*>/gi, "").replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+srcdoc\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+(href|src)\s*=\s*(["'])(.*?)\2/gi, (e, t, n, r) => X(r) ? "" : ` ${t}=${n}${r}${n}`).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) => Ne(n) ? "" : ` style=${t}${n}${t}`);
802
+ function Me(e) {
803
+ return e.replace(/<\s*(script|style|meta|link)\b[\s\S]*?<\s*\/\s*\1\s*>/gi, "").replace(/<\s*(meta|link)\b[^>]*>/gi, "").replace(/\s+on[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+srcdoc\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/\s+(href|src)\s*=\s*(["'])(.*?)\2/gi, (e, t, n, r) => X(r) ? "" : ` ${t}=${n}${r}${n}`).replace(/\s+style\s*=\s*(["'])(.*?)\1/gi, (e, t, n) => Fe(n) ? "" : ` style=${t}${n}${t}`);
754
804
  }
755
- function je(e, t) {
805
+ function Ne(e, t) {
756
806
  return {
757
807
  border: e?.style?.border ?? c(t("data-border")),
758
808
  underline: e?.style?.underline ?? c(t("data-underline")),
@@ -767,17 +817,17 @@ function je(e, t) {
767
817
  objectFit: e?.style?.objectFit ?? $(t("data-object-fit"))
768
818
  };
769
819
  }
770
- function Me(e, t) {
820
+ function Pe(e, t) {
771
821
  return e === "image" && X(t) ? "" : t;
772
822
  }
773
823
  function X(e) {
774
824
  let t = e.trim().replace(/[\u0000-\u001F\s]+/g, "").toLowerCase();
775
825
  return t.startsWith("javascript:") || t.startsWith("vbscript:") || t.startsWith("data:") && !t.startsWith("data:image/");
776
826
  }
777
- function Ne(e) {
827
+ function Fe(e) {
778
828
  return /expression\s*\(|javascript:|vbscript:/i.test(e);
779
829
  }
780
- function Pe(e) {
830
+ function Ie(e) {
781
831
  if (!e) return e;
782
832
  if (t()) {
783
833
  let t = new DOMParser().parseFromString(e, "text/html");
@@ -791,23 +841,23 @@ function Pe(e) {
791
841
  return n ? `<span${t}>\${{${n}}}</span>` : e;
792
842
  });
793
843
  }
794
- function Fe(e) {
844
+ function Le(e) {
795
845
  return e === "left" || e === "center" || e === "right";
796
846
  }
797
- function Ie(e) {
847
+ function Re(e) {
798
848
  return e === "solid" || e === "dashed";
799
849
  }
800
- function Le(e) {
850
+ function ze(e) {
801
851
  return e === "contain" || e === "cover" || e === "fill";
802
852
  }
803
853
  function Z(e) {
804
- return Fe(e) ? e : void 0;
854
+ return Le(e) ? e : void 0;
805
855
  }
806
856
  function Q(e) {
807
- return Ie(e) ? e : void 0;
857
+ return Re(e) ? e : void 0;
808
858
  }
809
859
  function $(e) {
810
- return Le(e) ? e : void 0;
860
+ return ze(e) ? e : void 0;
811
861
  }
812
862
  //#endregion
813
- export { w as ALL_DEFAULT_FIELD_TYPES, ae as CONTRACT_TEMPLATE_RENDERER_VERSION, ce as CONTRACT_TEMPLATE_RESERVED_VARIABLE_KEYS, oe as CONTRACT_TEMPLATE_STYLE_VERSION, se as CONTRACT_TEMPLATE_VARIABLE_KEY_PATTERN, U as ContractTemplatePageDecorationValidationError, x as DEFAULT_ADVANCED_CHOICE_FIELD_TYPES, S as DEFAULT_BUILTIN_SELECTOR_FIELD_TYPES, C as DEFAULT_CUSTOM_FIELD_TYPES, v as DEFAULT_FIELD_STYLE, b as DEFAULT_FIELD_TYPES, ie as DEFAULT_MULTILINE_LINE_HEIGHT, re as DEFAULT_MULTILINE_ROWS, _ as DEFAULT_PAGE_SIZE, g as PAGE_SIZE_OPTIONS, V as buildTemplateExpressionHtml, me as buildTemplateHtml, he as buildTemplatePreviewHtml, H as buildTemplatePreviewPages, D as cloneTemplateValue, G as collectTemplateValueVariableKeys, W as collectTemplateVariableKeys, ue as constrainTemplatePageSizes, I as createBlankPage, de as createBlankTemplate, F as createDefaultPage, L as createDefaultTemplate, E as createDesignerId, z as createTemplateVariable, ge as exportTemplateValue, N as findPageSizeOption, R as getFieldOption, j as getPageSizeKey, O as getPageSizeOption, k as inferPageFormat, le as normalizeContractTemplateMaxPages, M as normalizePageSizeOptions, pe as normalizeTemplateValue, A as resolvePageSize, Se as splitPageContentByMeasurements, ye as syncTemplateVariablesWithPages, y as validateContractTemplateVariableKey, _e as validateTemplateValue };
863
+ export { w as ALL_DEFAULT_FIELD_TYPES, oe as CONTRACT_TEMPLATE_RENDERER_VERSION, y as CONTRACT_TEMPLATE_RESERVED_VARIABLE_KEYS, se as CONTRACT_TEMPLATE_STYLE_VERSION, ce as CONTRACT_TEMPLATE_VARIABLE_KEY_PATTERN, U as ContractTemplatePageDecorationValidationError, S as DEFAULT_ADVANCED_CHOICE_FIELD_TYPES, ue as DEFAULT_BUILTIN_SELECTOR_FIELD_TYPES, C as DEFAULT_CUSTOM_FIELD_TYPES, v as DEFAULT_FIELD_STYLE, x as DEFAULT_FIELD_TYPES, ae as DEFAULT_MULTILINE_LINE_HEIGHT, ie as DEFAULT_MULTILINE_ROWS, _ as DEFAULT_PAGE_SIZE, g as PAGE_SIZE_OPTIONS, V as buildTemplateExpressionHtml, he as buildTemplateHtml, ge as buildTemplatePreviewHtml, H as buildTemplatePreviewPages, D as cloneTemplateValue, G as collectTemplateValueVariableKeys, W as collectTemplateVariableKeys, de as constrainTemplatePageSizes, I as createBlankPage, fe as createBlankTemplate, F as createDefaultPage, L as createDefaultTemplate, E as createDesignerId, be as createTemplateBodySync, z as createTemplateVariable, _e as exportTemplateValue, N as findPageSizeOption, R as getFieldOption, j as getPageSizeKey, O as getPageSizeOption, k as inferPageFormat, le as normalizeContractTemplateMaxPages, M as normalizePageSizeOptions, me as normalizeTemplateValue, A as resolvePageSize, Ce as splitPageContentByMeasurements, K as syncTemplateVariablesWithPages, b as validateContractTemplateVariableKey, ve as validateTemplateValue };
@@ -1,7 +1,8 @@
1
1
  import { closeHistory as e } from "../../../../node_modules/prosemirror-history/dist/index.mjs";
2
2
  import "../../../../node_modules/@tiptap/pm/dist/history/index.mjs";
3
+ import { toRaw as t } from "vue";
3
4
  //#region src/components/pro-contract-template-designer/src/utils/authoring-search.ts
4
- function t(e, t, n = !1) {
5
+ function n(e, t, n = !1) {
5
6
  if (!t) return [];
6
7
  let r = new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), n ? "gu" : "giu"), i = [];
7
8
  return e.descendants((e, t) => {
@@ -27,33 +28,53 @@ function t(e, t, n = !1) {
27
28
  }), o(), !1;
28
29
  }), i;
29
30
  }
30
- function n(n, r, i, a) {
31
- let o = new Set(t(n.doc, r.query, r.matchCase).map((e) => `${e.from}:${e.to}`)), s = /* @__PURE__ */ new Set(), c = a.filter((e) => {
32
- let t = `${e.from}:${e.to}`;
33
- return !o.has(t) || s.has(t) ? !1 : (s.add(t), n.doc.textBetween(e.from, e.to) !== i);
34
- }).sort((e, t) => t.from - e.from), l = e(n.tr);
31
+ function r() {
32
+ let e;
33
+ function r(r, i, a = !1) {
34
+ let o = t(r);
35
+ if (e?.doc === o && e.query === i && e.matchCase === a) return e.matches;
36
+ let s = n(o, i, a);
37
+ return e = {
38
+ doc: o,
39
+ query: i,
40
+ matchCase: a,
41
+ matches: s
42
+ }, s;
43
+ }
44
+ return {
45
+ read: r,
46
+ clear: () => {
47
+ e = void 0;
48
+ }
49
+ };
50
+ }
51
+ function i(t, r, i, a) {
52
+ let o = new Set(n(t.doc, r.query, r.matchCase).map((e) => `${e.from}:${e.to}`)), s = /* @__PURE__ */ new Set(), c = a.filter((e) => {
53
+ let n = `${e.from}:${e.to}`;
54
+ return !o.has(n) || s.has(n) ? !1 : (s.add(n), t.doc.textBetween(e.from, e.to) !== i);
55
+ }).sort((e, t) => t.from - e.from), l = e(t.tr);
35
56
  for (let e of c) {
36
57
  if (!i) {
37
58
  l.delete(e.from, e.to);
38
59
  continue;
39
60
  }
40
- let t = n.doc.resolve(e.from).nodeAfter?.marks ?? [];
41
- l.replaceWith(e.from, e.to, n.schema.text(i, t));
61
+ let n = t.doc.resolve(e.from).nodeAfter?.marks ?? [];
62
+ l.replaceWith(e.from, e.to, t.schema.text(i, n));
42
63
  }
43
64
  return {
44
65
  transaction: l,
45
66
  count: c.length
46
67
  };
47
68
  }
48
- function r(t, r, i, a, o) {
49
- if (!t || t.isDestroyed || r || !t.isEditable) return 0;
50
- let s = n(t.state, i, a, o);
69
+ function a(t, n, r, a, o) {
70
+ if (!t || t.isDestroyed || n || !t.isEditable) return 0;
71
+ let s = i(t.state, r, a, o);
51
72
  return s.count ? (t.view.dispatch(s.transaction), t.view.dispatch(e(t.state.tr).setMeta("addToHistory", !1)), s.count) : 0;
52
73
  }
53
- function i(e, t) {
74
+ function o(e, t) {
54
75
  if (!Number.isInteger(t) || t < 0) return;
55
76
  let n = 0, r;
56
77
  return e.descendants((e, i) => r !== void 0 || e.isAtom && !e.isText ? !1 : (e.type.name === "heading" && n++ === t && (r = i + 1), r === void 0)), r;
57
78
  }
58
79
  //#endregion
59
- export { i as findContractHeadingPosition, t as findContractTextMatches, r as replaceContractTextMatches };
80
+ export { r as createContractTextMatchCache, o as findContractHeadingPosition, n as findContractTextMatches, a as replaceContractTextMatches };
@@ -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 };
@@ -41,5 +41,28 @@ function s(s) {
41
41
  headings: d
42
42
  };
43
43
  }
44
+ function c() {
45
+ let e = /* @__PURE__ */ new Map();
46
+ function t(t) {
47
+ let n = new Set(t.map((e) => e.id));
48
+ for (let t of Array.from(e.keys())) n.has(t) || e.delete(t);
49
+ }
50
+ function n(n) {
51
+ return t(n), n.map((t) => {
52
+ let n = e.get(t.id);
53
+ if (n?.html === t.contentHtml) return n.content;
54
+ let r = s(t);
55
+ return e.set(t.id, {
56
+ html: t.contentHtml,
57
+ content: r
58
+ }), r;
59
+ });
60
+ }
61
+ return {
62
+ readPages: n,
63
+ retainPages: t,
64
+ clear: () => e.clear()
65
+ };
66
+ }
44
67
  //#endregion
45
- export { s as readContractPageNavigation };
68
+ export { c as createContractPageNavigationCache };
@@ -0,0 +1,15 @@
1
+ import { toRaw as e } from "vue";
2
+ //#region src/components/pro-contract-template-designer/src/utils/editor-snapshot-cache.ts
3
+ function t() {
4
+ let t, n, r;
5
+ function i(i) {
6
+ let a = e(i.state.doc);
7
+ return a !== t && (t = a, n = void 0, r = void 0), {
8
+ getHTML: () => n ??= i.getHTML(),
9
+ getJSON: () => r ??= i.getJSON()
10
+ };
11
+ }
12
+ return { read: i };
13
+ }
14
+ //#endregion
15
+ export { t as createEditorSnapshotCache };