@guodun/antdv 1.4.8 → 1.5.1
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/src/ContractSigningLocation.vue.mjs +315 -286
- package/dist/es/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.mjs +316 -285
- package/dist/es/components/contract-signing-location/src/ContractSigningTemplatePage.vue.mjs +62 -54
- package/dist/es/components/contract-signing-location/style/index.css +1 -1
- package/dist/es/components/index.mjs +1 -0
- package/dist/es/components/pro-contract-template-designer/index.mjs +1 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractPrintIframe.mjs +7 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractPrintIframe.vue.mjs +129 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractPrintIframe.vue_vue_type_style_index_0_scoped_a9912ff0_lang.css +1 -0
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePreviewModal.vue.mjs +10 -5
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.mjs +64 -43
- package/dist/es/components/pro-contract-template-designer/src/ContractTemplateRendererPage.vue.mjs +82 -53
- package/dist/es/components/pro-contract-template-designer/src/DesignerPage.vue.mjs +271 -265
- package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.mjs +762 -751
- package/dist/es/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.mjs +217 -197
- package/dist/es/components/pro-contract-template-designer/src/constants.mjs +29 -51
- package/dist/es/components/pro-contract-template-designer/src/extensions/template-variable.mjs +103 -103
- package/dist/es/components/pro-contract-template-designer/src/extensions/word-paste.mjs +24 -21
- package/dist/es/components/pro-contract-template-designer/src/utils/contract-print-document.mjs +314 -0
- package/dist/es/components/pro-contract-template-designer/src/utils/page-decorations.mjs +1 -1
- package/dist/es/components/pro-contract-template-designer/src/utils/template-variable-render.mjs +47 -47
- package/dist/es/components/pro-contract-template-designer/src/utils/word-paste.mjs +216 -148
- package/dist/es/components/pro-contract-template-designer/style/index.css +1 -1
- package/dist/es/index.mjs +27 -26
- 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/ContractSigningTemplatePage.vue.cjs +1 -1
- 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-template-designer/index.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractPrintIframe.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractPrintIframe.vue.cjs +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractPrintIframe.vue_vue_type_style_index_0_scoped_a9912ff0_lang.css +1 -0
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePreviewModal.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/ContractTemplateRendererPage.vue.cjs +1 -1
- 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/constants.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/extensions/template-variable.cjs +1 -1
- 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/contract-print-document.cjs +211 -0
- package/dist/lib/components/pro-contract-template-designer/src/utils/page-decorations.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/utils/template-variable-render.cjs +1 -1
- package/dist/lib/components/pro-contract-template-designer/src/utils/word-paste.cjs +2 -2
- 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/types/components/contract-signing-location/src/ContractSigningLocation.vue.d.ts +7 -0
- package/dist/types/components/contract-signing-location/src/ContractSigningLocationCanvas.vue.d.ts +4 -0
- package/dist/types/components/contract-signing-location/src/ContractSigningTemplatePage.vue.d.ts +9 -3
- package/dist/types/components/contract-signing-location/src/types.d.ts +5 -0
- package/dist/types/components/pro-contract-template-designer/index.d.ts +1 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractPrintIframe.vue.d.ts +35 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateDesignerToolbar.vue.d.ts +2 -2
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplatePreviewModal.vue.d.ts +1 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplatePreviewPage.vue.d.ts +1 -0
- package/dist/types/components/pro-contract-template-designer/src/ContractTemplateRendererPage.vue.d.ts +13 -1
- package/dist/types/components/pro-contract-template-designer/src/DesignerPage.vue.d.ts +6 -0
- package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateDesigner.vue.d.ts +1 -0
- package/dist/types/components/pro-contract-template-designer/src/ProContractTemplateRenderer.vue.d.ts +1 -0
- package/dist/types/components/pro-contract-template-designer/src/constants.d.ts +4 -4
- package/dist/types/components/pro-contract-template-designer/src/extensions/word-paste.d.ts +8 -0
- package/dist/types/components/pro-contract-template-designer/src/types.d.ts +10 -0
- package/dist/types/components/pro-contract-template-designer/src/utils/contract-print-document.d.ts +119 -0
- package/dist/types/components/pro-contract-template-designer/src/utils/word-paste.d.ts +2 -0
- package/package.json +4 -3
|
@@ -1,15 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import t from "
|
|
1
|
+
import { DEFAULT_CONTRACT_FONT_FAMILY as e } from "../constants.mjs";
|
|
2
|
+
import { isSafeContractImageUrl as t } from "./image-url.mjs";
|
|
3
|
+
import n from "dompurify";
|
|
3
4
|
//#region src/components/pro-contract-template-designer/src/utils/word-paste.ts
|
|
4
|
-
var
|
|
5
|
+
var r = 4 * 1024 * 1024, i = e, a = "16px", o = "1.75", s = new Set([
|
|
6
|
+
"serif",
|
|
7
|
+
"sans-serif",
|
|
8
|
+
"monospace",
|
|
9
|
+
"cursive",
|
|
10
|
+
"fantasy",
|
|
11
|
+
"system-ui",
|
|
12
|
+
"ui-serif",
|
|
13
|
+
"ui-sans-serif",
|
|
14
|
+
"ui-monospace",
|
|
15
|
+
"ui-rounded",
|
|
16
|
+
"emoji",
|
|
17
|
+
"math",
|
|
18
|
+
"fangsong",
|
|
19
|
+
"inherit",
|
|
20
|
+
"initial",
|
|
21
|
+
"unset",
|
|
22
|
+
"revert",
|
|
23
|
+
"revert-layer",
|
|
24
|
+
"-apple-system",
|
|
25
|
+
"blinkmacsystemfont"
|
|
26
|
+
]), c = new Set([
|
|
5
27
|
"image/png",
|
|
6
28
|
"image/jpeg",
|
|
7
29
|
"image/gif",
|
|
8
30
|
"image/webp",
|
|
9
31
|
"image/bmp"
|
|
10
|
-
]),
|
|
11
|
-
RegExp(`<(?:img|v:imagedata)\\b[^>]+\\bsrc\\s*=\\s*["']\\s*${
|
|
12
|
-
var
|
|
32
|
+
]), l = "(?:file:|cid:|mhtml:|wordml:|blob:)", u = RegExp(`^${l}`, "i");
|
|
33
|
+
RegExp(`<(?:img|v:imagedata)\\b[^>]+\\bsrc\\s*=\\s*["']\\s*${l}`, "i");
|
|
34
|
+
var d = /* @__PURE__ */ "p.div.span.br.hr.h1.h2.h3.h4.h5.h6.strong.b.em.i.u.s.strike.del.sup.sub.blockquote.pre.code.a.ul.ol.li.table.thead.tbody.tfoot.tr.th.td.img".split("."), f = [
|
|
13
35
|
"style",
|
|
14
36
|
"href",
|
|
15
37
|
"target",
|
|
@@ -24,7 +46,7 @@ var l = /* @__PURE__ */ "p.div.span.br.hr.h1.h2.h3.h4.h5.h6.strong.b.em.i.u.s.st
|
|
|
24
46
|
"title",
|
|
25
47
|
"width",
|
|
26
48
|
"height"
|
|
27
|
-
],
|
|
49
|
+
], p = new Set(f), m = new Set([
|
|
28
50
|
"script",
|
|
29
51
|
"style",
|
|
30
52
|
"meta",
|
|
@@ -50,7 +72,7 @@ var l = /* @__PURE__ */ "p.div.span.br.hr.h1.h2.h3.h4.h5.h6.strong.b.em.i.u.s.st
|
|
|
50
72
|
"math",
|
|
51
73
|
"xml",
|
|
52
74
|
"template"
|
|
53
|
-
]),
|
|
75
|
+
]), h = new Set([
|
|
54
76
|
"font-weight",
|
|
55
77
|
"font-style",
|
|
56
78
|
"text-decoration",
|
|
@@ -60,7 +82,7 @@ var l = /* @__PURE__ */ "p.div.span.br.hr.h1.h2.h3.h4.h5.h6.strong.b.em.i.u.s.st
|
|
|
60
82
|
"font-size",
|
|
61
83
|
"font-family",
|
|
62
84
|
"vertical-align"
|
|
63
|
-
]),
|
|
85
|
+
]), g = new Set([
|
|
64
86
|
"font-weight",
|
|
65
87
|
"font-style",
|
|
66
88
|
"text-decoration",
|
|
@@ -77,7 +99,7 @@ var l = /* @__PURE__ */ "p.div.span.br.hr.h1.h2.h3.h4.h5.h6.strong.b.em.i.u.s.st
|
|
|
77
99
|
"padding-left",
|
|
78
100
|
"text-indent",
|
|
79
101
|
"direction"
|
|
80
|
-
]),
|
|
102
|
+
]), _ = new Set([
|
|
81
103
|
"font-weight",
|
|
82
104
|
"font-style",
|
|
83
105
|
"text-decoration",
|
|
@@ -95,7 +117,7 @@ var l = /* @__PURE__ */ "p.div.span.br.hr.h1.h2.h3.h4.h5.h6.strong.b.em.i.u.s.st
|
|
|
95
117
|
"text-indent",
|
|
96
118
|
"direction",
|
|
97
119
|
"list-style-type"
|
|
98
|
-
]),
|
|
120
|
+
]), v = new Set([
|
|
99
121
|
"width",
|
|
100
122
|
"max-width",
|
|
101
123
|
"min-width",
|
|
@@ -103,31 +125,31 @@ var l = /* @__PURE__ */ "p.div.span.br.hr.h1.h2.h3.h4.h5.h6.strong.b.em.i.u.s.st
|
|
|
103
125
|
"border-collapse",
|
|
104
126
|
"margin-left",
|
|
105
127
|
"margin-right"
|
|
106
|
-
]),
|
|
128
|
+
]), y = new Set(/* @__PURE__ */ "font-weight.font-style.text-decoration.text-decoration-line.color.background-color.font-size.font-family.text-align.line-height.margin-top.margin-bottom.margin-left.text-indent.direction.width.height.min-width.vertical-align.padding.padding-top.padding-right.padding-bottom.padding-left.border.border-top.border-right.border-bottom.border-left".split(".")), ee = [
|
|
107
129
|
/urn:schemas-microsoft-com:office/i,
|
|
108
130
|
/xmlns:(?:o|w|m)\s*=/i,
|
|
109
131
|
/class\s*=\s*["'][^"']*\bMso/i,
|
|
110
132
|
/\bmso-[\w-]+\s*:/i,
|
|
111
133
|
/\[if\s+(?:gte\s+)?mso/i,
|
|
112
134
|
/Microsoft Word/i
|
|
113
|
-
],
|
|
135
|
+
], te = [
|
|
114
136
|
/\bListContainerWrapper\b/i,
|
|
115
137
|
/\bdata-listid\s*=/i,
|
|
116
138
|
/\bdata-list-defn-props\s*=/i,
|
|
117
139
|
/\bdata-ccp-props\s*=/i,
|
|
118
140
|
/\bdata-contrast\s*=/i
|
|
119
|
-
],
|
|
141
|
+
], b = [
|
|
120
142
|
/\b(?:WPS Office|Kingsoft)\b/i,
|
|
121
143
|
/\bwpsoffice\b/i,
|
|
122
144
|
/\bwps-(?:office|list|paragraph)\b/i
|
|
123
145
|
];
|
|
124
|
-
function
|
|
125
|
-
return /\bdata-pm-slice\s*=/i.test(e) ? "internal" :
|
|
146
|
+
function x(e) {
|
|
147
|
+
return /\bdata-pm-slice\s*=/i.test(e) ? "internal" : b.some((t) => t.test(e)) ? "wps" : te.some((t) => t.test(e)) ? "word-online" : ee.some((t) => t.test(e)) ? /Microsoft Word|Mso|xmlns:w/i.test(e) ? "word" : "office" : "generic";
|
|
126
148
|
}
|
|
127
|
-
function
|
|
149
|
+
function S(e) {
|
|
128
150
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'").split(/\r?\n\r?\n/).map((e) => `<p>${e.replace(/\r?\n/g, "<br>") || "<br>"}</p>`).join("");
|
|
129
151
|
}
|
|
130
|
-
function
|
|
152
|
+
function C(e) {
|
|
131
153
|
let t = /(?:^|;)\s*mso-list\s*:\s*(?:l(\d+)\s+)?level(\d+)(?:\s+lfo(\d+))?/i.exec(e);
|
|
132
154
|
if (t) return {
|
|
133
155
|
id: t[1] ?? "0",
|
|
@@ -135,8 +157,8 @@ function re(e) {
|
|
|
135
157
|
lfo: t[3] ?? "0"
|
|
136
158
|
};
|
|
137
159
|
}
|
|
138
|
-
function
|
|
139
|
-
let n = t.toLowerCase(), r = n === "td" || n === "th" ?
|
|
160
|
+
function w(e, t = "span") {
|
|
161
|
+
let n = t.toLowerCase(), r = n === "td" || n === "th" ? y : n === "table" ? v : n === "ul" || n === "ol" ? _ : /^(?:p|div|h[1-6]|blockquote|li)$/.test(n) ? g : h, i = E(e), a = i.find(([e]) => e.trim().toLowerCase() === "direction")?.[1]?.trim().toLowerCase() === "rtl" ? "rtl" : "ltr", o = /* @__PURE__ */ new Map();
|
|
140
162
|
for (let [e, t] of i) {
|
|
141
163
|
let n = e.toLowerCase().trim(), i = t.trim().replace(/\s*!important\s*$/i, "");
|
|
142
164
|
if (n === "mso-highlight" || n === "background") n = "background-color";
|
|
@@ -144,34 +166,34 @@ function b(e, t = "span") {
|
|
|
144
166
|
else if (n === "mso-border-alt") n = "border";
|
|
145
167
|
else if (/^mso-border-(top|right|bottom|left)-alt$/.test(n)) n = n.replace(/^mso-border-(top|right|bottom|left)-alt$/, "border-$1");
|
|
146
168
|
else if (n.startsWith("mso-")) continue;
|
|
147
|
-
r.has(n) && (n === "text-align" && /^(?:start|end)$/i.test(i) && (i =
|
|
169
|
+
r.has(n) && (n === "text-align" && /^(?:start|end)$/i.test(i) && (i = D(i, a)), i = le(n, i), i && o.set(n === "text-decoration-line" ? "text-decoration" : n, i));
|
|
148
170
|
}
|
|
149
171
|
return Array.from(o.entries()).map(([e, t]) => `${e}: ${t}`).join("; ");
|
|
150
172
|
}
|
|
151
|
-
function
|
|
173
|
+
function T(e) {
|
|
152
174
|
if (!e || e.length > 12582912 * 3) return [];
|
|
153
175
|
let t = [], n = 0, r = 0;
|
|
154
176
|
for (; r < e.length;) {
|
|
155
177
|
let i = e.indexOf("{\\pict", r);
|
|
156
178
|
if (i < 0) break;
|
|
157
|
-
let a =
|
|
179
|
+
let a = be(e, i);
|
|
158
180
|
if (a < 0) break;
|
|
159
181
|
let o = e.slice(i, a + 1);
|
|
160
182
|
r = i + 6;
|
|
161
|
-
let s =
|
|
183
|
+
let s = xe(o), c = /\\pngblip\b/i.test(s) ? "image/png" : /\\jpe?gblip\b/i.test(s) ? "image/jpeg" : "";
|
|
162
184
|
if (!c) continue;
|
|
163
185
|
let l = s.replace(/^\{\\pict\b/i, "").replace(/\\[a-z]+-?\d*\s?/gi, "").replace(/\\[^a-z]/gi, "").replace(/[{}\s]/g, "");
|
|
164
186
|
if (!l || l.length % 2 || /[^\da-f]/i.test(l)) continue;
|
|
165
187
|
let u = l.length / 2;
|
|
166
|
-
u > 5242880 || n + u > 12582912 ||
|
|
188
|
+
u > 5242880 || n + u > 12582912 || Ce(l, c) && (n += u, t.push(`data:${c};base64,${Se(l)}`));
|
|
167
189
|
}
|
|
168
190
|
return t;
|
|
169
191
|
}
|
|
170
|
-
async function
|
|
192
|
+
async function ne(e, t) {
|
|
171
193
|
let n = [], r = 0;
|
|
172
194
|
for (let i of e) {
|
|
173
195
|
let e = i.type.toLowerCase();
|
|
174
|
-
if (!
|
|
196
|
+
if (!c.has(e) || i.size <= 0 || i.size > 5242880) {
|
|
175
197
|
n.push(Promise.resolve(null));
|
|
176
198
|
continue;
|
|
177
199
|
}
|
|
@@ -179,53 +201,63 @@ async function S(e, t) {
|
|
|
179
201
|
n.push(Promise.resolve(null));
|
|
180
202
|
continue;
|
|
181
203
|
}
|
|
182
|
-
r += i.size, n.push((t ? t(i) :
|
|
204
|
+
r += i.size, n.push((t ? t(i) : we(i)).then((e) => e && Y(e) ? e : null).catch(() => null));
|
|
183
205
|
}
|
|
184
206
|
return Promise.all(n);
|
|
185
207
|
}
|
|
186
|
-
function
|
|
187
|
-
let i =
|
|
188
|
-
if (i === "internal" &&
|
|
208
|
+
function re(e, t = {}) {
|
|
209
|
+
let i = x(e);
|
|
210
|
+
if (i === "internal" && t.trustedInternal) return {
|
|
189
211
|
html: e,
|
|
190
212
|
source: i,
|
|
191
213
|
converted: !1,
|
|
192
214
|
fallback: !1,
|
|
193
|
-
recoveredImageCount: 0
|
|
215
|
+
recoveredImageCount: 0,
|
|
216
|
+
replacedFontFamilies: []
|
|
194
217
|
};
|
|
195
|
-
let a =
|
|
196
|
-
if (!e || e.length >
|
|
218
|
+
let a = S(t.plainText ?? oe(e));
|
|
219
|
+
if (!e || e.length > r || typeof window > "u" || typeof DOMParser > "u") return {
|
|
197
220
|
html: a,
|
|
198
221
|
source: i,
|
|
199
222
|
converted: !0,
|
|
200
223
|
fallback: !0,
|
|
201
|
-
recoveredImageCount: 0
|
|
224
|
+
recoveredImageCount: 0,
|
|
225
|
+
replacedFontFamilies: []
|
|
202
226
|
};
|
|
203
227
|
try {
|
|
204
|
-
let
|
|
205
|
-
(
|
|
206
|
-
let
|
|
207
|
-
office:
|
|
208
|
-
replacementImages:
|
|
209
|
-
appendClipboardImages:
|
|
228
|
+
let r = i !== "generic" && i !== "internal", o = ie(e), s = new DOMParser().parseFromString(r ? ae(o) : o, "text/html"), c = N(s), l = c.size > 0 || F(s);
|
|
229
|
+
(r || l) && P(s, c), r && (I(s), L(s));
|
|
230
|
+
let u = r ? T(t.rtf ?? "") : [], p = !!t.preferClipboardImages && u.length === 0, m = ue(s, {
|
|
231
|
+
office: r,
|
|
232
|
+
replacementImages: u.length ? u : t.clipboardImages ?? [],
|
|
233
|
+
appendClipboardImages: u.length === 0 ? t.clipboardImages ?? [] : [],
|
|
210
234
|
preferClipboardImages: p
|
|
211
|
-
}), h =
|
|
212
|
-
ALLOWED_TAGS:
|
|
213
|
-
ALLOWED_ATTR:
|
|
235
|
+
}), h = n(window), g = String(h.sanitize(s.body.innerHTML, {
|
|
236
|
+
ALLOWED_TAGS: d,
|
|
237
|
+
ALLOWED_ATTR: f,
|
|
214
238
|
ALLOW_DATA_ATTR: !1,
|
|
215
239
|
ALLOW_ARIA_ATTR: !1,
|
|
216
240
|
KEEP_CONTENT: !0,
|
|
217
241
|
RETURN_TRUSTED_TYPE: !1
|
|
218
242
|
}));
|
|
219
243
|
if (g) {
|
|
220
|
-
let e = new DOMParser().parseFromString(g, "text/html");
|
|
221
|
-
|
|
244
|
+
let e = new DOMParser().parseFromString(g, "text/html"), t = de(e);
|
|
245
|
+
return g = e.body.innerHTML, {
|
|
246
|
+
html: g || a,
|
|
247
|
+
source: i,
|
|
248
|
+
converted: !0,
|
|
249
|
+
fallback: !g,
|
|
250
|
+
recoveredImageCount: m,
|
|
251
|
+
replacedFontFamilies: g ? t : []
|
|
252
|
+
};
|
|
222
253
|
}
|
|
223
254
|
return {
|
|
224
|
-
html:
|
|
255
|
+
html: a,
|
|
225
256
|
source: i,
|
|
226
257
|
converted: !0,
|
|
227
|
-
fallback: !
|
|
228
|
-
recoveredImageCount: m
|
|
258
|
+
fallback: !0,
|
|
259
|
+
recoveredImageCount: m,
|
|
260
|
+
replacedFontFamilies: []
|
|
229
261
|
};
|
|
230
262
|
} catch {
|
|
231
263
|
return {
|
|
@@ -233,7 +265,8 @@ function C(e, r = {}) {
|
|
|
233
265
|
source: i,
|
|
234
266
|
converted: !0,
|
|
235
267
|
fallback: !0,
|
|
236
|
-
recoveredImageCount: 0
|
|
268
|
+
recoveredImageCount: 0,
|
|
269
|
+
replacedFontFamilies: []
|
|
237
270
|
};
|
|
238
271
|
}
|
|
239
272
|
}
|
|
@@ -246,7 +279,7 @@ function ae(e) {
|
|
|
246
279
|
function oe(e) {
|
|
247
280
|
return e.replace(/<br\s*\/?>/gi, "\n").replace(/<\/(?:p|div|li|h[1-6]|tr)>/gi, "\n").replace(/<[^>]*>/g, "").replace(/ /gi, " ").replace(/&/gi, "&").replace(/</gi, "<").replace(/>/gi, ">").trim();
|
|
248
281
|
}
|
|
249
|
-
function
|
|
282
|
+
function E(e) {
|
|
250
283
|
let t = [], n = 0, r = "", i = 0;
|
|
251
284
|
for (let a = 0; a <= e.length; a++) {
|
|
252
285
|
let o = e[a] ?? ";";
|
|
@@ -267,78 +300,112 @@ function w(e) {
|
|
|
267
300
|
}
|
|
268
301
|
return t;
|
|
269
302
|
}
|
|
270
|
-
function se(e
|
|
303
|
+
function se(e) {
|
|
304
|
+
let t = [], n = "", r = "";
|
|
305
|
+
for (let i of e) {
|
|
306
|
+
if (r) {
|
|
307
|
+
i === r ? r = "" : n += i;
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (i === "\"" || i === "'") {
|
|
311
|
+
r = i;
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
if (i === ",") {
|
|
315
|
+
let e = n.trim();
|
|
316
|
+
e && t.push(e), n = "";
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
n += i;
|
|
320
|
+
}
|
|
321
|
+
let i = n.trim();
|
|
322
|
+
return i && t.push(i), t;
|
|
323
|
+
}
|
|
324
|
+
function ce(e) {
|
|
325
|
+
let t = /* @__PURE__ */ new Set(), n = [], r = i.replace(/["']/g, "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
326
|
+
for (let i of e) {
|
|
327
|
+
let e = i.replace(/["']/g, "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
328
|
+
if (!(!e || e === r)) for (let e of se(i)) {
|
|
329
|
+
let r = e.replace(/^["']+|["']+$/g, "").trim();
|
|
330
|
+
if (!r) continue;
|
|
331
|
+
let i = r.replace(/\s+/g, " ").toLowerCase();
|
|
332
|
+
s.has(i) || t.has(i) || (t.add(i), n.push(r));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return n;
|
|
336
|
+
}
|
|
337
|
+
function le(e, t) {
|
|
271
338
|
let n = t.trim();
|
|
272
339
|
if (!n || n.length > 220 || /(?:url\s*\(|expression\s*\(|javascript:|vbscript:|data:|@import|var\s*\()/i.test(n)) return "";
|
|
273
|
-
if (e === "font-size") return
|
|
340
|
+
if (e === "font-size") return O(n, {
|
|
274
341
|
min: 8,
|
|
275
342
|
max: 120,
|
|
276
343
|
convertPt: !0,
|
|
277
344
|
allowPercent: !0
|
|
278
345
|
});
|
|
279
|
-
if (e === "padding") return
|
|
280
|
-
if (/^(?:margin-(?:top|bottom|left|right)|text-indent)$/.test(e)) return
|
|
346
|
+
if (e === "padding") return M(n);
|
|
347
|
+
if (/^(?:margin-(?:top|bottom|left|right)|text-indent)$/.test(e)) return O(n, {
|
|
281
348
|
min: -2e3,
|
|
282
349
|
max: 2e3,
|
|
283
350
|
allowPercent: !0
|
|
284
351
|
});
|
|
285
|
-
if (/^(?:padding-(?:top|right|bottom|left)|width|height|min-width|max-width)$/.test(e)) return
|
|
352
|
+
if (/^(?:padding-(?:top|right|bottom|left)|width|height|min-width|max-width)$/.test(e)) return O(n, {
|
|
286
353
|
min: 0,
|
|
287
354
|
max: 2400,
|
|
288
355
|
allowPercent: !0
|
|
289
356
|
});
|
|
290
357
|
if (e === "line-height") {
|
|
291
358
|
let e = Number(n);
|
|
292
|
-
return Number.isFinite(e) && e >= .5 && e <= 4 ? String(e) :
|
|
359
|
+
return Number.isFinite(e) && e >= .5 && e <= 4 ? String(e) : O(n, {
|
|
293
360
|
min: 8,
|
|
294
361
|
max: 160,
|
|
295
362
|
convertPt: !0,
|
|
296
363
|
allowPercent: !0
|
|
297
364
|
});
|
|
298
365
|
}
|
|
299
|
-
return e === "color" || e === "background-color" ?
|
|
366
|
+
return e === "color" || e === "background-color" ? A(n) : e === "font-family" ? /^[\w\s,'"\-\u00A0-\uFFFF]+$/.test(n) ? n : "" : e === "font-weight" ? /^(?:normal|bold|bolder|lighter|[1-9]00)$/i.test(n) ? n.toLowerCase() : "" : e === "font-style" ? /^(?:normal|italic|oblique)$/i.test(n) ? n.toLowerCase() : "" : e === "text-decoration" ? /^(?:(?:none|underline|line-through|overline)\s*)+$/i.test(n) ? n.toLowerCase() : "" : e === "text-align" ? /^(?:left|right|center|justify|start|end)$/i.test(n) ? D(n, "ltr") : "" : e === "vertical-align" ? /^(?:top|middle|bottom|baseline|sub|super)$/i.test(n) ? n.toLowerCase() : "" : e === "direction" ? /^(?:ltr|rtl)$/i.test(n) ? n.toLowerCase() : "" : e === "list-style-type" ? /^(?:disc|circle|square|decimal|lower-alpha|upper-alpha|lower-roman|upper-roman|cjk-ideographic)$/i.test(n) ? n.toLowerCase() : "" : e === "table-layout" ? /^(?:auto|fixed)$/i.test(n) ? n.toLowerCase() : "" : e === "border-collapse" ? /^(?:collapse|separate)$/i.test(n) ? n.toLowerCase() : "" : /^border(?:-(?:top|right|bottom|left))?$/.test(e) ? j(n) : "";
|
|
300
367
|
}
|
|
301
|
-
function
|
|
368
|
+
function D(e, t) {
|
|
302
369
|
let n = e.toLowerCase();
|
|
303
370
|
return n === "start" ? t === "rtl" ? "right" : "left" : n === "end" ? t === "rtl" ? "left" : "right" : n;
|
|
304
371
|
}
|
|
305
|
-
function
|
|
372
|
+
function O(e, t) {
|
|
306
373
|
if (e === "0") return "0";
|
|
307
374
|
let n = /^(-?(?:\d+(?:\.\d+)?|\.\d+))(px|pt|cm|mm|in|pc|em|rem|%)$/i.exec(e);
|
|
308
375
|
if (!n || !t.allowPercent && n[2] === "%") return "";
|
|
309
376
|
let r = Number(n[1]), i = n[2].toLowerCase();
|
|
310
377
|
if (i === "%" && (r < Math.max(t.min, -500) || r > Math.min(t.max, 500))) return "";
|
|
311
|
-
let a = i === "%" ? r : r *
|
|
378
|
+
let a = i === "%" ? r : r * k(i);
|
|
312
379
|
return !Number.isFinite(r) || a < t.min || a > t.max ? "" : r === 0 ? "0" : (t.convertPt && i === "pt" && (r = Math.round(r * 4 / 3 * 100) / 100, i = "px"), `${r}${i}`);
|
|
313
380
|
}
|
|
314
|
-
function
|
|
381
|
+
function k(e) {
|
|
315
382
|
return e === "pt" ? 4 / 3 : e === "cm" ? 96 / 2.54 : e === "mm" ? 96 / 25.4 : e === "in" ? 96 : e === "pc" || e === "em" || e === "rem" ? 16 : 1;
|
|
316
383
|
}
|
|
317
|
-
function
|
|
384
|
+
function A(e) {
|
|
318
385
|
return /^(?:windowtext|buttontext|canvastext)$/i.test(e) ? "black" : /^(?:window|buttonface|canvas)$/i.test(e) ? "white" : /^(?:transparent|currentcolor|black|white|red|green|blue|gray|grey|yellow|orange|purple|navy|teal|maroon|silver|fuchsia|aqua|lime)$/i.test(e) || /^#[\da-f]{3,8}$/i.test(e) ? e.toLowerCase() : /^(?:rgb|rgba|hsl|hsla)\(\s*[-\d.%]+(?:\s*[,/]\s*[-\d.%]+){2,3}\s*\)$/i.test(e) ? e : "";
|
|
319
386
|
}
|
|
320
|
-
function
|
|
387
|
+
function j(e) {
|
|
321
388
|
if (/^none$/i.test(e)) return "none";
|
|
322
389
|
let t = /^((?:\d+(?:\.\d+)?|\.\d+)(?:px|pt))\s+(solid|dashed|dotted|double)\s+(.+)$/i.exec(e), n = /^(solid|dashed|dotted|double)\s+(.+?)\s+((?:\d+(?:\.\d+)?|\.\d+)(?:px|pt))$/i.exec(e), r = t?.[1] ?? n?.[3], i = t?.[2] ?? n?.[1], a = t?.[3] ?? n?.[2];
|
|
323
390
|
if (!r || !i || !a) return "";
|
|
324
|
-
let o =
|
|
391
|
+
let o = O(r, {
|
|
325
392
|
min: 0,
|
|
326
393
|
max: 24,
|
|
327
394
|
convertPt: !0
|
|
328
|
-
}), s =
|
|
395
|
+
}), s = A(a.trim());
|
|
329
396
|
return o && s ? `${o} ${i.toLowerCase()} ${s}` : "";
|
|
330
397
|
}
|
|
331
|
-
function
|
|
398
|
+
function M(e) {
|
|
332
399
|
let t = e.trim().split(/\s+/);
|
|
333
400
|
if (t.length < 1 || t.length > 4) return "";
|
|
334
|
-
let n = t.map((e) =>
|
|
401
|
+
let n = t.map((e) => O(e, {
|
|
335
402
|
min: 0,
|
|
336
403
|
max: 2400,
|
|
337
404
|
allowPercent: !0
|
|
338
405
|
}));
|
|
339
406
|
return n.every(Boolean) ? n.join(" ") : "";
|
|
340
407
|
}
|
|
341
|
-
function
|
|
408
|
+
function N(e) {
|
|
342
409
|
let t = /* @__PURE__ */ new Map();
|
|
343
410
|
for (let n of Array.from(e.querySelectorAll("style"))) {
|
|
344
411
|
let e = n.textContent ?? "", r = /([^{}]+)\{([^{}]*)\}/g, i = r.exec(e);
|
|
@@ -352,26 +419,26 @@ function j(e) {
|
|
|
352
419
|
}
|
|
353
420
|
return t;
|
|
354
421
|
}
|
|
355
|
-
function
|
|
422
|
+
function P(e, t) {
|
|
356
423
|
for (let n of Array.from(e.body.querySelectorAll("[class]"))) {
|
|
357
424
|
let e = Array.from(n.classList).map((e) => t.get(e) ?? "").filter(Boolean).join(";");
|
|
358
425
|
e && n.setAttribute("style", `${e};${n.getAttribute("style") ?? ""}`);
|
|
359
426
|
}
|
|
360
427
|
}
|
|
361
|
-
function
|
|
428
|
+
function F(e) {
|
|
362
429
|
return !!e.body.querySelector("p[align],div[align],h1[align],h2[align],h3[align],h4[align],h5[align],h6[align],center,font");
|
|
363
430
|
}
|
|
364
|
-
function
|
|
431
|
+
function I(e) {
|
|
365
432
|
for (let t of Array.from(e.body.querySelectorAll("p,div"))) {
|
|
366
433
|
let n = t.className, r = t.getAttribute("style") ?? "", i = /(?:Mso)?Heading\s*([1-6])|MsoHeading([1-6])/i.exec(`${n};${r}`), a = i ? Number(i[1] ?? i[2]) : /MsoTitle/i.test(n) ? 1 : /MsoSubtitle/i.test(n) ? 2 : 0;
|
|
367
|
-
a &&
|
|
434
|
+
a && K(e, t, `h${a}`);
|
|
368
435
|
}
|
|
369
436
|
}
|
|
370
|
-
function
|
|
437
|
+
function L(e) {
|
|
371
438
|
let t = [e.body, ...Array.from(e.body.querySelectorAll("td,th,div,blockquote"))];
|
|
372
|
-
for (let n of t.reverse())
|
|
439
|
+
for (let n of t.reverse()) R(e, n);
|
|
373
440
|
}
|
|
374
|
-
function
|
|
441
|
+
function R(e, t) {
|
|
375
442
|
let n = Array.from(t.childNodes), r = [];
|
|
376
443
|
for (let i of n) {
|
|
377
444
|
if (i.nodeType === 3 && !(i.textContent ?? "").trim()) continue;
|
|
@@ -379,7 +446,7 @@ function I(e, t) {
|
|
|
379
446
|
r = [];
|
|
380
447
|
continue;
|
|
381
448
|
}
|
|
382
|
-
let n = i, a =
|
|
449
|
+
let n = i, a = z(n);
|
|
383
450
|
if (!a) {
|
|
384
451
|
r = [];
|
|
385
452
|
continue;
|
|
@@ -401,15 +468,15 @@ function I(e, t) {
|
|
|
401
468
|
}, r[o - 1] = s;
|
|
402
469
|
}
|
|
403
470
|
let c = e.createElement("li");
|
|
404
|
-
for (
|
|
471
|
+
for (U(n); n.firstChild;) c.appendChild(n.firstChild);
|
|
405
472
|
s.list.appendChild(c), s.lastItem = c, s.expectedStart = a.kind === "ol" ? (a.start ?? s.expectedStart ?? 1) + 1 : void 0, n.remove();
|
|
406
473
|
}
|
|
407
474
|
}
|
|
408
|
-
function
|
|
475
|
+
function z(e) {
|
|
409
476
|
if (!/^(?:p|div)$/i.test(e.tagName)) return;
|
|
410
|
-
let t =
|
|
477
|
+
let t = C(e.getAttribute("style") ?? "");
|
|
411
478
|
if (!t) return;
|
|
412
|
-
let n =
|
|
479
|
+
let n = W(e), r = n.text, i = n.font;
|
|
413
480
|
if (/[•·●○■□◆◇▪▫]/.test(r) || /(?:Symbol|Wingdings|Webdings)/i.test(i)) {
|
|
414
481
|
let e = /[○◇▫]/.test(r) ? "circle" : /[■□▪]/.test(r) ? "square" : "disc";
|
|
415
482
|
return {
|
|
@@ -419,7 +486,7 @@ function L(e) {
|
|
|
419
486
|
listStyleType: e
|
|
420
487
|
};
|
|
421
488
|
}
|
|
422
|
-
let a =
|
|
489
|
+
let a = B(r);
|
|
423
490
|
return {
|
|
424
491
|
...t,
|
|
425
492
|
session: `${t.id}:${t.lfo}`,
|
|
@@ -429,7 +496,7 @@ function L(e) {
|
|
|
429
496
|
start: a?.start
|
|
430
497
|
};
|
|
431
498
|
}
|
|
432
|
-
function
|
|
499
|
+
function B(e) {
|
|
433
500
|
let t = e.trim().replace(/^[((]/, "").replace(/[))\..、]\s*$/, "").trim();
|
|
434
501
|
if (/^\d+$/.test(t)) return {
|
|
435
502
|
start: Math.max(1, Number(t)),
|
|
@@ -439,7 +506,7 @@ function R(e) {
|
|
|
439
506
|
if (/^[ivxlcdm]+$/i.test(t)) {
|
|
440
507
|
let e = t === t.toUpperCase();
|
|
441
508
|
return {
|
|
442
|
-
start:
|
|
509
|
+
start: H(t),
|
|
443
510
|
type: e ? "I" : "i",
|
|
444
511
|
listStyleType: e ? "upper-roman" : "lower-roman"
|
|
445
512
|
};
|
|
@@ -453,12 +520,12 @@ function R(e) {
|
|
|
453
520
|
};
|
|
454
521
|
}
|
|
455
522
|
if (/^[零〇一二三四五六七八九十百千万]+$/.test(t)) return {
|
|
456
|
-
start:
|
|
523
|
+
start: V(t),
|
|
457
524
|
type: void 0,
|
|
458
525
|
listStyleType: "cjk-ideographic"
|
|
459
526
|
};
|
|
460
527
|
}
|
|
461
|
-
function
|
|
528
|
+
function V(e) {
|
|
462
529
|
let t = {
|
|
463
530
|
零: 0,
|
|
464
531
|
〇: 0,
|
|
@@ -487,7 +554,7 @@ function z(e) {
|
|
|
487
554
|
}
|
|
488
555
|
return Math.max(1, r + i + a);
|
|
489
556
|
}
|
|
490
|
-
function
|
|
557
|
+
function H(e) {
|
|
491
558
|
let t = {
|
|
492
559
|
i: 1,
|
|
493
560
|
v: 5,
|
|
@@ -503,17 +570,17 @@ function B(e) {
|
|
|
503
570
|
}
|
|
504
571
|
return Math.max(1, n);
|
|
505
572
|
}
|
|
506
|
-
function
|
|
507
|
-
|
|
573
|
+
function U(e) {
|
|
574
|
+
W(e).element?.remove(), e.firstChild?.nodeType === 3 && (e.firstChild.textContent = e.firstChild.textContent?.replace(/^[\s\u00A0]+/, "") ?? "");
|
|
508
575
|
}
|
|
509
|
-
function
|
|
576
|
+
function W(e) {
|
|
510
577
|
let t = Array.from(e.querySelectorAll("span")).find((e) => /mso-list\s*:\s*ignore/i.test(e.getAttribute("style") ?? ""));
|
|
511
578
|
if (t) return {
|
|
512
579
|
element: t,
|
|
513
|
-
text:
|
|
580
|
+
text: G(t.textContent ?? ""),
|
|
514
581
|
font: t.style.fontFamily
|
|
515
582
|
};
|
|
516
|
-
let n = e.querySelector("span"), r =
|
|
583
|
+
let n = e.querySelector("span"), r = G(n?.textContent ?? ""), i = n?.style.fontFamily ?? "";
|
|
517
584
|
return /[•·●○■□◆◇▪▫]/.test(r) || /(?:Symbol|Wingdings|Webdings)/i.test(i) || /^(?:\d+|[a-z]|[ivxlcdm]+)[.)、]$/i.test(r) || /^[((]?[零〇一二三四五六七八九十百千万]+[))\..、]$/.test(r) ? {
|
|
518
585
|
element: n ?? void 0,
|
|
519
586
|
text: r,
|
|
@@ -523,37 +590,37 @@ function H(e) {
|
|
|
523
590
|
font: ""
|
|
524
591
|
};
|
|
525
592
|
}
|
|
526
|
-
function
|
|
593
|
+
function G(e) {
|
|
527
594
|
return e.replace(/[\u00A0\s]+/g, " ").trim();
|
|
528
595
|
}
|
|
529
|
-
function
|
|
596
|
+
function K(e, t, n) {
|
|
530
597
|
let r = e.createElement(n);
|
|
531
598
|
for (let e of Array.from(t.attributes)) r.setAttribute(e.name, e.value);
|
|
532
599
|
for (; t.firstChild;) r.appendChild(t.firstChild);
|
|
533
600
|
return t.replaceWith(r), r;
|
|
534
601
|
}
|
|
535
|
-
function
|
|
536
|
-
|
|
602
|
+
function ue(e, t) {
|
|
603
|
+
$(e.body), he(e), ge(e), fe(e);
|
|
537
604
|
let n = 0, r = 0, i = 0;
|
|
538
605
|
for (let a of Array.from(e.body.querySelectorAll("*"))) {
|
|
539
606
|
let o = a.tagName.toLowerCase();
|
|
540
|
-
if (
|
|
607
|
+
if (m.has(o)) {
|
|
541
608
|
a.remove();
|
|
542
609
|
continue;
|
|
543
610
|
}
|
|
544
611
|
if (q(a), o === "img") {
|
|
545
|
-
let e = n < t.replacementImages.length, o =
|
|
612
|
+
let e = n < t.replacementImages.length, o = _e(a, t.replacementImages[n], e, t.preferClipboardImages === !0);
|
|
546
613
|
if (o.consumedReplacement && n++, o.usedReplacement && r++, !o.kept) continue;
|
|
547
614
|
i++;
|
|
548
|
-
} else o === "a" &&
|
|
549
|
-
let s =
|
|
550
|
-
s ? a.setAttribute("style", s) : a.removeAttribute("style"),
|
|
615
|
+
} else o === "a" && ve(a);
|
|
616
|
+
let s = w(a.getAttribute("style") ?? "", o);
|
|
617
|
+
s ? a.setAttribute("style", s) : a.removeAttribute("style"), me(e, a), pe(e, a), ye(a);
|
|
551
618
|
for (let e of Array.from(a.attributes)) {
|
|
552
619
|
let t = e.name.toLowerCase();
|
|
553
|
-
(!
|
|
620
|
+
(!p.has(t) || t.startsWith("on") || t.startsWith("data-") || t === "class" || t === "id" || t === "lang" || t.includes(":")) && a.removeAttribute(e.name);
|
|
554
621
|
}
|
|
555
622
|
let c = a.style.verticalAlign;
|
|
556
|
-
(c === "super" || c === "sub") && o === "span" &&
|
|
623
|
+
(c === "super" || c === "sub") && o === "span" && K(e, a, c === "super" ? "sup" : "sub");
|
|
557
624
|
}
|
|
558
625
|
if (!i && t.appendClipboardImages.length) for (let n of t.appendClipboardImages) {
|
|
559
626
|
if (!n || !Y(n)) continue;
|
|
@@ -562,20 +629,20 @@ function G(e, t) {
|
|
|
562
629
|
}
|
|
563
630
|
return r;
|
|
564
631
|
}
|
|
565
|
-
function
|
|
566
|
-
let t = /^(?:p|div|blockquote|li)$/,
|
|
567
|
-
for (let e of
|
|
568
|
-
let
|
|
569
|
-
for (let [t, n] of
|
|
632
|
+
function de(e) {
|
|
633
|
+
let t = [], n = /^(?:p|div|blockquote|li)$/, r = Array.from(e.body.querySelectorAll("*"));
|
|
634
|
+
for (let e of r) {
|
|
635
|
+
let r = e.tagName.toLowerCase(), s = /* @__PURE__ */ new Map();
|
|
636
|
+
for (let [t, n] of E(e.getAttribute("style") ?? "")) {
|
|
570
637
|
let e = t.trim().toLowerCase();
|
|
571
|
-
e &&
|
|
638
|
+
e && s.set(e, n.trim());
|
|
572
639
|
}
|
|
573
|
-
let
|
|
574
|
-
|
|
640
|
+
let c = s.has("font-family");
|
|
641
|
+
c && t.push(s.get("font-family") ?? ""), !(!n.test(r) && !c) && (s.set("font-family", i), /^(?:p|div|blockquote|li)$/.test(r) && (s.set("line-height", o), s.set("font-size", a), s.set("margin-top", "0"), s.set("margin-bottom", "10px")), e.setAttribute("style", Array.from(s, ([e, t]) => `${e}: ${t}`).join("; ")));
|
|
575
642
|
}
|
|
576
|
-
let
|
|
577
|
-
for (;
|
|
578
|
-
for (let e of
|
|
643
|
+
let s = e.createTreeWalker(e.body, e.defaultView?.NodeFilter?.SHOW_TEXT ?? 4), c = [], l = s.nextNode();
|
|
644
|
+
for (; l;) c.push(l), l = s.nextNode();
|
|
645
|
+
for (let e of c) {
|
|
579
646
|
let t = e.nodeValue ?? "";
|
|
580
647
|
if (!t) continue;
|
|
581
648
|
let n = e.parentElement;
|
|
@@ -586,15 +653,16 @@ function K(e) {
|
|
|
586
653
|
n && (t(e.previousElementSibling) || t(e.nextElementSibling)) ? e.nodeValue = " " : e.remove();
|
|
587
654
|
} else e.nodeValue = r;
|
|
588
655
|
}
|
|
656
|
+
return ce(t);
|
|
589
657
|
}
|
|
590
|
-
function
|
|
591
|
-
for (let t of Array.from(e.body.querySelectorAll("font"))) q(t),
|
|
592
|
-
for (let t of Array.from(e.body.querySelectorAll("center"))) t.setAttribute("style", `${t.getAttribute("style") ?? ""};text-align:center`),
|
|
658
|
+
function fe(e) {
|
|
659
|
+
for (let t of Array.from(e.body.querySelectorAll("font"))) q(t), K(e, t, "span");
|
|
660
|
+
for (let t of Array.from(e.body.querySelectorAll("center"))) t.setAttribute("style", `${t.getAttribute("style") ?? ""};text-align:center`), K(e, t, "div");
|
|
593
661
|
}
|
|
594
|
-
function
|
|
662
|
+
function pe(e, t) {
|
|
595
663
|
let n = t.tagName.toLowerCase();
|
|
596
664
|
if (!/^(?:b|strong|em|i|u|s|strike|del|sup|sub|a)$/.test(n)) return;
|
|
597
|
-
let r =
|
|
665
|
+
let r = E(t.getAttribute("style") ?? ""), i = [], a = [];
|
|
598
666
|
for (let [e, t] of r) {
|
|
599
667
|
let n = e.trim().toLowerCase(), r = t.trim();
|
|
600
668
|
(n === "font-family" || n === "font-size" || n === "color" || n === "background-color" ? i : a).push(`${n}: ${r}`);
|
|
@@ -605,13 +673,13 @@ function le(e, t) {
|
|
|
605
673
|
for (o.setAttribute("style", i.join("; ")); t.firstChild;) o.appendChild(t.firstChild);
|
|
606
674
|
t.appendChild(o);
|
|
607
675
|
}
|
|
608
|
-
function
|
|
676
|
+
function me(e, t) {
|
|
609
677
|
let n = t.tagName.toLowerCase();
|
|
610
678
|
if (!/^(?:p|div|h[1-6]|blockquote|li|td|th)$/.test(n)) return;
|
|
611
|
-
let r =
|
|
679
|
+
let r = E(t.getAttribute("style") ?? ""), i = [], a = [];
|
|
612
680
|
for (let [e, t] of r) {
|
|
613
681
|
let r = e.trim().toLowerCase(), o = t.trim();
|
|
614
|
-
(
|
|
682
|
+
(h.has(r) && r !== "vertical-align" && !((n === "td" || n === "th") && r === "background-color") ? i : a).push(`${r}: ${o}`);
|
|
615
683
|
}
|
|
616
684
|
if (!i.length) return;
|
|
617
685
|
a.length ? t.setAttribute("style", a.join("; ")) : t.removeAttribute("style");
|
|
@@ -619,7 +687,7 @@ function ue(e, t) {
|
|
|
619
687
|
for (o.setAttribute("style", i.join("; ")); t.firstChild;) o.appendChild(t.firstChild);
|
|
620
688
|
t.appendChild(o);
|
|
621
689
|
}
|
|
622
|
-
function
|
|
690
|
+
function he(e) {
|
|
623
691
|
for (let t of Array.from(e.body.querySelectorAll("*"))) {
|
|
624
692
|
if (t.tagName.toLowerCase() !== "v:imagedata") continue;
|
|
625
693
|
let n = e.createElement("img");
|
|
@@ -631,7 +699,7 @@ function de(e) {
|
|
|
631
699
|
} else t.replaceWith(n);
|
|
632
700
|
}
|
|
633
701
|
}
|
|
634
|
-
function
|
|
702
|
+
function ge(e) {
|
|
635
703
|
for (let t of Array.from(e.body.querySelectorAll("*")).reverse()) {
|
|
636
704
|
let e = t.tagName.toLowerCase();
|
|
637
705
|
if (e.includes(":")) {
|
|
@@ -652,57 +720,57 @@ function q(e) {
|
|
|
652
720
|
function J(e) {
|
|
653
721
|
return e ? /^\d+(?:\.\d+)?$/.test(e.trim()) ? `${e.trim()}px` : e.trim() : "";
|
|
654
722
|
}
|
|
655
|
-
function
|
|
656
|
-
let i = e.getAttribute("src") ?? "", a =
|
|
657
|
-
if (
|
|
723
|
+
function _e(e, t, n = !1, r = !1) {
|
|
724
|
+
let i = e.getAttribute("src") ?? "", a = u.test(i.trim()), o = (r || a) && n, s = !!(t && Y(t)), c = o && s, l = c && t ? t : i;
|
|
725
|
+
if (u.test(l.trim()) || !Y(l)) return e.remove(), {
|
|
658
726
|
kept: !1,
|
|
659
727
|
usedReplacement: !1,
|
|
660
728
|
consumedReplacement: o
|
|
661
729
|
};
|
|
662
|
-
e.setAttribute("src",
|
|
730
|
+
e.setAttribute("src", l.trim());
|
|
663
731
|
let d = X(e.getAttribute("width") ?? e.style.width), f = X(e.getAttribute("height") ?? e.style.height);
|
|
664
732
|
return d ? e.setAttribute("width", d) : e.removeAttribute("width"), f ? e.setAttribute("height", f) : e.removeAttribute("height"), e.setAttribute("alt", (e.getAttribute("alt") ?? "").slice(0, 500)), e.hasAttribute("title") && e.setAttribute("title", (e.getAttribute("title") ?? "").slice(0, 500)), {
|
|
665
733
|
kept: !0,
|
|
666
|
-
usedReplacement:
|
|
734
|
+
usedReplacement: c,
|
|
667
735
|
consumedReplacement: o
|
|
668
736
|
};
|
|
669
737
|
}
|
|
670
|
-
function Y(
|
|
671
|
-
let n =
|
|
672
|
-
return !!n &&
|
|
738
|
+
function Y(e) {
|
|
739
|
+
let n = e.trim();
|
|
740
|
+
return !!n && t(n);
|
|
673
741
|
}
|
|
674
742
|
function X(e) {
|
|
675
743
|
let t = /^(\d+(?:\.\d+)?)(px|pt|cm|mm|in|pc)?$/i.exec((e ?? "").trim());
|
|
676
744
|
if (!t) return "";
|
|
677
|
-
let n = Number(t[1]), r =
|
|
745
|
+
let n = Number(t[1]), r = k((t[2] ?? "px").toLowerCase()), i = Math.round(n * r);
|
|
678
746
|
return i >= 1 && i <= 2400 ? String(i) : "";
|
|
679
747
|
}
|
|
680
|
-
function
|
|
748
|
+
function ve(e) {
|
|
681
749
|
let t = (e.getAttribute("href") ?? "").trim();
|
|
682
|
-
if (!
|
|
750
|
+
if (!Z(t)) {
|
|
683
751
|
e.removeAttribute("href"), e.removeAttribute("target"), e.removeAttribute("rel");
|
|
684
752
|
return;
|
|
685
753
|
}
|
|
686
754
|
e.setAttribute("href", t), e.getAttribute("target") === "_blank" ? e.setAttribute("rel", "noopener noreferrer") : (e.removeAttribute("target"), e.removeAttribute("rel"));
|
|
687
755
|
}
|
|
688
|
-
function
|
|
756
|
+
function Z(e) {
|
|
689
757
|
if (!e) return !1;
|
|
690
758
|
let t = e.replace(/[\u0000-\u0020\u007F]+/g, "");
|
|
691
759
|
return /^(?:javascript|vbscript|data|file):/i.test(t) ? !1 : /^(?:https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(t) || !/^[a-z][a-z\d+.-]*:/i.test(t);
|
|
692
760
|
}
|
|
693
|
-
function
|
|
761
|
+
function ye(e) {
|
|
694
762
|
let t = e.tagName.toLowerCase();
|
|
695
|
-
if ((t === "td" || t === "th") && (
|
|
763
|
+
if ((t === "td" || t === "th") && (Q(e, "rowspan", 1, 100), Q(e, "colspan", 1, 100)), t === "td" || t === "th") {
|
|
696
764
|
let t = (e.getAttribute("colwidth") ?? "").split(",").map((e) => Number.parseInt(e.trim(), 10)).filter((e) => Number.isFinite(e) && e >= 1 && e <= 2400).slice(0, 100);
|
|
697
765
|
t.length ? e.setAttribute("colwidth", t.join(",")) : e.removeAttribute("colwidth");
|
|
698
766
|
}
|
|
699
767
|
if (t === "ol") {
|
|
700
|
-
|
|
768
|
+
Q(e, "start", 1, 1e5);
|
|
701
769
|
let t = e.getAttribute("type");
|
|
702
770
|
(!t || !/^(?:1|a|A|i|I)$/.test(t)) && e.removeAttribute("type");
|
|
703
771
|
}
|
|
704
772
|
}
|
|
705
|
-
function
|
|
773
|
+
function Q(e, t, n, r) {
|
|
706
774
|
let i = Number.parseInt(e.getAttribute(t) ?? "", 10);
|
|
707
775
|
if (!Number.isFinite(i)) {
|
|
708
776
|
e.removeAttribute(t);
|
|
@@ -710,10 +778,10 @@ function Z(e, t, n, r) {
|
|
|
710
778
|
}
|
|
711
779
|
e.setAttribute(t, String(Math.max(n, Math.min(r, i))));
|
|
712
780
|
}
|
|
713
|
-
function
|
|
714
|
-
for (let t of Array.from(e.childNodes)) t.nodeType === 8 ? t.remove() :
|
|
781
|
+
function $(e) {
|
|
782
|
+
for (let t of Array.from(e.childNodes)) t.nodeType === 8 ? t.remove() : $(t);
|
|
715
783
|
}
|
|
716
|
-
function
|
|
784
|
+
function be(e, t) {
|
|
717
785
|
let n = 0;
|
|
718
786
|
for (let r = t; r < e.length; r++) {
|
|
719
787
|
if (e[r] === "\\") {
|
|
@@ -725,7 +793,7 @@ function $(e, t) {
|
|
|
725
793
|
}
|
|
726
794
|
return -1;
|
|
727
795
|
}
|
|
728
|
-
function
|
|
796
|
+
function xe(e) {
|
|
729
797
|
let t = 0, n = "";
|
|
730
798
|
for (let r = 0; r < e.length; r++) {
|
|
731
799
|
let i = e[r];
|
|
@@ -747,20 +815,20 @@ function _e(e) {
|
|
|
747
815
|
}
|
|
748
816
|
return n;
|
|
749
817
|
}
|
|
750
|
-
function
|
|
818
|
+
function Se(e) {
|
|
751
819
|
let t = [], n = new Uint8Array(e.length / 2);
|
|
752
820
|
for (let t = 0; t < n.length; t++) n[t] = Number.parseInt(e.slice(t * 2, t * 2 + 2), 16);
|
|
753
821
|
for (let e = 0; e < n.length; e += 32768) t.push(String.fromCharCode(...Array.from(n.subarray(e, e + 32768))));
|
|
754
822
|
return btoa(t.join(""));
|
|
755
823
|
}
|
|
756
|
-
function
|
|
824
|
+
function Ce(e, t) {
|
|
757
825
|
return t === "image/png" ? e.toLowerCase().startsWith("89504e470d0a1a0a") : t === "image/jpeg" ? e.toLowerCase().startsWith("ffd8ff") : !1;
|
|
758
826
|
}
|
|
759
|
-
function
|
|
827
|
+
function we(e) {
|
|
760
828
|
return new Promise((t, n) => {
|
|
761
829
|
let r = new FileReader();
|
|
762
830
|
r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("clipboard image read failed")), r.onload = () => t(typeof r.result == "string" ? r.result : ""), r.readAsDataURL(e);
|
|
763
831
|
});
|
|
764
832
|
}
|
|
765
833
|
//#endregion
|
|
766
|
-
export {
|
|
834
|
+
export { x as detectClipboardHtmlSource, T as extractRtfImageDataUrls, w as normalizeOfficeStyle, re as normalizeWordClipboardHtml, S as plainTextToSafeHtml, ne as readClipboardImageFiles };
|