react-smart-copy 1.30.0 → 1.31.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/README.md +4 -1
- package/dist/chunks/copy-machine-B6apNst5.d.ts +132 -0
- package/dist/chunks/copy-machine-CmqX9J4V.d.cts +132 -0
- package/dist/chunks/copy-machine-DwdB-qva.js +292 -0
- package/dist/chunks/copy-machine-DwdB-qva.js.map +1 -0
- package/dist/chunks/copy-machine-oNmnrjMc.cjs +345 -0
- package/dist/chunks/copy-machine-oNmnrjMc.cjs.map +1 -0
- package/dist/chunks/{core-B8_wVOSU.js → core-CNSd-EgZ.js} +4 -290
- package/dist/chunks/core-CNSd-EgZ.js.map +1 -0
- package/dist/chunks/{core-BR8Jgea1.cjs → core-DsMKPNx_.cjs} +20 -348
- package/dist/chunks/core-DsMKPNx_.cjs.map +1 -0
- package/dist/chunks/{index-DjqQGsNs.d.ts → index-B4SEFtkx.d.ts} +3 -131
- package/dist/chunks/{index-uHZHddq0.d.cts → index-BDxj1EqC.d.cts} +3 -131
- package/dist/chunks/text-C2OYT-3o.cjs +478 -0
- package/dist/chunks/text-C2OYT-3o.cjs.map +1 -0
- package/dist/chunks/text-nc1LhgIh.js +413 -0
- package/dist/chunks/text-nc1LhgIh.js.map +1 -0
- package/dist/chunks/utils-C7_VlH79.cjs +53 -0
- package/dist/chunks/utils-C7_VlH79.cjs.map +1 -0
- package/dist/chunks/utils-CBBX2HN6.js +30 -0
- package/dist/chunks/utils-CBBX2HN6.js.map +1 -0
- package/dist/compat.cjs +94 -0
- package/dist/compat.cjs.map +1 -0
- package/dist/compat.d.cts +57 -0
- package/dist/compat.d.ts +57 -0
- package/dist/compat.js +88 -0
- package/dist/compat.js.map +1 -0
- package/dist/core.cjs +8 -7
- package/dist/core.d.cts +2 -1
- package/dist/core.d.ts +2 -1
- package/dist/core.js +2 -1
- package/dist/index.cjs +45 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -27
- package/dist/index.js.map +1 -1
- package/dist/rich.cjs +14 -422
- package/dist/rich.cjs.map +1 -1
- package/dist/rich.js +1 -409
- package/dist/rich.js.map +1 -1
- package/package.json +20 -1
- package/dist/chunks/core-B8_wVOSU.js.map +0 -1
- package/dist/chunks/core-BR8Jgea1.cjs.map +0 -1
package/dist/rich.cjs
CHANGED
|
@@ -5,325 +5,7 @@ const require_url = require("./chunks/url-CL4YTCvM.cjs");
|
|
|
5
5
|
const require_inert_html = require("./chunks/inert-html-aAsKvgJC.cjs");
|
|
6
6
|
const require_url$1 = require("./chunks/url-B9jdFGQy.cjs");
|
|
7
7
|
const require_contrast = require("./chunks/contrast-BatHkv8j.cjs");
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* What portable rich text may contain: the elements, attributes and CSS that Gmail,
|
|
11
|
-
* Outlook, Apple Mail, Google Docs, Word, Notion and Slack keep, and nothing that
|
|
12
|
-
* can run, load or track. Everything not listed here is left out.
|
|
13
|
-
*/
|
|
14
|
-
/** Elements written as they are. */
|
|
15
|
-
const KEEP = /* @__PURE__ */ new Set([
|
|
16
|
-
"a",
|
|
17
|
-
"abbr",
|
|
18
|
-
"b",
|
|
19
|
-
"bdi",
|
|
20
|
-
"bdo",
|
|
21
|
-
"blockquote",
|
|
22
|
-
"br",
|
|
23
|
-
"caption",
|
|
24
|
-
"cite",
|
|
25
|
-
"code",
|
|
26
|
-
"col",
|
|
27
|
-
"colgroup",
|
|
28
|
-
"dd",
|
|
29
|
-
"del",
|
|
30
|
-
"dfn",
|
|
31
|
-
"div",
|
|
32
|
-
"dl",
|
|
33
|
-
"dt",
|
|
34
|
-
"em",
|
|
35
|
-
"figcaption",
|
|
36
|
-
"figure",
|
|
37
|
-
"h1",
|
|
38
|
-
"h2",
|
|
39
|
-
"h3",
|
|
40
|
-
"h4",
|
|
41
|
-
"h5",
|
|
42
|
-
"h6",
|
|
43
|
-
"hr",
|
|
44
|
-
"i",
|
|
45
|
-
"img",
|
|
46
|
-
"ins",
|
|
47
|
-
"kbd",
|
|
48
|
-
"li",
|
|
49
|
-
"mark",
|
|
50
|
-
"ol",
|
|
51
|
-
"p",
|
|
52
|
-
"pre",
|
|
53
|
-
"q",
|
|
54
|
-
"s",
|
|
55
|
-
"samp",
|
|
56
|
-
"small",
|
|
57
|
-
"span",
|
|
58
|
-
"strong",
|
|
59
|
-
"sub",
|
|
60
|
-
"sup",
|
|
61
|
-
"table",
|
|
62
|
-
"tbody",
|
|
63
|
-
"td",
|
|
64
|
-
"tfoot",
|
|
65
|
-
"th",
|
|
66
|
-
"thead",
|
|
67
|
-
"time",
|
|
68
|
-
"tr",
|
|
69
|
-
"u",
|
|
70
|
-
"ul",
|
|
71
|
-
"var"
|
|
72
|
-
]);
|
|
73
|
-
/** Elements left out with everything inside them: they run, load, embed, or are page chrome. */
|
|
74
|
-
const DROP = /* @__PURE__ */ new Set([
|
|
75
|
-
"applet",
|
|
76
|
-
"audio",
|
|
77
|
-
"base",
|
|
78
|
-
"button",
|
|
79
|
-
"canvas",
|
|
80
|
-
"datalist",
|
|
81
|
-
"dialog",
|
|
82
|
-
"embed",
|
|
83
|
-
"frame",
|
|
84
|
-
"frameset",
|
|
85
|
-
"head",
|
|
86
|
-
"iframe",
|
|
87
|
-
"input",
|
|
88
|
-
"link",
|
|
89
|
-
"map",
|
|
90
|
-
"math",
|
|
91
|
-
"meta",
|
|
92
|
-
"meter",
|
|
93
|
-
"noembed",
|
|
94
|
-
"noframes",
|
|
95
|
-
"noscript",
|
|
96
|
-
"object",
|
|
97
|
-
"option",
|
|
98
|
-
"optgroup",
|
|
99
|
-
"output",
|
|
100
|
-
"param",
|
|
101
|
-
"portal",
|
|
102
|
-
"progress",
|
|
103
|
-
"script",
|
|
104
|
-
"select",
|
|
105
|
-
"slot",
|
|
106
|
-
"source",
|
|
107
|
-
"style",
|
|
108
|
-
"svg",
|
|
109
|
-
"template",
|
|
110
|
-
"textarea",
|
|
111
|
-
"title",
|
|
112
|
-
"track",
|
|
113
|
-
"video"
|
|
114
|
-
]);
|
|
115
|
-
/** Elements that become a `<div>`: blocks without an email-safe equivalent. */
|
|
116
|
-
const AS_BLOCK = /* @__PURE__ */ new Set([
|
|
117
|
-
"address",
|
|
118
|
-
"article",
|
|
119
|
-
"aside",
|
|
120
|
-
"body",
|
|
121
|
-
"center",
|
|
122
|
-
"details",
|
|
123
|
-
"fieldset",
|
|
124
|
-
"footer",
|
|
125
|
-
"form",
|
|
126
|
-
"header",
|
|
127
|
-
"hgroup",
|
|
128
|
-
"html",
|
|
129
|
-
"legend",
|
|
130
|
-
"listing",
|
|
131
|
-
"main",
|
|
132
|
-
"menu",
|
|
133
|
-
"nav",
|
|
134
|
-
"plaintext",
|
|
135
|
-
"search",
|
|
136
|
-
"section",
|
|
137
|
-
"summary",
|
|
138
|
-
"xmp"
|
|
139
|
-
]);
|
|
140
|
-
/** Elements whose children are block-level text in the plain-text version. */
|
|
141
|
-
const TEXT_BLOCKS = /* @__PURE__ */ new Set([
|
|
142
|
-
"blockquote",
|
|
143
|
-
"caption",
|
|
144
|
-
"dd",
|
|
145
|
-
"div",
|
|
146
|
-
"dl",
|
|
147
|
-
"dt",
|
|
148
|
-
"figcaption",
|
|
149
|
-
"figure",
|
|
150
|
-
"h1",
|
|
151
|
-
"h2",
|
|
152
|
-
"h3",
|
|
153
|
-
"h4",
|
|
154
|
-
"h5",
|
|
155
|
-
"h6",
|
|
156
|
-
"hr",
|
|
157
|
-
"li",
|
|
158
|
-
"ol",
|
|
159
|
-
"p",
|
|
160
|
-
"pre",
|
|
161
|
-
"table",
|
|
162
|
-
"tbody",
|
|
163
|
-
"tfoot",
|
|
164
|
-
"thead",
|
|
165
|
-
"tr",
|
|
166
|
-
"ul"
|
|
167
|
-
]);
|
|
168
|
-
/** What table parts may contain: anything else is moved out of the table by every HTML parser. */
|
|
169
|
-
const TABLE_CHILDREN = {
|
|
170
|
-
table: /* @__PURE__ */ new Set([
|
|
171
|
-
"caption",
|
|
172
|
-
"colgroup",
|
|
173
|
-
"thead",
|
|
174
|
-
"tbody",
|
|
175
|
-
"tfoot",
|
|
176
|
-
"tr"
|
|
177
|
-
]),
|
|
178
|
-
thead: /* @__PURE__ */ new Set(["tr"]),
|
|
179
|
-
tbody: /* @__PURE__ */ new Set(["tr"]),
|
|
180
|
-
tfoot: /* @__PURE__ */ new Set(["tr"]),
|
|
181
|
-
tr: /* @__PURE__ */ new Set(["td", "th"]),
|
|
182
|
-
colgroup: /* @__PURE__ */ new Set(["col"])
|
|
183
|
-
};
|
|
184
|
-
/** Elements that hold only text-level content: a block inside one would be split out by HTML parsers. */
|
|
185
|
-
const PHRASING = /* @__PURE__ */ new Set([
|
|
186
|
-
"a",
|
|
187
|
-
"abbr",
|
|
188
|
-
"b",
|
|
189
|
-
"bdi",
|
|
190
|
-
"bdo",
|
|
191
|
-
"cite",
|
|
192
|
-
"code",
|
|
193
|
-
"del",
|
|
194
|
-
"dfn",
|
|
195
|
-
"em",
|
|
196
|
-
"h1",
|
|
197
|
-
"h2",
|
|
198
|
-
"h3",
|
|
199
|
-
"h4",
|
|
200
|
-
"h5",
|
|
201
|
-
"h6",
|
|
202
|
-
"i",
|
|
203
|
-
"ins",
|
|
204
|
-
"kbd",
|
|
205
|
-
"mark",
|
|
206
|
-
"p",
|
|
207
|
-
"q",
|
|
208
|
-
"s",
|
|
209
|
-
"samp",
|
|
210
|
-
"small",
|
|
211
|
-
"span",
|
|
212
|
-
"strong",
|
|
213
|
-
"sub",
|
|
214
|
-
"sup",
|
|
215
|
-
"time",
|
|
216
|
-
"u",
|
|
217
|
-
"var"
|
|
218
|
-
]);
|
|
219
|
-
/** Table parts: outside their own parent, HTML parsers ignore their tags. */
|
|
220
|
-
const TABLE_PARTS = /* @__PURE__ */ new Set([
|
|
221
|
-
"caption",
|
|
222
|
-
"col",
|
|
223
|
-
"colgroup",
|
|
224
|
-
"tbody",
|
|
225
|
-
"td",
|
|
226
|
-
"tfoot",
|
|
227
|
-
"th",
|
|
228
|
-
"thead",
|
|
229
|
-
"tr"
|
|
230
|
-
]);
|
|
231
|
-
const HEADINGS$1 = /* @__PURE__ */ new Set([
|
|
232
|
-
"h1",
|
|
233
|
-
"h2",
|
|
234
|
-
"h3",
|
|
235
|
-
"h4",
|
|
236
|
-
"h5",
|
|
237
|
-
"h6"
|
|
238
|
-
]);
|
|
239
|
-
/** Elements whose start tag closes an open `<p>`: a paragraph holding one is split in two by HTML parsers. */
|
|
240
|
-
const CLOSES_P = /* @__PURE__ */ new Set([
|
|
241
|
-
"blockquote",
|
|
242
|
-
"dd",
|
|
243
|
-
"dl",
|
|
244
|
-
"dt",
|
|
245
|
-
"figcaption",
|
|
246
|
-
"figure",
|
|
247
|
-
"h1",
|
|
248
|
-
"h2",
|
|
249
|
-
"h3",
|
|
250
|
-
"h4",
|
|
251
|
-
"h5",
|
|
252
|
-
"h6",
|
|
253
|
-
"hr",
|
|
254
|
-
"li",
|
|
255
|
-
"ol",
|
|
256
|
-
"p",
|
|
257
|
-
"pre",
|
|
258
|
-
"table",
|
|
259
|
-
"ul"
|
|
260
|
-
]);
|
|
261
|
-
/** Where HTML parsers stop looking for an open list item to close: their "special" elements, less address, div and p. */
|
|
262
|
-
const ITEM_SCOPE = /* @__PURE__ */ new Set([
|
|
263
|
-
"blockquote",
|
|
264
|
-
"br",
|
|
265
|
-
"caption",
|
|
266
|
-
"col",
|
|
267
|
-
"colgroup",
|
|
268
|
-
"dd",
|
|
269
|
-
"dl",
|
|
270
|
-
"dt",
|
|
271
|
-
"figcaption",
|
|
272
|
-
"figure",
|
|
273
|
-
"h1",
|
|
274
|
-
"h2",
|
|
275
|
-
"h3",
|
|
276
|
-
"h4",
|
|
277
|
-
"h5",
|
|
278
|
-
"h6",
|
|
279
|
-
"hr",
|
|
280
|
-
"img",
|
|
281
|
-
"li",
|
|
282
|
-
"ol",
|
|
283
|
-
"pre",
|
|
284
|
-
"table",
|
|
285
|
-
"tbody",
|
|
286
|
-
"td",
|
|
287
|
-
"tfoot",
|
|
288
|
-
"th",
|
|
289
|
-
"thead",
|
|
290
|
-
"tr",
|
|
291
|
-
"ul"
|
|
292
|
-
]);
|
|
293
|
-
/** Whether a new `li` (or `dd`, `dt`) under `parent` would close an open one, as HTML parsers do with `<li>` in `<li>`. */
|
|
294
|
-
function closesItem(name, parent) {
|
|
295
|
-
const group = name === "li" ? ["li"] : ["dd", "dt"];
|
|
296
|
-
for (let node = parent; node !== null && node.nodeType === 1; node = node.parentNode) {
|
|
297
|
-
const tag = node.localName;
|
|
298
|
-
if (group.includes(tag)) return true;
|
|
299
|
-
if (ITEM_SCOPE.has(tag)) return false;
|
|
300
|
-
}
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
const INTEGER = /^\d{1,4}$/;
|
|
304
|
-
/** Attributes kept per element (after `href` and `src`, which are checked as URLs). */
|
|
305
|
-
function attributeAllowed(tag, name, value) {
|
|
306
|
-
switch (name) {
|
|
307
|
-
case "dir": return /^(?:ltr|rtl|auto)$/i.test(value);
|
|
308
|
-
case "lang": return /^[a-z]{2,3}(?:-[a-z\d]{1,8})*$/i.test(value);
|
|
309
|
-
case "title": return [
|
|
310
|
-
"a",
|
|
311
|
-
"abbr",
|
|
312
|
-
"dfn"
|
|
313
|
-
].includes(tag);
|
|
314
|
-
case "colspan":
|
|
315
|
-
case "rowspan": return (tag === "td" || tag === "th") && INTEGER.test(value) && Number(value) >= 1 && Number(value) <= 1e3;
|
|
316
|
-
case "scope": return tag === "th" && /^(?:row|col|rowgroup|colgroup)$/i.test(value);
|
|
317
|
-
case "span": return (tag === "col" || tag === "colgroup") && INTEGER.test(value);
|
|
318
|
-
case "start": return tag === "ol" && /^-?\d{1,9}$/.test(value);
|
|
319
|
-
case "reversed": return tag === "ol";
|
|
320
|
-
case "type": return tag === "ol" && /^[1aAiI]$/.test(value);
|
|
321
|
-
case "value": return tag === "li" && /^-?\d{1,9}$/.test(value);
|
|
322
|
-
case "datetime": return tag === "time" && /^[\d\-:T.+ Z]{1,40}$/.test(value);
|
|
323
|
-
default: return false;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
//#endregion
|
|
8
|
+
const require_text = require("./chunks/text-C2OYT-3o.cjs");
|
|
327
9
|
//#region src/rich/style.ts
|
|
328
10
|
const INHERITED = [
|
|
329
11
|
"color",
|
|
@@ -533,96 +215,6 @@ function box(values, background, colors) {
|
|
|
533
215
|
return out;
|
|
534
216
|
}
|
|
535
217
|
//#endregion
|
|
536
|
-
//#region src/rich/text.ts
|
|
537
|
-
/**
|
|
538
|
-
* Readable plain text for sanitized rich content: blocks on their own lines, list
|
|
539
|
-
* items with bullets or numbers (indented when nested), table cells separated by tabs,
|
|
540
|
-
* images by their alt text, and preformatted text as it is.
|
|
541
|
-
*/
|
|
542
|
-
function plainText(root) {
|
|
543
|
-
const lines = [];
|
|
544
|
-
let line = "";
|
|
545
|
-
const flush = () => {
|
|
546
|
-
const trimmed = line.replace(/[ \t\u00A0]+$/, "");
|
|
547
|
-
if (trimmed !== "" || lines.length > 0 && lines[lines.length - 1] !== "") lines.push(trimmed);
|
|
548
|
-
line = "";
|
|
549
|
-
};
|
|
550
|
-
const breakBlock = () => {
|
|
551
|
-
if (line.trim() !== "") flush();
|
|
552
|
-
else line = "";
|
|
553
|
-
};
|
|
554
|
-
const walk = (node, pre, depth) => {
|
|
555
|
-
if (node.nodeType === 3) {
|
|
556
|
-
const data = node.data;
|
|
557
|
-
if (pre) line += data.replace(/\r\n?/g, "\n");
|
|
558
|
-
else {
|
|
559
|
-
const collapsed = data.replace(/\s+/g, " ");
|
|
560
|
-
line += /(?:^|[ \t])$/.test(line) && collapsed.startsWith(" ") ? collapsed.slice(1) : collapsed;
|
|
561
|
-
}
|
|
562
|
-
if (pre && line.includes("\n")) {
|
|
563
|
-
const parts = line.split("\n");
|
|
564
|
-
line = parts.pop();
|
|
565
|
-
for (const part of parts) lines.push(part);
|
|
566
|
-
}
|
|
567
|
-
if (!pre && line.trimStart() === "") line = "";
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
|
-
if (node.nodeType !== 1) return;
|
|
571
|
-
const element = node;
|
|
572
|
-
const tag = element.localName;
|
|
573
|
-
switch (tag) {
|
|
574
|
-
case "br":
|
|
575
|
-
flush();
|
|
576
|
-
return;
|
|
577
|
-
case "img":
|
|
578
|
-
line += element.getAttribute("alt") ?? "";
|
|
579
|
-
return;
|
|
580
|
-
case "hr":
|
|
581
|
-
breakBlock();
|
|
582
|
-
lines.push("—".repeat(3));
|
|
583
|
-
return;
|
|
584
|
-
case "td":
|
|
585
|
-
case "th":
|
|
586
|
-
if (element.previousElementSibling !== null) line += " ";
|
|
587
|
-
element.childNodes.forEach((child) => {
|
|
588
|
-
walk(child, pre, depth);
|
|
589
|
-
});
|
|
590
|
-
return;
|
|
591
|
-
case "li": {
|
|
592
|
-
breakBlock();
|
|
593
|
-
const list = element.parentElement;
|
|
594
|
-
const ordered = list?.localName === "ol";
|
|
595
|
-
let marker = "•";
|
|
596
|
-
if (ordered) {
|
|
597
|
-
const items = Array.from(list.children).filter((child) => child.localName === "li");
|
|
598
|
-
const start = Number(list.getAttribute("start") ?? "1");
|
|
599
|
-
const own = element.getAttribute("value");
|
|
600
|
-
marker = `${String(own === null ? start + items.indexOf(element) : Number(own))}.`;
|
|
601
|
-
}
|
|
602
|
-
line = `${" ".repeat(Math.max(0, depth - 1))}${marker} `;
|
|
603
|
-
element.childNodes.forEach((child) => {
|
|
604
|
-
walk(child, pre, depth);
|
|
605
|
-
});
|
|
606
|
-
breakBlock();
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
609
|
-
default: {
|
|
610
|
-
const block = TEXT_BLOCKS.has(tag);
|
|
611
|
-
const list = tag === "ul" || tag === "ol";
|
|
612
|
-
if (block) breakBlock();
|
|
613
|
-
const keep = pre || tag === "pre" || /white-space:\s*pre/.test(element.getAttribute("style") ?? "");
|
|
614
|
-
element.childNodes.forEach((child) => {
|
|
615
|
-
walk(child, keep, list ? depth + 1 : depth);
|
|
616
|
-
});
|
|
617
|
-
if (block) breakBlock();
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
};
|
|
621
|
-
walk(root, false, 0);
|
|
622
|
-
flush();
|
|
623
|
-
return lines.join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
624
|
-
}
|
|
625
|
-
//#endregion
|
|
626
218
|
//#region src/rich/walk.ts
|
|
627
219
|
const VOID = /* @__PURE__ */ new Set([
|
|
628
220
|
"br",
|
|
@@ -639,7 +231,7 @@ function positive$1(value, fallback, name) {
|
|
|
639
231
|
}
|
|
640
232
|
/** Whether `source` holds an element that would close a paragraph around it. */
|
|
641
233
|
function holdsBlocks(source) {
|
|
642
|
-
for (let child = source.firstElementChild; child !== null; child = child.nextElementSibling) if (CLOSES_P.has(child.localName) || holdsBlocks(child)) return true;
|
|
234
|
+
for (let child = source.firstElementChild; child !== null; child = child.nextElementSibling) if (require_text.CLOSES_P.has(child.localName) || holdsBlocks(child)) return true;
|
|
643
235
|
return false;
|
|
644
236
|
}
|
|
645
237
|
/** Whether `node` is (inside) a link in the output. */
|
|
@@ -729,7 +321,7 @@ var Builder = class {
|
|
|
729
321
|
const end = source === range.endContainer ? range.endOffset : text.length;
|
|
730
322
|
text = text.slice(source === range.startContainer ? range.startOffset : 0, end);
|
|
731
323
|
}
|
|
732
|
-
if (TABLE_CHILDREN[parent.localName] !== void 0 && text.trim() !== "") {
|
|
324
|
+
if (require_text.TABLE_CHILDREN[parent.localName] !== void 0 && text.trim() !== "") {
|
|
733
325
|
this.remove("misplaced", "#text");
|
|
734
326
|
return;
|
|
735
327
|
}
|
|
@@ -748,7 +340,7 @@ var Builder = class {
|
|
|
748
340
|
}
|
|
749
341
|
element(source, parent, inherited, background, range, root) {
|
|
750
342
|
const tag = source.localName.toLowerCase();
|
|
751
|
-
if (DROP.has(tag) || source.namespaceURI !== "http://www.w3.org/1999/xhtml") {
|
|
343
|
+
if (require_text.DROP.has(tag) || source.namespaceURI !== "http://www.w3.org/1999/xhtml") {
|
|
752
344
|
this.remove("unsafe-element", tag);
|
|
753
345
|
return;
|
|
754
346
|
}
|
|
@@ -777,7 +369,7 @@ var Builder = class {
|
|
|
777
369
|
this.image(source, parent);
|
|
778
370
|
return;
|
|
779
371
|
}
|
|
780
|
-
let name = KEEP.has(tag) ? tag : AS_BLOCK.has(tag) || BLOCK_DISPLAY.test(values.display ?? "") ? "div" : "span";
|
|
372
|
+
let name = require_text.KEEP.has(tag) ? tag : require_text.AS_BLOCK.has(tag) || BLOCK_DISPLAY.test(values.display ?? "") ? "div" : "span";
|
|
781
373
|
let href = null;
|
|
782
374
|
if (tag === "a") {
|
|
783
375
|
const raw = source.getAttribute("href");
|
|
@@ -789,7 +381,7 @@ var Builder = class {
|
|
|
789
381
|
}
|
|
790
382
|
let target = parent;
|
|
791
383
|
let parentTag = parent.localName;
|
|
792
|
-
if (TABLE_PARTS.has(name) && TABLE_CHILDREN[parentTag] === void 0) {
|
|
384
|
+
if (require_text.TABLE_PARTS.has(name) && require_text.TABLE_CHILDREN[parentTag] === void 0) {
|
|
793
385
|
if (root) {
|
|
794
386
|
target = parent.appendChild(this.out.createElement("table"));
|
|
795
387
|
parentTag = "table";
|
|
@@ -802,15 +394,15 @@ var Builder = class {
|
|
|
802
394
|
if (parentTag === "table" && (name === "tr" || name === "td" || name === "th")) implied.push("tbody");
|
|
803
395
|
if ((name === "td" || name === "th") && (implied.length > 0 || parentTag === "tbody" || parentTag === "thead" || parentTag === "tfoot")) implied.push("tr");
|
|
804
396
|
if (parentTag === "table" && name === "col") implied.push("colgroup");
|
|
805
|
-
const allowed = TABLE_CHILDREN[implied.at(-1) ?? parentTag];
|
|
397
|
+
const allowed = require_text.TABLE_CHILDREN[implied.at(-1) ?? parentTag];
|
|
806
398
|
if (allowed !== void 0 && !allowed.has(name)) {
|
|
807
399
|
this.remove("misplaced", tag);
|
|
808
400
|
return;
|
|
809
401
|
}
|
|
810
402
|
if (name === "p" && holdsBlocks(source)) name = "div";
|
|
811
|
-
if (HEADINGS
|
|
812
|
-
if ((name === "li" || name === "dd" || name === "dt") && closesItem(name, parent)) name = "div";
|
|
813
|
-
if (name === "div" && PHRASING.has(parentTag)) name = "span";
|
|
403
|
+
if (require_text.HEADINGS.has(name) && require_text.HEADINGS.has(parentTag)) name = "span";
|
|
404
|
+
if ((name === "li" || name === "dd" || name === "dt") && require_text.closesItem(name, parent)) name = "div";
|
|
405
|
+
if (name === "div" && require_text.PHRASING.has(parentTag)) name = "span";
|
|
814
406
|
if (name === "a" && insideLink(parent)) name = "span";
|
|
815
407
|
if (!this.budget(name.length * 2 + 5)) return;
|
|
816
408
|
for (const wrapper of implied) {
|
|
@@ -823,7 +415,7 @@ var Builder = class {
|
|
|
823
415
|
if (href !== null && name === "a") out.setAttribute("href", href);
|
|
824
416
|
for (const attribute of Array.from(source.attributes)) {
|
|
825
417
|
const key = attribute.name.toLowerCase();
|
|
826
|
-
if (name === tag && attributeAllowed(tag, key, attribute.value)) out.setAttribute(key, attribute.value);
|
|
418
|
+
if (name === tag && require_text.attributeAllowed(tag, key, attribute.value)) out.setAttribute(key, attribute.value);
|
|
827
419
|
}
|
|
828
420
|
const style = declarations(name, values, root ? ROOT_PARENT : inherited, background, this.colors);
|
|
829
421
|
if (style.droppedColor) this.remove("unreadable-color", tag);
|
|
@@ -936,7 +528,7 @@ function prepareRich(source, options = {}) {
|
|
|
936
528
|
if (typeof source === "string") builder.children(root, container, ROOT_PARENT, page, null);
|
|
937
529
|
else builder.node(root, container, ROOT_PARENT, page, range, true);
|
|
938
530
|
container.normalize();
|
|
939
|
-
const text = (options.text ?? plainText)(container);
|
|
531
|
+
const text = (options.text ?? require_text.plainText)(container);
|
|
940
532
|
if (typeof text !== "string") throw require_errors.copyFailure("invalid-payload", "`text` must return a string.");
|
|
941
533
|
const first = container.firstChild;
|
|
942
534
|
if (first?.nodeType === 3) first.data = first.data.replace(/^\s+/, "");
|
|
@@ -1124,7 +716,7 @@ function bitsOf(bits, tag, style) {
|
|
|
1124
716
|
}
|
|
1125
717
|
/** Never content: scripts, metadata, embeds, media, controls, and Word's `<o:p>` spacers. */
|
|
1126
718
|
const SKIP = /* @__PURE__ */ new Set([
|
|
1127
|
-
...DROP,
|
|
719
|
+
...require_text.DROP,
|
|
1128
720
|
"xml",
|
|
1129
721
|
"o:p",
|
|
1130
722
|
"area",
|
|
@@ -2091,7 +1683,7 @@ function pasteAsRich(event, options) {
|
|
|
2091
1683
|
exports.RICH_PASTE_FORMATS = RICH_PASTE_FORMATS;
|
|
2092
1684
|
exports.pasteAsRich = pasteAsRich;
|
|
2093
1685
|
exports.pasteToRich = pasteToRich;
|
|
2094
|
-
exports.plainText = plainText;
|
|
1686
|
+
exports.plainText = require_text.plainText;
|
|
2095
1687
|
exports.prepareRich = prepareRich;
|
|
2096
1688
|
exports.richPayload = richPayload;
|
|
2097
1689
|
exports.richTransform = richTransform;
|