@guodun/antdv 1.3.2 → 1.4.0
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/contract-signing-location/index.mjs +1 -0
- package/dist/es/components/contract-signing-location/src/ContractSigningLocation.vue.mjs +304 -289
- package/dist/es/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.mjs +337 -326
- package/dist/es/components/contract-signing-location/src/ContractSigningLocationNavigator.vue.mjs +41 -33
- package/dist/es/components/contract-signing-location/src/ContractSigningTemplatePage.mjs +5 -0
- package/dist/es/components/contract-signing-location/src/ContractSigningTemplatePage.vue.mjs +23 -0
- package/dist/es/components/contract-signing-location/src/location-rules.mjs +115 -77
- package/dist/es/components/contract-signing-location/src/template-source.mjs +85 -0
- package/dist/es/components/contract-signing-location/style/index.css +1 -1
- package/dist/es/components/index.mjs +8 -6
- package/dist/es/components/pro-contract-signing-flow/src/ContractSigningFlowCanvas.vue.mjs +164 -57
- package/dist/es/components/pro-contract-signing-flow/src/ContractSigningFlowInspector.vue.mjs +128 -125
- package/dist/es/components/pro-contract-signing-flow/src/ContractSigningFlowNodeCard.vue.mjs +75 -49
- package/dist/es/components/pro-contract-signing-flow/src/ProContractSigningFlow.vue.mjs +135 -91
- package/dist/es/components/pro-contract-signing-flow/src/constants.mjs +25 -5
- package/dist/es/components/pro-contract-signing-flow/style/index.css +1 -1
- package/dist/es/components/pro-contract-template-designer/index.mjs +5 -4
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.mjs +5 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.mjs +347 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.mjs +5 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.mjs +171 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateFileBar.mjs +5 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateFileBar.vue.mjs +166 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererField.vue.mjs +4 -4
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererValidation.mjs +5 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererValidation.vue.mjs +36 -0
- package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +202 -202
- package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +1591 -1612
- package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.mjs +235 -239
- package/dist/es/components/pro-contract-template-designer/src/SigningPlacementLayer.vue.mjs +16 -16
- package/dist/es/components/pro-contract-template-designer/src/composables/use-template-designer.mjs +166 -166
- package/dist/es/components/pro-contract-template-designer/src/composables/use-template-draft-cache.mjs +100 -33
- package/dist/es/components/pro-contract-template-designer/src/composables/use-template-files.mjs +77 -0
- package/dist/es/components/pro-contract-template-designer/src/extensions/word-paste.mjs +23 -23
- package/dist/es/components/pro-contract-template-designer/src/utils/file-tabs.mjs +14 -0
- package/dist/es/components/pro-contract-template-designer/src/utils/template-renderer.mjs +121 -121
- package/dist/es/components/pro-contract-template-designer/src/utils/toolbar-overflow.mjs +19 -0
- package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
- package/dist/es/index.mjs +23 -21
- package/dist/lib/components/contract-signing-location/index.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/ContractSigningLocation.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/ContractSigningLocationNavigator.vue.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/ContractSigningTemplatePage.cjs +1 -0
- package/dist/lib/components/contract-signing-location/src/ContractSigningTemplatePage.vue.cjs +1 -0
- package/dist/lib/components/contract-signing-location/src/location-rules.cjs +1 -1
- package/dist/lib/components/contract-signing-location/src/template-source.cjs +1 -0
- package/dist/lib/components/contract-signing-location/style/index.css +1 -1
- package/dist/lib/components/index.cjs +1 -1
- package/dist/lib/components/pro-contract-signing-flow/src/ContractSigningFlowCanvas.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-signing-flow/src/ContractSigningFlowInspector.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-signing-flow/src/ContractSigningFlowNodeCard.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-signing-flow/src/ProContractSigningFlow.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-signing-flow/src/constants.cjs +1 -1
- package/dist/lib/components/pro-contract-signing-flow/style/index.css +1 -1
- package/dist/lib/components/pro-contract-template-designer/index.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateFileBar.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateFileBar.vue.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererField.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererValidation.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererValidation.vue.cjs +1 -0
- 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/ProContractTemplateRenderer.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/SigningPlacementLayer.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-designer.cjs +2 -2
- package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-draft-cache.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/composables/use-template-files.cjs +2 -0
- package/dist/lib/components/pro-contract-template-designer/src/extensions/word-paste.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/utils/file-tabs.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/utils/template-renderer.cjs +2 -2
- package/dist/lib/components/pro-contract-template-designer/src/utils/toolbar-overflow.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/theme/contract-signing-location.css +1 -1
- package/dist/theme/icon.css +1 -1
- package/dist/theme/index.css +1 -1
- package/dist/theme/pro-contract-signing-flow.css +1 -1
- package/dist/types/components/contract-signing-location/index.d.ts +1 -0
- package/dist/types/components/contract-signing-location/src/ContractSigningLocation.vue.d.ts +3 -1
- package/dist/types/components/contract-signing-location/src/ContractSigningLocationInspector.vue.d.ts +2 -2
- package/dist/types/components/contract-signing-location/src/ContractSigningTemplatePage.vue.d.ts +6 -0
- package/dist/types/components/contract-signing-location/src/location-rules.d.ts +3 -3
- package/dist/types/components/contract-signing-location/src/template-source.d.ts +20 -0
- package/dist/types/components/contract-signing-location/src/types.d.ts +47 -2
- package/dist/types/components/pro-contract-signing-flow/src/ContractSigningFlowCanvas.vue.d.ts +19 -3
- package/dist/types/components/pro-contract-signing-flow/src/ProContractSigningFlow.vue.d.ts +223 -2
- package/dist/types/components/pro-contract-signing-flow/src/constants.d.ts +15 -0
- package/dist/types/components/pro-contract-signing-flow/src/types.d.ts +12 -0
- package/dist/types/components/pro-contract-template-designer/index.d.ts +1 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerInspector.vue.d.ts +103 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerSidebar.vue.d.ts +48 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateFileBar.vue.d.ts +231 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateRendererValidation.vue.d.ts +15 -0
- package/dist/types/components/pro-contract-template-designer/src/DesignerPage.vue.d.ts +1 -1
- package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.d.ts +25 -2
- package/dist/types/components/pro-contract-template-designer/src/SigningPlacementInspector.vue.d.ts +2 -2
- package/dist/types/components/pro-contract-template-designer/src/composables/use-template-designer.d.ts +1 -1
- package/dist/types/components/pro-contract-template-designer/src/composables/use-template-draft-cache.d.ts +29 -1
- package/dist/types/components/pro-contract-template-designer/src/composables/use-template-files.d.ts +24 -0
- package/dist/types/components/pro-contract-template-designer/src/constants.d.ts +2 -2
- package/dist/types/components/pro-contract-template-designer/src/types.d.ts +59 -1
- package/dist/types/components/pro-contract-template-designer/src/utils/file-tabs.d.ts +3 -0
- package/dist/types/components/pro-contract-template-designer/src/utils/toolbar-overflow.d.ts +11 -0
- package/package.json +2 -1
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
//#region src/components/pro-contract-template-designer/src/composables/use-template-draft-cache.ts
|
|
2
|
-
var e = 1, t = "gd-antdv:pro-contract-template-designer:draft",
|
|
3
|
-
function
|
|
2
|
+
var e = 1, t = 1, n = "gd-antdv:pro-contract-template-designer:draft", r = 5e3, i = 2 * 1024 * 1024;
|
|
3
|
+
function a() {
|
|
4
4
|
if (!(typeof window > "u")) try {
|
|
5
|
-
let e = window.localStorage,
|
|
6
|
-
return e.setItem(
|
|
5
|
+
let e = window.localStorage, t = `${n}:availability`;
|
|
6
|
+
return e.setItem(t, "1"), e.removeItem(t), e;
|
|
7
7
|
} catch {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function o(e, t, n = {}) {
|
|
12
12
|
return {
|
|
13
13
|
type: e,
|
|
14
14
|
message: t,
|
|
15
15
|
...n
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function s(e) {
|
|
19
19
|
return typeof TextEncoder < "u" ? new TextEncoder().encode(e).length : e.length * 2;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function c(e) {
|
|
22
22
|
if (!e) return "";
|
|
23
23
|
let t = new Date(e);
|
|
24
24
|
return `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}`;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
let { storage: t, key: n, value: r, maxBytes: i, previousValueSerialized:
|
|
28
|
-
if (!t) return { status:
|
|
26
|
+
function l(e) {
|
|
27
|
+
let { storage: t, key: n, value: r, maxBytes: i, previousValueSerialized: a } = e;
|
|
28
|
+
if (!t) return { status: o("unavailable", "localStorage 不可用") };
|
|
29
29
|
let c = JSON.stringify(r);
|
|
30
|
-
if (c ===
|
|
31
|
-
status:
|
|
30
|
+
if (c === a) return {
|
|
31
|
+
status: o("unchanged", "草稿内容未变化"),
|
|
32
32
|
valueSerialized: c
|
|
33
33
|
};
|
|
34
34
|
let l = Date.now(), u = JSON.stringify({
|
|
35
35
|
version: 1,
|
|
36
36
|
savedAt: l,
|
|
37
37
|
value: r
|
|
38
|
-
}), d =
|
|
38
|
+
}), d = s(u);
|
|
39
39
|
if (d > i) return {
|
|
40
|
-
status:
|
|
40
|
+
status: o("too-large", "草稿过大,未缓存", {
|
|
41
41
|
bytes: d,
|
|
42
42
|
maxBytes: i
|
|
43
43
|
}),
|
|
@@ -45,7 +45,7 @@ function c(e) {
|
|
|
45
45
|
};
|
|
46
46
|
try {
|
|
47
47
|
return t.setItem(n, u), {
|
|
48
|
-
status:
|
|
48
|
+
status: o("saved", "草稿已缓存", {
|
|
49
49
|
savedAt: l,
|
|
50
50
|
bytes: d,
|
|
51
51
|
maxBytes: i
|
|
@@ -54,7 +54,7 @@ function c(e) {
|
|
|
54
54
|
};
|
|
55
55
|
} catch (e) {
|
|
56
56
|
return {
|
|
57
|
-
status:
|
|
57
|
+
status: o("write-failed", "草稿缓存失败", {
|
|
58
58
|
bytes: d,
|
|
59
59
|
maxBytes: i,
|
|
60
60
|
error: e instanceof Error ? e.message : String(e)
|
|
@@ -63,47 +63,114 @@ function c(e) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
66
|
+
function u(e) {
|
|
67
|
+
let { storage: t, key: n, value: r, maxBytes: i, previousValueSerialized: a } = e;
|
|
68
|
+
if (!t) return { status: o("unavailable", "localStorage 不可用") };
|
|
69
|
+
let c = JSON.stringify(r);
|
|
70
|
+
if (c === a) return {
|
|
71
|
+
status: o("unchanged", "草稿内容未变化"),
|
|
72
|
+
valueSerialized: c
|
|
73
|
+
};
|
|
74
|
+
let l = Date.now(), u = JSON.stringify({
|
|
75
|
+
kind: "files",
|
|
76
|
+
version: 1,
|
|
77
|
+
savedAt: l,
|
|
78
|
+
value: r
|
|
79
|
+
}), d = s(u);
|
|
80
|
+
if (d > i) return {
|
|
81
|
+
status: o("too-large", "草稿过大,未缓存", {
|
|
82
|
+
bytes: d,
|
|
83
|
+
maxBytes: i
|
|
84
|
+
}),
|
|
85
|
+
valueSerialized: c
|
|
86
|
+
};
|
|
87
|
+
try {
|
|
88
|
+
return t.setItem(n, u), {
|
|
89
|
+
status: o("saved", "草稿已缓存", {
|
|
90
|
+
savedAt: l,
|
|
91
|
+
bytes: d,
|
|
92
|
+
maxBytes: i
|
|
93
|
+
}),
|
|
94
|
+
valueSerialized: c
|
|
95
|
+
};
|
|
96
|
+
} catch (e) {
|
|
97
|
+
return {
|
|
98
|
+
status: o("write-failed", "草稿缓存失败", {
|
|
99
|
+
bytes: d,
|
|
100
|
+
maxBytes: i,
|
|
101
|
+
error: e instanceof Error ? e.message : String(e)
|
|
102
|
+
}),
|
|
103
|
+
valueSerialized: c
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function d(e, t) {
|
|
108
|
+
if (!e) return { status: o("unavailable", "localStorage 不可用") };
|
|
68
109
|
let n;
|
|
69
110
|
try {
|
|
70
111
|
n = e.getItem(t);
|
|
71
112
|
} catch (e) {
|
|
72
|
-
return { status:
|
|
113
|
+
return { status: o("read-failed", "草稿读取失败", { error: e instanceof Error ? e.message : String(e) }) };
|
|
73
114
|
}
|
|
74
|
-
if (!n) return { status:
|
|
115
|
+
if (!n) return { status: o("idle", "暂无本地草稿") };
|
|
75
116
|
try {
|
|
76
117
|
let e = JSON.parse(n);
|
|
77
|
-
return e.version !== 1 || !e.value ? { status:
|
|
78
|
-
status:
|
|
118
|
+
return e.version !== 1 || !e.value ? { status: o("invalid", "草稿版本不兼容") } : {
|
|
119
|
+
status: o("restored", "已恢复本地草稿", {
|
|
79
120
|
savedAt: e.savedAt,
|
|
80
|
-
bytes:
|
|
121
|
+
bytes: s(n)
|
|
81
122
|
}),
|
|
82
123
|
value: e.value,
|
|
83
124
|
valueSerialized: JSON.stringify(e.value)
|
|
84
125
|
};
|
|
85
126
|
} catch (e) {
|
|
86
|
-
return { status:
|
|
127
|
+
return { status: o("invalid", "草稿格式无效", { error: e instanceof Error ? e.message : String(e) }) };
|
|
87
128
|
}
|
|
88
129
|
}
|
|
89
|
-
function
|
|
90
|
-
if (!e) return
|
|
130
|
+
function f(e, t) {
|
|
131
|
+
if (!e) return { status: o("unavailable", "localStorage 不可用") };
|
|
132
|
+
let n;
|
|
91
133
|
try {
|
|
92
|
-
|
|
134
|
+
n = e.getItem(t);
|
|
93
135
|
} catch (e) {
|
|
94
|
-
return
|
|
136
|
+
return { status: o("read-failed", "草稿读取失败", { error: e instanceof Error ? e.message : String(e) }) };
|
|
137
|
+
}
|
|
138
|
+
if (!n) return { status: o("idle", "暂无本地草稿") };
|
|
139
|
+
try {
|
|
140
|
+
let e = JSON.parse(n);
|
|
141
|
+
return e.kind !== "files" || e.version !== 1 || !e.value || !Array.isArray(e.value.files) || typeof e.value.activeFileId != "string" ? { status: o("invalid", "草稿版本不兼容") } : {
|
|
142
|
+
status: o("restored", "已恢复本地草稿", {
|
|
143
|
+
savedAt: e.savedAt,
|
|
144
|
+
bytes: s(n)
|
|
145
|
+
}),
|
|
146
|
+
value: e.value,
|
|
147
|
+
valueSerialized: JSON.stringify(e.value)
|
|
148
|
+
};
|
|
149
|
+
} catch (e) {
|
|
150
|
+
return { status: o("invalid", "草稿格式无效", { error: e instanceof Error ? e.message : String(e) }) };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function p(e, t) {
|
|
154
|
+
if (!e) return o("unavailable", "localStorage 不可用");
|
|
155
|
+
try {
|
|
156
|
+
return e.removeItem(t), o("cleared", "草稿缓存已清理");
|
|
157
|
+
} catch (e) {
|
|
158
|
+
return o("write-failed", "草稿缓存清理失败", { error: e instanceof Error ? e.message : String(e) });
|
|
95
159
|
}
|
|
96
160
|
}
|
|
97
|
-
function
|
|
161
|
+
function m(e) {
|
|
98
162
|
if (!e) return !0;
|
|
99
163
|
if (e.variables.length || e.pages.length > 1 || e.signingPlacements?.length) return !1;
|
|
100
164
|
let t = e.pages[0];
|
|
101
|
-
return t ?
|
|
165
|
+
return t ? g(t.contentHtml || "") && _(t.contentJson) : !0;
|
|
166
|
+
}
|
|
167
|
+
function h(e) {
|
|
168
|
+
return !e || e.files.length === 0 || e.files.every((e) => m(e.template));
|
|
102
169
|
}
|
|
103
|
-
function
|
|
170
|
+
function g(e) {
|
|
104
171
|
return e.replace(/<br\s*\/?>/gi, "").replace(/<\/?p[^>]*>/gi, "").replace(/ /gi, "").replace(/\s+/g, "").trim().length === 0;
|
|
105
172
|
}
|
|
106
|
-
function
|
|
173
|
+
function _(e) {
|
|
107
174
|
return e?.content?.length ? e.content.every((e) => {
|
|
108
175
|
if (e.type !== "paragraph") return !1;
|
|
109
176
|
let t = e.content;
|
|
@@ -111,4 +178,4 @@ function p(e) {
|
|
|
111
178
|
}) : !0;
|
|
112
179
|
}
|
|
113
180
|
//#endregion
|
|
114
|
-
export { e as CONTRACT_TEMPLATE_DRAFT_CACHE_VERSION,
|
|
181
|
+
export { e as CONTRACT_TEMPLATE_DRAFT_CACHE_VERSION, t as CONTRACT_TEMPLATE_FILES_DRAFT_CACHE_VERSION, r as DEFAULT_DRAFT_CACHE_INTERVAL, n as DEFAULT_DRAFT_CACHE_KEY, i as DEFAULT_DRAFT_CACHE_MAX_BYTES, p as clearTemplateDraftCache, o as createDraftCacheStatus, s as estimateDraftCacheBytes, c as formatDraftCacheSavedAt, a as getBrowserDraftCacheStorage, m as isBlankTemplateDraftValue, h as isBlankTemplateFilesDraftValue, d as loadTemplateDraftCache, f as loadTemplateFilesDraftCache, l as saveTemplateDraftCache, u as saveTemplateFilesDraftCache };
|
package/dist/es/components/pro-contract-template-designer/src/composables/use-template-files.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { cloneTemplateValue as e, createBlankTemplate as t, createDesignerId as n, exportTemplateValue as r, normalizeTemplateValue as i } from "./use-template-designer.mjs";
|
|
2
|
+
//#region src/components/pro-contract-template-designer/src/composables/use-template-files.ts
|
|
3
|
+
function a(t) {
|
|
4
|
+
return t.map((t) => ({
|
|
5
|
+
id: t.id,
|
|
6
|
+
name: t.name,
|
|
7
|
+
template: e(t.template)
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
function o(e = "合同文件 1", r) {
|
|
11
|
+
return {
|
|
12
|
+
id: n("contract-file"),
|
|
13
|
+
name: e.trim() || "合同文件",
|
|
14
|
+
template: t(r)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function s(e, r, a) {
|
|
18
|
+
let o = Array.isArray(e) && e.length ? e : [{
|
|
19
|
+
id: n("contract-file"),
|
|
20
|
+
name: "合同文件 1",
|
|
21
|
+
template: r ?? t(a)
|
|
22
|
+
}], s = /* @__PURE__ */ new Set();
|
|
23
|
+
return o.map((e, t) => {
|
|
24
|
+
let r = typeof e?.id == "string" ? e.id.trim() : "";
|
|
25
|
+
return (!r || s.has(r)) && (r = n("contract-file")), s.add(r), {
|
|
26
|
+
id: r,
|
|
27
|
+
name: String(e?.name || "").trim() || `合同文件 ${t + 1}`,
|
|
28
|
+
template: i(e?.template, a)
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function c(e, t) {
|
|
33
|
+
let n = typeof t == "string" ? t.trim() : "";
|
|
34
|
+
return e.some((e) => e.id === n) ? n : e[0]?.id ?? "";
|
|
35
|
+
}
|
|
36
|
+
function l(t, n, r) {
|
|
37
|
+
return t.map((t) => t.id === n ? {
|
|
38
|
+
...t,
|
|
39
|
+
template: e(r)
|
|
40
|
+
} : t);
|
|
41
|
+
}
|
|
42
|
+
function u(e, t, n) {
|
|
43
|
+
let r = n.trim();
|
|
44
|
+
return e.map((e) => e.id === t ? {
|
|
45
|
+
...e,
|
|
46
|
+
name: r || e.name
|
|
47
|
+
} : e);
|
|
48
|
+
}
|
|
49
|
+
function d(e, t) {
|
|
50
|
+
return e.length <= 1 || !e.some((e) => e.id === t) ? [...e] : e.filter((e) => e.id !== t);
|
|
51
|
+
}
|
|
52
|
+
function f(e, t, n) {
|
|
53
|
+
let r = e.findIndex((e) => e.id === t), i = r + n;
|
|
54
|
+
if (r < 0 || i < 0 || i >= e.length) return [...e];
|
|
55
|
+
let a = [...e], [o] = a.splice(r, 1);
|
|
56
|
+
return o && a.splice(i, 0, o), a;
|
|
57
|
+
}
|
|
58
|
+
function p(e) {
|
|
59
|
+
let t = e.map((e) => {
|
|
60
|
+
let t = r(e.template);
|
|
61
|
+
return {
|
|
62
|
+
id: e.id,
|
|
63
|
+
name: e.name,
|
|
64
|
+
template: t,
|
|
65
|
+
html: t.html
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
files: t,
|
|
70
|
+
combinedHtml: t.map((e) => `<section data-contract-file-id="${m(e.id)}" data-contract-file-name="${m(e.name)}">${e.template.html}</section>`).join("\n")
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function m(e) {
|
|
74
|
+
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { a as cloneContractTemplateFiles, o as createContractTemplateFile, p as exportContractTemplateFiles, f as moveContractTemplateFile, s as normalizeContractTemplateFiles, d as removeContractTemplateFile, u as renameContractTemplateFile, l as replaceContractTemplateFile, c as resolveContractTemplateActiveFileId };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { escapeHtmlAttribute as e } from "../utils/html.mjs";
|
|
2
|
+
import { detectClipboardHtmlSource as t, extractRtfImageDataUrls as n, normalizeWordClipboardHtml as r, plainTextToSafeHtml as i, readClipboardImageFiles as a } from "../utils/word-paste.mjs";
|
|
3
3
|
import { Extension as o } from "@tiptap/core";
|
|
4
4
|
import { Plugin as s, PluginKey as c } from "@tiptap/pm/state";
|
|
5
5
|
//#region src/components/pro-contract-template-designer/src/extensions/word-paste.ts
|
|
@@ -13,15 +13,15 @@ var l = 0, u = "application/x-gd-contract-template", d = `contract-template-${Da
|
|
|
13
13
|
return {};
|
|
14
14
|
},
|
|
15
15
|
transformPastedHTML(e) {
|
|
16
|
-
let t = this.storage.pending,
|
|
16
|
+
let t = this.storage.pending, n = r(e, {
|
|
17
17
|
plainText: t?.plainText,
|
|
18
18
|
rtf: t?.rtf,
|
|
19
19
|
trustedInternal: t?.trustedInternal
|
|
20
20
|
});
|
|
21
|
-
return t && (t.source =
|
|
21
|
+
return t && (t.source = n.source, t.recoveredRtfImages = n.recoveredImageCount), n.html;
|
|
22
22
|
},
|
|
23
23
|
addProseMirrorPlugins() {
|
|
24
|
-
let
|
|
24
|
+
let n = this.editor, o = this.storage, c = this.options.processImageFile;
|
|
25
25
|
return [new s({
|
|
26
26
|
key: f,
|
|
27
27
|
state: {
|
|
@@ -50,7 +50,7 @@ var l = 0, u = "application/x-gd-contract-template", d = `contract-template-${Da
|
|
|
50
50
|
handleDOMEvents: {
|
|
51
51
|
copy: (e, t) => m(e, t, !1),
|
|
52
52
|
cut: (e, t) => m(e, t, !0),
|
|
53
|
-
paste: (
|
|
53
|
+
paste: (e, n) => {
|
|
54
54
|
let r = n.clipboardData;
|
|
55
55
|
if (!r) return !1;
|
|
56
56
|
let i = r.getData("text/html"), a = {
|
|
@@ -58,7 +58,7 @@ var l = 0, u = "application/x-gd-contract-template", d = `contract-template-${Da
|
|
|
58
58
|
plainText: r.getData("text/plain"),
|
|
59
59
|
rtf: r.getData("text/rtf") || r.getData("application/rtf"),
|
|
60
60
|
files: _(r),
|
|
61
|
-
source:
|
|
61
|
+
source: t(i),
|
|
62
62
|
recoveredRtfImages: 0,
|
|
63
63
|
trustedInternal: r.getData(u) === d || i.includes(`data-gd-contract-copy="${d}"`) || i.includes(`data-gd-contract-copy='${d}'`)
|
|
64
64
|
};
|
|
@@ -67,7 +67,7 @@ var l = 0, u = "application/x-gd-contract-template", d = `contract-template-${Da
|
|
|
67
67
|
}), !1;
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
-
handlePaste: (
|
|
70
|
+
handlePaste: (t, s) => {
|
|
71
71
|
let u = o.pending;
|
|
72
72
|
if (!u) return !1;
|
|
73
73
|
let d = u.files.length ? u.files : _(s.clipboardData), p = u.recoveredRtfImages || v(u.rtf), m = d.length > 0 && p === 0 && !u.trustedInternal;
|
|
@@ -75,28 +75,28 @@ var l = 0, u = "application/x-gd-contract-template", d = `contract-template-${Da
|
|
|
75
75
|
s.preventDefault();
|
|
76
76
|
let y = `word-paste-${++l}`, b = {
|
|
77
77
|
token: y,
|
|
78
|
-
from:
|
|
79
|
-
to:
|
|
78
|
+
from: t.state.selection.from,
|
|
79
|
+
to: t.state.selection.to
|
|
80
80
|
};
|
|
81
|
-
return
|
|
81
|
+
return t.dispatch(t.state.tr.setMeta(f, {
|
|
82
82
|
type: "set",
|
|
83
83
|
...b
|
|
84
|
-
}).setMeta("addToHistory", !1)),
|
|
85
|
-
if (
|
|
86
|
-
let
|
|
87
|
-
if (!
|
|
88
|
-
let o =
|
|
89
|
-
g(
|
|
84
|
+
}).setMeta("addToHistory", !1)), a(d, c).then((t) => {
|
|
85
|
+
if (n.isDestroyed) return;
|
|
86
|
+
let a = f.getState(n.state)?.get(y);
|
|
87
|
+
if (!a) return;
|
|
88
|
+
let o = t.filter((e) => !!e);
|
|
89
|
+
g(n, a, (u.html ? r(u.html, {
|
|
90
90
|
plainText: u.plainText,
|
|
91
91
|
rtf: u.rtf,
|
|
92
|
-
clipboardImages:
|
|
92
|
+
clipboardImages: t,
|
|
93
93
|
preferClipboardImages: !0,
|
|
94
94
|
trustedInternal: u.trustedInternal
|
|
95
|
-
}).html : o.length ? `<p>${o.map((
|
|
95
|
+
}).html : o.length ? `<p>${o.map((t) => `<img src="${e(t)}" alt="">`).join("")}</p>` : i(u.plainText)) || i(u.plainText));
|
|
96
96
|
}).catch(() => {
|
|
97
|
-
if (
|
|
98
|
-
let e = f.getState(
|
|
99
|
-
e ? g(
|
|
97
|
+
if (n.isDestroyed) return;
|
|
98
|
+
let e = f.getState(n.state)?.get(y);
|
|
99
|
+
e ? g(n, e, i(u.plainText)) : h(n, y);
|
|
100
100
|
}), !0;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -139,7 +139,7 @@ function _(e) {
|
|
|
139
139
|
return t;
|
|
140
140
|
}
|
|
141
141
|
function v(e) {
|
|
142
|
-
return
|
|
142
|
+
return n(e).length;
|
|
143
143
|
}
|
|
144
144
|
//#endregion
|
|
145
145
|
export { p as WordPaste };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/components/pro-contract-template-designer/src/utils/file-tabs.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
if (!(n <= 0 || e < 0 || e >= n)) switch (t) {
|
|
4
|
+
case "ArrowDown":
|
|
5
|
+
case "ArrowRight": return (e + 1) % n;
|
|
6
|
+
case "ArrowLeft":
|
|
7
|
+
case "ArrowUp": return (e - 1 + n) % n;
|
|
8
|
+
case "Home": return 0;
|
|
9
|
+
case "End": return n - 1;
|
|
10
|
+
default: return;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { e as resolveContractTemplateFileTabTargetIndex };
|