@wordpress/dom 3.2.5 → 3.3.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/CHANGELOG.md +2 -0
- package/LICENSE.md +1 -1
- package/README.md +3 -3
- package/build/data-transfer.js +8 -5
- package/build/data-transfer.js.map +1 -1
- package/build/dom/clean-node-list.js +11 -11
- package/build/dom/clean-node-list.js.map +1 -1
- package/build/dom/document-has-text-selection.js +1 -1
- package/build/dom/document-has-text-selection.js.map +1 -1
- package/build/dom/document-has-uncollapsed-selection.js +2 -2
- package/build/dom/document-has-uncollapsed-selection.js.map +1 -1
- package/build/dom/get-range-height.js +12 -6
- package/build/dom/get-range-height.js.map +1 -1
- package/build/dom/get-rectangle-from-range.js +6 -3
- package/build/dom/get-rectangle-from-range.js.map +1 -1
- package/build/dom/index.js +38 -38
- package/build/dom/is-edge.js +3 -1
- package/build/dom/is-edge.js.map +1 -1
- package/build/dom/strip-html.js +14 -2
- package/build/dom/strip-html.js.map +1 -1
- package/build/focusable.js +5 -3
- package/build/focusable.js.map +1 -1
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/tabbable.js +2 -2
- package/build-module/data-transfer.js +8 -5
- package/build-module/data-transfer.js.map +1 -1
- package/build-module/dom/clean-node-list.js +11 -11
- package/build-module/dom/clean-node-list.js.map +1 -1
- package/build-module/dom/document-has-text-selection.js +1 -1
- package/build-module/dom/document-has-text-selection.js.map +1 -1
- package/build-module/dom/document-has-uncollapsed-selection.js +2 -2
- package/build-module/dom/document-has-uncollapsed-selection.js.map +1 -1
- package/build-module/dom/get-range-height.js +12 -6
- package/build-module/dom/get-range-height.js.map +1 -1
- package/build-module/dom/get-rectangle-from-range.js +6 -3
- package/build-module/dom/get-rectangle-from-range.js.map +1 -1
- package/build-module/dom/is-edge.js +3 -1
- package/build-module/dom/is-edge.js.map +1 -1
- package/build-module/dom/strip-html.js +11 -2
- package/build-module/dom/strip-html.js.map +1 -1
- package/build-module/focusable.js +5 -3
- package/build-module/focusable.js.map +1 -1
- package/build-types/dom/clean-node-list.d.ts +2 -2
- package/build-types/dom/document-has-text-selection.d.ts +1 -1
- package/build-types/dom/document-has-uncollapsed-selection.d.ts +2 -2
- package/build-types/dom/strip-html.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/dom/document-has-text-selection.js +1 -1
- package/src/dom/document-has-uncollapsed-selection.js +2 -2
- package/src/dom/strip-html.js +12 -5
- package/src/dom/test/strip-html.js +64 -0
- package/src/test/dom.js +0 -15
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/LICENSE.md
CHANGED
package/README.md
CHANGED
@@ -42,7 +42,7 @@ _Returns_
|
|
42
42
|
### documentHasTextSelection
|
43
43
|
|
44
44
|
Check whether the current document has selected text. This applies to ranges
|
45
|
-
of text in the document, and not selection inside
|
45
|
+
of text in the document, and not selection inside `<input>` and `<textarea>`
|
46
46
|
elements.
|
47
47
|
|
48
48
|
See: <https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects>.
|
@@ -58,8 +58,8 @@ _Returns_
|
|
58
58
|
### documentHasUncollapsedSelection
|
59
59
|
|
60
60
|
Check whether the current document has any sort of selection. This includes
|
61
|
-
ranges of text across elements and any selection inside
|
62
|
-
|
61
|
+
ranges of text across elements and any selection inside `<input>` and
|
62
|
+
`<textarea>` elements.
|
63
63
|
|
64
64
|
_Parameters_
|
65
65
|
|
package/build/data-transfer.js
CHANGED
@@ -17,11 +17,14 @@ function getFilesFromDataTransfer(dataTransfer) {
|
|
17
17
|
Array.from(dataTransfer.items).forEach(item => {
|
18
18
|
const file = item.getAsFile();
|
19
19
|
|
20
|
-
if (file && !files.find(
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
if (file && !files.find(_ref => {
|
21
|
+
let {
|
22
|
+
name,
|
23
|
+
type,
|
24
|
+
size
|
25
|
+
} = _ref;
|
26
|
+
return name === file.name && type === file.type && size === file.size;
|
27
|
+
})) {
|
25
28
|
files.push(file);
|
26
29
|
}
|
27
30
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/data-transfer.js"],"names":["getFilesFromDataTransfer","dataTransfer","files","Array","from","items","forEach","item","file","getAsFile","find","name","type","size","push"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAT,CAAmCC,YAAnC,EAAkD;AACxD,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACC,KAAzB,CAAd;AAEAC,EAAAA,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACI,KAAzB,EAAiCC,OAAjC,CAA4CC,IAAF,IAAY;AACrD,UAAMC,IAAI,GAAGD,IAAI,CAACE,SAAL,EAAb;;AAEA,QACCD,IAAI,IACJ,CAAEN,KAAK,CAACQ,IAAN,CACD,
|
1
|
+
{"version":3,"sources":["@wordpress/dom/src/data-transfer.js"],"names":["getFilesFromDataTransfer","dataTransfer","files","Array","from","items","forEach","item","file","getAsFile","find","name","type","size","push"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAT,CAAmCC,YAAnC,EAAkD;AACxD,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACC,KAAzB,CAAd;AAEAC,EAAAA,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACI,KAAzB,EAAiCC,OAAjC,CAA4CC,IAAF,IAAY;AACrD,UAAMC,IAAI,GAAGD,IAAI,CAACE,SAAL,EAAb;;AAEA,QACCD,IAAI,IACJ,CAAEN,KAAK,CAACQ,IAAN,CACD;AAAA,UAAE;AAAEC,QAAAA,IAAF;AAAQC,QAAAA,IAAR;AAAcC,QAAAA;AAAd,OAAF;AAAA,aACCF,IAAI,KAAKH,IAAI,CAACG,IAAd,IACAC,IAAI,KAAKJ,IAAI,CAACI,IADd,IAEAC,IAAI,KAAKL,IAAI,CAACK,IAHf;AAAA,KADC,CAFH,EAQE;AACDX,MAAAA,KAAK,CAACY,IAAN,CAAYN,IAAZ;AACA;AACD,GAdD;AAgBA,SAAON,KAAP;AACA","sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\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"]}
|
@@ -55,9 +55,9 @@ var _isElement = _interopRequireDefault(require("./is-element"));
|
|
55
55
|
* @param {boolean} inline Whether to clean for inline mode.
|
56
56
|
*/
|
57
57
|
function cleanNodeList(nodeList, doc, schema, inline) {
|
58
|
-
Array.from(nodeList).forEach(
|
58
|
+
Array.from(nodeList).forEach((
|
59
59
|
/** @type {Node & { nextElementSibling?: unknown }} */
|
60
|
-
node => {
|
60
|
+
node) => {
|
61
61
|
var _schema$tag$isMatch, _schema$tag;
|
62
62
|
|
63
63
|
const tag = node.nodeName.toLowerCase(); // It's a valid child, if the tag exists in the schema without an isMatch
|
@@ -81,9 +81,11 @@ function cleanNodeList(nodeList, doc, schema, inline) {
|
|
81
81
|
|
82
82
|
if (node.hasAttributes()) {
|
83
83
|
// Strip invalid attributes.
|
84
|
-
Array.from(node.attributes).forEach(
|
85
|
-
|
86
|
-
|
84
|
+
Array.from(node.attributes).forEach(_ref => {
|
85
|
+
let {
|
86
|
+
name
|
87
|
+
} = _ref;
|
88
|
+
|
87
89
|
if (name !== 'class' && !(0, _lodash.includes)(attributes, name)) {
|
88
90
|
node.removeAttribute(name);
|
89
91
|
}
|
@@ -95,14 +97,12 @@ function cleanNodeList(nodeList, doc, schema, inline) {
|
|
95
97
|
const mattchers = classes.map(item => {
|
96
98
|
if (typeof item === 'string') {
|
97
99
|
return (
|
98
|
-
|
99
|
-
|
100
|
-
);
|
100
|
+
/** @type {string} */
|
101
|
+
className) => className === item;
|
101
102
|
} else if (item instanceof RegExp) {
|
102
103
|
return (
|
103
|
-
|
104
|
-
|
105
|
-
);
|
104
|
+
/** @type {string} */
|
105
|
+
className) => item.test(className);
|
106
106
|
}
|
107
107
|
|
108
108
|
return _lodash.noop;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/clean-node-list.js"],"names":["cleanNodeList","nodeList","doc","schema","inline","Array","from","forEach","node","tag","nodeName","toLowerCase","hasOwnProperty","isMatch","attributes","classes","children","require","allowEmpty","hasAttributes","name","removeAttribute","classList","length","mattchers","map","item","className","RegExp","test","noop","some","remove","hasChildNodes","querySelector","join","childNodes","parentNode","child","firstChild","nextElementSibling","createElement"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAT,CAAwBC,QAAxB,EAAkCC,GAAlC,EAAuCC,MAAvC,EAA+CC,MAA/C,EAAwD;AACtEC,EAAAA,KAAK,CAACC,IAAN,CAAYL,QAAZ,EAAuBM,OAAvB;AACC;AAAuDC,EAAAA,IADxB,IAE3B;AAAA;;AACJ,UAAMC,GAAG,GAAGD,IAAI,CAACE,QAAL,CAAcC,WAAd,EAAZ,CADI,CAGJ;AACA;;AACA,QACCR,MAAM,CAACS,cAAP,CAAuBH,GAAvB,MACE,CAAEN,MAAM,CAAEM,GAAF,CAAN,CAA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AAA,aAAa,CACZQ,IAAI,CAAC4B,UADO,EAEZlC,GAFY,EAGZc,QAHY,EAIZZ,MAJY,CAAb;AAMA,aA3Cc,CA4Cf;;AACA,WA7CD,MA6CO;AACN,mBAAQI,IAAI,CAAC+B,UAAb,EAA0B;AACzB,mCAAQ/B,IAAI,CAAC+B,UAAb;AACA;AACD;AACD;AACD,OAtHA,CAuHD;;AACA,KA3HD,MA2HO;AACNvC,MAAAA,aAAa,CAAEQ,IAAI,CAAC4B,UAAP,EAAmBlC,GAAnB,EAAwBC,MAAxB,EAAgCC,MAAhC,CAAb,CADM,CAGN;AACA;;AACA,UACCA,MAAM,IACN,CAAE,wCAAmBI,IAAnB,CADF,IAEAA,IAAI,CAACgC,kBAHN,EAIE;AACD,kCAAatC,GAAG,CAACuC,aAAJ,CAAmB,IAAnB,CAAb,EAAwCjC,IAAxC;AACA;;AAED,2BAAQA,IAAR;AACA;AACD,GAjJD;AAkJA","sourcesContent":["/**\n * External dependencies\n */\nimport { includes, noop } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport 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';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach( (\n\t\t/** @type {Node & { nextElementSibling?: unknown }} */ node\n\t) => {\n\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t// function, or with an isMatch function that matches the node.\n\t\tif (\n\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t) {\n\t\t\tif ( isElement( node ) ) {\n\t\t\t\tconst {\n\t\t\t\t\tattributes = [],\n\t\t\t\t\tclasses = [],\n\t\t\t\t\tchildren,\n\t\t\t\t\trequire = [],\n\t\t\t\t\tallowEmpty,\n\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t// remove the node.\n\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\tremove( node );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t! includes( attributes, name )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\tif ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\treturn ( /** @type {string} */ className ) =>\n\t\t\t\t\t\t\t\t\tclassName === item;\n\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\treturn ( /** @type {string} */ className ) =>\n\t\t\t\t\t\t\t\t\titem.test( className );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\tisMatch( name )\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\tnode.classList.remove( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tunwrap( node );\n\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// contains children that are block content, unwrap\n\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t( child ) => ! isPhrasingContent( child )\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\tunwrap( node );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t} else {\n\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t} else {\n\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t// are not phrasing content.\n\t\t\tif (\n\t\t\t\tinline &&\n\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\tnode.nextElementSibling\n\t\t\t) {\n\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t}\n\n\t\t\tunwrap( node );\n\t\t}\n\t} );\n}\n"]}
|
1
|
+
{"version":3,"sources":["@wordpress/dom/src/dom/clean-node-list.js"],"names":["cleanNodeList","nodeList","doc","schema","inline","Array","from","forEach","node","tag","nodeName","toLowerCase","hasOwnProperty","isMatch","attributes","classes","children","require","allowEmpty","hasAttributes","name","removeAttribute","classList","length","mattchers","map","item","className","RegExp","test","noop","some","remove","hasChildNodes","querySelector","join","childNodes","parentNode","child","firstChild","nextElementSibling","createElement"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,aAAT,CAAwBC,QAAxB,EAAkCC,GAAlC,EAAuCC,MAAvC,EAA+CC,MAA/C,EAAwD;AACtEC,EAAAA,KAAK,CAACC,IAAN,CAAYL,QAAZ,EAAuBM,OAAvB,CAAgC;AAC/B;AAAuDC,EAAAA,IADxB,KAE3B;AAAA;;AACJ,UAAMC,GAAG,GAAGD,IAAI,CAACE,QAAL,CAAcC,WAAd,EAAZ,CADI,CAGJ;AACA;;AACA,QACCR,MAAM,CAACS,cAAP,CAAuBH,GAAvB,MACE,CAAEN,MAAM,CAAEM,GAAF,CAAN,CAAcI,OAAhB,2BAA2B,eAAAV,MAAM,CAAEM,GAAF,CAAN,EAAcI,OAAzC,gDAA2B,sCAAyBL,IAAzB,CAD7B,CADD,EAGE;AACD,UAAK,wBAAWA,IAAX,CAAL,EAAyB;AACxB,cAAM;AACLM,UAAAA,UAAU,GAAG,EADR;AAELC,UAAAA,OAAO,GAAG,EAFL;AAGLC,UAAAA,QAHK;AAILC,UAAAA,OAAO,GAAG,EAJL;AAKLC,UAAAA;AALK,YAMFf,MAAM,CAAEM,GAAF,CANV,CADwB,CASxB;AACA;;AACA,YAAKO,QAAQ,IAAI,CAAEE,UAAd,IAA4B,sBAASV,IA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CA,MAAM,IACN,CAAE,wCAAmBI,IAAnB,CADF,IAEAA,IAAI,CAACgC,kBAHN,EAIE;AACD,kCAAatC,GAAG,CAACuC,aAAJ,CAAmB,IAAnB,CAAb,EAAwCjC,IAAxC;AACA;;AAED,2BAAQA,IAAR;AACA;AACD,GAjJD;AAkJA","sourcesContent":["/**\n * External dependencies\n */\nimport { includes, noop } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport 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';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach( (\n\t\t/** @type {Node & { nextElementSibling?: unknown }} */ node\n\t) => {\n\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t// function, or with an isMatch function that matches the node.\n\t\tif (\n\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t) {\n\t\t\tif ( isElement( node ) ) {\n\t\t\t\tconst {\n\t\t\t\t\tattributes = [],\n\t\t\t\t\tclasses = [],\n\t\t\t\t\tchildren,\n\t\t\t\t\trequire = [],\n\t\t\t\t\tallowEmpty,\n\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t// remove the node.\n\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\tremove( node );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t! includes( attributes, name )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\tif ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\treturn ( /** @type {string} */ className ) =>\n\t\t\t\t\t\t\t\t\tclassName === item;\n\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\treturn ( /** @type {string} */ className ) =>\n\t\t\t\t\t\t\t\t\titem.test( className );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\tisMatch( name )\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\tnode.classList.remove( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tunwrap( node );\n\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// contains children that are block content, unwrap\n\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t( child ) => ! isPhrasingContent( child )\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\tunwrap( node );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t} else {\n\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t} else {\n\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t// are not phrasing content.\n\t\t\tif (\n\t\t\t\tinline &&\n\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\tnode.nextElementSibling\n\t\t\t) {\n\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t}\n\n\t\t\tunwrap( node );\n\t\t}\n\t} );\n}\n"]}
|
@@ -13,7 +13,7 @@ var _assertIsDefined = require("../utils/assert-is-defined");
|
|
13
13
|
|
14
14
|
/**
|
15
15
|
* Check whether the current document has selected text. This applies to ranges
|
16
|
-
* of text in the document, and not selection inside
|
16
|
+
* of text in the document, and not selection inside `<input>` and `<textarea>`
|
17
17
|
* elements.
|
18
18
|
*
|
19
19
|
* See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/document-has-text-selection.js"],"names":["documentHasTextSelection","doc","defaultView","selection","getSelection","range","rangeCount","getRangeAt","collapsed"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,wBAAT,CAAmCC,GAAnC,EAAyC;AACvD,wCAAiBA,GAAG,CAACC,WAArB,EAAkC,iBAAlC;AACA,QAAMC,SAAS,GAAGF,GAAG,CAACC,WAAJ,CAAgBE,YAAhB,EAAlB;AACA,wCAAiBD,SAAjB,EAA4B,WAA5B;AACA,QAAME,KAAK,GAAGF,SAAS,CAACG,UAAV,GAAuBH,SAAS,CAACI,UAAV,CAAsB,CAAtB,CAAvB,GAAmD,IAAjE;AACA,SAAO,CAAC,CAAEF,KAAH,IAAY,CAAEA,KAAK,CAACG,SAA3B;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Check whether the current document has selected text. This applies to ranges\n * of text in the document, and not selection inside
|
1
|
+
{"version":3,"sources":["@wordpress/dom/src/dom/document-has-text-selection.js"],"names":["documentHasTextSelection","doc","defaultView","selection","getSelection","range","rangeCount","getRangeAt","collapsed"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,wBAAT,CAAmCC,GAAnC,EAAyC;AACvD,wCAAiBA,GAAG,CAACC,WAArB,EAAkC,iBAAlC;AACA,QAAMC,SAAS,GAAGF,GAAG,CAACC,WAAJ,CAAgBE,YAAhB,EAAlB;AACA,wCAAiBD,SAAjB,EAA4B,WAA5B;AACA,QAAME,KAAK,GAAGF,SAAS,CAACG,UAAV,GAAuBH,SAAS,CAACI,UAAV,CAAsB,CAAtB,CAAvB,GAAmD,IAAjE;AACA,SAAO,CAAC,CAAEF,KAAH,IAAY,CAAEA,KAAK,CAACG,SAA3B;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Check whether the current document has selected text. This applies to ranges\n * of text in the document, and not selection inside `<input>` and `<textarea>`\n * elements.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} True if there is selection, false if not.\n */\nexport default function documentHasTextSelection( doc ) {\n\tassertIsDefined( doc.defaultView, 'doc.defaultView' );\n\tconst selection = doc.defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\treturn !! range && ! range.collapsed;\n}\n"]}
|
@@ -17,8 +17,8 @@ var _inputFieldHasUncollapsedSelection = _interopRequireDefault(require("./input
|
|
17
17
|
|
18
18
|
/**
|
19
19
|
* Check whether the current document has any sort of selection. This includes
|
20
|
-
* ranges of text across elements and any selection inside
|
21
|
-
*
|
20
|
+
* ranges of text across elements and any selection inside `<input>` and
|
21
|
+
* `<textarea>` elements.
|
22
22
|
*
|
23
23
|
* @param {Document} doc The document to check.
|
24
24
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/document-has-uncollapsed-selection.js"],"names":["documentHasUncollapsedSelection","doc","activeElement"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,+BAAT,CAA0CC,GAA1C,EAAgD;AAC9D,SACC,uCAA0BA,GAA1B,KACE,CAAC,CAAEA,GAAG,CAACC,aAAP,IACD,gDAAmCD,GAAG,CAACC,aAAvC,CAHF;AAKA","sourcesContent":["/**\n * Internal dependencies\n */\nimport documentHasTextSelection from './document-has-text-selection';\nimport inputFieldHasUncollapsedSelection from './input-field-has-uncollapsed-selection';\n\n/**\n * Check whether the current document has any sort of selection. This includes\n * ranges of text across elements and any selection inside
|
1
|
+
{"version":3,"sources":["@wordpress/dom/src/dom/document-has-uncollapsed-selection.js"],"names":["documentHasUncollapsedSelection","doc","activeElement"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,+BAAT,CAA0CC,GAA1C,EAAgD;AAC9D,SACC,uCAA0BA,GAA1B,KACE,CAAC,CAAEA,GAAG,CAACC,aAAP,IACD,gDAAmCD,GAAG,CAACC,aAAvC,CAHF;AAKA","sourcesContent":["/**\n * Internal dependencies\n */\nimport documentHasTextSelection from './document-has-text-selection';\nimport inputFieldHasUncollapsedSelection from './input-field-has-uncollapsed-selection';\n\n/**\n * Check whether the current document has any sort of selection. This includes\n * ranges of text across elements and any selection inside `<input>` and\n * `<textarea>` elements.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} Whether there is any sort of \"selection\" in the document.\n */\nexport default function documentHasUncollapsedSelection( doc ) {\n\treturn (\n\t\tdocumentHasTextSelection( doc ) ||\n\t\t( !! doc.activeElement &&\n\t\t\tinputFieldHasUncollapsedSelection( doc.activeElement ) )\n\t);\n}\n"]}
|
@@ -19,12 +19,18 @@ function getRangeHeight(range) {
|
|
19
19
|
return;
|
20
20
|
}
|
21
21
|
|
22
|
-
const highestTop = Math.min(...rects.map(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
})
|
22
|
+
const highestTop = Math.min(...rects.map(_ref => {
|
23
|
+
let {
|
24
|
+
top
|
25
|
+
} = _ref;
|
26
|
+
return top;
|
27
|
+
}));
|
28
|
+
const lowestBottom = Math.max(...rects.map(_ref2 => {
|
29
|
+
let {
|
30
|
+
bottom
|
31
|
+
} = _ref2;
|
32
|
+
return bottom;
|
33
|
+
}));
|
28
34
|
return lowestBottom - highestTop;
|
29
35
|
}
|
30
36
|
//# sourceMappingURL=get-range-height.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/get-range-height.js"],"names":["getRangeHeight","range","rects","Array","from","getClientRects","length","highestTop","Math","min","map","top","lowestBottom","max","bottom"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AAC/C,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,KAAK,CAACI,cAAN,EAAZ,CAAd;;AAEA,MAAK,CAAEH,KAAK,CAACI,MAAb,EAAsB;AACrB;AACA;;AAED,QAAMC,UAAU,GAAGC,IAAI,CAACC,GAAL,CAAU,GAAGP,KAAK,CAACQ,GAAN,CAAW,
|
1
|
+
{"version":3,"sources":["@wordpress/dom/src/dom/get-range-height.js"],"names":["getRangeHeight","range","rects","Array","from","getClientRects","length","highestTop","Math","min","map","top","lowestBottom","max","bottom"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AAC/C,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,KAAK,CAACI,cAAN,EAAZ,CAAd;;AAEA,MAAK,CAAEH,KAAK,CAACI,MAAb,EAAsB;AACrB;AACA;;AAED,QAAMC,UAAU,GAAGC,IAAI,CAACC,GAAL,CAAU,GAAGP,KAAK,CAACQ,GAAN,CAAW;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WAAeA,GAAf;AAAA,GAAX,CAAb,CAAnB;AACA,QAAMC,YAAY,GAAGJ,IAAI,CAACK,GAAL,CAAU,GAAGX,KAAK,CAACQ,GAAN,CAAW;AAAA,QAAE;AAAEI,MAAAA;AAAF,KAAF;AAAA,WAAkBA,MAAlB;AAAA,GAAX,CAAb,CAArB;AAEA,SAAOF,YAAY,GAAGL,UAAtB;AACA","sourcesContent":["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param {Range} range The range to check.\n * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range ) {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"]}
|
@@ -30,9 +30,12 @@ function getRectangleFromRange(range) {
|
|
30
30
|
} // Ignore tiny selection at the edge of a range.
|
31
31
|
|
32
32
|
|
33
|
-
const filteredRects = rects.filter(
|
34
|
-
|
35
|
-
|
33
|
+
const filteredRects = rects.filter(_ref => {
|
34
|
+
let {
|
35
|
+
width
|
36
|
+
} = _ref;
|
37
|
+
return width > 1;
|
38
|
+
}); // If it's full of tiny selections, return browser default.
|
36
39
|
|
37
40
|
if (filteredRects.length === 0) {
|
38
41
|
return range.getBoundingClientRect();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/get-rectangle-from-range.js"],"names":["getRectangleFromRange","range","collapsed","rects","Array","from","getClientRects","length","filteredRects","filter","width","getBoundingClientRect","top","furthestTop","bottom","furthestBottom","left","furthestLeft","right","furthestRight","window","DOMRect","startContainer","ownerDocument","nodeName","parentNode","index","childNodes","indexOf","createRange","setStart","setEnd","rect","padNode","createTextNode","cloneRange","insertNode","removeChild"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAT,CAAgCC,KAAhC,EAAwC;AACtD;AACA;AACA;AACA,MAAK,CAAEA,KAAK,CAACC,SAAb,EAAyB;AACxB,UAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYJ,KAAK,CAACK,cAAN,EAAZ,CAAd,CADwB,CAGxB;;AACA,QAAKH,KAAK,CAACI,MAAN,KAAiB,CAAtB,EAA0B;AACzB,aAAOJ,KAAK,CAAE,CAAF,CAAZ;AACA,KANuB,CAQxB;;;AACA,UAAMK,aAAa,GAAGL,KAAK,CAACM,MAAN,CAAc,
|
1
|
+
{"version":3,"sources":["@wordpress/dom/src/dom/get-rectangle-from-range.js"],"names":["getRectangleFromRange","range","collapsed","rects","Array","from","getClientRects","length","filteredRects","filter","width","getBoundingClientRect","top","furthestTop","bottom","furthestBottom","left","furthestLeft","right","furthestRight","window","DOMRect","startContainer","ownerDocument","nodeName","parentNode","index","childNodes","indexOf","createRange","setStart","setEnd","rect","padNode","createTextNode","cloneRange","insertNode","removeChild"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,qBAAT,CAAgCC,KAAhC,EAAwC;AACtD;AACA;AACA;AACA,MAAK,CAAEA,KAAK,CAACC,SAAb,EAAyB;AACxB,UAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYJ,KAAK,CAACK,cAAN,EAAZ,CAAd,CADwB,CAGxB;;AACA,QAAKH,KAAK,CAACI,MAAN,KAAiB,CAAtB,EAA0B;AACzB,aAAOJ,KAAK,CAAE,CAAF,CAAZ;AACA,KANuB,CAQxB;;;AACA,UAAMK,aAAa,GAAGL,KAAK,CAACM,MAAN,CAAc;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAiBA,KAAK,GAAG,CAAzB;AAAA,KAAd,CAAtB,CATwB,CAWxB;;AACA,QAAKF,aAAa,CAACD,MAAd,KAAyB,CAA9B,EAAkC;AACjC,aAAON,KAAK,CAACU,qBAAN,EAAP;AACA;;AAED,QAAKH,aAAa,CAACD,MAAd,KAAyB,CAA9B,EAAkC;AACjC,aAAOC,aAAa,CAAE,CAAF,CAApB;AACA;;AAED,QAAI;AACHI,MAAAA,GAAG,EAAEC,WADF;AAEHC,MAAAA,MAAM,EAAEC,cAFL;AAGHC,MAAAA,IAAI,EAAEC,YAHH;AAIHC,MAAAA,KAAK,EAAEC;AAJJ,QAKAX,aAAa,CAAE,CAAF,CALjB;;AAOA,SAAM,MAAM;AAAEI,MAAAA,GAAF;AAAOE,MAAAA,MAAP;AAAeE,MAAAA,I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GAAGV,aAAa,CAACW,cAAd,CAA8B,QAA9B,CAAhB,CAFa,CAGb;;AACAjC,IAAAA,KAAK,GAAGA,KAAK,CAACkC,UAAN,EAAR;AACAlC,IAAAA,KAAK,CAACmC,UAAN,CAAkBH,OAAlB;AACAD,IAAAA,IAAI,GAAG/B,KAAK,CAACK,cAAN,GAAwB,CAAxB,CAAP;AACA,0CAAiB2B,OAAO,CAACR,UAAzB,EAAqC,oBAArC;AACAQ,IAAAA,OAAO,CAACR,UAAR,CAAmBY,WAAnB,CAAgCJ,OAAhC;AACA;;AAED,SAAOD,IAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle of a given Range.\n *\n * @param {Range} range The range.\n *\n * @return {DOMRect} The rectangle.\n */\nexport default function getRectangleFromRange( range ) {\n\t// For uncollapsed ranges, get the rectangle that bounds the contents of the\n\t// range; this a rectangle enclosing the union of the bounding rectangles\n\t// for all the elements in the range.\n\tif ( ! range.collapsed ) {\n\t\tconst rects = Array.from( range.getClientRects() );\n\n\t\t// If there's just a single rect, return it.\n\t\tif ( rects.length === 1 ) {\n\t\t\treturn rects[ 0 ];\n\t\t}\n\n\t\t// Ignore tiny selection at the edge of a range.\n\t\tconst filteredRects = rects.filter( ( { width } ) => width > 1 );\n\n\t\t// If it's full of tiny selections, return browser default.\n\t\tif ( filteredRects.length === 0 ) {\n\t\t\treturn range.getBoundingClientRect();\n\t\t}\n\n\t\tif ( filteredRects.length === 1 ) {\n\t\t\treturn filteredRects[ 0 ];\n\t\t}\n\n\t\tlet {\n\t\t\ttop: furthestTop,\n\t\t\tbottom: furthestBottom,\n\t\t\tleft: furthestLeft,\n\t\t\tright: furthestRight,\n\t\t} = filteredRects[ 0 ];\n\n\t\tfor ( const { top, bottom, left, right } of filteredRects ) {\n\t\t\tif ( top < furthestTop ) furthestTop = top;\n\t\t\tif ( bottom > furthestBottom ) furthestBottom = bottom;\n\t\t\tif ( left < furthestLeft ) furthestLeft = left;\n\t\t\tif ( right > furthestRight ) furthestRight = right;\n\t\t}\n\n\t\treturn new window.DOMRect(\n\t\t\tfurthestLeft,\n\t\t\tfurthestTop,\n\t\t\tfurthestRight - furthestLeft,\n\t\t\tfurthestBottom - furthestTop\n\t\t);\n\t}\n\n\tconst { startContainer } = range;\n\tconst { ownerDocument } = startContainer;\n\n\t// Correct invalid \"BR\" ranges. The cannot contain any children.\n\tif ( startContainer.nodeName === 'BR' ) {\n\t\tconst { parentNode } = startContainer;\n\t\tassertIsDefined( parentNode, 'parentNode' );\n\t\tconst index = /** @type {Node[]} */ ( Array.from(\n\t\t\tparentNode.childNodes\n\t\t) ).indexOf( startContainer );\n\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\trange = ownerDocument.createRange();\n\t\trange.setStart( parentNode, index );\n\t\trange.setEnd( parentNode, index );\n\t}\n\n\tlet rect = range.getClientRects()[ 0 ];\n\n\t// If the collapsed range starts (and therefore ends) at an element node,\n\t// `getClientRects` can be empty in some browsers. This can be resolved\n\t// by adding a temporary text node with zero-width space to the range.\n\t//\n\t// See: https://stackoverflow.com/a/6847328/995445\n\tif ( ! rect ) {\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\tconst padNode = ownerDocument.createTextNode( '\\u200b' );\n\t\t// Do not modify the live range.\n\t\trange = range.cloneRange();\n\t\trange.insertNode( padNode );\n\t\trect = range.getClientRects()[ 0 ];\n\t\tassertIsDefined( padNode.parentNode, 'padNode.parentNode' );\n\t\tpadNode.parentNode.removeChild( padNode );\n\t}\n\n\treturn rect;\n}\n"]}
|
package/build/dom/index.js
CHANGED
@@ -5,12 +5,24 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
6
6
|
value: true
|
7
7
|
});
|
8
|
+
Object.defineProperty(exports, "__unstableStripHTML", {
|
9
|
+
enumerable: true,
|
10
|
+
get: function () {
|
11
|
+
return _stripHtml.default;
|
12
|
+
}
|
13
|
+
});
|
8
14
|
Object.defineProperty(exports, "computeCaretRect", {
|
9
15
|
enumerable: true,
|
10
16
|
get: function () {
|
11
17
|
return _computeCaretRect.default;
|
12
18
|
}
|
13
19
|
});
|
20
|
+
Object.defineProperty(exports, "documentHasSelection", {
|
21
|
+
enumerable: true,
|
22
|
+
get: function () {
|
23
|
+
return _documentHasSelection.default;
|
24
|
+
}
|
25
|
+
});
|
14
26
|
Object.defineProperty(exports, "documentHasTextSelection", {
|
15
27
|
enumerable: true,
|
16
28
|
get: function () {
|
@@ -23,10 +35,10 @@ Object.defineProperty(exports, "documentHasUncollapsedSelection", {
|
|
23
35
|
return _documentHasUncollapsedSelection.default;
|
24
36
|
}
|
25
37
|
});
|
26
|
-
Object.defineProperty(exports, "
|
38
|
+
Object.defineProperty(exports, "getOffsetParent", {
|
27
39
|
enumerable: true,
|
28
40
|
get: function () {
|
29
|
-
return
|
41
|
+
return _getOffsetParent.default;
|
30
42
|
}
|
31
43
|
});
|
32
44
|
Object.defineProperty(exports, "getRectangleFromRange", {
|
@@ -41,10 +53,16 @@ Object.defineProperty(exports, "getScrollContainer", {
|
|
41
53
|
return _getScrollContainer.default;
|
42
54
|
}
|
43
55
|
});
|
44
|
-
Object.defineProperty(exports, "
|
56
|
+
Object.defineProperty(exports, "insertAfter", {
|
45
57
|
enumerable: true,
|
46
58
|
get: function () {
|
47
|
-
return
|
59
|
+
return _insertAfter.default;
|
60
|
+
}
|
61
|
+
});
|
62
|
+
Object.defineProperty(exports, "isEmpty", {
|
63
|
+
enumerable: true,
|
64
|
+
get: function () {
|
65
|
+
return _isEmpty.default;
|
48
66
|
}
|
49
67
|
});
|
50
68
|
Object.defineProperty(exports, "isEntirelySelected", {
|
@@ -65,6 +83,12 @@ Object.defineProperty(exports, "isNumberInput", {
|
|
65
83
|
return _isNumberInput.default;
|
66
84
|
}
|
67
85
|
});
|
86
|
+
Object.defineProperty(exports, "isRTL", {
|
87
|
+
enumerable: true,
|
88
|
+
get: function () {
|
89
|
+
return _isRtl.default;
|
90
|
+
}
|
91
|
+
});
|
68
92
|
Object.defineProperty(exports, "isTextField", {
|
69
93
|
enumerable: true,
|
70
94
|
get: function () {
|
@@ -89,28 +113,22 @@ Object.defineProperty(exports, "placeCaretAtVerticalEdge", {
|
|
89
113
|
return _placeCaretAtVerticalEdge.default;
|
90
114
|
}
|
91
115
|
});
|
92
|
-
Object.defineProperty(exports, "replace", {
|
93
|
-
enumerable: true,
|
94
|
-
get: function () {
|
95
|
-
return _replace.default;
|
96
|
-
}
|
97
|
-
});
|
98
116
|
Object.defineProperty(exports, "remove", {
|
99
117
|
enumerable: true,
|
100
118
|
get: function () {
|
101
119
|
return _remove.default;
|
102
120
|
}
|
103
121
|
});
|
104
|
-
Object.defineProperty(exports, "
|
122
|
+
Object.defineProperty(exports, "removeInvalidHTML", {
|
105
123
|
enumerable: true,
|
106
124
|
get: function () {
|
107
|
-
return
|
125
|
+
return _removeInvalidHtml.default;
|
108
126
|
}
|
109
127
|
});
|
110
|
-
Object.defineProperty(exports, "
|
128
|
+
Object.defineProperty(exports, "replace", {
|
111
129
|
enumerable: true,
|
112
130
|
get: function () {
|
113
|
-
return
|
131
|
+
return _replace.default;
|
114
132
|
}
|
115
133
|
});
|
116
134
|
Object.defineProperty(exports, "replaceTag", {
|
@@ -119,40 +137,22 @@ Object.defineProperty(exports, "replaceTag", {
|
|
119
137
|
return _replaceTag.default;
|
120
138
|
}
|
121
139
|
});
|
122
|
-
Object.defineProperty(exports, "
|
123
|
-
enumerable: true,
|
124
|
-
get: function () {
|
125
|
-
return _wrap.default;
|
126
|
-
}
|
127
|
-
});
|
128
|
-
Object.defineProperty(exports, "__unstableStripHTML", {
|
129
|
-
enumerable: true,
|
130
|
-
get: function () {
|
131
|
-
return _stripHtml.default;
|
132
|
-
}
|
133
|
-
});
|
134
|
-
Object.defineProperty(exports, "isEmpty", {
|
135
|
-
enumerable: true,
|
136
|
-
get: function () {
|
137
|
-
return _isEmpty.default;
|
138
|
-
}
|
139
|
-
});
|
140
|
-
Object.defineProperty(exports, "removeInvalidHTML", {
|
140
|
+
Object.defineProperty(exports, "safeHTML", {
|
141
141
|
enumerable: true,
|
142
142
|
get: function () {
|
143
|
-
return
|
143
|
+
return _safeHtml.default;
|
144
144
|
}
|
145
145
|
});
|
146
|
-
Object.defineProperty(exports, "
|
146
|
+
Object.defineProperty(exports, "unwrap", {
|
147
147
|
enumerable: true,
|
148
148
|
get: function () {
|
149
|
-
return
|
149
|
+
return _unwrap.default;
|
150
150
|
}
|
151
151
|
});
|
152
|
-
Object.defineProperty(exports, "
|
152
|
+
Object.defineProperty(exports, "wrap", {
|
153
153
|
enumerable: true,
|
154
154
|
get: function () {
|
155
|
-
return
|
155
|
+
return _wrap.default;
|
156
156
|
}
|
157
157
|
});
|
158
158
|
|
package/build/dom/is-edge.js
CHANGED
@@ -36,7 +36,9 @@ var _isInputOrTextArea = _interopRequireDefault(require("./is-input-or-text-area
|
|
36
36
|
*
|
37
37
|
* @return {boolean} True if at the edge, false if not.
|
38
38
|
*/
|
39
|
-
function isEdge(container, isReverse
|
39
|
+
function isEdge(container, isReverse) {
|
40
|
+
let onlyVertical = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
41
|
+
|
40
42
|
if ((0, _isInputOrTextArea.default)(container) && typeof container.selectionStart === 'number') {
|
41
43
|
if (container.selectionStart !== container.selectionEnd) {
|
42
44
|
return false;
|
package/build/dom/is-edge.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/is-edge.js"],"names":["isEdge","container","isReverse","onlyVertical","selectionStart","selectionEnd","value","length","isContentEditable","ownerDocument","defaultView","selection","getSelection","rangeCount","range","getRangeAt","collapsedRange","cloneRange","isForward","isCollapsed","collapse","collapsedRangeRect","rangeRect","rangeHeight","height","isReverseDir","containerRect","getBoundingClientRect","x","left","right","y","top","bottom","testRange","testRect","verticalSide","horizontalSide","verticalDiff","horizontalDiff","hasVerticalDiff","Math","abs","hasHorizontalDiff"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AATA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,MAAT,CAAiBC,SAAjB,EAA4BC,SAA5B,
|
1
|
+
{"version":3,"sources":["@wordpress/dom/src/dom/is-edge.js"],"names":["isEdge","container","isReverse","onlyVertical","selectionStart","selectionEnd","value","length","isContentEditable","ownerDocument","defaultView","selection","getSelection","rangeCount","range","getRangeAt","collapsedRange","cloneRange","isForward","isCollapsed","collapse","collapsedRangeRect","rangeRect","rangeHeight","height","isReverseDir","containerRect","getBoundingClientRect","x","left","right","y","top","bottom","testRange","testRect","verticalSide","horizontalSide","verticalDiff","horizontalDiff","hasVerticalDiff","Math","abs","hasHorizontalDiff"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AATA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,MAAT,CAAiBC,SAAjB,EAA4BC,SAA5B,EAA8D;AAAA,MAAvBC,YAAuB,uEAAR,KAAQ;;AAC5E,MACC,gCAAmBF,SAAnB,KACA,OAAOA,SAAS,CAACG,cAAjB,KAAoC,QAFrC,EAGE;AACD,QAAKH,SAAS,CAACG,cAAV,KAA6BH,SAAS,CAACI,YAA5C,EAA2D;AAC1D,aAAO,KAAP;AACA;;AAED,QAAKH,SAAL,EAAiB;AAChB,aAAOD,SAAS,CAACG,cAAV,KAA6B,CAApC;AACA;;AAED,WAAOH,SAAS,CAACK,KAAV,CAAgBC,MAAhB,KAA2BN,SAAS,CAACG,cAA5C;AACA;;AAED,MAAK;AAAG;AAA6BH,EAAAA,SAAF,CAAcO,iBAAjD,EAAsE;AACrE,WAAO,IAAP;AACA;;AAED,QAAM;AAAEC,IAAAA;AAAF,MAAoBR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,aAAa,CAACI,KAAd,GAAsB,CAAxE;AACA,QAAMC,CAAC,GAAG7B,SAAS,GAAGwB,aAAa,CAACM,GAAd,GAAoB,CAAvB,GAA2BN,aAAa,CAACO,MAAd,GAAuB,CAArE;AACA,QAAMC,SAAS,GAAG,wCACjBzB,aADiB,EAEjBmB,CAFiB,EAGjBG,CAHiB;AAIjB;AAA6B9B,EAAAA,SAJZ,CAAlB;;AAOA,MAAK,CAAEiC,SAAP,EAAmB;AAClB,WAAO,KAAP;AACA;;AAED,QAAMC,QAAQ,GAAG,oCAAuBD,SAAvB,CAAjB;;AAEA,MAAK,CAAEC,QAAP,EAAkB;AACjB,WAAO,KAAP;AACA;;AAED,QAAMC,YAAY,GAAGlC,SAAS,GAAG,KAAH,GAAW,QAAzC;AACA,QAAMmC,cAAc,GAAGZ,YAAY,GAAG,MAAH,GAAY,OAA/C;AACA,QAAMa,YAAY,GAAGH,QAAQ,CAAEC,YAAF,CAAR,GAA2Bd,SAAS,CAAEc,YAAF,CAAzD;AACA,QAAMG,cAAc,GACnBJ,QAAQ,CAAEE,cAAF,CAAR,GAA6BhB,kBAAkB,CAAEgB,cAAF,CADhD,CAhG4E,CAmG5E;;AACA,QAAMG,eAAe,GAAGC,IAAI,CAACC,GAAL,CAAUJ,YAAV,KAA4B,CAApD;AACA,QAAMK,iBAAiB,GAAGF,IAAI,CAACC,GAAL,CAAUH,cAAV,KAA8B,CAAxD;AAEA,SAAOpC,YAAY,GAChBqC,eADgB,GAEhBA,eAAe,IAAIG,iBAFtB;AAGA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param {Element} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false to check right.\n * @param {boolean} [onlyVertical=false] Set to true to check only vertical position.\n *\n * @return {boolean} True if at the edge, false if not.\n */\nexport default function isEdge( container, isReverse, onlyVertical = false ) {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! (/** @type {HTMLElement} */ ( container ).isContentEditable) ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\tconst testRange = hiddenCaretRangeFromPoint(\n\t\townerDocument,\n\t\tx,\n\t\ty,\n\t\t/** @type {HTMLElement} */ ( container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"]}
|
package/build/dom/strip-html.js
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
4
6
|
value: true
|
5
7
|
});
|
6
8
|
exports.default = stripHTML;
|
7
9
|
|
10
|
+
var _safeHtml = _interopRequireDefault(require("./safe-html"));
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Internal dependencies
|
14
|
+
*/
|
15
|
+
|
8
16
|
/**
|
9
17
|
* Removes any HTML tags from the provided string.
|
10
18
|
*
|
@@ -13,7 +21,11 @@ exports.default = stripHTML;
|
|
13
21
|
* @return {string} The text content with any html removed.
|
14
22
|
*/
|
15
23
|
function stripHTML(html) {
|
16
|
-
|
17
|
-
|
24
|
+
// Remove any script tags or on* attributes otherwise their *contents* will be left
|
25
|
+
// in place following removal of HTML tags.
|
26
|
+
html = (0, _safeHtml.default)(html);
|
27
|
+
const doc = document.implementation.createHTMLDocument('');
|
28
|
+
doc.body.innerHTML = html;
|
29
|
+
return doc.body.textContent || '';
|
18
30
|
}
|
19
31
|
//# sourceMappingURL=strip-html.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/strip-html.js"],"names":["stripHTML","html","
|
1
|
+
{"version":3,"sources":["@wordpress/dom/src/dom/strip-html.js"],"names":["stripHTML","html","doc","document","implementation","createHTMLDocument","body","innerHTML","textContent"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,SAAT,CAAoBC,IAApB,EAA2B;AACzC;AACA;AACAA,EAAAA,IAAI,GAAG,uBAAUA,IAAV,CAAP;AAEA,QAAMC,GAAG,GAAGC,QAAQ,CAACC,cAAT,CAAwBC,kBAAxB,CAA4C,EAA5C,CAAZ;AACAH,EAAAA,GAAG,CAACI,IAAJ,CAASC,SAAT,GAAqBN,IAArB;AACA,SAAOC,GAAG,CAACI,IAAJ,CAASE,WAAT,IAAwB,EAA/B;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport safeHTML from './safe-html';\n\n/**\n * Removes any HTML tags from the provided string.\n *\n * @param {string} html The string containing html.\n *\n * @return {string} The text content with any html removed.\n */\nexport default function stripHTML( html ) {\n\t// Remove any script tags or on* attributes otherwise their *contents* will be left\n\t// in place following removal of HTML tags.\n\thtml = safeHTML( html );\n\n\tconst doc = document.implementation.createHTMLDocument( '' );\n\tdoc.body.innerHTML = html;\n\treturn doc.body.textContent || '';\n}\n"]}
|
package/build/focusable.js
CHANGED
@@ -91,9 +91,11 @@ function isValidFocusableArea(element) {
|
|
91
91
|
*/
|
92
92
|
|
93
93
|
|
94
|
-
function find(context
|
95
|
-
|
96
|
-
|
94
|
+
function find(context) {
|
95
|
+
let {
|
96
|
+
sequential = false
|
97
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
98
|
+
|
97
99
|
/* eslint-disable jsdoc/no-undefined-types */
|
98
100
|
|
99
101
|
/** @type {NodeListOf<HTMLElement>} */
|
package/build/focusable.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/focusable.js"],"names":["buildSelector","sequential","join","isVisible","element","offsetWidth","offsetHeight","getClientRects","length","isValidFocusableArea","map","closest","img","ownerDocument","querySelector","name","find","context","elements","querySelectorAll","Array","from","filter","nodeName"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,CAAwBC,UAAxB,EAAqC;AACpC,SAAO,CACNA,UAAU,GAAG,iCAAH,GAAuC,YAD3C,EAEN,SAFM,EAGN,wBAHM,EAIN,4CAJM,EAKN,wBALM,EAMN,0BANM,EAON,6BAPM,EAQN,QARM,EASN,OATM,EAUN,YAVM,EAWN,gDAXM,EAYLC,IAZK,CAYC,GAZD,CAAP;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,SAAT,CAAoBC,OAApB,EAA8B;AAC7B,SACCA,OAAO,CAACC,WAAR,GAAsB,CAAtB,IACAD,OAAO,CAACE,YAAR,GAAuB,CADvB,IAEAF,OAAO,CAACG,cAAR,GAAyBC,MAAzB,GAAkC,CAHnC;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,oBAAT,CAA+BL,OAA/B,EAAyC;AACxC;AACA,QAAMM,GAAG,GAAGN,OAAO,CAACO,OAAR,CAAiB,WAAjB,CAAZ;;AACA,MAAK,CAAED,GAAP,EAAa;AACZ,WAAO,KAAP;AACA;AAED;;;AACA,QAAME,GAAG,GAAGR,OAAO,CAACS,aAAR,CAAsBC,aAAtB,CACX,kBAAkBJ,GAAG,CAACK,IAAtB,GAA6B,IADlB,CAAZ;AAGA,SAAO,CAAC,CAAEH,GAAH,IAAUT,SAAS,CAAES,GAAF,CAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,IAAT,CAAeC,OAAf,
|
1
|
+
{"version":3,"sources":["@wordpress/dom/src/focusable.js"],"names":["buildSelector","sequential","join","isVisible","element","offsetWidth","offsetHeight","getClientRects","length","isValidFocusableArea","map","closest","img","ownerDocument","querySelector","name","find","context","elements","querySelectorAll","Array","from","filter","nodeName"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,CAAwBC,UAAxB,EAAqC;AACpC,SAAO,CACNA,UAAU,GAAG,iCAAH,GAAuC,YAD3C,EAEN,SAFM,EAGN,wBAHM,EAIN,4CAJM,EAKN,wBALM,EAMN,0BANM,EAON,6BAPM,EAQN,QARM,EASN,OATM,EAUN,YAVM,EAWN,gDAXM,EAYLC,IAZK,CAYC,GAZD,CAAP;AAaA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,SAAT,CAAoBC,OAApB,EAA8B;AAC7B,SACCA,OAAO,CAACC,WAAR,GAAsB,CAAtB,IACAD,OAAO,CAACE,YAAR,GAAuB,CADvB,IAEAF,OAAO,CAACG,cAAR,GAAyBC,MAAzB,GAAkC,CAHnC;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,oBAAT,CAA+BL,OAA/B,EAAyC;AACxC;AACA,QAAMM,GAAG,GAAGN,OAAO,CAACO,OAAR,CAAiB,WAAjB,CAAZ;;AACA,MAAK,CAAED,GAAP,EAAa;AACZ,WAAO,KAAP;AACA;AAED;;;AACA,QAAME,GAAG,GAAGR,OAAO,CAACS,aAAR,CAAsBC,aAAtB,CACX,kBAAkBJ,GAAG,CAACK,IAAtB,GAA6B,IADlB,CAAZ;AAGA,SAAO,CAAC,CAAEH,GAAH,IAAUT,SAAS,CAAES,GAAF,CAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,IAAT,CAAeC,OAAf,EAAsD;AAAA,MAA9B;AAAEhB,IAAAA,UAAU,GAAG;AAAf,GAA8B,uEAAL,EAAK;;AAC5D;;AACA;;AACA;AACA,QAAMiB,QAAQ,GAAGD,OAAO,CAACE,gBAAR,CAA0BnB,aAAa,CAAEC,UAAF,CAAvC,CAAjB;AAEA,SAAOmB,KAAK,CAACC,IAAN,CAAYH,QAAZ,EAAuBI,MAAvB,CAAiClB,OAAF,IAAe;AACpD,QAAK,CAAED,SAAS,CAAEC,OAAF,CAAhB,EAA8B;AAC7B,aAAO,KAAP;AACA;;AAED,UAAM;AAAEmB,MAAAA;AAAF,QAAenB,OAArB;;AACA,QAAK,WAAWmB,QAAhB,EAA2B;AAC1B,aAAOd,oBAAoB;AAC1B;AAAiCL,MAAAA,OADP,CAA3B;AAGA;;AAED,WAAO,IAAP;AACA,GAbM,CAAP;AAcA","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'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 {Element[]} Focusable elements.\n */\nexport function find( context, { sequential = false } = {} ) {\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {NodeListOf<HTMLElement>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\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"]}
|
package/build/index.js
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4
|
-
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
6
4
|
value: true
|
7
5
|
});
|
@@ -56,6 +54,10 @@ Object.keys(_dataTransfer).forEach(function (key) {
|
|
56
54
|
});
|
57
55
|
});
|
58
56
|
|
57
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
58
|
+
|
59
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
60
|
+
|
59
61
|
/**
|
60
62
|
* Internal dependencies
|
61
63
|
*/
|
package/build/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/index.js"],"names":["focus","focusable","tabbable"],"mappings":"
|
1
|
+
{"version":3,"sources":["@wordpress/dom/src/index.js"],"names":["focus","focusable","tabbable"],"mappings":";;;;;;;;;;AAGA;;AACA;;AAQA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;;;;AAdA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACO,MAAMA,KAAK,GAAG;AAAEC,EAAAA,SAAF;AAAaC,EAAAA;AAAb,CAAd","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"]}
|