@wordpress/dom 3.38.0 → 3.40.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 +4 -0
- package/README.md +2 -2
- package/build/data-transfer.js +0 -2
- package/build/data-transfer.js.map +1 -1
- package/build/dom/caret-range-from-point.js +3 -5
- package/build/dom/caret-range-from-point.js.map +1 -1
- package/build/dom/clean-node-list.js +25 -42
- package/build/dom/clean-node-list.js.map +1 -1
- package/build/dom/compute-caret-rect.js +0 -6
- package/build/dom/compute-caret-rect.js.map +1 -1
- package/build/dom/document-has-selection.js +0 -5
- package/build/dom/document-has-selection.js.map +1 -1
- package/build/dom/document-has-text-selection.js +0 -2
- package/build/dom/document-has-text-selection.js.map +1 -1
- package/build/dom/document-has-uncollapsed-selection.js +0 -4
- package/build/dom/document-has-uncollapsed-selection.js.map +1 -1
- package/build/dom/get-computed-style.js +0 -3
- package/build/dom/get-computed-style.js.map +1 -1
- package/build/dom/get-offset-parent.js +8 -19
- package/build/dom/get-offset-parent.js.map +1 -1
- package/build/dom/get-range-height.js +0 -3
- package/build/dom/get-range-height.js.map +1 -1
- package/build/dom/get-rectangle-from-range.js +15 -22
- package/build/dom/get-rectangle-from-range.js.map +1 -1
- package/build/dom/get-scroll-container.js +3 -13
- package/build/dom/get-scroll-container.js.map +1 -1
- package/build/dom/hidden-caret-range-from-point.js +2 -6
- package/build/dom/hidden-caret-range-from-point.js.map +1 -1
- package/build/dom/index.js +0 -27
- package/build/dom/index.js.map +1 -1
- package/build/dom/input-field-has-uncollapsed-selection.js +8 -12
- package/build/dom/input-field-has-uncollapsed-selection.js.map +1 -1
- package/build/dom/insert-after.js +0 -2
- package/build/dom/insert-after.js.map +1 -1
- package/build/dom/is-edge.js +18 -40
- package/build/dom/is-edge.js.map +1 -1
- package/build/dom/is-element.js +0 -2
- package/build/dom/is-element.js.map +1 -1
- package/build/dom/is-empty.js +1 -7
- package/build/dom/is-empty.js.map +1 -1
- package/build/dom/is-entirely-selected.js +2 -18
- package/build/dom/is-entirely-selected.js.map +1 -1
- package/build/dom/is-form-element.js +0 -4
- package/build/dom/is-form-element.js.map +1 -1
- package/build/dom/is-horizontal-edge.js +2 -5
- package/build/dom/is-horizontal-edge.js.map +1 -1
- package/build/dom/is-html-input-element.js +0 -2
- package/build/dom/is-html-input-element.js.map +1 -1
- package/build/dom/is-input-or-text-area.js +0 -2
- package/build/dom/is-input-or-text-area.js.map +1 -1
- package/build/dom/is-number-input.js +0 -6
- package/build/dom/is-number-input.js.map +1 -1
- package/build/dom/is-rtl.js +0 -3
- package/build/dom/is-rtl.js.map +1 -1
- package/build/dom/is-selection-forward.js +6 -10
- package/build/dom/is-selection-forward.js.map +1 -1
- package/build/dom/is-text-field.js +1 -7
- package/build/dom/is-text-field.js.map +1 -1
- package/build/dom/is-vertical-edge.js +2 -5
- package/build/dom/is-vertical-edge.js.map +1 -1
- package/build/dom/place-caret-at-edge.js +8 -31
- package/build/dom/place-caret-at-edge.js.map +1 -1
- package/build/dom/place-caret-at-horizontal-edge.js +0 -3
- package/build/dom/place-caret-at-horizontal-edge.js.map +1 -1
- package/build/dom/place-caret-at-vertical-edge.js +0 -3
- package/build/dom/place-caret-at-vertical-edge.js.map +1 -1
- package/build/dom/remove-invalid-html.js +0 -3
- package/build/dom/remove-invalid-html.js.map +1 -1
- package/build/dom/remove.js +0 -2
- package/build/dom/remove.js.map +1 -1
- package/build/dom/replace-tag.js +0 -4
- package/build/dom/replace-tag.js.map +1 -1
- package/build/dom/replace.js +0 -5
- package/build/dom/replace.js.map +1 -1
- package/build/dom/safe-html.js +0 -8
- package/build/dom/safe-html.js.map +1 -1
- package/build/dom/scroll-if-no-range.js +31 -0
- package/build/dom/scroll-if-no-range.js.map +1 -0
- package/build/dom/strip-html.js +0 -3
- package/build/dom/strip-html.js.map +1 -1
- package/build/dom/unwrap.js +0 -4
- package/build/dom/unwrap.js.map +1 -1
- package/build/dom/wrap.js +0 -2
- package/build/dom/wrap.js.map +1 -1
- package/build/focusable.js +5 -18
- package/build/focusable.js.map +1 -1
- package/build/index.js +0 -11
- package/build/index.js.map +1 -1
- package/build/phrasing-content.js +13 -14
- package/build/phrasing-content.js.map +1 -1
- package/build/tabbable.js +21 -37
- package/build/tabbable.js.map +1 -1
- package/build/utils/assert-is-defined.js +0 -1
- package/build/utils/assert-is-defined.js.map +1 -1
- package/build-module/data-transfer.js +0 -1
- package/build-module/data-transfer.js.map +1 -1
- package/build-module/dom/caret-range-from-point.js +3 -4
- package/build-module/dom/caret-range-from-point.js.map +1 -1
- package/build-module/dom/clean-node-list.js +24 -35
- package/build-module/dom/clean-node-list.js.map +1 -1
- package/build-module/dom/compute-caret-rect.js +1 -3
- package/build-module/dom/compute-caret-rect.js.map +1 -1
- package/build-module/dom/document-has-selection.js +1 -1
- package/build-module/dom/document-has-selection.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 +1 -1
- package/build-module/dom/document-has-uncollapsed-selection.js.map +1 -1
- package/build-module/dom/get-computed-style.js +1 -2
- package/build-module/dom/get-computed-style.js.map +1 -1
- package/build-module/dom/get-offset-parent.js +9 -17
- package/build-module/dom/get-offset-parent.js.map +1 -1
- package/build-module/dom/get-range-height.js +0 -2
- package/build-module/dom/get-range-height.js.map +1 -1
- package/build-module/dom/get-rectangle-from-range.js +16 -21
- package/build-module/dom/get-rectangle-from-range.js.map +1 -1
- package/build-module/dom/get-scroll-container.js +4 -11
- package/build-module/dom/get-scroll-container.js.map +1 -1
- package/build-module/dom/hidden-caret-range-from-point.js +3 -3
- package/build-module/dom/hidden-caret-range-from-point.js.map +1 -1
- package/build-module/dom/index.js.map +1 -1
- package/build-module/dom/input-field-has-uncollapsed-selection.js +9 -9
- package/build-module/dom/input-field-has-uncollapsed-selection.js.map +1 -1
- package/build-module/dom/insert-after.js +1 -1
- package/build-module/dom/insert-after.js.map +1 -1
- package/build-module/dom/is-edge.js +19 -32
- package/build-module/dom/is-edge.js.map +1 -1
- package/build-module/dom/is-element.js +0 -1
- package/build-module/dom/is-element.js.map +1 -1
- package/build-module/dom/is-empty.js +1 -6
- package/build-module/dom/is-empty.js.map +1 -1
- package/build-module/dom/is-entirely-selected.js +3 -14
- package/build-module/dom/is-entirely-selected.js.map +1 -1
- package/build-module/dom/is-form-element.js +1 -2
- package/build-module/dom/is-form-element.js.map +1 -1
- package/build-module/dom/is-horizontal-edge.js +3 -3
- package/build-module/dom/is-horizontal-edge.js.map +1 -1
- package/build-module/dom/is-html-input-element.js +0 -1
- package/build-module/dom/is-html-input-element.js.map +1 -1
- package/build-module/dom/is-input-or-text-area.js +0 -1
- package/build-module/dom/is-input-or-text-area.js.map +1 -1
- package/build-module/dom/is-number-input.js +2 -4
- package/build-module/dom/is-number-input.js.map +1 -1
- package/build-module/dom/is-rtl.js +1 -1
- package/build-module/dom/is-rtl.js.map +1 -1
- package/build-module/dom/is-selection-forward.js +7 -9
- package/build-module/dom/is-selection-forward.js.map +1 -1
- package/build-module/dom/is-text-field.js +2 -5
- package/build-module/dom/is-text-field.js.map +1 -1
- package/build-module/dom/is-vertical-edge.js +3 -3
- package/build-module/dom/is-vertical-edge.js.map +1 -1
- package/build-module/dom/place-caret-at-edge.js +9 -26
- package/build-module/dom/place-caret-at-edge.js.map +1 -1
- package/build-module/dom/place-caret-at-horizontal-edge.js +1 -1
- package/build-module/dom/place-caret-at-horizontal-edge.js.map +1 -1
- package/build-module/dom/place-caret-at-vertical-edge.js +1 -1
- package/build-module/dom/place-caret-at-vertical-edge.js.map +1 -1
- package/build-module/dom/remove-invalid-html.js +1 -1
- package/build-module/dom/remove-invalid-html.js.map +1 -1
- package/build-module/dom/remove.js +1 -1
- package/build-module/dom/remove.js.map +1 -1
- package/build-module/dom/replace-tag.js +1 -3
- package/build-module/dom/replace-tag.js.map +1 -1
- package/build-module/dom/replace.js +1 -1
- package/build-module/dom/replace.js.map +1 -1
- package/build-module/dom/safe-html.js +1 -6
- package/build-module/dom/safe-html.js.map +1 -1
- package/build-module/dom/scroll-if-no-range.js +25 -0
- package/build-module/dom/scroll-if-no-range.js.map +1 -0
- package/build-module/dom/strip-html.js +1 -1
- package/build-module/dom/strip-html.js.map +1 -1
- package/build-module/dom/unwrap.js +1 -3
- package/build-module/dom/unwrap.js.map +1 -1
- package/build-module/dom/wrap.js +1 -1
- package/build-module/dom/wrap.js.map +1 -1
- package/build-module/focusable.js +5 -17
- package/build-module/focusable.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/phrasing-content.js +13 -11
- package/build-module/phrasing-content.js.map +1 -1
- package/build-module/tabbable.js +22 -33
- package/build-module/tabbable.js.map +1 -1
- package/build-module/utils/assert-is-defined.js.map +1 -1
- package/build-types/dom/is-edge.d.ts +4 -4
- package/build-types/dom/is-edge.d.ts.map +1 -1
- package/build-types/dom/is-horizontal-edge.d.ts +3 -3
- package/build-types/dom/is-horizontal-edge.d.ts.map +1 -1
- package/build-types/dom/is-vertical-edge.d.ts +3 -3
- package/build-types/dom/is-vertical-edge.d.ts.map +1 -1
- package/build-types/dom/place-caret-at-edge.d.ts.map +1 -1
- package/build-types/dom/scroll-if-no-range.d.ts +12 -0
- package/build-types/dom/scroll-if-no-range.d.ts.map +1 -0
- package/build-types/index.d.ts +2 -2
- package/build-types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/dom/is-edge.js +6 -8
- package/src/dom/is-horizontal-edge.js +2 -2
- package/src/dom/is-vertical-edge.js +2 -2
- package/src/dom/place-caret-at-edge.js +5 -19
- package/src/dom/scroll-if-no-range.js +34 -0
- package/tsconfig.tsbuildinfo +1 -1
@@ -8,37 +8,32 @@ import isSelectionForward from './is-selection-forward';
|
|
8
8
|
import hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';
|
9
9
|
import { assertIsDefined } from '../utils/assert-is-defined';
|
10
10
|
import isInputOrTextArea from './is-input-or-text-area';
|
11
|
+
import { scrollIfNoRange } from './scroll-if-no-range';
|
12
|
+
|
11
13
|
/**
|
12
14
|
* Check whether the selection is at the edge of the container. Checks for
|
13
15
|
* horizontal position by default. Set `onlyVertical` to true to check only
|
14
16
|
* vertically.
|
15
17
|
*
|
16
|
-
* @param {
|
17
|
-
* @param {boolean}
|
18
|
-
* @param {boolean}
|
18
|
+
* @param {HTMLElement} container Focusable element.
|
19
|
+
* @param {boolean} isReverse Set to true to check left, false to check right.
|
20
|
+
* @param {boolean} [onlyVertical=false] Set to true to check only vertical position.
|
19
21
|
*
|
20
22
|
* @return {boolean} True if at the edge, false if not.
|
21
23
|
*/
|
22
|
-
|
23
24
|
export default function isEdge(container, isReverse, onlyVertical = false) {
|
24
25
|
if (isInputOrTextArea(container) && typeof container.selectionStart === 'number') {
|
25
26
|
if (container.selectionStart !== container.selectionEnd) {
|
26
27
|
return false;
|
27
28
|
}
|
28
|
-
|
29
29
|
if (isReverse) {
|
30
30
|
return container.selectionStart === 0;
|
31
31
|
}
|
32
|
-
|
33
32
|
return container.value.length === container.selectionStart;
|
34
33
|
}
|
35
|
-
|
36
|
-
if (!
|
37
|
-
/** @type {HTMLElement} */
|
38
|
-
container.isContentEditable) {
|
34
|
+
if (! /** @type {HTMLElement} */container.isContentEditable) {
|
39
35
|
return true;
|
40
36
|
}
|
41
|
-
|
42
37
|
const {
|
43
38
|
ownerDocument
|
44
39
|
} = container;
|
@@ -47,39 +42,37 @@ export default function isEdge(container, isReverse, onlyVertical = false) {
|
|
47
42
|
} = ownerDocument;
|
48
43
|
assertIsDefined(defaultView, 'defaultView');
|
49
44
|
const selection = defaultView.getSelection();
|
50
|
-
|
51
45
|
if (!selection || !selection.rangeCount) {
|
52
46
|
return false;
|
53
47
|
}
|
54
|
-
|
55
48
|
const range = selection.getRangeAt(0);
|
56
49
|
const collapsedRange = range.cloneRange();
|
57
50
|
const isForward = isSelectionForward(selection);
|
58
|
-
const isCollapsed = selection.isCollapsed;
|
51
|
+
const isCollapsed = selection.isCollapsed;
|
59
52
|
|
53
|
+
// Collapse in direction of selection.
|
60
54
|
if (!isCollapsed) {
|
61
55
|
collapsedRange.collapse(!isForward);
|
62
56
|
}
|
63
|
-
|
64
57
|
const collapsedRangeRect = getRectangleFromRange(collapsedRange);
|
65
58
|
const rangeRect = getRectangleFromRange(range);
|
66
|
-
|
67
59
|
if (!collapsedRangeRect || !rangeRect) {
|
68
60
|
return false;
|
69
|
-
}
|
61
|
+
}
|
62
|
+
|
63
|
+
// Only consider the multiline selection at the edge if the direction is
|
70
64
|
// towards the edge. The selection is multiline if it is taller than the
|
71
65
|
// collapsed selection.
|
72
|
-
|
73
|
-
|
74
66
|
const rangeHeight = getRangeHeight(range);
|
75
|
-
|
76
67
|
if (!isCollapsed && rangeHeight && rangeHeight > collapsedRangeRect.height && isForward === isReverse) {
|
77
68
|
return false;
|
78
|
-
}
|
79
|
-
|
69
|
+
}
|
80
70
|
|
71
|
+
// In the case of RTL scripts, the horizontal edge is at the opposite side.
|
81
72
|
const isReverseDir = isRTL(container) ? !isReverse : isReverse;
|
82
|
-
const containerRect = container.getBoundingClientRect();
|
73
|
+
const containerRect = container.getBoundingClientRect();
|
74
|
+
|
75
|
+
// To check if a selection is at the edge, we insert a test selection at the
|
83
76
|
// edge of the container and check if the selections have the same vertical
|
84
77
|
// or horizontal position. If they do, the selection is at the edge.
|
85
78
|
// This method proves to be better than a DOM-based calculation for the
|
@@ -89,28 +82,22 @@ export default function isEdge(container, isReverse, onlyVertical = false) {
|
|
89
82
|
// It also proves better than using the computed style for the vertical
|
90
83
|
// edge, because we cannot know the padding and line height reliably in
|
91
84
|
// pixels. `getComputedStyle` may return a value with different units.
|
92
|
-
|
93
85
|
const x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;
|
94
86
|
const y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;
|
95
|
-
const testRange = hiddenCaretRangeFromPoint(ownerDocument, x, y,
|
96
|
-
/** @type {HTMLElement} */
|
97
|
-
container);
|
98
|
-
|
87
|
+
const testRange = scrollIfNoRange(container, isReverse, () => hiddenCaretRangeFromPoint(ownerDocument, x, y, container));
|
99
88
|
if (!testRange) {
|
100
89
|
return false;
|
101
90
|
}
|
102
|
-
|
103
91
|
const testRect = getRectangleFromRange(testRange);
|
104
|
-
|
105
92
|
if (!testRect) {
|
106
93
|
return false;
|
107
94
|
}
|
108
|
-
|
109
95
|
const verticalSide = isReverse ? 'top' : 'bottom';
|
110
96
|
const horizontalSide = isReverseDir ? 'left' : 'right';
|
111
97
|
const verticalDiff = testRect[verticalSide] - rangeRect[verticalSide];
|
112
|
-
const horizontalDiff = testRect[horizontalSide] - collapsedRangeRect[horizontalSide];
|
98
|
+
const horizontalDiff = testRect[horizontalSide] - collapsedRangeRect[horizontalSide];
|
113
99
|
|
100
|
+
// Allow the position to be 1px off.
|
114
101
|
const hasVerticalDiff = Math.abs(verticalDiff) <= 1;
|
115
102
|
const hasHorizontalDiff = Math.abs(horizontalDiff) <= 1;
|
116
103
|
return onlyVertical ? hasVerticalDiff : hasVerticalDiff && hasHorizontalDiff;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["isRTL","getRangeHeight","getRectangleFromRange","isSelectionForward","hiddenCaretRangeFromPoint","assertIsDefined","isInputOrTextArea","scrollIfNoRange","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"],"sources":["@wordpress/dom/src/dom/is-edge.js"],"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 ( ! ( /** @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 = 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"],"mappings":"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"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["isElement","node","nodeType","ELEMENT_NODE"],"sources":["@wordpress/dom/src/dom/is-element.js"],"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"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,SAASA,CAAEC,IAAI,EAAG;EACzC;EACA,OAAO,CAAC,CAAEA,IAAI,IAAIA,IAAI,CAACC,QAAQ,KAAKD,IAAI,CAACE,YAAY;AACtD"}
|
@@ -12,19 +12,14 @@ export default function isEmpty(element) {
|
|
12
12
|
// We cannot use \s since it includes special spaces which we want
|
13
13
|
// to preserve.
|
14
14
|
return /^[ \f\n\r\t\v\u00a0]*$/.test(element.nodeValue || '');
|
15
|
-
|
16
15
|
case element.ELEMENT_NODE:
|
17
16
|
if (element.hasAttributes()) {
|
18
17
|
return false;
|
19
18
|
} else if (!element.hasChildNodes()) {
|
20
19
|
return true;
|
21
20
|
}
|
22
|
-
|
23
|
-
return (
|
24
|
-
/** @type {Element[]} */
|
25
|
-
Array.from(element.childNodes).every(isEmpty)
|
21
|
+
return (/** @type {Element[]} */Array.from(element.childNodes).every(isEmpty)
|
26
22
|
);
|
27
|
-
|
28
23
|
default:
|
29
24
|
return true;
|
30
25
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["isEmpty","element","nodeType","TEXT_NODE","test","nodeValue","ELEMENT_NODE","hasAttributes","hasChildNodes","Array","from","childNodes","every"],"sources":["@wordpress/dom/src/dom/is-empty.js"],"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"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,OAAOA,CAAEC,OAAO,EAAG;EAC1C,QAASA,OAAO,CAACC,QAAQ;IACxB,KAAKD,OAAO,CAACE,SAAS;MACrB;MACA;MACA,OAAO,wBAAwB,CAACC,IAAI,CAAEH,OAAO,CAACI,SAAS,IAAI,EAAG,CAAC;IAChE,KAAKJ,OAAO,CAACK,YAAY;MACxB,IAAKL,OAAO,CAACM,aAAa,CAAC,CAAC,EAAG;QAC9B,OAAO,KAAK;MACb,CAAC,MAAM,IAAK,CAAEN,OAAO,CAACO,aAAa,CAAC,CAAC,EAAG;QACvC,OAAO,IAAI;MACZ;MAEA,OAAO,yBACNC,KAAK,CAACC,IAAI,CAAET,OAAO,CAACU,UAAW,CAAC,CAC/BC,KAAK,CAAEZ,OAAQ;MAAC;IACnB;MACC,OAAO,IAAI;EACb;AACD"}
|
@@ -3,6 +3,7 @@
|
|
3
3
|
*/
|
4
4
|
import { assertIsDefined } from '../utils/assert-is-defined';
|
5
5
|
import isInputOrTextArea from './is-input-or-text-area';
|
6
|
+
|
6
7
|
/**
|
7
8
|
* Check whether the contents of the element have been entirely selected.
|
8
9
|
* Returns true if there is no possibility of selection.
|
@@ -11,16 +12,13 @@ import isInputOrTextArea from './is-input-or-text-area';
|
|
11
12
|
*
|
12
13
|
* @return {boolean} True if entirely selected, false if not.
|
13
14
|
*/
|
14
|
-
|
15
15
|
export default function isEntirelySelected(element) {
|
16
16
|
if (isInputOrTextArea(element)) {
|
17
17
|
return element.selectionStart === 0 && element.value.length === element.selectionEnd;
|
18
18
|
}
|
19
|
-
|
20
19
|
if (!element.isContentEditable) {
|
21
20
|
return true;
|
22
21
|
}
|
23
|
-
|
24
22
|
const {
|
25
23
|
ownerDocument
|
26
24
|
} = element;
|
@@ -31,29 +29,24 @@ export default function isEntirelySelected(element) {
|
|
31
29
|
const selection = defaultView.getSelection();
|
32
30
|
assertIsDefined(selection, 'selection');
|
33
31
|
const range = selection.rangeCount ? selection.getRangeAt(0) : null;
|
34
|
-
|
35
32
|
if (!range) {
|
36
33
|
return true;
|
37
34
|
}
|
38
|
-
|
39
35
|
const {
|
40
36
|
startContainer,
|
41
37
|
endContainer,
|
42
38
|
startOffset,
|
43
39
|
endOffset
|
44
40
|
} = range;
|
45
|
-
|
46
41
|
if (startContainer === element && endContainer === element && startOffset === 0 && endOffset === element.childNodes.length) {
|
47
42
|
return true;
|
48
43
|
}
|
49
|
-
|
50
44
|
const lastChild = element.lastChild;
|
51
45
|
assertIsDefined(lastChild, 'lastChild');
|
52
|
-
const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ?
|
53
|
-
/** @type {Text} */
|
54
|
-
endContainer.data.length : endContainer.childNodes.length;
|
46
|
+
const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ? /** @type {Text} */endContainer.data.length : endContainer.childNodes.length;
|
55
47
|
return isDeepChild(startContainer, element, 'firstChild') && isDeepChild(endContainer, element, 'lastChild') && startOffset === 0 && endOffset === endContainerContentLength;
|
56
48
|
}
|
49
|
+
|
57
50
|
/**
|
58
51
|
* Check whether the contents of the element have been entirely selected.
|
59
52
|
* Returns true if there is no possibility of selection.
|
@@ -64,19 +57,15 @@ export default function isEntirelySelected(element) {
|
|
64
57
|
*
|
65
58
|
* @return {boolean} True if query is a deep first/last child of container, false otherwise.
|
66
59
|
*/
|
67
|
-
|
68
60
|
function isDeepChild(query, container, propName) {
|
69
61
|
/** @type {HTMLElement | ChildNode | null} */
|
70
62
|
let candidate = container;
|
71
|
-
|
72
63
|
do {
|
73
64
|
if (query === candidate) {
|
74
65
|
return true;
|
75
66
|
}
|
76
|
-
|
77
67
|
candidate = candidate[propName];
|
78
68
|
} while (candidate);
|
79
|
-
|
80
69
|
return false;
|
81
70
|
}
|
82
71
|
//# sourceMappingURL=is-entirely-selected.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["assertIsDefined","isInputOrTextArea","isEntirelySelected","element","selectionStart","value","length","selectionEnd","isContentEditable","ownerDocument","defaultView","selection","getSelection","range","rangeCount","getRangeAt","startContainer","endContainer","startOffset","endOffset","childNodes","lastChild","endContainerContentLength","nodeType","TEXT_NODE","data","isDeepChild","query","container","propName","candidate"],"sources":["@wordpress/dom/src/dom/is-entirely-selected.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n * Check whether the contents of the element have been entirely selected.\n * Returns true if there is no possibility of selection.\n *\n * @param {HTMLElement} element The element to check.\n *\n * @return {boolean} True if entirely selected, false if not.\n */\nexport default function isEntirelySelected( element ) {\n\tif ( isInputOrTextArea( element ) ) {\n\t\treturn (\n\t\t\telement.selectionStart === 0 &&\n\t\t\telement.value.length === element.selectionEnd\n\t\t);\n\t}\n\n\tif ( ! element.isContentEditable ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\n\tif ( ! range ) {\n\t\treturn true;\n\t}\n\n\tconst { startContainer, endContainer, startOffset, endOffset } = range;\n\n\tif (\n\t\tstartContainer === element &&\n\t\tendContainer === element &&\n\t\tstartOffset === 0 &&\n\t\tendOffset === element.childNodes.length\n\t) {\n\t\treturn true;\n\t}\n\n\tconst lastChild = element.lastChild;\n\tassertIsDefined( lastChild, 'lastChild' );\n\tconst endContainerContentLength =\n\t\tendContainer.nodeType === endContainer.TEXT_NODE\n\t\t\t? /** @type {Text} */ ( endContainer ).data.length\n\t\t\t: endContainer.childNodes.length;\n\n\treturn (\n\t\tisDeepChild( startContainer, element, 'firstChild' ) &&\n\t\tisDeepChild( endContainer, element, 'lastChild' ) &&\n\t\tstartOffset === 0 &&\n\t\tendOffset === endContainerContentLength\n\t);\n}\n\n/**\n * Check whether the contents of the element have been entirely selected.\n * Returns true if there is no possibility of selection.\n *\n * @param {HTMLElement|Node} query The element to check.\n * @param {HTMLElement} container The container that we suspect \"query\" may be a first or last child of.\n * @param {\"firstChild\"|\"lastChild\"} propName \"firstChild\" or \"lastChild\"\n *\n * @return {boolean} True if query is a deep first/last child of container, false otherwise.\n */\nfunction isDeepChild( query, container, propName ) {\n\t/** @type {HTMLElement | ChildNode | null} */\n\tlet candidate = container;\n\tdo {\n\t\tif ( query === candidate ) {\n\t\t\treturn true;\n\t\t}\n\t\tcandidate = candidate[ propName ];\n\t} while ( candidate );\n\treturn false;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,4BAA4B;AAC5D,OAAOC,iBAAiB,MAAM,yBAAyB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,kBAAkBA,CAAEC,OAAO,EAAG;EACrD,IAAKF,iBAAiB,CAAEE,OAAQ,CAAC,EAAG;IACnC,OACCA,OAAO,CAACC,cAAc,KAAK,CAAC,IAC5BD,OAAO,CAACE,KAAK,CAACC,MAAM,KAAKH,OAAO,CAACI,YAAY;EAE/C;EAEA,IAAK,CAAEJ,OAAO,CAACK,iBAAiB,EAAG;IAClC,OAAO,IAAI;EACZ;EAEA,MAAM;IAAEC;EAAc,CAAC,GAAGN,OAAO;EACjC,MAAM;IAAEO;EAAY,CAAC,GAAGD,aAAa;EACrCT,eAAe,CAAEU,WAAW,EAAE,aAAc,CAAC;EAC7C,MAAMC,SAAS,GAAGD,WAAW,CAACE,YAAY,CAAC,CAAC;EAC5CZ,eAAe,CAAEW,SAAS,EAAE,WAAY,CAAC;EACzC,MAAME,KAAK,GAAGF,SAAS,CAACG,UAAU,GAAGH,SAAS,CAACI,UAAU,CAAE,CAAE,CAAC,GAAG,IAAI;EAErE,IAAK,CAAEF,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,MAAM;IAAEG,cAAc;IAAEC,YAAY;IAAEC,WAAW;IAAEC;EAAU,CAAC,GAAGN,KAAK;EAEtE,IACCG,cAAc,KAAKb,OAAO,IAC1Bc,YAAY,KAAKd,OAAO,IACxBe,WAAW,KAAK,CAAC,IACjBC,SAAS,KAAKhB,OAAO,CAACiB,UAAU,CAACd,MAAM,EACtC;IACD,OAAO,IAAI;EACZ;EAEA,MAAMe,SAAS,GAAGlB,OAAO,CAACkB,SAAS;EACnCrB,eAAe,CAAEqB,SAAS,EAAE,WAAY,CAAC;EACzC,MAAMC,yBAAyB,GAC9BL,YAAY,CAACM,QAAQ,KAAKN,YAAY,CAACO,SAAS,GAC7C,mBAAsBP,YAAY,CAAGQ,IAAI,CAACnB,MAAM,GAChDW,YAAY,CAACG,UAAU,CAACd,MAAM;EAElC,OACCoB,WAAW,CAAEV,cAAc,EAAEb,OAAO,EAAE,YAAa,CAAC,IACpDuB,WAAW,CAAET,YAAY,EAAEd,OAAO,EAAE,WAAY,CAAC,IACjDe,WAAW,KAAK,CAAC,IACjBC,SAAS,KAAKG,yBAAyB;AAEzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,WAAWA,CAAEC,KAAK,EAAEC,SAAS,EAAEC,QAAQ,EAAG;EAClD;EACA,IAAIC,SAAS,GAAGF,SAAS;EACzB,GAAG;IACF,IAAKD,KAAK,KAAKG,SAAS,EAAG;MAC1B,OAAO,IAAI;IACZ;IACAA,SAAS,GAAGA,SAAS,CAAED,QAAQ,CAAE;EAClC,CAAC,QAASC,SAAS;EACnB,OAAO,KAAK;AACb"}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
* Internal dependencies
|
3
3
|
*/
|
4
4
|
import isInputOrTextArea from './is-input-or-text-area';
|
5
|
+
|
5
6
|
/**
|
6
7
|
*
|
7
8
|
* Detects if element is a form element.
|
@@ -10,12 +11,10 @@ import isInputOrTextArea from './is-input-or-text-area';
|
|
10
11
|
*
|
11
12
|
* @return {boolean} True if form element and false otherwise.
|
12
13
|
*/
|
13
|
-
|
14
14
|
export default function isFormElement(element) {
|
15
15
|
if (!element) {
|
16
16
|
return false;
|
17
17
|
}
|
18
|
-
|
19
18
|
const {
|
20
19
|
tagName
|
21
20
|
} = element;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["isInputOrTextArea","isFormElement","element","tagName","checkForInputTextarea"],"sources":["@wordpress/dom/src/dom/is-form-element.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n *\n * Detects if element is a form element.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} True if form element and false otherwise.\n */\nexport default function isFormElement( element ) {\n\tif ( ! element ) {\n\t\treturn false;\n\t}\n\n\tconst { tagName } = element;\n\tconst checkForInputTextarea = isInputOrTextArea( element );\n\treturn (\n\t\tcheckForInputTextarea || tagName === 'BUTTON' || tagName === 'SELECT'\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,iBAAiB,MAAM,yBAAyB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,aAAaA,CAAEC,OAAO,EAAG;EAChD,IAAK,CAAEA,OAAO,EAAG;IAChB,OAAO,KAAK;EACb;EAEA,MAAM;IAAEC;EAAQ,CAAC,GAAGD,OAAO;EAC3B,MAAME,qBAAqB,GAAGJ,iBAAiB,CAAEE,OAAQ,CAAC;EAC1D,OACCE,qBAAqB,IAAID,OAAO,KAAK,QAAQ,IAAIA,OAAO,KAAK,QAAQ;AAEvE"}
|
@@ -2,15 +2,15 @@
|
|
2
2
|
* Internal dependencies
|
3
3
|
*/
|
4
4
|
import isEdge from './is-edge';
|
5
|
+
|
5
6
|
/**
|
6
7
|
* Check whether the selection is horizontally at the edge of the container.
|
7
8
|
*
|
8
|
-
* @param {
|
9
|
-
* @param {boolean}
|
9
|
+
* @param {HTMLElement} container Focusable element.
|
10
|
+
* @param {boolean} isReverse Set to true to check left, false for right.
|
10
11
|
*
|
11
12
|
* @return {boolean} True if at the horizontal edge, false if not.
|
12
13
|
*/
|
13
|
-
|
14
14
|
export default function isHorizontalEdge(container, isReverse) {
|
15
15
|
return isEdge(container, isReverse);
|
16
16
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["isEdge","isHorizontalEdge","container","isReverse"],"sources":["@wordpress/dom/src/dom/is-horizontal-edge.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isEdge from './is-edge';\n\n/**\n * Check whether the selection is horizontally at the edge of the container.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false for right.\n *\n * @return {boolean} True if at the horizontal edge, false if not.\n */\nexport default function isHorizontalEdge( container, isReverse ) {\n\treturn isEdge( container, isReverse );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,WAAW;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,gBAAgBA,CAAEC,SAAS,EAAEC,SAAS,EAAG;EAChE,OAAOH,MAAM,CAAEE,SAAS,EAAEC,SAAU,CAAC;AACtC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/is-html-input-element.js"],"
|
1
|
+
{"version":3,"names":["isHTMLInputElement","node","nodeName"],"sources":["@wordpress/dom/src/dom/is-html-input-element.js"],"sourcesContent":["/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Node} node\n * @return {node is HTMLInputElement} Whether the node is an HTMLInputElement.\n */\nexport default function isHTMLInputElement( node ) {\n\t/* eslint-enable jsdoc/valid-types */\n\treturn node?.nodeName === 'INPUT';\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,kBAAkBA,CAAEC,IAAI,EAAG;EAClD;EACA,OAAOA,IAAI,EAAEC,QAAQ,KAAK,OAAO;AAClC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["@wordpress/dom/src/dom/is-input-or-text-area.js"],"
|
1
|
+
{"version":3,"names":["isInputOrTextArea","element","tagName"],"sources":["@wordpress/dom/src/dom/is-input-or-text-area.js"],"sourcesContent":["/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Element} element\n * @return {element is HTMLInputElement | HTMLTextAreaElement} Whether the element is an input or textarea\n */\nexport default function isInputOrTextArea( element ) {\n\t/* eslint-enable jsdoc/valid-types */\n\treturn element.tagName === 'INPUT' || element.tagName === 'TEXTAREA';\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,iBAAiBA,CAAEC,OAAO,EAAG;EACpD;EACA,OAAOA,OAAO,CAACC,OAAO,KAAK,OAAO,IAAID,OAAO,CAACC,OAAO,KAAK,UAAU;AACrE"}
|
@@ -2,13 +2,13 @@
|
|
2
2
|
* WordPress dependencies
|
3
3
|
*/
|
4
4
|
import deprecated from '@wordpress/deprecated';
|
5
|
+
|
5
6
|
/**
|
6
7
|
* Internal dependencies
|
7
8
|
*/
|
8
|
-
|
9
9
|
import isHTMLInputElement from './is-html-input-element';
|
10
|
-
/* eslint-disable jsdoc/valid-types */
|
11
10
|
|
11
|
+
/* eslint-disable jsdoc/valid-types */
|
12
12
|
/**
|
13
13
|
* Check whether the given element is an input field of type number.
|
14
14
|
*
|
@@ -16,14 +16,12 @@ import isHTMLInputElement from './is-html-input-element';
|
|
16
16
|
*
|
17
17
|
* @return {node is HTMLInputElement} True if the node is number input.
|
18
18
|
*/
|
19
|
-
|
20
19
|
export default function isNumberInput(node) {
|
21
20
|
deprecated('wp.dom.isNumberInput', {
|
22
21
|
since: '6.1',
|
23
22
|
version: '6.5'
|
24
23
|
});
|
25
24
|
/* eslint-enable jsdoc/valid-types */
|
26
|
-
|
27
25
|
return isHTMLInputElement(node) && node.type === 'number' && !isNaN(node.valueAsNumber);
|
28
26
|
}
|
29
27
|
//# sourceMappingURL=is-number-input.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["deprecated","isHTMLInputElement","isNumberInput","node","since","version","type","isNaN","valueAsNumber"],"sources":["@wordpress/dom/src/dom/is-number-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport isHTMLInputElement from './is-html-input-element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Check whether the given element is an input field of type number.\n *\n * @param {Node} node The HTML node.\n *\n * @return {node is HTMLInputElement} True if the node is number input.\n */\nexport default function isNumberInput( node ) {\n\tdeprecated( 'wp.dom.isNumberInput', {\n\t\tsince: '6.1',\n\t\tversion: '6.5',\n\t} );\n\t/* eslint-enable jsdoc/valid-types */\n\treturn (\n\t\tisHTMLInputElement( node ) &&\n\t\tnode.type === 'number' &&\n\t\t! isNaN( node.valueAsNumber )\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,uBAAuB;;AAE9C;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,yBAAyB;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,aAAaA,CAAEC,IAAI,EAAG;EAC7CH,UAAU,CAAE,sBAAsB,EAAE;IACnCI,KAAK,EAAE,KAAK;IACZC,OAAO,EAAE;EACV,CAAE,CAAC;EACH;EACA,OACCJ,kBAAkB,CAAEE,IAAK,CAAC,IAC1BA,IAAI,CAACG,IAAI,KAAK,QAAQ,IACtB,CAAEC,KAAK,CAAEJ,IAAI,CAACK,aAAc,CAAC;AAE/B"}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
* Internal dependencies
|
3
3
|
*/
|
4
4
|
import getComputedStyle from './get-computed-style';
|
5
|
+
|
5
6
|
/**
|
6
7
|
* Whether the element's text direction is right-to-left.
|
7
8
|
*
|
@@ -9,7 +10,6 @@ import getComputedStyle from './get-computed-style';
|
|
9
10
|
*
|
10
11
|
* @return {boolean} True if rtl, false if ltr.
|
11
12
|
*/
|
12
|
-
|
13
13
|
export default function isRTL(element) {
|
14
14
|
return getComputedStyle(element).direction === 'rtl';
|
15
15
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["getComputedStyle","isRTL","element","direction"],"sources":["@wordpress/dom/src/dom/is-rtl.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Whether the element's text direction is right-to-left.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} True if rtl, false if ltr.\n */\nexport default function isRTL( element ) {\n\treturn getComputedStyle( element ).direction === 'rtl';\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,gBAAgB,MAAM,sBAAsB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,KAAKA,CAAEC,OAAO,EAAG;EACxC,OAAOF,gBAAgB,CAAEE,OAAQ,CAAC,CAACC,SAAS,KAAK,KAAK;AACvD"}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
* Internal dependencies
|
3
3
|
*/
|
4
4
|
import { assertIsDefined } from '../utils/assert-is-defined';
|
5
|
+
|
5
6
|
/**
|
6
7
|
* Returns true if the given selection object is in the forward direction, or
|
7
8
|
* false otherwise.
|
@@ -12,7 +13,6 @@ import { assertIsDefined } from '../utils/assert-is-defined';
|
|
12
13
|
*
|
13
14
|
* @return {boolean} Whether the selection is forward.
|
14
15
|
*/
|
15
|
-
|
16
16
|
export default function isSelectionForward(selection) {
|
17
17
|
const {
|
18
18
|
anchorNode,
|
@@ -22,30 +22,28 @@ export default function isSelectionForward(selection) {
|
|
22
22
|
} = selection;
|
23
23
|
assertIsDefined(anchorNode, 'anchorNode');
|
24
24
|
assertIsDefined(focusNode, 'focusNode');
|
25
|
-
const position = anchorNode.compareDocumentPosition(focusNode);
|
26
|
-
// so bitwise operators are intended.
|
25
|
+
const position = anchorNode.compareDocumentPosition(focusNode);
|
27
26
|
|
27
|
+
// Disable reason: `Node#compareDocumentPosition` returns a bitmask value,
|
28
|
+
// so bitwise operators are intended.
|
28
29
|
/* eslint-disable no-bitwise */
|
29
30
|
// Compare whether anchor node precedes focus node. If focus node (where
|
30
31
|
// end of selection occurs) is after the anchor node, it is forward.
|
31
|
-
|
32
32
|
if (position & anchorNode.DOCUMENT_POSITION_PRECEDING) {
|
33
33
|
return false;
|
34
34
|
}
|
35
|
-
|
36
35
|
if (position & anchorNode.DOCUMENT_POSITION_FOLLOWING) {
|
37
36
|
return true;
|
38
37
|
}
|
39
38
|
/* eslint-enable no-bitwise */
|
39
|
+
|
40
40
|
// `compareDocumentPosition` returns 0 when passed the same node, in which
|
41
41
|
// case compare offsets.
|
42
|
-
|
43
|
-
|
44
42
|
if (position === 0) {
|
45
43
|
return anchorOffset <= focusOffset;
|
46
|
-
}
|
47
|
-
|
44
|
+
}
|
48
45
|
|
46
|
+
// This should never be reached, but return true as default case.
|
49
47
|
return true;
|
50
48
|
}
|
51
49
|
//# sourceMappingURL=is-selection-forward.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["assertIsDefined","isSelectionForward","selection","anchorNode","focusNode","anchorOffset","focusOffset","position","compareDocumentPosition","DOCUMENT_POSITION_PRECEDING","DOCUMENT_POSITION_FOLLOWING"],"sources":["@wordpress/dom/src/dom/is-selection-forward.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Returns true if the given selection object is in the forward direction, or\n * false otherwise.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition\n *\n * @param {Selection} selection Selection object to check.\n *\n * @return {boolean} Whether the selection is forward.\n */\nexport default function isSelectionForward( selection ) {\n\tconst { anchorNode, focusNode, anchorOffset, focusOffset } = selection;\n\n\tassertIsDefined( anchorNode, 'anchorNode' );\n\tassertIsDefined( focusNode, 'focusNode' );\n\tconst position = anchorNode.compareDocumentPosition( focusNode );\n\n\t// Disable reason: `Node#compareDocumentPosition` returns a bitmask value,\n\t// so bitwise operators are intended.\n\t/* eslint-disable no-bitwise */\n\t// Compare whether anchor node precedes focus node. If focus node (where\n\t// end of selection occurs) is after the anchor node, it is forward.\n\tif ( position & anchorNode.DOCUMENT_POSITION_PRECEDING ) {\n\t\treturn false;\n\t}\n\n\tif ( position & anchorNode.DOCUMENT_POSITION_FOLLOWING ) {\n\t\treturn true;\n\t}\n\t/* eslint-enable no-bitwise */\n\n\t// `compareDocumentPosition` returns 0 when passed the same node, in which\n\t// case compare offsets.\n\tif ( position === 0 ) {\n\t\treturn anchorOffset <= focusOffset;\n\t}\n\n\t// This should never be reached, but return true as default case.\n\treturn true;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,4BAA4B;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,kBAAkBA,CAAEC,SAAS,EAAG;EACvD,MAAM;IAAEC,UAAU;IAAEC,SAAS;IAAEC,YAAY;IAAEC;EAAY,CAAC,GAAGJ,SAAS;EAEtEF,eAAe,CAAEG,UAAU,EAAE,YAAa,CAAC;EAC3CH,eAAe,CAAEI,SAAS,EAAE,WAAY,CAAC;EACzC,MAAMG,QAAQ,GAAGJ,UAAU,CAACK,uBAAuB,CAAEJ,SAAU,CAAC;;EAEhE;EACA;EACA;EACA;EACA;EACA,IAAKG,QAAQ,GAAGJ,UAAU,CAACM,2BAA2B,EAAG;IACxD,OAAO,KAAK;EACb;EAEA,IAAKF,QAAQ,GAAGJ,UAAU,CAACO,2BAA2B,EAAG;IACxD,OAAO,IAAI;EACZ;EACA;;EAEA;EACA;EACA,IAAKH,QAAQ,KAAK,CAAC,EAAG;IACrB,OAAOF,YAAY,IAAIC,WAAW;EACnC;;EAEA;EACA,OAAO,IAAI;AACZ"}
|
@@ -2,8 +2,8 @@
|
|
2
2
|
* Internal dependencies
|
3
3
|
*/
|
4
4
|
import isHTMLInputElement from './is-html-input-element';
|
5
|
-
/* eslint-disable jsdoc/valid-types */
|
6
5
|
|
6
|
+
/* eslint-disable jsdoc/valid-types */
|
7
7
|
/**
|
8
8
|
* Check whether the given element is a text field, where text field is defined
|
9
9
|
* by the ability to select within the input, or that it is contenteditable.
|
@@ -13,12 +13,9 @@ import isHTMLInputElement from './is-html-input-element';
|
|
13
13
|
* @param {Node} node The HTML element.
|
14
14
|
* @return {node is HTMLElement} True if the element is an text field, false if not.
|
15
15
|
*/
|
16
|
-
|
17
16
|
export default function isTextField(node) {
|
18
17
|
/* eslint-enable jsdoc/valid-types */
|
19
18
|
const nonTextInputs = ['button', 'checkbox', 'hidden', 'file', 'radio', 'image', 'range', 'reset', 'submit', 'number', 'email', 'time'];
|
20
|
-
return isHTMLInputElement(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === 'TEXTAREA' ||
|
21
|
-
/** @type {HTMLElement} */
|
22
|
-
node.contentEditable === 'true';
|
19
|
+
return isHTMLInputElement(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === 'TEXTAREA' || /** @type {HTMLElement} */node.contentEditable === 'true';
|
23
20
|
}
|
24
21
|
//# sourceMappingURL=is-text-field.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["isHTMLInputElement","isTextField","node","nonTextInputs","type","includes","nodeName","contentEditable"],"sources":["@wordpress/dom/src/dom/is-text-field.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isHTMLInputElement from './is-html-input-element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Check whether the given element is a text field, where text field is defined\n * by the ability to select within the input, or that it is contenteditable.\n *\n * See: https://html.spec.whatwg.org/#textFieldSelection\n *\n * @param {Node} node The HTML element.\n * @return {node is HTMLElement} True if the element is an text field, false if not.\n */\nexport default function isTextField( node ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tconst nonTextInputs = [\n\t\t'button',\n\t\t'checkbox',\n\t\t'hidden',\n\t\t'file',\n\t\t'radio',\n\t\t'image',\n\t\t'range',\n\t\t'reset',\n\t\t'submit',\n\t\t'number',\n\t\t'email',\n\t\t'time',\n\t];\n\treturn (\n\t\t( isHTMLInputElement( node ) &&\n\t\t\tnode.type &&\n\t\t\t! nonTextInputs.includes( node.type ) ) ||\n\t\tnode.nodeName === 'TEXTAREA' ||\n\t\t/** @type {HTMLElement} */ ( node ).contentEditable === 'true'\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,kBAAkB,MAAM,yBAAyB;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAAEC,IAAI,EAAG;EAC3C;EACA,MAAMC,aAAa,GAAG,CACrB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,MAAM,EACN,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,MAAM,CACN;EACD,OACGH,kBAAkB,CAAEE,IAAK,CAAC,IAC3BA,IAAI,CAACE,IAAI,IACT,CAAED,aAAa,CAACE,QAAQ,CAAEH,IAAI,CAACE,IAAK,CAAC,IACtCF,IAAI,CAACI,QAAQ,KAAK,UAAU,IAC5B,0BAA6BJ,IAAI,CAAGK,eAAe,KAAK,MAAM;AAEhE"}
|
@@ -2,15 +2,15 @@
|
|
2
2
|
* Internal dependencies
|
3
3
|
*/
|
4
4
|
import isEdge from './is-edge';
|
5
|
+
|
5
6
|
/**
|
6
7
|
* Check whether the selection is vertically at the edge of the container.
|
7
8
|
*
|
8
|
-
* @param {
|
9
|
-
* @param {boolean}
|
9
|
+
* @param {HTMLElement} container Focusable element.
|
10
|
+
* @param {boolean} isReverse Set to true to check top, false for bottom.
|
10
11
|
*
|
11
12
|
* @return {boolean} True if at the vertical edge, false if not.
|
12
13
|
*/
|
13
|
-
|
14
14
|
export default function isVerticalEdge(container, isReverse) {
|
15
15
|
return isEdge(container, isReverse, true);
|
16
16
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"names":["isEdge","isVerticalEdge","container","isReverse"],"sources":["@wordpress/dom/src/dom/is-vertical-edge.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isEdge from './is-edge';\n\n/**\n * Check whether the selection is vertically at the edge of the container.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse Set to true to check top, false for bottom.\n *\n * @return {boolean} True if at the vertical edge, false if not.\n */\nexport default function isVerticalEdge( container, isReverse ) {\n\treturn isEdge( container, isReverse, true );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,WAAW;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CAAEC,SAAS,EAAEC,SAAS,EAAG;EAC9D,OAAOH,MAAM,CAAEE,SAAS,EAAEC,SAAS,EAAE,IAAK,CAAC;AAC5C"}
|