@wordpress/dom 4.32.0 → 4.32.1-next.47f435fc9.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/build/data-transfer.js +30 -18
- package/build/data-transfer.js.map +7 -1
- package/build/dom/caret-range-from-point.js +22 -25
- package/build/dom/caret-range-from-point.js.map +7 -1
- package/build/dom/clean-node-list.js +122 -129
- package/build/dom/clean-node-list.js.map +7 -1
- package/build/dom/compute-caret-rect.js +36 -21
- package/build/dom/compute-caret-rect.js.map +7 -1
- package/build/dom/document-has-selection.js +36 -22
- package/build/dom/document-has-selection.js.map +7 -1
- package/build/dom/document-has-text-selection.js +25 -23
- package/build/dom/document-has-text-selection.js.map +7 -1
- package/build/dom/document-has-uncollapsed-selection.js +35 -22
- package/build/dom/document-has-uncollapsed-selection.js.map +7 -1
- package/build/dom/get-computed-style.js +27 -17
- package/build/dom/get-computed-style.js.map +7 -1
- package/build/dom/get-offset-parent.js +43 -32
- package/build/dom/get-offset-parent.js.map +7 -1
- package/build/dom/get-range-height.js +24 -18
- package/build/dom/get-range-height.js.map +7 -1
- package/build/dom/get-rectangle-from-range.js +47 -68
- package/build/dom/get-rectangle-from-range.js.map +7 -1
- package/build/dom/get-scroll-container.js +44 -37
- package/build/dom/get-scroll-container.js.map +7 -1
- package/build/dom/hidden-caret-range-from-point.js +39 -33
- package/build/dom/hidden-caret-range-from-point.js.map +7 -1
- package/build/dom/index.js +116 -195
- package/build/dom/index.js.map +7 -1
- package/build/dom/input-field-has-uncollapsed-selection.js +40 -42
- package/build/dom/input-field-has-uncollapsed-selection.js.map +7 -1
- package/build/dom/insert-after.js +24 -19
- package/build/dom/insert-after.js.map +7 -1
- package/build/dom/is-edge.js +57 -67
- package/build/dom/is-edge.js.map +7 -1
- package/build/dom/is-element.js +22 -11
- package/build/dom/is-element.js.map +7 -1
- package/build/dom/is-empty.js +27 -17
- package/build/dom/is-empty.js.map +7 -1
- package/build/dom/is-entirely-selected.js +46 -50
- package/build/dom/is-entirely-selected.js.map +7 -1
- package/build/dom/is-form-element.js +36 -24
- package/build/dom/is-form-element.js.map +7 -1
- package/build/dom/is-horizontal-edge.js +34 -20
- package/build/dom/is-horizontal-edge.js.map +7 -1
- package/build/dom/is-html-input-element.js +23 -12
- package/build/dom/is-html-input-element.js.map +7 -1
- package/build/dom/is-input-or-text-area.js +23 -12
- package/build/dom/is-input-or-text-area.js.map +7 -1
- package/build/dom/is-number-input.js +38 -29
- package/build/dom/is-number-input.js.map +7 -1
- package/build/dom/is-rtl.js +34 -19
- package/build/dom/is-rtl.js.map +7 -1
- package/build/dom/is-selection-forward.js +26 -40
- package/build/dom/is-selection-forward.js.map +7 -1
- package/build/dom/is-text-field.js +49 -24
- package/build/dom/is-text-field.js.map +7 -1
- package/build/dom/is-vertical-edge.js +34 -20
- package/build/dom/is-vertical-edge.js.map +7 -1
- package/build/dom/place-caret-at-edge.js +52 -55
- package/build/dom/place-caret-at-edge.js.map +7 -1
- package/build/dom/place-caret-at-horizontal-edge.js +34 -18
- package/build/dom/place-caret-at-horizontal-edge.js.map +7 -1
- package/build/dom/place-caret-at-vertical-edge.js +34 -19
- package/build/dom/place-caret-at-vertical-edge.js.map +7 -1
- package/build/dom/remove-invalid-html.js +35 -22
- package/build/dom/remove-invalid-html.js.map +7 -1
- package/build/dom/remove.js +24 -17
- package/build/dom/remove.js.map +7 -1
- package/build/dom/replace-tag.js +24 -19
- package/build/dom/replace-tag.js.map +7 -1
- package/build/dom/replace.js +38 -23
- package/build/dom/replace.js.map +7 -1
- package/build/dom/safe-html.js +39 -28
- package/build/dom/safe-html.js.map +7 -1
- package/build/dom/scroll-if-no-range.js +26 -18
- package/build/dom/scroll-if-no-range.js.map +7 -1
- package/build/dom/strip-html.js +36 -23
- package/build/dom/strip-html.js.map +7 -1
- package/build/dom/unwrap.js +24 -18
- package/build/dom/unwrap.js.map +7 -1
- package/build/dom/wrap.js +24 -17
- package/build/dom/wrap.js.map +7 -1
- package/build/focusable.js +52 -85
- package/build/focusable.js.map +7 -1
- package/build/index.js +44 -58
- package/build/index.js.map +7 -1
- package/build/phrasing-content.js +88 -128
- package/build/phrasing-content.js.map +7 -1
- package/build/tabbable.js +52 -137
- package/build/tabbable.js.map +7 -1
- package/build/utils/assert-is-defined.js +30 -7
- package/build/utils/assert-is-defined.js.map +7 -1
- package/build-module/data-transfer.js +9 -15
- package/build-module/data-transfer.js.map +7 -1
- package/build-module/dom/caret-range-from-point.js +5 -22
- package/build-module/dom/caret-range-from-point.js.map +7 -1
- package/build-module/dom/clean-node-list.js +94 -123
- package/build-module/dom/clean-node-list.js.map +7 -1
- package/build-module/dom/compute-caret-rect.js +8 -16
- package/build-module/dom/compute-caret-rect.js.map +7 -1
- package/build-module/dom/document-has-selection.js +8 -17
- package/build-module/dom/document-has-selection.js.map +7 -1
- package/build-module/dom/document-has-text-selection.js +8 -20
- package/build-module/dom/document-has-text-selection.js.map +7 -1
- package/build-module/dom/document-has-uncollapsed-selection.js +7 -17
- package/build-module/dom/document-has-uncollapsed-selection.js.map +7 -1
- package/build-module/dom/get-computed-style.js +10 -14
- package/build-module/dom/get-computed-style.js.map +7 -1
- package/build-module/dom/get-offset-parent.js +16 -28
- package/build-module/dom/get-offset-parent.js.map +7 -1
- package/build-module/dom/get-range-height.js +7 -15
- package/build-module/dom/get-range-height.js.map +7 -1
- package/build-module/dom/get-rectangle-from-range.js +30 -65
- package/build-module/dom/get-rectangle-from-range.js.map +7 -1
- package/build-module/dom/get-scroll-container.js +16 -32
- package/build-module/dom/get-scroll-container.js.map +7 -1
- package/build-module/dom/hidden-caret-range-from-point.js +11 -28
- package/build-module/dom/hidden-caret-range-from-point.js.map +7 -1
- package/build-module/dom/index.js +57 -28
- package/build-module/dom/index.js.map +7 -1
- package/build-module/dom/input-field-has-uncollapsed-selection.js +12 -37
- package/build-module/dom/input-field-has-uncollapsed-selection.js.map +7 -1
- package/build-module/dom/insert-after.js +7 -16
- package/build-module/dom/insert-after.js.map +7 -1
- package/build-module/dom/is-edge.js +24 -57
- package/build-module/dom/is-edge.js.map +7 -1
- package/build-module/dom/is-element.js +5 -8
- package/build-module/dom/is-element.js.map +7 -1
- package/build-module/dom/is-empty.js +10 -14
- package/build-module/dom/is-empty.js.map +7 -1
- package/build-module/dom/is-entirely-selected.js +18 -45
- package/build-module/dom/is-entirely-selected.js.map +7 -1
- package/build-module/dom/is-form-element.js +8 -19
- package/build-module/dom/is-form-element.js.map +7 -1
- package/build-module/dom/is-horizontal-edge.js +6 -15
- package/build-module/dom/is-horizontal-edge.js.map +7 -1
- package/build-module/dom/is-html-input-element.js +6 -9
- package/build-module/dom/is-html-input-element.js.map +7 -1
- package/build-module/dom/is-input-or-text-area.js +6 -9
- package/build-module/dom/is-input-or-text-area.js.map +7 -1
- package/build-module/dom/is-number-input.js +11 -25
- package/build-module/dom/is-number-input.js.map +7 -1
- package/build-module/dom/is-rtl.js +7 -15
- package/build-module/dom/is-rtl.js.map +7 -1
- package/build-module/dom/is-selection-forward.js +9 -37
- package/build-module/dom/is-selection-forward.js.map +7 -1
- package/build-module/dom/is-text-field.js +22 -20
- package/build-module/dom/is-text-field.js.map +7 -1
- package/build-module/dom/is-vertical-edge.js +6 -15
- package/build-module/dom/is-vertical-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-edge.js +22 -48
- package/build-module/dom/place-caret-at-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-horizontal-edge.js +7 -14
- package/build-module/dom/place-caret-at-horizontal-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-vertical-edge.js +6 -14
- package/build-module/dom/place-caret-at-vertical-edge.js.map +7 -1
- package/build-module/dom/remove-invalid-html.js +7 -17
- package/build-module/dom/remove-invalid-html.js.map +7 -1
- package/build-module/dom/remove.js +7 -14
- package/build-module/dom/remove.js.map +7 -1
- package/build-module/dom/replace-tag.js +7 -16
- package/build-module/dom/replace-tag.js.map +7 -1
- package/build-module/dom/replace.js +9 -17
- package/build-module/dom/replace.js.map +7 -1
- package/build-module/dom/safe-html.js +11 -23
- package/build-module/dom/safe-html.js.map +7 -1
- package/build-module/dom/scroll-if-no-range.js +5 -15
- package/build-module/dom/scroll-if-no-range.js.map +7 -1
- package/build-module/dom/strip-html.js +8 -18
- package/build-module/dom/strip-html.js.map +7 -1
- package/build-module/dom/unwrap.js +7 -15
- package/build-module/dom/unwrap.js.map +7 -1
- package/build-module/dom/wrap.js +7 -14
- package/build-module/dom/wrap.js.map +7 -1
- package/build-module/focusable.js +30 -81
- package/build-module/focusable.js.map +7 -1
- package/build-module/index.js +9 -17
- package/build-module/index.js.map +7 -1
- package/build-module/phrasing-content.js +67 -125
- package/build-module/phrasing-content.js.map +7 -1
- package/build-module/tabbable.js +30 -133
- package/build-module/tabbable.js.map +7 -1
- package/build-module/utils/assert-is-defined.js +9 -4
- package/build-module/utils/assert-is-defined.js.map +7 -1
- package/package.json +11 -4
package/build/focusable.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/focusable.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * References:\n *\n * Focusable:\n * - https://www.w3.org/TR/html5/editing.html#focus-management\n *\n * Sequential focus navigation:\n * - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute\n *\n * Disabled elements:\n * - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements\n *\n * getClientRects algorithm (requiring layout box):\n * - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface\n *\n * AREA elements associated with an IMG:\n * - https://w3c.github.io/html/editing.html#data-model\n */\n\n/**\n * Returns a CSS selector used to query for focusable elements.\n *\n * @param {boolean} sequential If set, only query elements that are sequentially\n * focusable. Non-interactive elements with a\n * negative `tabindex` are focusable but not\n * sequentially focusable.\n * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute\n *\n * @return {string} CSS selector.\n */\nfunction buildSelector( sequential ) {\n\treturn [\n\t\tsequential ? '[tabindex]:not([tabindex^=\"-\"])' : '[tabindex]',\n\t\t'a[href]',\n\t\t'button:not([disabled])',\n\t\t'input:not([type=\"hidden\"]):not([disabled])',\n\t\t'select:not([disabled])',\n\t\t'textarea:not([disabled])',\n\t\t'iframe:not([tabindex^=\"-\"])',\n\t\t'object',\n\t\t'embed',\n\t\t'summary',\n\t\t'area[href]',\n\t\t'[contenteditable]:not([contenteditable=false])',\n\t].join( ',' );\n}\n\n/**\n * Returns true if the specified element is visible (i.e. neither display: none\n * nor visibility: hidden).\n *\n * @param {HTMLElement} element DOM element to test.\n *\n * @return {boolean} Whether element is visible.\n */\nfunction isVisible( element ) {\n\treturn (\n\t\telement.offsetWidth > 0 ||\n\t\telement.offsetHeight > 0 ||\n\t\telement.getClientRects().length > 0\n\t);\n}\n\n/**\n * Returns true if the specified area element is a valid focusable element, or\n * false otherwise. Area is only focusable if within a map where a named map\n * referenced by an image somewhere in the document.\n *\n * @param {HTMLAreaElement} element DOM area element to test.\n *\n * @return {boolean} Whether area element is valid for focus.\n */\nfunction isValidFocusableArea( element ) {\n\t/** @type {HTMLMapElement | null} */\n\tconst map = element.closest( 'map[name]' );\n\tif ( ! map ) {\n\t\treturn false;\n\t}\n\n\t/** @type {HTMLImageElement | null} */\n\tconst img = element.ownerDocument.querySelector(\n\t\t'img[usemap=\"#' + map.name + '\"]'\n\t);\n\treturn !! img && isVisible( img );\n}\n\n/**\n * Returns all focusable elements within a given context.\n *\n * @param {Element} context Element in which to search.\n * @param {Object} options\n * @param {boolean} [options.sequential] If set, only return elements that are\n * sequentially focusable.\n * Non-interactive elements with a\n * negative `tabindex` are focusable but\n * not sequentially focusable.\n * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute\n *\n * @return {HTMLElement[]} Focusable elements.\n */\nexport function find( context, { sequential = false } = {} ) {\n\t/** @type {NodeListOf<HTMLElement>} */\n\tconst elements = context.querySelectorAll( buildSelector( sequential ) );\n\n\treturn Array.from( elements ).filter( ( element ) => {\n\t\tif ( ! isVisible( element ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst { nodeName } = element;\n\t\tif ( 'AREA' === nodeName ) {\n\t\t\treturn isValidFocusableArea(\n\t\t\t\t/** @type {HTMLAreaElement} */ ( element )\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BA,SAAS,cAAe,YAAa;AACpC,SAAO;AAAA,IACN,aAAa,oCAAoC;AAAA,IACjD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,EAAE,KAAM,GAAI;AACb;AAUA,SAAS,UAAW,SAAU;AAC7B,SACC,QAAQ,cAAc,KACtB,QAAQ,eAAe,KACvB,QAAQ,eAAe,EAAE,SAAS;AAEpC;AAWA,SAAS,qBAAsB,SAAU;AAExC,QAAM,MAAM,QAAQ,QAAS,WAAY;AACzC,MAAK,CAAE,KAAM;AACZ,WAAO;AAAA,EACR;AAGA,QAAM,MAAM,QAAQ,cAAc;AAAA,IACjC,kBAAkB,IAAI,OAAO;AAAA,EAC9B;AACA,SAAO,CAAC,CAAE,OAAO,UAAW,GAAI;AACjC;AAgBO,SAAS,KAAM,SAAS,EAAE,aAAa,MAAM,IAAI,CAAC,GAAI;AAE5D,QAAM,WAAW,QAAQ,iBAAkB,cAAe,UAAW,CAAE;AAEvE,SAAO,MAAM,KAAM,QAAS,EAAE,OAAQ,CAAE,YAAa;AACpD,QAAK,CAAE,UAAW,OAAQ,GAAI;AAC7B,aAAO;AAAA,IACR;AAEA,UAAM,EAAE,SAAS,IAAI;AACrB,QAAK,WAAW,UAAW;AAC1B,aAAO;AAAA;AAAA,QAC2B;AAAA,MAClC;AAAA,IACD;AAEA,WAAO;AAAA,EACR,CAAE;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/index.js
CHANGED
|
@@ -1,62 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
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 });
|
|
8
11
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () {
|
|
32
|
-
return _phrasingContent[key];
|
|
33
|
-
}
|
|
34
|
-
});
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
focus: () => focus
|
|
35
33
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
module.exports = __toCommonJS(index_exports);
|
|
35
|
+
var focusable = __toESM(require("./focusable"));
|
|
36
|
+
var tabbable = __toESM(require("./tabbable"));
|
|
37
|
+
__reExport(index_exports, require("./dom"), module.exports);
|
|
38
|
+
__reExport(index_exports, require("./phrasing-content"), module.exports);
|
|
39
|
+
__reExport(index_exports, require("./data-transfer"), module.exports);
|
|
40
|
+
const focus = { focusable, tabbable };
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
focus,
|
|
44
|
+
...require("./dom"),
|
|
45
|
+
...require("./phrasing-content"),
|
|
46
|
+
...require("./data-transfer")
|
|
47
47
|
});
|
|
48
|
-
|
|
49
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
50
|
-
/**
|
|
51
|
-
* Internal dependencies
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Object grouping `focusable` and `tabbable` utils
|
|
56
|
-
* under the keys with the same name.
|
|
57
|
-
*/
|
|
58
|
-
const focus = exports.focus = {
|
|
59
|
-
focusable,
|
|
60
|
-
tabbable
|
|
61
|
-
};
|
|
62
|
-
//# sourceMappingURL=index.js.map
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport * as focusable from './focusable';\nimport * as tabbable from './tabbable';\n\n/**\n * Object grouping `focusable` and `tabbable` utils\n * under the keys with the same name.\n */\nexport const focus = { focusable, tabbable };\n\nexport * from './dom';\nexport * from './phrasing-content';\nexport * from './data-transfer';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gBAA2B;AAC3B,eAA0B;AAQ1B,0BAAc,kBAZd;AAaA,0BAAc,+BAbd;AAcA,0BAAc,4BAdd;AAUO,MAAM,QAAQ,EAAE,WAAW,SAAS;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,65 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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
|
+
var phrasing_content_exports = {};
|
|
20
|
+
__export(phrasing_content_exports, {
|
|
21
|
+
getPhrasingContentSchema: () => getPhrasingContentSchema,
|
|
22
|
+
isPhrasingContent: () => isPhrasingContent,
|
|
23
|
+
isTextContent: () => isTextContent
|
|
5
24
|
});
|
|
6
|
-
exports
|
|
7
|
-
exports.isPhrasingContent = isPhrasingContent;
|
|
8
|
-
exports.isTextContent = isTextContent;
|
|
9
|
-
/**
|
|
10
|
-
* All phrasing content elements.
|
|
11
|
-
*
|
|
12
|
-
* @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @typedef {Record<string,SemanticElementDefinition>} ContentSchema
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @typedef SemanticElementDefinition
|
|
21
|
-
* @property {string[]} [attributes] Content attributes
|
|
22
|
-
* @property {ContentSchema} [children] Content attributes
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* All text-level semantic elements.
|
|
27
|
-
*
|
|
28
|
-
* @see https://html.spec.whatwg.org/multipage/text-level-semantics.html
|
|
29
|
-
*
|
|
30
|
-
* @type {ContentSchema}
|
|
31
|
-
*/
|
|
25
|
+
module.exports = __toCommonJS(phrasing_content_exports);
|
|
32
26
|
const textContentSchema = {
|
|
33
27
|
strong: {},
|
|
34
28
|
em: {},
|
|
35
29
|
s: {},
|
|
36
30
|
del: {},
|
|
37
31
|
ins: {},
|
|
38
|
-
a: {
|
|
39
|
-
attributes: ['href', 'target', 'rel', 'id']
|
|
40
|
-
},
|
|
32
|
+
a: { attributes: ["href", "target", "rel", "id"] },
|
|
41
33
|
code: {},
|
|
42
|
-
abbr: {
|
|
43
|
-
attributes: ['title']
|
|
44
|
-
},
|
|
34
|
+
abbr: { attributes: ["title"] },
|
|
45
35
|
sub: {},
|
|
46
36
|
sup: {},
|
|
47
37
|
br: {},
|
|
48
38
|
small: {},
|
|
49
39
|
// To do: fix blockquote.
|
|
50
40
|
// cite: {},
|
|
51
|
-
q: {
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
attributes: ['title']
|
|
56
|
-
},
|
|
57
|
-
data: {
|
|
58
|
-
attributes: ['value']
|
|
59
|
-
},
|
|
60
|
-
time: {
|
|
61
|
-
attributes: ['datetime']
|
|
62
|
-
},
|
|
41
|
+
q: { attributes: ["cite"] },
|
|
42
|
+
dfn: { attributes: ["title"] },
|
|
43
|
+
data: { attributes: ["value"] },
|
|
44
|
+
time: { attributes: ["datetime"] },
|
|
63
45
|
var: {},
|
|
64
46
|
samp: {},
|
|
65
47
|
kbd: {},
|
|
@@ -70,84 +52,75 @@ const textContentSchema = {
|
|
|
70
52
|
ruby: {},
|
|
71
53
|
rt: {},
|
|
72
54
|
rp: {},
|
|
73
|
-
bdi: {
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
bdo: {
|
|
77
|
-
attributes: ['dir']
|
|
78
|
-
},
|
|
55
|
+
bdi: { attributes: ["dir"] },
|
|
56
|
+
bdo: { attributes: ["dir"] },
|
|
79
57
|
wbr: {},
|
|
80
|
-
|
|
58
|
+
"#text": {}
|
|
81
59
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// Impossible: strong > strong.
|
|
86
|
-
const excludedElements = ['#text', 'br'];
|
|
87
|
-
Object.keys(textContentSchema).filter(element => !excludedElements.includes(element)).forEach(tag => {
|
|
88
|
-
const {
|
|
89
|
-
[tag]: removedTag,
|
|
90
|
-
...restSchema
|
|
91
|
-
} = textContentSchema;
|
|
60
|
+
const excludedElements = ["#text", "br"];
|
|
61
|
+
Object.keys(textContentSchema).filter((element) => !excludedElements.includes(element)).forEach((tag) => {
|
|
62
|
+
const { [tag]: removedTag, ...restSchema } = textContentSchema;
|
|
92
63
|
textContentSchema[tag].children = restSchema;
|
|
93
64
|
});
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Embedded content elements.
|
|
97
|
-
*
|
|
98
|
-
* @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0
|
|
99
|
-
*
|
|
100
|
-
* @type {ContentSchema}
|
|
101
|
-
*/
|
|
102
65
|
const embeddedContentSchema = {
|
|
103
66
|
audio: {
|
|
104
|
-
attributes: [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
67
|
+
attributes: [
|
|
68
|
+
"src",
|
|
69
|
+
"preload",
|
|
70
|
+
"autoplay",
|
|
71
|
+
"mediagroup",
|
|
72
|
+
"loop",
|
|
73
|
+
"muted"
|
|
74
|
+
]
|
|
111
75
|
},
|
|
76
|
+
canvas: { attributes: ["width", "height"] },
|
|
77
|
+
embed: { attributes: ["src", "type", "width", "height"] },
|
|
112
78
|
img: {
|
|
113
|
-
attributes: [
|
|
79
|
+
attributes: [
|
|
80
|
+
"alt",
|
|
81
|
+
"src",
|
|
82
|
+
"srcset",
|
|
83
|
+
"usemap",
|
|
84
|
+
"ismap",
|
|
85
|
+
"width",
|
|
86
|
+
"height"
|
|
87
|
+
]
|
|
114
88
|
},
|
|
115
89
|
object: {
|
|
116
|
-
attributes: [
|
|
90
|
+
attributes: [
|
|
91
|
+
"data",
|
|
92
|
+
"type",
|
|
93
|
+
"name",
|
|
94
|
+
"usemap",
|
|
95
|
+
"form",
|
|
96
|
+
"width",
|
|
97
|
+
"height"
|
|
98
|
+
]
|
|
117
99
|
},
|
|
118
100
|
video: {
|
|
119
|
-
attributes: [
|
|
101
|
+
attributes: [
|
|
102
|
+
"src",
|
|
103
|
+
"poster",
|
|
104
|
+
"preload",
|
|
105
|
+
"playsinline",
|
|
106
|
+
"autoplay",
|
|
107
|
+
"mediagroup",
|
|
108
|
+
"loop",
|
|
109
|
+
"muted",
|
|
110
|
+
"controls",
|
|
111
|
+
"width",
|
|
112
|
+
"height"
|
|
113
|
+
]
|
|
120
114
|
}
|
|
121
115
|
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Phrasing content elements.
|
|
125
|
-
*
|
|
126
|
-
* @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
|
|
127
|
-
*/
|
|
128
116
|
const phrasingContentSchema = {
|
|
129
117
|
...textContentSchema,
|
|
130
118
|
...embeddedContentSchema
|
|
131
119
|
};
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Get schema of possible paths for phrasing content.
|
|
135
|
-
*
|
|
136
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
|
|
137
|
-
*
|
|
138
|
-
* @param {string} [context] Set to "paste" to exclude invisible elements and
|
|
139
|
-
* sensitive data.
|
|
140
|
-
*
|
|
141
|
-
* @return {Partial<ContentSchema>} Schema.
|
|
142
|
-
*/
|
|
143
120
|
function getPhrasingContentSchema(context) {
|
|
144
|
-
if (context !==
|
|
121
|
+
if (context !== "paste") {
|
|
145
122
|
return phrasingContentSchema;
|
|
146
123
|
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @type {Partial<ContentSchema>}
|
|
150
|
-
*/
|
|
151
124
|
const {
|
|
152
125
|
u,
|
|
153
126
|
// Used to mark misspelling. Shouldn't be pasted.
|
|
@@ -168,36 +141,23 @@ function getPhrasingContentSchema(context) {
|
|
|
168
141
|
...phrasingContentSchema,
|
|
169
142
|
// We shouldn't paste potentially sensitive information which is not
|
|
170
143
|
// visible to the user when pasted, so strip the attributes.
|
|
171
|
-
ins: {
|
|
172
|
-
|
|
173
|
-
},
|
|
174
|
-
del: {
|
|
175
|
-
children: phrasingContentSchema.del.children
|
|
176
|
-
}
|
|
144
|
+
ins: { children: phrasingContentSchema.ins.children },
|
|
145
|
+
del: { children: phrasingContentSchema.del.children }
|
|
177
146
|
};
|
|
178
147
|
return remainingContentSchema;
|
|
179
148
|
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Find out whether or not the given node is phrasing content.
|
|
183
|
-
*
|
|
184
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
|
|
185
|
-
*
|
|
186
|
-
* @param {Node} node The node to test.
|
|
187
|
-
*
|
|
188
|
-
* @return {boolean} True if phrasing content, false if not.
|
|
189
|
-
*/
|
|
190
149
|
function isPhrasingContent(node) {
|
|
191
150
|
const tag = node.nodeName.toLowerCase();
|
|
192
|
-
return getPhrasingContentSchema().hasOwnProperty(tag) || tag ===
|
|
151
|
+
return getPhrasingContentSchema().hasOwnProperty(tag) || tag === "span";
|
|
193
152
|
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* @param {Node} node
|
|
197
|
-
* @return {boolean} Node is text content
|
|
198
|
-
*/
|
|
199
153
|
function isTextContent(node) {
|
|
200
154
|
const tag = node.nodeName.toLowerCase();
|
|
201
|
-
return textContentSchema.hasOwnProperty(tag) || tag ===
|
|
155
|
+
return textContentSchema.hasOwnProperty(tag) || tag === "span";
|
|
202
156
|
}
|
|
203
|
-
|
|
157
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
158
|
+
0 && (module.exports = {
|
|
159
|
+
getPhrasingContentSchema,
|
|
160
|
+
isPhrasingContent,
|
|
161
|
+
isTextContent
|
|
162
|
+
});
|
|
163
|
+
//# sourceMappingURL=phrasing-content.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/phrasing-content.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * All phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\n\n/**\n * @typedef {Record<string,SemanticElementDefinition>} ContentSchema\n */\n\n/**\n * @typedef SemanticElementDefinition\n * @property {string[]} [attributes] Content attributes\n * @property {ContentSchema} [children] Content attributes\n */\n\n/**\n * All text-level semantic elements.\n *\n * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html\n *\n * @type {ContentSchema}\n */\nconst textContentSchema = {\n\tstrong: {},\n\tem: {},\n\ts: {},\n\tdel: {},\n\tins: {},\n\ta: { attributes: [ 'href', 'target', 'rel', 'id' ] },\n\tcode: {},\n\tabbr: { attributes: [ 'title' ] },\n\tsub: {},\n\tsup: {},\n\tbr: {},\n\tsmall: {},\n\t// To do: fix blockquote.\n\t// cite: {},\n\tq: { attributes: [ 'cite' ] },\n\tdfn: { attributes: [ 'title' ] },\n\tdata: { attributes: [ 'value' ] },\n\ttime: { attributes: [ 'datetime' ] },\n\tvar: {},\n\tsamp: {},\n\tkbd: {},\n\ti: {},\n\tb: {},\n\tu: {},\n\tmark: {},\n\truby: {},\n\trt: {},\n\trp: {},\n\tbdi: { attributes: [ 'dir' ] },\n\tbdo: { attributes: [ 'dir' ] },\n\twbr: {},\n\t'#text': {},\n};\n\n// Recursion is needed.\n// Possible: strong > em > strong.\n// Impossible: strong > strong.\nconst excludedElements = [ '#text', 'br' ];\nObject.keys( textContentSchema )\n\t.filter( ( element ) => ! excludedElements.includes( element ) )\n\t.forEach( ( tag ) => {\n\t\tconst { [ tag ]: removedTag, ...restSchema } = textContentSchema;\n\t\ttextContentSchema[ tag ].children = restSchema;\n\t} );\n\n/**\n * Embedded content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0\n *\n * @type {ContentSchema}\n */\nconst embeddedContentSchema = {\n\taudio: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'preload',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t],\n\t},\n\tcanvas: { attributes: [ 'width', 'height' ] },\n\tembed: { attributes: [ 'src', 'type', 'width', 'height' ] },\n\timg: {\n\t\tattributes: [\n\t\t\t'alt',\n\t\t\t'src',\n\t\t\t'srcset',\n\t\t\t'usemap',\n\t\t\t'ismap',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tobject: {\n\t\tattributes: [\n\t\t\t'data',\n\t\t\t'type',\n\t\t\t'name',\n\t\t\t'usemap',\n\t\t\t'form',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n\tvideo: {\n\t\tattributes: [\n\t\t\t'src',\n\t\t\t'poster',\n\t\t\t'preload',\n\t\t\t'playsinline',\n\t\t\t'autoplay',\n\t\t\t'mediagroup',\n\t\t\t'loop',\n\t\t\t'muted',\n\t\t\t'controls',\n\t\t\t'width',\n\t\t\t'height',\n\t\t],\n\t},\n};\n\n/**\n * Phrasing content elements.\n *\n * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0\n */\nconst phrasingContentSchema = {\n\t...textContentSchema,\n\t...embeddedContentSchema,\n};\n\n/**\n * Get schema of possible paths for phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param {string} [context] Set to \"paste\" to exclude invisible elements and\n * sensitive data.\n *\n * @return {Partial<ContentSchema>} Schema.\n */\nexport function getPhrasingContentSchema( context ) {\n\tif ( context !== 'paste' ) {\n\t\treturn phrasingContentSchema;\n\t}\n\n\t/**\n\t * @type {Partial<ContentSchema>}\n\t */\n\tconst {\n\t\tu, // Used to mark misspelling. Shouldn't be pasted.\n\t\tabbr, // Invisible.\n\t\tdata, // Invisible.\n\t\ttime, // Invisible.\n\t\twbr, // Invisible.\n\t\tbdi, // Invisible.\n\t\tbdo, // Invisible.\n\t\t...remainingContentSchema\n\t} = {\n\t\t...phrasingContentSchema,\n\t\t// We shouldn't paste potentially sensitive information which is not\n\t\t// visible to the user when pasted, so strip the attributes.\n\t\tins: { children: phrasingContentSchema.ins.children },\n\t\tdel: { children: phrasingContentSchema.del.children },\n\t};\n\n\treturn remainingContentSchema;\n}\n\n/**\n * Find out whether or not the given node is phrasing content.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content\n *\n * @param {Node} node The node to test.\n *\n * @return {boolean} True if phrasing content, false if not.\n */\nexport function isPhrasingContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn getPhrasingContentSchema().hasOwnProperty( tag ) || tag === 'span';\n}\n\n/**\n * @param {Node} node\n * @return {boolean} Node is text content\n */\nexport function isTextContent( node ) {\n\tconst tag = node.nodeName.toLowerCase();\n\treturn textContentSchema.hasOwnProperty( tag ) || tag === 'span';\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|