@wordpress/dom 5.0.0 → 5.1.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 +1 -1
- package/build/data-transfer.cjs +20 -38
- package/build/data-transfer.cjs.map +1 -7
- package/build/dom/caret-range-from-point.cjs +31 -38
- package/build/dom/caret-range-from-point.cjs.map +1 -7
- package/build/dom/clean-node-list.cjs +87 -132
- package/build/dom/clean-node-list.cjs.map +1 -7
- package/build/dom/compute-caret-rect.cjs +35 -35
- package/build/dom/compute-caret-rect.cjs.map +1 -7
- package/build/dom/document-has-selection.cjs +35 -30
- package/build/dom/document-has-selection.cjs.map +1 -7
- package/build/dom/document-has-text-selection.cjs +24 -30
- package/build/dom/document-has-text-selection.cjs.map +1 -7
- package/build/dom/document-has-uncollapsed-selection.cjs +34 -29
- package/build/dom/document-has-uncollapsed-selection.cjs.map +1 -7
- package/build/dom/get-computed-style.cjs +14 -30
- package/build/dom/get-computed-style.cjs.map +1 -7
- package/build/dom/get-offset-parent.cjs +40 -39
- package/build/dom/get-offset-parent.cjs.map +1 -7
- package/build/dom/get-range-height.cjs +18 -31
- package/build/dom/get-range-height.cjs.map +1 -7
- package/build/dom/get-rectangle-from-range.cjs +82 -128
- package/build/dom/get-rectangle-from-range.cjs.map +1 -7
- package/build/dom/get-scroll-container.cjs +46 -50
- package/build/dom/get-scroll-container.cjs.map +1 -7
- package/build/dom/hidden-caret-range-from-point.cjs +48 -42
- package/build/dom/hidden-caret-range-from-point.cjs.map +1 -7
- package/build/dom/index.cjs +233 -110
- package/build/dom/input-field-has-uncollapsed-selection.cjs +48 -43
- package/build/dom/input-field-has-uncollapsed-selection.cjs.map +1 -7
- package/build/dom/insert-after.cjs +17 -27
- package/build/dom/insert-after.cjs.map +1 -7
- package/build/dom/is-edge.cjs +82 -97
- package/build/dom/is-edge.cjs.map +1 -7
- package/build/dom/is-element.cjs +12 -25
- package/build/dom/is-element.cjs.map +1 -7
- package/build/dom/is-empty.cjs +23 -37
- package/build/dom/is-empty.cjs.map +1 -7
- package/build/dom/is-entirely-selected.cjs +70 -67
- package/build/dom/is-entirely-selected.cjs.map +1 -7
- package/build/dom/is-form-element.cjs +33 -33
- package/build/dom/is-form-element.cjs.map +1 -7
- package/build/dom/is-horizontal-edge.cjs +31 -28
- package/build/dom/is-horizontal-edge.cjs.map +1 -7
- package/build/dom/is-html-input-element.cjs +12 -25
- package/build/dom/is-html-input-element.cjs.map +1 -7
- package/build/dom/is-input-or-text-area.cjs +12 -25
- package/build/dom/is-input-or-text-area.cjs.map +1 -7
- package/build/dom/is-number-input.cjs +36 -33
- package/build/dom/is-number-input.cjs.map +1 -7
- package/build/dom/is-rtl.cjs +30 -28
- package/build/dom/is-rtl.cjs.map +1 -7
- package/build/dom/is-selection-forward.cjs +26 -39
- package/build/dom/is-selection-forward.cjs.map +1 -7
- package/build/dom/is-text-field.cjs +45 -42
- package/build/dom/is-text-field.cjs.map +1 -7
- package/build/dom/is-vertical-edge.cjs +31 -28
- package/build/dom/is-vertical-edge.cjs.map +1 -7
- package/build/dom/place-caret-at-edge.cjs +75 -78
- package/build/dom/place-caret-at-edge.cjs.map +1 -7
- package/build/dom/place-caret-at-horizontal-edge.cjs +29 -28
- package/build/dom/place-caret-at-horizontal-edge.cjs.map +1 -7
- package/build/dom/place-caret-at-vertical-edge.cjs +30 -28
- package/build/dom/place-caret-at-vertical-edge.cjs.map +1 -7
- package/build/dom/remove-invalid-html.cjs +35 -31
- package/build/dom/remove-invalid-html.cjs.map +1 -7
- package/build/dom/remove.cjs +15 -27
- package/build/dom/remove.cjs.map +1 -7
- package/build/dom/replace-tag.cjs +21 -32
- package/build/dom/replace-tag.cjs.map +1 -7
- package/build/dom/replace.cjs +34 -32
- package/build/dom/replace.cjs.map +1 -7
- package/build/dom/safe-html.cjs +45 -46
- package/build/dom/safe-html.cjs.map +1 -7
- package/build/dom/scroll-if-no-range.cjs +24 -37
- package/build/dom/scroll-if-no-range.cjs.map +1 -7
- package/build/dom/strip-html.cjs +33 -31
- package/build/dom/strip-html.cjs.map +1 -7
- package/build/dom/types.cjs +4 -18
- package/build/dom/unwrap.cjs +17 -31
- package/build/dom/unwrap.cjs.map +1 -7
- package/build/dom/wrap.cjs +17 -28
- package/build/dom/wrap.cjs.map +1 -7
- package/build/focusable.cjs +99 -76
- package/build/focusable.cjs.map +1 -7
- package/build/index.cjs +57 -38
- package/build/index.cjs.map +1 -7
- package/build/phrasing-content.cjs +163 -159
- package/build/phrasing-content.cjs.map +1 -7
- package/build/tabbable.cjs +123 -78
- package/build/tabbable.cjs.map +1 -7
- package/build/types.cjs +4 -18
- package/build/utils/assert-is-defined.cjs +8 -33
- package/build/utils/assert-is-defined.cjs.map +1 -7
- package/build-module/data-transfer.mjs +16 -14
- package/build-module/data-transfer.mjs.map +1 -7
- package/build-module/dom/caret-range-from-point.mjs +27 -18
- package/build-module/dom/caret-range-from-point.mjs.map +1 -7
- package/build-module/dom/clean-node-list.mjs +60 -105
- package/build-module/dom/clean-node-list.mjs.map +1 -7
- package/build-module/dom/compute-caret-rect.mjs +16 -12
- package/build-module/dom/compute-caret-rect.mjs.map +1 -7
- package/build-module/dom/document-has-selection.mjs +13 -6
- package/build-module/dom/document-has-selection.mjs.map +1 -7
- package/build-module/dom/document-has-text-selection.mjs +20 -10
- package/build-module/dom/document-has-text-selection.mjs.map +1 -7
- package/build-module/dom/document-has-uncollapsed-selection.mjs +14 -6
- package/build-module/dom/document-has-uncollapsed-selection.mjs.map +1 -7
- package/build-module/dom/get-computed-style.mjs +10 -10
- package/build-module/dom/get-computed-style.mjs.map +1 -7
- package/build-module/dom/get-offset-parent.mjs +20 -16
- package/build-module/dom/get-offset-parent.mjs.map +1 -7
- package/build-module/dom/get-range-height.mjs +14 -11
- package/build-module/dom/get-range-height.mjs.map +1 -7
- package/build-module/dom/get-rectangle-from-range.mjs +78 -108
- package/build-module/dom/get-rectangle-from-range.mjs.map +1 -7
- package/build-module/dom/get-scroll-container.mjs +28 -28
- package/build-module/dom/get-scroll-container.mjs.map +1 -7
- package/build-module/dom/hidden-caret-range-from-point.mjs +28 -19
- package/build-module/dom/hidden-caret-range-from-point.mjs.map +1 -7
- package/build-module/dom/index.mjs +28 -58
- package/build-module/dom/input-field-has-uncollapsed-selection.mjs +28 -20
- package/build-module/dom/input-field-has-uncollapsed-selection.mjs.map +1 -7
- package/build-module/dom/insert-after.mjs +13 -7
- package/build-module/dom/insert-after.mjs.map +1 -7
- package/build-module/dom/is-edge.mjs +53 -69
- package/build-module/dom/is-edge.mjs.map +1 -7
- package/build-module/dom/is-element.mjs +8 -5
- package/build-module/dom/is-element.mjs.map +1 -7
- package/build-module/dom/is-empty.mjs +19 -17
- package/build-module/dom/is-empty.mjs.map +1 -7
- package/build-module/dom/is-entirely-selected.mjs +51 -44
- package/build-module/dom/is-entirely-selected.mjs.map +1 -7
- package/build-module/dom/is-form-element.mjs +15 -11
- package/build-module/dom/is-form-element.mjs.map +1 -7
- package/build-module/dom/is-horizontal-edge.mjs +13 -6
- package/build-module/dom/is-horizontal-edge.mjs.map +1 -7
- package/build-module/dom/is-html-input-element.mjs +8 -5
- package/build-module/dom/is-html-input-element.mjs.map +1 -7
- package/build-module/dom/is-input-or-text-area.mjs +8 -5
- package/build-module/dom/is-input-or-text-area.mjs.map +1 -7
- package/build-module/dom/is-number-input.mjs +16 -10
- package/build-module/dom/is-number-input.mjs.map +1 -7
- package/build-module/dom/is-rtl.mjs +12 -6
- package/build-module/dom/is-rtl.mjs.map +1 -7
- package/build-module/dom/is-selection-forward.mjs +22 -19
- package/build-module/dom/is-selection-forward.mjs.map +1 -7
- package/build-module/dom/is-text-field.mjs +27 -20
- package/build-module/dom/is-text-field.mjs.map +1 -7
- package/build-module/dom/is-vertical-edge.mjs +13 -6
- package/build-module/dom/is-vertical-edge.mjs.map +1 -7
- package/build-module/dom/place-caret-at-edge.mjs +51 -52
- package/build-module/dom/place-caret-at-edge.mjs.map +1 -7
- package/build-module/dom/place-caret-at-horizontal-edge.mjs +11 -6
- package/build-module/dom/place-caret-at-horizontal-edge.mjs.map +1 -7
- package/build-module/dom/place-caret-at-vertical-edge.mjs +12 -6
- package/build-module/dom/place-caret-at-vertical-edge.mjs.map +1 -7
- package/build-module/dom/remove-invalid-html.mjs +17 -9
- package/build-module/dom/remove-invalid-html.mjs.map +1 -7
- package/build-module/dom/remove.mjs +11 -7
- package/build-module/dom/remove.mjs.map +1 -7
- package/build-module/dom/replace-tag.mjs +17 -12
- package/build-module/dom/replace-tag.mjs.map +1 -7
- package/build-module/dom/replace.mjs +13 -8
- package/build-module/dom/replace.mjs.map +1 -7
- package/build-module/dom/safe-html.mjs +27 -24
- package/build-module/dom/safe-html.mjs.map +1 -7
- package/build-module/dom/scroll-if-no-range.mjs +20 -13
- package/build-module/dom/scroll-if-no-range.mjs.map +1 -7
- package/build-module/dom/strip-html.mjs +15 -9
- package/build-module/dom/strip-html.mjs.map +1 -7
- package/build-module/dom/types.mjs +0 -1
- package/build-module/dom/unwrap.mjs +13 -11
- package/build-module/dom/unwrap.mjs.map +1 -7
- package/build-module/dom/wrap.mjs +13 -8
- package/build-module/dom/wrap.mjs.map +1 -7
- package/build-module/focusable.mjs +95 -52
- package/build-module/focusable.mjs.map +1 -7
- package/build-module/index.mjs +11 -5
- package/build-module/index.mjs.map +1 -7
- package/build-module/phrasing-content.mjs +157 -133
- package/build-module/phrasing-content.mjs.map +1 -7
- package/build-module/tabbable.mjs +116 -51
- package/build-module/tabbable.mjs.map +1 -7
- package/build-module/types.mjs +0 -1
- package/build-module/utils/assert-is-defined.mjs +4 -9
- package/build-module/utils/assert-is-defined.mjs.map +1 -7
- package/build-types/dom/clean-node-list.d.ts +2 -2
- package/build-types/dom/clean-node-list.d.ts.map +1 -1
- package/build-types/dom/is-edge.d.ts.map +1 -1
- package/build-types/dom/remove-invalid-html.d.ts +4 -4
- package/build-types/dom/remove-invalid-html.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/dom/clean-node-list.ts +2 -2
- package/src/dom/is-edge.ts +35 -43
- package/src/dom/remove-invalid-html.ts +4 -4
- package/src/dom/test/{get-rectangle-from-range.browser.test.js → get-rectangle-from-range.browser.test.ts} +25 -25
- package/src/test/{dom.jsdom.test.js → dom.jsdom.test.ts} +9 -6
- package/src/test/{focusable.browser.test.js → focusable.browser.test.ts} +14 -13
- package/src/test/{tabbable.browser.test.js → tabbable.browser.test.ts} +3 -2
- package/build/dom/index.cjs.map +0 -7
- package/build/dom/types.cjs.map +0 -7
- package/build/types.cjs.map +0 -7
- package/build-module/dom/index.mjs.map +0 -7
- package/build-module/dom/types.mjs.map +0 -7
- package/build-module/types.mjs.map +0 -7
- /package/src/dom/test/{safe-html.jsdom.test.js → safe-html.jsdom.test.ts} +0 -0
- /package/src/dom/test/{strip-html.jsdom.test.js → strip-html.jsdom.test.ts} +0 -0
- /package/src/test/{focusable-area.jsdom.test.js → focusable-area.jsdom.test.ts} +0 -0
- /package/src/test/{utils.js → utils.ts} +0 -0
package/README.md
CHANGED
package/build/data-transfer.cjs
CHANGED
|
@@ -1,42 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/dom/src/data-transfer.ts
|
|
21
|
-
var data_transfer_exports = {};
|
|
22
|
-
__export(data_transfer_exports, {
|
|
23
|
-
getFilesFromDataTransfer: () => getFilesFromDataTransfer
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
5
|
});
|
|
25
|
-
|
|
6
|
+
// packages/dom/src/data-transfer.ts
|
|
7
|
+
/**
|
|
8
|
+
* Gets all files from a DataTransfer object.
|
|
9
|
+
*
|
|
10
|
+
* @param dataTransfer DataTransfer object to inspect.
|
|
11
|
+
*
|
|
12
|
+
* @return An array containing all files.
|
|
13
|
+
*/
|
|
26
14
|
function getFilesFromDataTransfer(dataTransfer) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
files.push(file);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
return files;
|
|
15
|
+
const files = Array.from(dataTransfer.files);
|
|
16
|
+
Array.from(dataTransfer.items).forEach((item) => {
|
|
17
|
+
const file = item.getAsFile();
|
|
18
|
+
if (file && !files.find(({ name, type, size }) => name === file.name && type === file.type && size === file.size)) files.push(file);
|
|
19
|
+
});
|
|
20
|
+
return files;
|
|
37
21
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
//# sourceMappingURL=data-transfer.cjs.map
|
|
22
|
+
exports.getFilesFromDataTransfer = getFilesFromDataTransfer;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=data-transfer.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/data-transfer.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Gets all files from a DataTransfer object.\n *\n * @param dataTransfer DataTransfer object to inspect.\n *\n * @return An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer: DataTransfer ): File[] {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,yBAA0B,cAAqC;AAC9E,QAAM,QAAQ,MAAM,KAAM,aAAa,KAAM;AAE7C,QAAM,KAAM,aAAa,KAAM,EAAE,QAAS,CAAE,SAAU;AACrD,UAAM,OAAO,KAAK,UAAU;AAE5B,QACC,QACA,CAAE,MAAM;AAAA,MACP,CAAE,EAAE,MAAM,MAAM,KAAK,MACpB,SAAS,KAAK,QACd,SAAS,KAAK,QACd,SAAS,KAAK;AAAA,IAChB,GACC;AACD,YAAM,KAAM,IAAK;AAAA,IAClB;AAAA,EACD,CAAE;AAEF,SAAO;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"data-transfer.cjs","names":[],"sources":["../src/data-transfer.ts"],"sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param dataTransfer DataTransfer object to inspect.\n *\n * @return An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer: DataTransfer ): File[] {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAgB,yBAA0B,cAAqC;CAC9E,MAAM,QAAQ,MAAM,KAAM,aAAa,KAAM;CAE7C,MAAM,KAAM,aAAa,KAAM,CAAC,CAAC,SAAW,SAAU;EACrD,MAAM,OAAO,KAAK,UAAU;EAE5B,IACC,QACA,CAAE,MAAM,MACL,EAAE,MAAM,MAAM,WACf,SAAS,KAAK,QACd,SAAS,KAAK,QACd,SAAS,KAAK,IAChB,GAEA,MAAM,KAAM,IAAK;CAEnB,CAAE;CAEF,OAAO;AACR"}
|
|
@@ -1,42 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/dom/src/dom/caret-range-from-point.ts
|
|
21
|
-
var caret_range_from_point_exports = {};
|
|
22
|
-
__export(caret_range_from_point_exports, {
|
|
23
|
-
default: () => caretRangeFromPoint
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
24
5
|
});
|
|
25
|
-
|
|
6
|
+
// packages/dom/src/dom/caret-range-from-point.ts
|
|
7
|
+
/**
|
|
8
|
+
* Get a collapsed range for a given point.
|
|
9
|
+
*
|
|
10
|
+
* Prefers the standard `caretPositionFromPoint` API and falls back to the
|
|
11
|
+
* non-standard, WebKit-originated `caretRangeFromPoint` for older browsers.
|
|
12
|
+
*
|
|
13
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint
|
|
14
|
+
*
|
|
15
|
+
* @param doc The document of the range.
|
|
16
|
+
* @param x Horizontal position within the current viewport.
|
|
17
|
+
* @param y Vertical position within the current viewport.
|
|
18
|
+
*
|
|
19
|
+
* @return The best range for the given point.
|
|
20
|
+
*/
|
|
26
21
|
function caretRangeFromPoint(doc, x, y) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (doc.caretRangeFromPoint) {
|
|
38
|
-
return doc.caretRangeFromPoint(x, y);
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
22
|
+
if (doc.caretPositionFromPoint) {
|
|
23
|
+
const point = doc.caretPositionFromPoint(x, y);
|
|
24
|
+
if (!point) return null;
|
|
25
|
+
const range = doc.createRange();
|
|
26
|
+
range.setStart(point.offsetNode, point.offset);
|
|
27
|
+
range.collapse(true);
|
|
28
|
+
return range;
|
|
29
|
+
}
|
|
30
|
+
if (doc.caretRangeFromPoint) return doc.caretRangeFromPoint(x, y);
|
|
31
|
+
return null;
|
|
41
32
|
}
|
|
42
|
-
|
|
33
|
+
exports.default = caretRangeFromPoint;
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=caret-range-from-point.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/caret-range-from-point.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Get a collapsed range for a given point.\n *\n * Prefers the standard `caretPositionFromPoint` API and falls back to the\n * non-standard, WebKit-originated `caretRangeFromPoint` for older browsers.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n *\n * @param doc The document of the range.\n * @param x Horizontal position within the current viewport.\n * @param y Vertical position within the current viewport.\n *\n * @return The best range for the given point.\n */\nexport default function caretRangeFromPoint(\n\tdoc: Document,\n\tx: number,\n\ty: number\n): Range | null {\n\tif ( doc.caretPositionFromPoint ) {\n\t\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n\t\tif ( ! point ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst range = doc.createRange();\n\n\t\trange.setStart( point.offsetNode, point.offset );\n\t\trange.collapse( true );\n\n\t\treturn range;\n\t}\n\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\treturn null;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAce,SAAR,oBACN,KACA,GACA,GACe;AACf,MAAK,IAAI,wBAAyB;AACjC,UAAM,QAAQ,IAAI,uBAAwB,GAAG,CAAE;AAI/C,QAAK,CAAE,OAAQ;AACd,aAAO;AAAA,IACR;AAEA,UAAM,QAAQ,IAAI,YAAY;AAE9B,UAAM,SAAU,MAAM,YAAY,MAAM,MAAO;AAC/C,UAAM,SAAU,IAAK;AAErB,WAAO;AAAA,EACR;AAEA,MAAK,IAAI,qBAAsB;AAC9B,WAAO,IAAI,oBAAqB,GAAG,CAAE;AAAA,EACtC;AAEA,SAAO;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"caret-range-from-point.cjs","names":[],"sources":["../../src/dom/caret-range-from-point.ts"],"sourcesContent":["/**\n * Get a collapsed range for a given point.\n *\n * Prefers the standard `caretPositionFromPoint` API and falls back to the\n * non-standard, WebKit-originated `caretRangeFromPoint` for older browsers.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n *\n * @param doc The document of the range.\n * @param x Horizontal position within the current viewport.\n * @param y Vertical position within the current viewport.\n *\n * @return The best range for the given point.\n */\nexport default function caretRangeFromPoint(\n\tdoc: Document,\n\tx: number,\n\ty: number\n): Range | null {\n\tif ( doc.caretPositionFromPoint ) {\n\t\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n\t\tif ( ! point ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst range = doc.createRange();\n\n\t\trange.setStart( point.offsetNode, point.offset );\n\t\trange.collapse( true );\n\n\t\treturn range;\n\t}\n\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\treturn null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAcA,SAAwB,oBACvB,KACA,GACA,GACe;CACf,IAAK,IAAI,wBAAyB;EACjC,MAAM,QAAQ,IAAI,uBAAwB,GAAG,CAAE;EAI/C,IAAK,CAAE,OACN,OAAO;EAGR,MAAM,QAAQ,IAAI,YAAY;EAE9B,MAAM,SAAU,MAAM,YAAY,MAAM,MAAO;EAC/C,MAAM,SAAU,IAAK;EAErB,OAAO;CACR;CAEA,IAAK,IAAI,qBACR,OAAO,IAAI,oBAAqB,GAAG,CAAE;CAGtC,OAAO;AACR"}
|
|
@@ -1,144 +1,99 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// \0rolldown/runtime.js
|
|
2
7
|
var __create = Object.create;
|
|
3
8
|
var __defProp = Object.defineProperty;
|
|
4
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
13
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
19
22
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
let __is_empty_ts = require("./is-empty.cjs");
|
|
28
|
+
__is_empty_ts = __toESM(__is_empty_ts);
|
|
29
|
+
let __remove_ts = require("./remove.cjs");
|
|
30
|
+
__remove_ts = __toESM(__remove_ts);
|
|
31
|
+
let __unwrap_ts = require("./unwrap.cjs");
|
|
32
|
+
__unwrap_ts = __toESM(__unwrap_ts);
|
|
33
|
+
let ___phrasing_content_ts = require("../phrasing-content.cjs");
|
|
34
|
+
let __insert_after_ts = require("./insert-after.cjs");
|
|
35
|
+
__insert_after_ts = __toESM(__insert_after_ts);
|
|
36
|
+
let __is_element_ts = require("./is-element.cjs");
|
|
37
|
+
__is_element_ts = __toESM(__is_element_ts);
|
|
30
38
|
// packages/dom/src/dom/clean-node-list.ts
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var import_is_element = __toESM(require("./is-element.cjs"));
|
|
42
|
-
var noop = () => {
|
|
43
|
-
};
|
|
39
|
+
const noop = () => {};
|
|
40
|
+
/**
|
|
41
|
+
* Given a schema, unwraps or removes nodes, attributes and classes on a node
|
|
42
|
+
* list.
|
|
43
|
+
*
|
|
44
|
+
* @param nodeList The nodeList to filter.
|
|
45
|
+
* @param doc The document of the nodeList.
|
|
46
|
+
* @param schema Schema for the HTML.
|
|
47
|
+
* @param [inline] Whether to clean for inline mode.
|
|
48
|
+
*/
|
|
44
49
|
function cleanNodeList(nodeList, doc, schema, inline) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (node.hasChildNodes()) {
|
|
95
|
-
if (children === "*") {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (children) {
|
|
99
|
-
if (require2.length && !node.querySelector(require2.join(","))) {
|
|
100
|
-
cleanNodeList(
|
|
101
|
-
node.childNodes,
|
|
102
|
-
doc,
|
|
103
|
-
schema,
|
|
104
|
-
inline
|
|
105
|
-
);
|
|
106
|
-
(0, import_unwrap.default)(node);
|
|
107
|
-
} else if (node.parentNode && node.parentNode.nodeName === "BODY" && (0, import_phrasing_content.isPhrasingContent)(node)) {
|
|
108
|
-
cleanNodeList(
|
|
109
|
-
node.childNodes,
|
|
110
|
-
doc,
|
|
111
|
-
schema,
|
|
112
|
-
inline
|
|
113
|
-
);
|
|
114
|
-
if (Array.from(node.childNodes).some(
|
|
115
|
-
(child) => !(0, import_phrasing_content.isPhrasingContent)(child)
|
|
116
|
-
)) {
|
|
117
|
-
(0, import_unwrap.default)(node);
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
cleanNodeList(
|
|
121
|
-
node.childNodes,
|
|
122
|
-
doc,
|
|
123
|
-
children,
|
|
124
|
-
inline
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
} else {
|
|
128
|
-
while (node.firstChild) {
|
|
129
|
-
(0, import_remove.default)(node.firstChild);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
cleanNodeList(node.childNodes, doc, schema, inline);
|
|
136
|
-
if (inline && !(0, import_phrasing_content.isPhrasingContent)(node) && node.nextElementSibling) {
|
|
137
|
-
(0, import_insert_after.default)(doc.createElement("br"), node);
|
|
138
|
-
}
|
|
139
|
-
(0, import_unwrap.default)(node);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
);
|
|
50
|
+
Array.from(nodeList).forEach((node) => {
|
|
51
|
+
const tag = node.nodeName.toLowerCase();
|
|
52
|
+
if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
|
|
53
|
+
if ((0, __is_element_ts.default)(node)) {
|
|
54
|
+
const { attributes = [], classes = [], children, require: require$1 = [], allowEmpty } = schema[tag];
|
|
55
|
+
if (children && !allowEmpty && (0, __is_empty_ts.default)(node)) {
|
|
56
|
+
if ((0, ___phrasing_content_ts.isPhrasingContent)(node) && node.hasChildNodes()) (0, __unwrap_ts.default)(node);
|
|
57
|
+
else (0, __remove_ts.default)(node);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (node.hasAttributes()) {
|
|
61
|
+
Array.from(node.attributes).forEach(({ name }) => {
|
|
62
|
+
if (name !== "class" && !attributes.includes(name)) node.removeAttribute(name);
|
|
63
|
+
});
|
|
64
|
+
if (node.classList && node.classList.length) {
|
|
65
|
+
const mattchers = classes.map((item) => {
|
|
66
|
+
if (item === "*") return () => true;
|
|
67
|
+
else if (typeof item === "string") return (className) => className === item;
|
|
68
|
+
else if (item instanceof RegExp) return (className) => item.test(className);
|
|
69
|
+
return noop;
|
|
70
|
+
});
|
|
71
|
+
Array.from(node.classList).forEach((name) => {
|
|
72
|
+
if (!mattchers.some((isMatch) => isMatch(name))) node.classList.remove(name);
|
|
73
|
+
});
|
|
74
|
+
if (!node.classList.length) node.removeAttribute("class");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (node.hasChildNodes()) {
|
|
78
|
+
if (children === "*") return;
|
|
79
|
+
if (children) {
|
|
80
|
+
if (require$1.length && !node.querySelector(require$1.join(","))) {
|
|
81
|
+
cleanNodeList(node.childNodes, doc, schema, inline);
|
|
82
|
+
(0, __unwrap_ts.default)(node);
|
|
83
|
+
} else if (node.parentNode && node.parentNode.nodeName === "BODY" && (0, ___phrasing_content_ts.isPhrasingContent)(node)) {
|
|
84
|
+
cleanNodeList(node.childNodes, doc, schema, inline);
|
|
85
|
+
if (Array.from(node.childNodes).some((child) => !(0, ___phrasing_content_ts.isPhrasingContent)(child))) (0, __unwrap_ts.default)(node);
|
|
86
|
+
} else cleanNodeList(node.childNodes, doc, children, inline);
|
|
87
|
+
} else while (node.firstChild) (0, __remove_ts.default)(node.firstChild);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
cleanNodeList(node.childNodes, doc, schema, inline);
|
|
92
|
+
if (inline && !(0, ___phrasing_content_ts.isPhrasingContent)(node) && node.nextElementSibling) (0, __insert_after_ts.default)(doc.createElement("br"), node);
|
|
93
|
+
(0, __unwrap_ts.default)(node);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
143
96
|
}
|
|
144
|
-
|
|
97
|
+
exports.default = cleanNodeList;
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=clean-node-list.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/clean-node-list.ts"],
|
|
4
|
-
"sourcesContent": ["import isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\nimport type { Schema } from './types';\n\nconst noop = () => {};\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param nodeList The nodeList to filter.\n * @param doc The document of the nodeList.\n * @param schema Schema for the HTML.\n * @param inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList(\n\tnodeList: NodeList,\n\tdoc: Document,\n\tschema: Schema,\n\tinline: boolean\n) {\n\tArray.from( nodeList ).forEach(\n\t\t( node: Node & { nextElementSibling?: unknown } ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node. For phrasing content nodes that contain\n\t\t\t\t\t// only whitespace, unwrap instead to preserve the text.\n\t\t\t\t\t// See https://github.com/WordPress/gutenberg/issues/50898\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisPhrasingContent( node ) &&\n\t\t\t\t\t\t\tnode.hasChildNodes()\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( item === '*' ) {\n\t\t\t\t\t\t\t\t\t// Keep all classes.\n\t\t\t\t\t\t\t\t\treturn () => true;\n\t\t\t\t\t\t\t\t} else if ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn ( className: string ) =>\n\t\t\t\t\t\t\t\t\t\tclassName === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn ( className: string ) =>\n\t\t\t\t\t\t\t\t\t\titem.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["isElement", "require", "isEmpty", "unwrap", "remove", "insertAfter"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"clean-node-list.cjs","names":["isElement","isEmpty","isPhrasingContent","require"],"sources":["../../src/dom/clean-node-list.ts"],"sourcesContent":["import isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\nimport type { Schema } from './types';\n\nconst noop = () => {};\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param nodeList The nodeList to filter.\n * @param doc The document of the nodeList.\n * @param schema Schema for the HTML.\n * @param [inline] Whether to clean for inline mode.\n */\nexport default function cleanNodeList(\n\tnodeList: NodeList,\n\tdoc: Document,\n\tschema: Schema,\n\tinline?: boolean\n) {\n\tArray.from( nodeList ).forEach(\n\t\t( node: Node & { nextElementSibling?: unknown } ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node. For phrasing content nodes that contain\n\t\t\t\t\t// only whitespace, unwrap instead to preserve the text.\n\t\t\t\t\t// See https://github.com/WordPress/gutenberg/issues/50898\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisPhrasingContent( node ) &&\n\t\t\t\t\t\t\tnode.hasChildNodes()\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( item === '*' ) {\n\t\t\t\t\t\t\t\t\t// Keep all classes.\n\t\t\t\t\t\t\t\t\treturn () => true;\n\t\t\t\t\t\t\t\t} else if ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn ( className: string ) =>\n\t\t\t\t\t\t\t\t\t\tclassName === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn ( className: string ) =>\n\t\t\t\t\t\t\t\t\t\titem.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,aAAa,CAAC;;;;;;;;;;AAWpB,SAAwB,cACvB,UACA,KACA,QACA,QACC;CACD,MAAM,KAAM,QAAS,CAAC,CAAC,SACpB,SAAmD;EACpD,MAAM,MAAM,KAAK,SAAS,YAAY;EAItC,IACC,OAAO,eAAgB,GAAI,MACzB,CAAE,OAAQ,IAAK,CAAC,WAAW,OAAQ,IAAK,CAAC,UAAW,IAAK,IAEtDA;QAAAA,GAAAA,gBAAAA,QAAAA,CAAW,IAAK,GAAI;IACxB,MAAM,EACL,aAAa,CAAC,GACd,UAAU,CAAC,GACX,UACA,SAAA,YAAU,CAAC,GACX,eACG,OAAQ;IAMZ,IAAK,YAAY,CAAE,eAAA,GAAcC,cAAAA,QAAAA,CAAS,IAAK,GAAI;KAClD,KAAA,GACCC,uBAAAA,kBAAAA,CAAmB,IAAK,KACxB,KAAK,cAAc,GAEnB,CAAA,GAAA,YAAA,QAAA,CAAQ,IAAK;UAEb,CAAA,GAAA,YAAA,QAAA,CAAQ,IAAK;KAEd;IACD;IAEA,IAAK,KAAK,cAAc,GAAI;KAE3B,MAAM,KAAM,KAAK,UAAW,CAAC,CAAC,SAAW,EAAE,WAAY;MACtD,IACC,SAAS,WACT,CAAE,WAAW,SAAU,IAAK,GAE5B,KAAK,gBAAiB,IAAK;KAE7B,CAAE;KAKF,IAAK,KAAK,aAAa,KAAK,UAAU,QAAS;MAC9C,MAAM,YAAY,QAAQ,KAAO,SAAU;OAC1C,IAAK,SAAS,KAEb,aAAa;YACP,IAAK,OAAO,SAAS,UAC3B,QAAS,cACR,cAAc;YACT,IAAK,gBAAgB,QAC3B,QAAS,cACR,KAAK,KAAM,SAAU;OAGvB,OAAO;MACR,CAAE;MAEF,MAAM,KAAM,KAAK,SAAU,CAAC,CAAC,SAAW,SAAU;OACjD,IACC,CAAE,UAAU,MAAQ,YACnB,QAAS,IAAK,CACf,GAEA,KAAK,UAAU,OAAQ,IAAK;MAE9B,CAAE;MAEF,IAAK,CAAE,KAAK,UAAU,QACrB,KAAK,gBAAiB,OAAQ;KAEhC;IACD;IAEA,IAAK,KAAK,cAAc,GAAI;KAE3B,IAAK,aAAa,KACjB;KAID,IAAK,UAAW;MAGf,IACCC,UAAQ,UACR,CAAE,KAAK,cAAeA,UAAQ,KAAM,GAAI,CAAE,GACzC;OACD,cACC,KAAK,YACL,KACA,QACA,MACD;OACA,CAAA,GAAA,YAAA,QAAA,CAAQ,IAAK;MAId,OAAO,IACN,KAAK,cACL,KAAK,WAAW,aAAa,WAAA,GAC7BD,uBAAAA,kBAAAA,CAAmB,IAAK,GACvB;OACD,cACC,KAAK,YACL,KACA,QACA,MACD;OAEA,IACC,MAAM,KAAM,KAAK,UAAW,CAAC,CAAC,MAC3B,UACD,EAAA,GAAEA,uBAAAA,kBAAAA,CAAmB,KAAM,CAC7B,GAEA,CAAA,GAAA,YAAA,QAAA,CAAQ,IAAK;MAEf,OACC,cACC,KAAK,YACL,KACA,UACA,MACD;KAGF,OACC,OAAQ,KAAK,YACZ,CAAA,GAAA,YAAA,QAAA,CAAQ,KAAK,UAAW;IAG3B;GACD;SAEM;GACN,cAAe,KAAK,YAAY,KAAK,QAAQ,MAAO;GAIpD,IACC,UACA,EAAA,GAAEA,uBAAAA,kBAAAA,CAAmB,IAAK,KAC1B,KAAK,oBAEL,CAAA,GAAA,kBAAA,QAAA,CAAa,IAAI,cAAe,IAAK,GAAG,IAAK;GAG9C,CAAA,GAAA,YAAA,QAAA,CAAQ,IAAK;EACd;CACD,CACD;AACD"}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// \0rolldown/runtime.js
|
|
2
7
|
var __create = Object.create;
|
|
3
8
|
var __defProp = Object.defineProperty;
|
|
4
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
13
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
19
22
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
let __get_rectangle_from_range_ts = require("./get-rectangle-from-range.cjs");
|
|
28
|
+
__get_rectangle_from_range_ts = __toESM(__get_rectangle_from_range_ts);
|
|
29
|
+
let ___utils_assert_is_defined_ts = require("../utils/assert-is-defined.cjs");
|
|
30
30
|
// packages/dom/src/dom/compute-caret-rect.ts
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Get the rectangle for the selection in a container.
|
|
33
|
+
*
|
|
34
|
+
* @param win The window of the selection.
|
|
35
|
+
*
|
|
36
|
+
* @return The rectangle.
|
|
37
|
+
*/
|
|
38
38
|
function computeCaretRect(win) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
return (0, import_get_rectangle_from_range.default)(range);
|
|
39
|
+
const selection = win.getSelection();
|
|
40
|
+
(0, ___utils_assert_is_defined_ts.assertIsDefined)(selection, "selection");
|
|
41
|
+
const range = selection.rangeCount ? selection.getRangeAt(0) : null;
|
|
42
|
+
if (!range) return null;
|
|
43
|
+
return (0, __get_rectangle_from_range_ts.default)(range);
|
|
46
44
|
}
|
|
47
|
-
|
|
45
|
+
exports.default = computeCaretRect;
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=compute-caret-rect.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/compute-caret-rect.ts"],
|
|
4
|
-
"sourcesContent": ["import getRectangleFromRange from './get-rectangle-from-range';\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle for the selection in a container.\n *\n * @param win The window of the selection.\n *\n * @return The rectangle.\n */\nexport default function computeCaretRect( win: Window ): DOMRect | null {\n\tconst selection = win.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\n\tif ( ! range ) {\n\t\treturn null;\n\t}\n\n\treturn getRectangleFromRange( range );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAkC;AAClC,+BAAgC;AASjB,SAAR,iBAAmC,KAA8B;AACvE,QAAM,YAAY,IAAI,aAAa;AACnC,gDAAiB,WAAW,WAAY;AACxC,QAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;AAEjE,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,aAAO,gCAAAA,SAAuB,KAAM;AACrC;",
|
|
6
|
-
"names": ["getRectangleFromRange"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"compute-caret-rect.cjs","names":["getRectangleFromRange"],"sources":["../../src/dom/compute-caret-rect.ts"],"sourcesContent":["import getRectangleFromRange from './get-rectangle-from-range';\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle for the selection in a container.\n *\n * @param win The window of the selection.\n *\n * @return The rectangle.\n */\nexport default function computeCaretRect( win: Window ): DOMRect | null {\n\tconst selection = win.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\n\tif ( ! range ) {\n\t\treturn null;\n\t}\n\n\treturn getRectangleFromRange( range );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,SAAwB,iBAAkB,KAA8B;CACvE,MAAM,YAAY,IAAI,aAAa;CACnC,CAAA,GAAA,8BAAA,gBAAA,CAAiB,WAAW,WAAY;CACxC,MAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;CAEjE,IAAK,CAAE,OACN,OAAO;CAGR,QAAA,GAAOA,8BAAAA,QAAAA,CAAuB,KAAM;AACrC"}
|