@wordpress/dom 4.32.0 → 4.32.1-next.b8c8708f3.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
|
@@ -1,58 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
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 });
|
|
11
|
+
};
|
|
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var input_field_has_uncollapsed_selection_exports = {};
|
|
30
|
+
__export(input_field_has_uncollapsed_selection_exports, {
|
|
31
|
+
default: () => inputFieldHasUncollapsedSelection
|
|
6
32
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Check whether the given input field or textarea contains a (uncollapsed)
|
|
16
|
-
* selection of text.
|
|
17
|
-
*
|
|
18
|
-
* CAVEAT: Only specific text-based HTML inputs support the selection APIs
|
|
19
|
-
* needed to determine whether they have a collapsed or uncollapsed selection.
|
|
20
|
-
* This function defaults to returning `true` when the selection cannot be
|
|
21
|
-
* inspected, such as with `<input type="time">`. The rationale is that this
|
|
22
|
-
* should cause the block editor to defer to the browser's native selection
|
|
23
|
-
* handling (e.g. copying and pasting), thereby reducing friction for the user.
|
|
24
|
-
*
|
|
25
|
-
* See: https://html.spec.whatwg.org/multipage/input.html#do-not-apply
|
|
26
|
-
*
|
|
27
|
-
* @param {Element} element The HTML element.
|
|
28
|
-
*
|
|
29
|
-
* @return {boolean} Whether the input/textarea element has some "selection".
|
|
30
|
-
*/
|
|
33
|
+
module.exports = __toCommonJS(input_field_has_uncollapsed_selection_exports);
|
|
34
|
+
var import_is_text_field = __toESM(require("./is-text-field"));
|
|
35
|
+
var import_is_html_input_element = __toESM(require("./is-html-input-element"));
|
|
31
36
|
function inputFieldHasUncollapsedSelection(element) {
|
|
32
|
-
if (!(0,
|
|
37
|
+
if (!(0, import_is_html_input_element.default)(element) && !(0, import_is_text_field.default)(element)) {
|
|
33
38
|
return false;
|
|
34
39
|
}
|
|
35
|
-
|
|
36
|
-
// Safari throws a type error when trying to get `selectionStart` and
|
|
37
|
-
// `selectionEnd` on non-text <input> elements, so a try/catch construct is
|
|
38
|
-
// necessary.
|
|
39
40
|
try {
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const { selectionStart, selectionEnd } = (
|
|
42
|
+
/** @type {HTMLInputElement | HTMLTextAreaElement} */
|
|
43
|
+
element
|
|
44
|
+
);
|
|
44
45
|
return (
|
|
45
46
|
// `null` means the input type doesn't implement selection, thus we
|
|
46
47
|
// cannot determine whether the selection is collapsed, so we
|
|
47
48
|
// default to true.
|
|
48
|
-
selectionStart === null ||
|
|
49
|
-
// when not null, compare the two points
|
|
49
|
+
selectionStart === null || // when not null, compare the two points
|
|
50
50
|
selectionStart !== selectionEnd
|
|
51
51
|
);
|
|
52
52
|
} catch (error) {
|
|
53
|
-
// This is Safari's way of saying that the input type doesn't implement
|
|
54
|
-
// selection, so we default to true.
|
|
55
53
|
return true;
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
|
-
//# sourceMappingURL=input-field-has-uncollapsed-selection.js.map
|
|
56
|
+
//# sourceMappingURL=input-field-has-uncollapsed-selection.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/input-field-has-uncollapsed-selection.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport isTextField from './is-text-field';\nimport isHTMLInputElement from './is-html-input-element';\n\n/**\n * Check whether the given input field or textarea contains a (uncollapsed)\n * selection of text.\n *\n * CAVEAT: Only specific text-based HTML inputs support the selection APIs\n * needed to determine whether they have a collapsed or uncollapsed selection.\n * This function defaults to returning `true` when the selection cannot be\n * inspected, such as with `<input type=\"time\">`. The rationale is that this\n * should cause the block editor to defer to the browser's native selection\n * handling (e.g. copying and pasting), thereby reducing friction for the user.\n *\n * See: https://html.spec.whatwg.org/multipage/input.html#do-not-apply\n *\n * @param {Element} element The HTML element.\n *\n * @return {boolean} Whether the input/textarea element has some \"selection\".\n */\nexport default function inputFieldHasUncollapsedSelection( element ) {\n\tif ( ! isHTMLInputElement( element ) && ! isTextField( element ) ) {\n\t\treturn false;\n\t}\n\n\t// Safari throws a type error when trying to get `selectionStart` and\n\t// `selectionEnd` on non-text <input> elements, so a try/catch construct is\n\t// necessary.\n\ttry {\n\t\tconst { selectionStart, selectionEnd } =\n\t\t\t/** @type {HTMLInputElement | HTMLTextAreaElement} */ ( element );\n\t\treturn (\n\t\t\t// `null` means the input type doesn't implement selection, thus we\n\t\t\t// cannot determine whether the selection is collapsed, so we\n\t\t\t// default to true.\n\t\t\tselectionStart === null ||\n\t\t\t// when not null, compare the two points\n\t\t\tselectionStart !== selectionEnd\n\t\t);\n\t} catch ( error ) {\n\t\t// This is Safari's way of saying that the input type doesn't implement\n\t\t// selection, so we default to true.\n\t\treturn true;\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,2BAAwB;AACxB,mCAA+B;AAmBhB,SAAR,kCAAoD,SAAU;AACpE,MAAK,KAAE,6BAAAA,SAAoB,OAAQ,KAAK,KAAE,qBAAAC,SAAa,OAAQ,GAAI;AAClE,WAAO;AAAA,EACR;AAKA,MAAI;AACH,UAAM,EAAE,gBAAgB,aAAa;AAAA;AAAA,MACoB;AAAA;AACzD;AAAA;AAAA;AAAA;AAAA,MAIC,mBAAmB;AAAA,MAEnB,mBAAmB;AAAA;AAAA,EAErB,SAAU,OAAQ;AAGjB,WAAO;AAAA,EACR;AACD;",
|
|
6
|
+
"names": ["isHTMLInputElement", "isTextField"]
|
|
7
|
+
}
|
|
@@ -1,24 +1,29 @@
|
|
|
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 insert_after_exports = {};
|
|
20
|
+
__export(insert_after_exports, {
|
|
21
|
+
default: () => insertAfter
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Given two DOM nodes, inserts the former in the DOM as the next sibling of
|
|
14
|
-
* the latter.
|
|
15
|
-
*
|
|
16
|
-
* @param {Node} newNode Node to be inserted.
|
|
17
|
-
* @param {Node} referenceNode Node after which to perform the insertion.
|
|
18
|
-
* @return {void}
|
|
19
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(insert_after_exports);
|
|
24
|
+
var import_assert_is_defined = require("../utils/assert-is-defined");
|
|
20
25
|
function insertAfter(newNode, referenceNode) {
|
|
21
|
-
(0,
|
|
26
|
+
(0, import_assert_is_defined.assertIsDefined)(referenceNode.parentNode, "referenceNode.parentNode");
|
|
22
27
|
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
|
|
23
28
|
}
|
|
24
|
-
//# sourceMappingURL=insert-after.js.map
|
|
29
|
+
//# sourceMappingURL=insert-after.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/insert-after.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Given two DOM nodes, inserts the former in the DOM as the next sibling of\n * the latter.\n *\n * @param {Node} newNode Node to be inserted.\n * @param {Node} referenceNode Node after which to perform the insertion.\n * @return {void}\n */\nexport default function insertAfter( newNode, referenceNode ) {\n\tassertIsDefined( referenceNode.parentNode, 'referenceNode.parentNode' );\n\treferenceNode.parentNode.insertBefore( newNode, referenceNode.nextSibling );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAAgC;AAUjB,SAAR,YAA8B,SAAS,eAAgB;AAC7D,gDAAiB,cAAc,YAAY,0BAA2B;AACtE,gBAAc,WAAW,aAAc,SAAS,cAAc,WAAY;AAC3E;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/dom/is-edge.js
CHANGED
|
@@ -1,35 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
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 });
|
|
11
|
+
};
|
|
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var is_edge_exports = {};
|
|
30
|
+
__export(is_edge_exports, {
|
|
31
|
+
default: () => isEdge
|
|
6
32
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Check whether the selection is at the edge of the container. Checks for
|
|
22
|
-
* horizontal position by default. Set `onlyVertical` to true to check only
|
|
23
|
-
* vertically.
|
|
24
|
-
*
|
|
25
|
-
* @param {HTMLElement} container Focusable element.
|
|
26
|
-
* @param {boolean} isReverse Set to true to check left, false to check right.
|
|
27
|
-
* @param {boolean} [onlyVertical=false] Set to true to check only vertical position.
|
|
28
|
-
*
|
|
29
|
-
* @return {boolean} True if at the edge, false if not.
|
|
30
|
-
*/
|
|
33
|
+
module.exports = __toCommonJS(is_edge_exports);
|
|
34
|
+
var import_is_rtl = __toESM(require("./is-rtl"));
|
|
35
|
+
var import_get_range_height = __toESM(require("./get-range-height"));
|
|
36
|
+
var import_get_rectangle_from_range = __toESM(require("./get-rectangle-from-range"));
|
|
37
|
+
var import_is_selection_forward = __toESM(require("./is-selection-forward"));
|
|
38
|
+
var import_hidden_caret_range_from_point = __toESM(require("./hidden-caret-range-from-point"));
|
|
39
|
+
var import_assert_is_defined = require("../utils/assert-is-defined");
|
|
40
|
+
var import_is_input_or_text_area = __toESM(require("./is-input-or-text-area"));
|
|
41
|
+
var import_scroll_if_no_range = require("./scroll-if-no-range");
|
|
31
42
|
function isEdge(container, isReverse, onlyVertical = false) {
|
|
32
|
-
if ((0,
|
|
43
|
+
if ((0, import_is_input_or_text_area.default)(container) && typeof container.selectionStart === "number") {
|
|
33
44
|
if (container.selectionStart !== container.selectionEnd) {
|
|
34
45
|
return false;
|
|
35
46
|
}
|
|
@@ -41,72 +52,51 @@ function isEdge(container, isReverse, onlyVertical = false) {
|
|
|
41
52
|
if (!container.isContentEditable) {
|
|
42
53
|
return true;
|
|
43
54
|
}
|
|
44
|
-
const {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
defaultView
|
|
49
|
-
} = ownerDocument;
|
|
50
|
-
(0, _assertIsDefined.assertIsDefined)(defaultView, 'defaultView');
|
|
55
|
+
const { ownerDocument } = container;
|
|
56
|
+
const { defaultView } = ownerDocument;
|
|
57
|
+
(0, import_assert_is_defined.assertIsDefined)(defaultView, "defaultView");
|
|
51
58
|
const selection = defaultView.getSelection();
|
|
52
59
|
if (!selection || !selection.rangeCount) {
|
|
53
60
|
return false;
|
|
54
61
|
}
|
|
55
62
|
const range = selection.getRangeAt(0);
|
|
56
63
|
const collapsedRange = range.cloneRange();
|
|
57
|
-
const isForward = (0,
|
|
64
|
+
const isForward = (0, import_is_selection_forward.default)(selection);
|
|
58
65
|
const isCollapsed = selection.isCollapsed;
|
|
59
|
-
|
|
60
|
-
// Collapse in direction of selection.
|
|
61
66
|
if (!isCollapsed) {
|
|
62
67
|
collapsedRange.collapse(!isForward);
|
|
63
68
|
}
|
|
64
|
-
const collapsedRangeRect = (0,
|
|
65
|
-
const rangeRect = (0,
|
|
69
|
+
const collapsedRangeRect = (0, import_get_rectangle_from_range.default)(collapsedRange);
|
|
70
|
+
const rangeRect = (0, import_get_rectangle_from_range.default)(range);
|
|
66
71
|
if (!collapsedRangeRect || !rangeRect) {
|
|
67
72
|
return false;
|
|
68
73
|
}
|
|
69
|
-
|
|
70
|
-
// Only consider the multiline selection at the edge if the direction is
|
|
71
|
-
// towards the edge. The selection is multiline if it is taller than the
|
|
72
|
-
// collapsed selection.
|
|
73
|
-
const rangeHeight = (0, _getRangeHeight.default)(range);
|
|
74
|
+
const rangeHeight = (0, import_get_range_height.default)(range);
|
|
74
75
|
if (!isCollapsed && rangeHeight && rangeHeight > collapsedRangeRect.height && isForward === isReverse) {
|
|
75
76
|
return false;
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
-
// In the case of RTL scripts, the horizontal edge is at the opposite side.
|
|
79
|
-
const isReverseDir = (0, _isRtl.default)(container) ? !isReverse : isReverse;
|
|
78
|
+
const isReverseDir = (0, import_is_rtl.default)(container) ? !isReverse : isReverse;
|
|
80
79
|
const containerRect = container.getBoundingClientRect();
|
|
81
|
-
|
|
82
|
-
// To check if a selection is at the edge, we insert a test selection at the
|
|
83
|
-
// edge of the container and check if the selections have the same vertical
|
|
84
|
-
// or horizontal position. If they do, the selection is at the edge.
|
|
85
|
-
// This method proves to be better than a DOM-based calculation for the
|
|
86
|
-
// horizontal edge, since it ignores empty textnodes and a trailing line
|
|
87
|
-
// break element. In other words, we need to check visual positioning, not
|
|
88
|
-
// DOM positioning.
|
|
89
|
-
// It also proves better than using the computed style for the vertical
|
|
90
|
-
// edge, because we cannot know the padding and line height reliably in
|
|
91
|
-
// pixels. `getComputedStyle` may return a value with different units.
|
|
92
80
|
const x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;
|
|
93
81
|
const y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;
|
|
94
|
-
const testRange = (0,
|
|
82
|
+
const testRange = (0, import_scroll_if_no_range.scrollIfNoRange)(
|
|
83
|
+
container,
|
|
84
|
+
isReverse,
|
|
85
|
+
() => (0, import_hidden_caret_range_from_point.default)(ownerDocument, x, y, container)
|
|
86
|
+
);
|
|
95
87
|
if (!testRange) {
|
|
96
88
|
return false;
|
|
97
89
|
}
|
|
98
|
-
const testRect = (0,
|
|
90
|
+
const testRect = (0, import_get_rectangle_from_range.default)(testRange);
|
|
99
91
|
if (!testRect) {
|
|
100
92
|
return false;
|
|
101
93
|
}
|
|
102
|
-
const verticalSide = isReverse ?
|
|
103
|
-
const horizontalSide = isReverseDir ?
|
|
94
|
+
const verticalSide = isReverse ? "top" : "bottom";
|
|
95
|
+
const horizontalSide = isReverseDir ? "left" : "right";
|
|
104
96
|
const verticalDiff = testRect[verticalSide] - rangeRect[verticalSide];
|
|
105
97
|
const horizontalDiff = testRect[horizontalSide] - collapsedRangeRect[horizontalSide];
|
|
106
|
-
|
|
107
|
-
// Allow the position to be 1px off.
|
|
108
98
|
const hasVerticalDiff = Math.abs(verticalDiff) <= 1;
|
|
109
99
|
const hasHorizontalDiff = Math.abs(horizontalDiff) <= 1;
|
|
110
100
|
return onlyVertical ? hasVerticalDiff : hasVerticalDiff && hasHorizontalDiff;
|
|
111
101
|
}
|
|
112
|
-
//# sourceMappingURL=is-edge.js.map
|
|
102
|
+
//# sourceMappingURL=is-edge.js.map
|
package/build/dom/is-edge.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/is-edge.js"],
|
|
4
|
+
"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';\nimport { scrollIfNoRange } from './scroll-if-no-range';\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 {HTMLElement} 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 ( ! 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 = scrollIfNoRange( container, isReverse, () =>\n\t\thiddenCaretRangeFromPoint( ownerDocument, x, y, 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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAkB;AAClB,8BAA2B;AAC3B,sCAAkC;AAClC,kCAA+B;AAC/B,2CAAsC;AACtC,+BAAgC;AAChC,mCAA8B;AAC9B,gCAAgC;AAajB,SAAR,OAAyB,WAAW,WAAW,eAAe,OAAQ;AAC5E,UACC,6BAAAA,SAAmB,SAAU,KAC7B,OAAO,UAAU,mBAAmB,UACnC;AACD,QAAK,UAAU,mBAAmB,UAAU,cAAe;AAC1D,aAAO;AAAA,IACR;AAEA,QAAK,WAAY;AAChB,aAAO,UAAU,mBAAmB;AAAA,IACrC;AAEA,WAAO,UAAU,MAAM,WAAW,UAAU;AAAA,EAC7C;AAEA,MAAK,CAAE,UAAU,mBAAoB;AACpC,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,cAAc,IAAI;AAC1B,QAAM,EAAE,YAAY,IAAI;AAExB,gDAAiB,aAAa,aAAc;AAC5C,QAAM,YAAY,YAAY,aAAa;AAE3C,MAAK,CAAE,aAAa,CAAE,UAAU,YAAa;AAC5C,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,UAAU,WAAY,CAAE;AACtC,QAAM,iBAAiB,MAAM,WAAW;AACxC,QAAM,gBAAY,4BAAAC,SAAoB,SAAU;AAChD,QAAM,cAAc,UAAU;AAG9B,MAAK,CAAE,aAAc;AACpB,mBAAe,SAAU,CAAE,SAAU;AAAA,EACtC;AAEA,QAAM,yBAAqB,gCAAAC,SAAuB,cAAe;AACjE,QAAM,gBAAY,gCAAAA,SAAuB,KAAM;AAE/C,MAAK,CAAE,sBAAsB,CAAE,WAAY;AAC1C,WAAO;AAAA,EACR;AAKA,QAAM,kBAAc,wBAAAC,SAAgB,KAAM;AAC1C,MACC,CAAE,eACF,eACA,cAAc,mBAAmB,UACjC,cAAc,WACb;AACD,WAAO;AAAA,EACR;AAGA,QAAM,mBAAe,cAAAC,SAAO,SAAU,IAAI,CAAE,YAAY;AACxD,QAAM,gBAAgB,UAAU,sBAAsB;AAYtD,QAAM,IAAI,eAAe,cAAc,OAAO,IAAI,cAAc,QAAQ;AACxE,QAAM,IAAI,YAAY,cAAc,MAAM,IAAI,cAAc,SAAS;AACrE,QAAM,gBAAY;AAAA,IAAiB;AAAA,IAAW;AAAA,IAAW,UACxD,qCAAAC,SAA2B,eAAe,GAAG,GAAG,SAAU;AAAA,EAC3D;AAEA,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAEA,QAAM,eAAW,gCAAAH,SAAuB,SAAU;AAElD,MAAK,CAAE,UAAW;AACjB,WAAO;AAAA,EACR;AAEA,QAAM,eAAe,YAAY,QAAQ;AACzC,QAAM,iBAAiB,eAAe,SAAS;AAC/C,QAAM,eAAe,SAAU,YAAa,IAAI,UAAW,YAAa;AACxE,QAAM,iBACL,SAAU,cAAe,IAAI,mBAAoB,cAAe;AAGjE,QAAM,kBAAkB,KAAK,IAAK,YAAa,KAAK;AACpD,QAAM,oBAAoB,KAAK,IAAK,cAAe,KAAK;AAExD,SAAO,eACJ,kBACA,mBAAmB;AACvB;",
|
|
6
|
+
"names": ["isInputOrTextArea", "isSelectionForward", "getRectangleFromRange", "getRangeHeight", "isRTL", "hiddenCaretRangeFromPoint"]
|
|
7
|
+
}
|
package/build/dom/is-element.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
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 is_element_exports = {};
|
|
20
|
+
__export(is_element_exports, {
|
|
21
|
+
default: () => isElement
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
/* eslint-disable jsdoc/valid-types */
|
|
8
|
-
/**
|
|
9
|
-
* @param {Node | null | undefined} node
|
|
10
|
-
* @return {node is Element} True if node is an Element node
|
|
11
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(is_element_exports);
|
|
12
24
|
function isElement(node) {
|
|
13
|
-
/* eslint-enable jsdoc/valid-types */
|
|
14
25
|
return !!node && node.nodeType === node.ELEMENT_NODE;
|
|
15
26
|
}
|
|
16
|
-
//# sourceMappingURL=is-element.js.map
|
|
27
|
+
//# sourceMappingURL=is-element.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/is-element.js"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Node | null | undefined} node\n * @return {node is Element} True if node is an Element node\n */\nexport default function isElement( node ) {\n\t/* eslint-enable jsdoc/valid-types */\n\treturn !! node && node.nodeType === node.ELEMENT_NODE;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKe,SAAR,UAA4B,MAAO;AAEzC,SAAO,CAAC,CAAE,QAAQ,KAAK,aAAa,KAAK;AAC1C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/dom/is-empty.js
CHANGED
|
@@ -1,32 +1,42 @@
|
|
|
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 is_empty_exports = {};
|
|
20
|
+
__export(is_empty_exports, {
|
|
21
|
+
default: () => isEmpty
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
/**
|
|
8
|
-
* Recursively checks if an element is empty. An element is not empty if it
|
|
9
|
-
* contains text or contains elements with attributes such as images.
|
|
10
|
-
*
|
|
11
|
-
* @param {Element} element The element to check.
|
|
12
|
-
*
|
|
13
|
-
* @return {boolean} Whether or not the element is empty.
|
|
14
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(is_empty_exports);
|
|
15
24
|
function isEmpty(element) {
|
|
16
25
|
switch (element.nodeType) {
|
|
17
26
|
case element.TEXT_NODE:
|
|
18
|
-
|
|
19
|
-
// to preserve.
|
|
20
|
-
return /^[ \f\n\r\t\v\u00a0]*$/.test(element.nodeValue || '');
|
|
27
|
+
return /^[ \f\n\r\t\v\u00a0]*$/.test(element.nodeValue || "");
|
|
21
28
|
case element.ELEMENT_NODE:
|
|
22
29
|
if (element.hasAttributes()) {
|
|
23
30
|
return false;
|
|
24
31
|
} else if (!element.hasChildNodes()) {
|
|
25
32
|
return true;
|
|
26
33
|
}
|
|
27
|
-
return
|
|
34
|
+
return (
|
|
35
|
+
/** @type {Element[]} */
|
|
36
|
+
Array.from(element.childNodes).every(isEmpty)
|
|
37
|
+
);
|
|
28
38
|
default:
|
|
29
39
|
return true;
|
|
30
40
|
}
|
|
31
41
|
}
|
|
32
|
-
//# sourceMappingURL=is-empty.js.map
|
|
42
|
+
//# sourceMappingURL=is-empty.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/is-empty.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Recursively checks if an element is empty. An element is not empty if it\n * contains text or contains elements with attributes such as images.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} Whether or not the element is empty.\n */\nexport default function isEmpty( element ) {\n\tswitch ( element.nodeType ) {\n\t\tcase element.TEXT_NODE:\n\t\t\t// We cannot use \\s since it includes special spaces which we want\n\t\t\t// to preserve.\n\t\t\treturn /^[ \\f\\n\\r\\t\\v\\u00a0]*$/.test( element.nodeValue || '' );\n\t\tcase element.ELEMENT_NODE:\n\t\t\tif ( element.hasAttributes() ) {\n\t\t\t\treturn false;\n\t\t\t} else if ( ! element.hasChildNodes() ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn /** @type {Element[]} */ (\n\t\t\t\tArray.from( element.childNodes )\n\t\t\t).every( isEmpty );\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQe,SAAR,QAA0B,SAAU;AAC1C,UAAS,QAAQ,UAAW;AAAA,IAC3B,KAAK,QAAQ;AAGZ,aAAO,yBAAyB,KAAM,QAAQ,aAAa,EAAG;AAAA,IAC/D,KAAK,QAAQ;AACZ,UAAK,QAAQ,cAAc,GAAI;AAC9B,eAAO;AAAA,MACR,WAAY,CAAE,QAAQ,cAAc,GAAI;AACvC,eAAO;AAAA,MACR;AAEA;AAAA;AAAA,QACC,MAAM,KAAM,QAAQ,UAAW,EAC9B,MAAO,OAAQ;AAAA;AAAA,IAClB;AACC,aAAO;AAAA,EACT;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,71 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
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 });
|
|
11
|
+
};
|
|
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var is_entirely_selected_exports = {};
|
|
30
|
+
__export(is_entirely_selected_exports, {
|
|
31
|
+
default: () => isEntirelySelected
|
|
6
32
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Check whether the contents of the element have been entirely selected.
|
|
16
|
-
* Returns true if there is no possibility of selection.
|
|
17
|
-
*
|
|
18
|
-
* @param {HTMLElement} element The element to check.
|
|
19
|
-
*
|
|
20
|
-
* @return {boolean} True if entirely selected, false if not.
|
|
21
|
-
*/
|
|
33
|
+
module.exports = __toCommonJS(is_entirely_selected_exports);
|
|
34
|
+
var import_assert_is_defined = require("../utils/assert-is-defined");
|
|
35
|
+
var import_is_input_or_text_area = __toESM(require("./is-input-or-text-area"));
|
|
22
36
|
function isEntirelySelected(element) {
|
|
23
|
-
if ((0,
|
|
37
|
+
if ((0, import_is_input_or_text_area.default)(element)) {
|
|
24
38
|
return element.selectionStart === 0 && element.value.length === element.selectionEnd;
|
|
25
39
|
}
|
|
26
40
|
if (!element.isContentEditable) {
|
|
27
41
|
return true;
|
|
28
42
|
}
|
|
29
|
-
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const {
|
|
33
|
-
defaultView
|
|
34
|
-
} = ownerDocument;
|
|
35
|
-
(0, _assertIsDefined.assertIsDefined)(defaultView, 'defaultView');
|
|
43
|
+
const { ownerDocument } = element;
|
|
44
|
+
const { defaultView } = ownerDocument;
|
|
45
|
+
(0, import_assert_is_defined.assertIsDefined)(defaultView, "defaultView");
|
|
36
46
|
const selection = defaultView.getSelection();
|
|
37
|
-
(0,
|
|
47
|
+
(0, import_assert_is_defined.assertIsDefined)(selection, "selection");
|
|
38
48
|
const range = selection.rangeCount ? selection.getRangeAt(0) : null;
|
|
39
49
|
if (!range) {
|
|
40
50
|
return true;
|
|
41
51
|
}
|
|
42
|
-
const {
|
|
43
|
-
startContainer,
|
|
44
|
-
endContainer,
|
|
45
|
-
startOffset,
|
|
46
|
-
endOffset
|
|
47
|
-
} = range;
|
|
52
|
+
const { startContainer, endContainer, startOffset, endOffset } = range;
|
|
48
53
|
if (startContainer === element && endContainer === element && startOffset === 0 && endOffset === element.childNodes.length) {
|
|
49
54
|
return true;
|
|
50
55
|
}
|
|
51
56
|
const lastChild = element.lastChild;
|
|
52
|
-
(0,
|
|
53
|
-
const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ?
|
|
54
|
-
|
|
57
|
+
(0, import_assert_is_defined.assertIsDefined)(lastChild, "lastChild");
|
|
58
|
+
const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ? (
|
|
59
|
+
/** @type {Text} */
|
|
60
|
+
endContainer.data.length
|
|
61
|
+
) : endContainer.childNodes.length;
|
|
62
|
+
return isDeepChild(startContainer, element, "firstChild") && isDeepChild(endContainer, element, "lastChild") && startOffset === 0 && endOffset === endContainerContentLength;
|
|
55
63
|
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Check whether the contents of the element have been entirely selected.
|
|
59
|
-
* Returns true if there is no possibility of selection.
|
|
60
|
-
*
|
|
61
|
-
* @param {HTMLElement|Node} query The element to check.
|
|
62
|
-
* @param {HTMLElement} container The container that we suspect "query" may be a first or last child of.
|
|
63
|
-
* @param {"firstChild"|"lastChild"} propName "firstChild" or "lastChild"
|
|
64
|
-
*
|
|
65
|
-
* @return {boolean} True if query is a deep first/last child of container, false otherwise.
|
|
66
|
-
*/
|
|
67
64
|
function isDeepChild(query, container, propName) {
|
|
68
|
-
/** @type {HTMLElement | ChildNode | null} */
|
|
69
65
|
let candidate = container;
|
|
70
66
|
do {
|
|
71
67
|
if (query === candidate) {
|
|
@@ -75,4 +71,4 @@ function isDeepChild(query, container, propName) {
|
|
|
75
71
|
} while (candidate);
|
|
76
72
|
return false;
|
|
77
73
|
}
|
|
78
|
-
//# sourceMappingURL=is-entirely-selected.js.map
|
|
74
|
+
//# sourceMappingURL=is-entirely-selected.js.map
|