@wordpress/dom 4.32.0 → 4.32.1-next.47f435fc9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/data-transfer.js +30 -18
- package/build/data-transfer.js.map +7 -1
- package/build/dom/caret-range-from-point.js +22 -25
- package/build/dom/caret-range-from-point.js.map +7 -1
- package/build/dom/clean-node-list.js +122 -129
- package/build/dom/clean-node-list.js.map +7 -1
- package/build/dom/compute-caret-rect.js +36 -21
- package/build/dom/compute-caret-rect.js.map +7 -1
- package/build/dom/document-has-selection.js +36 -22
- package/build/dom/document-has-selection.js.map +7 -1
- package/build/dom/document-has-text-selection.js +25 -23
- package/build/dom/document-has-text-selection.js.map +7 -1
- package/build/dom/document-has-uncollapsed-selection.js +35 -22
- package/build/dom/document-has-uncollapsed-selection.js.map +7 -1
- package/build/dom/get-computed-style.js +27 -17
- package/build/dom/get-computed-style.js.map +7 -1
- package/build/dom/get-offset-parent.js +43 -32
- package/build/dom/get-offset-parent.js.map +7 -1
- package/build/dom/get-range-height.js +24 -18
- package/build/dom/get-range-height.js.map +7 -1
- package/build/dom/get-rectangle-from-range.js +47 -68
- package/build/dom/get-rectangle-from-range.js.map +7 -1
- package/build/dom/get-scroll-container.js +44 -37
- package/build/dom/get-scroll-container.js.map +7 -1
- package/build/dom/hidden-caret-range-from-point.js +39 -33
- package/build/dom/hidden-caret-range-from-point.js.map +7 -1
- package/build/dom/index.js +116 -195
- package/build/dom/index.js.map +7 -1
- package/build/dom/input-field-has-uncollapsed-selection.js +40 -42
- package/build/dom/input-field-has-uncollapsed-selection.js.map +7 -1
- package/build/dom/insert-after.js +24 -19
- package/build/dom/insert-after.js.map +7 -1
- package/build/dom/is-edge.js +57 -67
- package/build/dom/is-edge.js.map +7 -1
- package/build/dom/is-element.js +22 -11
- package/build/dom/is-element.js.map +7 -1
- package/build/dom/is-empty.js +27 -17
- package/build/dom/is-empty.js.map +7 -1
- package/build/dom/is-entirely-selected.js +46 -50
- package/build/dom/is-entirely-selected.js.map +7 -1
- package/build/dom/is-form-element.js +36 -24
- package/build/dom/is-form-element.js.map +7 -1
- package/build/dom/is-horizontal-edge.js +34 -20
- package/build/dom/is-horizontal-edge.js.map +7 -1
- package/build/dom/is-html-input-element.js +23 -12
- package/build/dom/is-html-input-element.js.map +7 -1
- package/build/dom/is-input-or-text-area.js +23 -12
- package/build/dom/is-input-or-text-area.js.map +7 -1
- package/build/dom/is-number-input.js +38 -29
- package/build/dom/is-number-input.js.map +7 -1
- package/build/dom/is-rtl.js +34 -19
- package/build/dom/is-rtl.js.map +7 -1
- package/build/dom/is-selection-forward.js +26 -40
- package/build/dom/is-selection-forward.js.map +7 -1
- package/build/dom/is-text-field.js +49 -24
- package/build/dom/is-text-field.js.map +7 -1
- package/build/dom/is-vertical-edge.js +34 -20
- package/build/dom/is-vertical-edge.js.map +7 -1
- package/build/dom/place-caret-at-edge.js +52 -55
- package/build/dom/place-caret-at-edge.js.map +7 -1
- package/build/dom/place-caret-at-horizontal-edge.js +34 -18
- package/build/dom/place-caret-at-horizontal-edge.js.map +7 -1
- package/build/dom/place-caret-at-vertical-edge.js +34 -19
- package/build/dom/place-caret-at-vertical-edge.js.map +7 -1
- package/build/dom/remove-invalid-html.js +35 -22
- package/build/dom/remove-invalid-html.js.map +7 -1
- package/build/dom/remove.js +24 -17
- package/build/dom/remove.js.map +7 -1
- package/build/dom/replace-tag.js +24 -19
- package/build/dom/replace-tag.js.map +7 -1
- package/build/dom/replace.js +38 -23
- package/build/dom/replace.js.map +7 -1
- package/build/dom/safe-html.js +39 -28
- package/build/dom/safe-html.js.map +7 -1
- package/build/dom/scroll-if-no-range.js +26 -18
- package/build/dom/scroll-if-no-range.js.map +7 -1
- package/build/dom/strip-html.js +36 -23
- package/build/dom/strip-html.js.map +7 -1
- package/build/dom/unwrap.js +24 -18
- package/build/dom/unwrap.js.map +7 -1
- package/build/dom/wrap.js +24 -17
- package/build/dom/wrap.js.map +7 -1
- package/build/focusable.js +52 -85
- package/build/focusable.js.map +7 -1
- package/build/index.js +44 -58
- package/build/index.js.map +7 -1
- package/build/phrasing-content.js +88 -128
- package/build/phrasing-content.js.map +7 -1
- package/build/tabbable.js +52 -137
- package/build/tabbable.js.map +7 -1
- package/build/utils/assert-is-defined.js +30 -7
- package/build/utils/assert-is-defined.js.map +7 -1
- package/build-module/data-transfer.js +9 -15
- package/build-module/data-transfer.js.map +7 -1
- package/build-module/dom/caret-range-from-point.js +5 -22
- package/build-module/dom/caret-range-from-point.js.map +7 -1
- package/build-module/dom/clean-node-list.js +94 -123
- package/build-module/dom/clean-node-list.js.map +7 -1
- package/build-module/dom/compute-caret-rect.js +8 -16
- package/build-module/dom/compute-caret-rect.js.map +7 -1
- package/build-module/dom/document-has-selection.js +8 -17
- package/build-module/dom/document-has-selection.js.map +7 -1
- package/build-module/dom/document-has-text-selection.js +8 -20
- package/build-module/dom/document-has-text-selection.js.map +7 -1
- package/build-module/dom/document-has-uncollapsed-selection.js +7 -17
- package/build-module/dom/document-has-uncollapsed-selection.js.map +7 -1
- package/build-module/dom/get-computed-style.js +10 -14
- package/build-module/dom/get-computed-style.js.map +7 -1
- package/build-module/dom/get-offset-parent.js +16 -28
- package/build-module/dom/get-offset-parent.js.map +7 -1
- package/build-module/dom/get-range-height.js +7 -15
- package/build-module/dom/get-range-height.js.map +7 -1
- package/build-module/dom/get-rectangle-from-range.js +30 -65
- package/build-module/dom/get-rectangle-from-range.js.map +7 -1
- package/build-module/dom/get-scroll-container.js +16 -32
- package/build-module/dom/get-scroll-container.js.map +7 -1
- package/build-module/dom/hidden-caret-range-from-point.js +11 -28
- package/build-module/dom/hidden-caret-range-from-point.js.map +7 -1
- package/build-module/dom/index.js +57 -28
- package/build-module/dom/index.js.map +7 -1
- package/build-module/dom/input-field-has-uncollapsed-selection.js +12 -37
- package/build-module/dom/input-field-has-uncollapsed-selection.js.map +7 -1
- package/build-module/dom/insert-after.js +7 -16
- package/build-module/dom/insert-after.js.map +7 -1
- package/build-module/dom/is-edge.js +24 -57
- package/build-module/dom/is-edge.js.map +7 -1
- package/build-module/dom/is-element.js +5 -8
- package/build-module/dom/is-element.js.map +7 -1
- package/build-module/dom/is-empty.js +10 -14
- package/build-module/dom/is-empty.js.map +7 -1
- package/build-module/dom/is-entirely-selected.js +18 -45
- package/build-module/dom/is-entirely-selected.js.map +7 -1
- package/build-module/dom/is-form-element.js +8 -19
- package/build-module/dom/is-form-element.js.map +7 -1
- package/build-module/dom/is-horizontal-edge.js +6 -15
- package/build-module/dom/is-horizontal-edge.js.map +7 -1
- package/build-module/dom/is-html-input-element.js +6 -9
- package/build-module/dom/is-html-input-element.js.map +7 -1
- package/build-module/dom/is-input-or-text-area.js +6 -9
- package/build-module/dom/is-input-or-text-area.js.map +7 -1
- package/build-module/dom/is-number-input.js +11 -25
- package/build-module/dom/is-number-input.js.map +7 -1
- package/build-module/dom/is-rtl.js +7 -15
- package/build-module/dom/is-rtl.js.map +7 -1
- package/build-module/dom/is-selection-forward.js +9 -37
- package/build-module/dom/is-selection-forward.js.map +7 -1
- package/build-module/dom/is-text-field.js +22 -20
- package/build-module/dom/is-text-field.js.map +7 -1
- package/build-module/dom/is-vertical-edge.js +6 -15
- package/build-module/dom/is-vertical-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-edge.js +22 -48
- package/build-module/dom/place-caret-at-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-horizontal-edge.js +7 -14
- package/build-module/dom/place-caret-at-horizontal-edge.js.map +7 -1
- package/build-module/dom/place-caret-at-vertical-edge.js +6 -14
- package/build-module/dom/place-caret-at-vertical-edge.js.map +7 -1
- package/build-module/dom/remove-invalid-html.js +7 -17
- package/build-module/dom/remove-invalid-html.js.map +7 -1
- package/build-module/dom/remove.js +7 -14
- package/build-module/dom/remove.js.map +7 -1
- package/build-module/dom/replace-tag.js +7 -16
- package/build-module/dom/replace-tag.js.map +7 -1
- package/build-module/dom/replace.js +9 -17
- package/build-module/dom/replace.js.map +7 -1
- package/build-module/dom/safe-html.js +11 -23
- package/build-module/dom/safe-html.js.map +7 -1
- package/build-module/dom/scroll-if-no-range.js +5 -15
- package/build-module/dom/scroll-if-no-range.js.map +7 -1
- package/build-module/dom/strip-html.js +8 -18
- package/build-module/dom/strip-html.js.map +7 -1
- package/build-module/dom/unwrap.js +7 -15
- package/build-module/dom/unwrap.js.map +7 -1
- package/build-module/dom/wrap.js +7 -14
- package/build-module/dom/wrap.js.map +7 -1
- package/build-module/focusable.js +30 -81
- package/build-module/focusable.js.map +7 -1
- package/build-module/index.js +9 -17
- package/build-module/index.js.map +7 -1
- package/build-module/phrasing-content.js +67 -125
- package/build-module/phrasing-content.js.map +7 -1
- package/build-module/tabbable.js +30 -133
- package/build-module/tabbable.js.map +7 -1
- package/build-module/utils/assert-is-defined.js +9 -4
- package/build-module/utils/assert-is-defined.js.map +7 -1
- package/package.json +11 -4
|
@@ -1,34 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { assertIsDefined } from '../utils/assert-is-defined';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Get the rectangle of a given Range. Returns `null` if no suitable rectangle
|
|
8
|
-
* can be found.
|
|
9
|
-
*
|
|
10
|
-
* @param {Range} range The range.
|
|
11
|
-
*
|
|
12
|
-
* @return {DOMRect?} The rectangle.
|
|
13
|
-
*/
|
|
14
|
-
export default function getRectangleFromRange(range) {
|
|
15
|
-
// For uncollapsed ranges, get the rectangle that bounds the contents of the
|
|
16
|
-
// range; this a rectangle enclosing the union of the bounding rectangles
|
|
17
|
-
// for all the elements in the range.
|
|
1
|
+
import { assertIsDefined } from "../utils/assert-is-defined";
|
|
2
|
+
function getRectangleFromRange(range) {
|
|
18
3
|
if (!range.collapsed) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (rects.length === 1) {
|
|
23
|
-
return rects[0];
|
|
4
|
+
const rects2 = Array.from(range.getClientRects());
|
|
5
|
+
if (rects2.length === 1) {
|
|
6
|
+
return rects2[0];
|
|
24
7
|
}
|
|
25
|
-
|
|
26
|
-
// Ignore tiny selection at the edge of a range.
|
|
27
|
-
const filteredRects = rects.filter(({
|
|
28
|
-
width
|
|
29
|
-
}) => width > 1);
|
|
30
|
-
|
|
31
|
-
// If it's full of tiny selections, return browser default.
|
|
8
|
+
const filteredRects = rects2.filter(({ width }) => width > 1);
|
|
32
9
|
if (filteredRects.length === 0) {
|
|
33
10
|
return range.getBoundingClientRect();
|
|
34
11
|
}
|
|
@@ -41,12 +18,7 @@ export default function getRectangleFromRange(range) {
|
|
|
41
18
|
left: furthestLeft,
|
|
42
19
|
right: furthestRight
|
|
43
20
|
} = filteredRects[0];
|
|
44
|
-
for (const {
|
|
45
|
-
top,
|
|
46
|
-
bottom,
|
|
47
|
-
left,
|
|
48
|
-
right
|
|
49
|
-
} of filteredRects) {
|
|
21
|
+
for (const { top, bottom, left, right } of filteredRects) {
|
|
50
22
|
if (top < furthestTop) {
|
|
51
23
|
furthestTop = top;
|
|
52
24
|
}
|
|
@@ -60,51 +32,44 @@ export default function getRectangleFromRange(range) {
|
|
|
60
32
|
furthestRight = right;
|
|
61
33
|
}
|
|
62
34
|
}
|
|
63
|
-
return new window.DOMRect(
|
|
35
|
+
return new window.DOMRect(
|
|
36
|
+
furthestLeft,
|
|
37
|
+
furthestTop,
|
|
38
|
+
furthestRight - furthestLeft,
|
|
39
|
+
furthestBottom - furthestTop
|
|
40
|
+
);
|
|
64
41
|
}
|
|
65
|
-
const {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
parentNode
|
|
76
|
-
} = startContainer;
|
|
77
|
-
assertIsDefined(parentNode, 'parentNode');
|
|
78
|
-
const index = /** @type {Node[]} */Array.from(parentNode.childNodes).indexOf(startContainer);
|
|
79
|
-
assertIsDefined(ownerDocument, 'ownerDocument');
|
|
42
|
+
const { startContainer } = range;
|
|
43
|
+
const { ownerDocument } = startContainer;
|
|
44
|
+
if (startContainer.nodeName === "BR") {
|
|
45
|
+
const { parentNode } = startContainer;
|
|
46
|
+
assertIsDefined(parentNode, "parentNode");
|
|
47
|
+
const index = (
|
|
48
|
+
/** @type {Node[]} */
|
|
49
|
+
Array.from(parentNode.childNodes).indexOf(startContainer)
|
|
50
|
+
);
|
|
51
|
+
assertIsDefined(ownerDocument, "ownerDocument");
|
|
80
52
|
range = ownerDocument.createRange();
|
|
81
53
|
range.setStart(parentNode, index);
|
|
82
54
|
range.setEnd(parentNode, index);
|
|
83
55
|
}
|
|
84
56
|
const rects = range.getClientRects();
|
|
85
|
-
|
|
86
|
-
// If we have multiple rectangles for a collapsed range, there's no way to
|
|
87
|
-
// know which it is, so don't return anything.
|
|
88
57
|
if (rects.length > 1) {
|
|
89
58
|
return null;
|
|
90
59
|
}
|
|
91
60
|
let rect = rects[0];
|
|
92
|
-
|
|
93
|
-
// If the collapsed range starts (and therefore ends) at an element node,
|
|
94
|
-
// `getClientRects` can be empty in some browsers. This can be resolved
|
|
95
|
-
// by adding a temporary text node with zero-width space to the range.
|
|
96
|
-
//
|
|
97
|
-
// See: https://stackoverflow.com/a/6847328/995445
|
|
98
61
|
if (!rect || rect.height === 0) {
|
|
99
|
-
assertIsDefined(ownerDocument,
|
|
100
|
-
const padNode = ownerDocument.createTextNode(
|
|
101
|
-
// Do not modify the live range.
|
|
62
|
+
assertIsDefined(ownerDocument, "ownerDocument");
|
|
63
|
+
const padNode = ownerDocument.createTextNode("\u200B");
|
|
102
64
|
range = range.cloneRange();
|
|
103
65
|
range.insertNode(padNode);
|
|
104
66
|
rect = range.getClientRects()[0];
|
|
105
|
-
assertIsDefined(padNode.parentNode,
|
|
67
|
+
assertIsDefined(padNode.parentNode, "padNode.parentNode");
|
|
106
68
|
padNode.parentNode.removeChild(padNode);
|
|
107
69
|
}
|
|
108
70
|
return rect;
|
|
109
71
|
}
|
|
110
|
-
|
|
72
|
+
export {
|
|
73
|
+
getRectangleFromRange as default
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=get-rectangle-from-range.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/get-rectangle-from-range.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle of a given Range. Returns `null` if no suitable rectangle\n * can be found.\n *\n * @param {Range} range The range.\n *\n * @return {DOMRect?} The rectangle.\n */\nexport default function getRectangleFromRange( range ) {\n\t// For uncollapsed ranges, get the rectangle that bounds the contents of the\n\t// range; this a rectangle enclosing the union of the bounding rectangles\n\t// for all the elements in the range.\n\tif ( ! range.collapsed ) {\n\t\tconst rects = Array.from( range.getClientRects() );\n\n\t\t// If there's just a single rect, return it.\n\t\tif ( rects.length === 1 ) {\n\t\t\treturn rects[ 0 ];\n\t\t}\n\n\t\t// Ignore tiny selection at the edge of a range.\n\t\tconst filteredRects = rects.filter( ( { width } ) => width > 1 );\n\n\t\t// If it's full of tiny selections, return browser default.\n\t\tif ( filteredRects.length === 0 ) {\n\t\t\treturn range.getBoundingClientRect();\n\t\t}\n\n\t\tif ( filteredRects.length === 1 ) {\n\t\t\treturn filteredRects[ 0 ];\n\t\t}\n\n\t\tlet {\n\t\t\ttop: furthestTop,\n\t\t\tbottom: furthestBottom,\n\t\t\tleft: furthestLeft,\n\t\t\tright: furthestRight,\n\t\t} = filteredRects[ 0 ];\n\n\t\tfor ( const { top, bottom, left, right } of filteredRects ) {\n\t\t\tif ( top < furthestTop ) {\n\t\t\t\tfurthestTop = top;\n\t\t\t}\n\t\t\tif ( bottom > furthestBottom ) {\n\t\t\t\tfurthestBottom = bottom;\n\t\t\t}\n\t\t\tif ( left < furthestLeft ) {\n\t\t\t\tfurthestLeft = left;\n\t\t\t}\n\t\t\tif ( right > furthestRight ) {\n\t\t\t\tfurthestRight = right;\n\t\t\t}\n\t\t}\n\n\t\treturn new window.DOMRect(\n\t\t\tfurthestLeft,\n\t\t\tfurthestTop,\n\t\t\tfurthestRight - furthestLeft,\n\t\t\tfurthestBottom - furthestTop\n\t\t);\n\t}\n\n\tconst { startContainer } = range;\n\tconst { ownerDocument } = startContainer;\n\n\t// Correct invalid \"BR\" ranges. The cannot contain any children.\n\tif ( startContainer.nodeName === 'BR' ) {\n\t\tconst { parentNode } = startContainer;\n\t\tassertIsDefined( parentNode, 'parentNode' );\n\t\tconst index = /** @type {Node[]} */ (\n\t\t\tArray.from( parentNode.childNodes )\n\t\t).indexOf( startContainer );\n\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\trange = ownerDocument.createRange();\n\t\trange.setStart( parentNode, index );\n\t\trange.setEnd( parentNode, index );\n\t}\n\n\tconst rects = range.getClientRects();\n\n\t// If we have multiple rectangles for a collapsed range, there's no way to\n\t// know which it is, so don't return anything.\n\tif ( rects.length > 1 ) {\n\t\treturn null;\n\t}\n\n\tlet rect = rects[ 0 ];\n\n\t// If the collapsed range starts (and therefore ends) at an element node,\n\t// `getClientRects` can be empty in some browsers. This can be resolved\n\t// by adding a temporary text node with zero-width space to the range.\n\t//\n\t// See: https://stackoverflow.com/a/6847328/995445\n\tif ( ! rect || rect.height === 0 ) {\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\tconst padNode = ownerDocument.createTextNode( '\\u200b' );\n\t\t// Do not modify the live range.\n\t\trange = range.cloneRange();\n\t\trange.insertNode( padNode );\n\t\trect = range.getClientRects()[ 0 ];\n\t\tassertIsDefined( padNode.parentNode, 'padNode.parentNode' );\n\t\tpadNode.parentNode.removeChild( padNode );\n\t}\n\n\treturn rect;\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,uBAAuB;AAUjB,SAAR,sBAAwC,OAAQ;AAItD,MAAK,CAAE,MAAM,WAAY;AACxB,UAAMA,SAAQ,MAAM,KAAM,MAAM,eAAe,CAAE;AAGjD,QAAKA,OAAM,WAAW,GAAI;AACzB,aAAOA,OAAO,CAAE;AAAA,IACjB;AAGA,UAAM,gBAAgBA,OAAM,OAAQ,CAAE,EAAE,MAAM,MAAO,QAAQ,CAAE;AAG/D,QAAK,cAAc,WAAW,GAAI;AACjC,aAAO,MAAM,sBAAsB;AAAA,IACpC;AAEA,QAAK,cAAc,WAAW,GAAI;AACjC,aAAO,cAAe,CAAE;AAAA,IACzB;AAEA,QAAI;AAAA,MACH,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,IACR,IAAI,cAAe,CAAE;AAErB,eAAY,EAAE,KAAK,QAAQ,MAAM,MAAM,KAAK,eAAgB;AAC3D,UAAK,MAAM,aAAc;AACxB,sBAAc;AAAA,MACf;AACA,UAAK,SAAS,gBAAiB;AAC9B,yBAAiB;AAAA,MAClB;AACA,UAAK,OAAO,cAAe;AAC1B,uBAAe;AAAA,MAChB;AACA,UAAK,QAAQ,eAAgB;AAC5B,wBAAgB;AAAA,MACjB;AAAA,IACD;AAEA,WAAO,IAAI,OAAO;AAAA,MACjB;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IAClB;AAAA,EACD;AAEA,QAAM,EAAE,eAAe,IAAI;AAC3B,QAAM,EAAE,cAAc,IAAI;AAG1B,MAAK,eAAe,aAAa,MAAO;AACvC,UAAM,EAAE,WAAW,IAAI;AACvB,oBAAiB,YAAY,YAAa;AAC1C,UAAM;AAAA;AAAA,MACL,MAAM,KAAM,WAAW,UAAW,EACjC,QAAS,cAAe;AAAA;AAE1B,oBAAiB,eAAe,eAAgB;AAChD,YAAQ,cAAc,YAAY;AAClC,UAAM,SAAU,YAAY,KAAM;AAClC,UAAM,OAAQ,YAAY,KAAM;AAAA,EACjC;AAEA,QAAM,QAAQ,MAAM,eAAe;AAInC,MAAK,MAAM,SAAS,GAAI;AACvB,WAAO;AAAA,EACR;AAEA,MAAI,OAAO,MAAO,CAAE;AAOpB,MAAK,CAAE,QAAQ,KAAK,WAAW,GAAI;AAClC,oBAAiB,eAAe,eAAgB;AAChD,UAAM,UAAU,cAAc,eAAgB,QAAS;AAEvD,YAAQ,MAAM,WAAW;AACzB,UAAM,WAAY,OAAQ;AAC1B,WAAO,MAAM,eAAe,EAAG,CAAE;AACjC,oBAAiB,QAAQ,YAAY,oBAAqB;AAC1D,YAAQ,WAAW,YAAa,OAAQ;AAAA,EACzC;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": ["rects"]
|
|
7
|
+
}
|
|
@@ -1,40 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import getComputedStyle from './get-computed-style';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Given a DOM node, finds the closest scrollable container node or the node
|
|
8
|
-
* itself, if scrollable.
|
|
9
|
-
*
|
|
10
|
-
* @param {Element | null} node Node from which to start.
|
|
11
|
-
* @param {?string} direction Direction of scrollable container to search for ('vertical', 'horizontal', 'all').
|
|
12
|
-
* Defaults to 'vertical'.
|
|
13
|
-
* @return {Element | undefined} Scrollable container node, if found.
|
|
14
|
-
*/
|
|
15
|
-
export default function getScrollContainer(node, direction = 'vertical') {
|
|
1
|
+
import getComputedStyle from "./get-computed-style";
|
|
2
|
+
function getScrollContainer(node, direction = "vertical") {
|
|
16
3
|
if (!node) {
|
|
17
|
-
return
|
|
4
|
+
return void 0;
|
|
18
5
|
}
|
|
19
|
-
if (direction ===
|
|
20
|
-
// Scrollable if scrollable height exceeds displayed...
|
|
6
|
+
if (direction === "vertical" || direction === "all") {
|
|
21
7
|
if (node.scrollHeight > node.clientHeight) {
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
overflowY
|
|
25
|
-
} = getComputedStyle(node);
|
|
8
|
+
const { overflowY } = getComputedStyle(node);
|
|
26
9
|
if (/(auto|scroll)/.test(overflowY)) {
|
|
27
10
|
return node;
|
|
28
11
|
}
|
|
29
12
|
}
|
|
30
13
|
}
|
|
31
|
-
if (direction ===
|
|
32
|
-
// Scrollable if scrollable width exceeds displayed...
|
|
14
|
+
if (direction === "horizontal" || direction === "all") {
|
|
33
15
|
if (node.scrollWidth > node.clientWidth) {
|
|
34
|
-
|
|
35
|
-
const {
|
|
36
|
-
overflowX
|
|
37
|
-
} = getComputedStyle(node);
|
|
16
|
+
const { overflowX } = getComputedStyle(node);
|
|
38
17
|
if (/(auto|scroll)/.test(overflowX)) {
|
|
39
18
|
return node;
|
|
40
19
|
}
|
|
@@ -43,8 +22,13 @@ export default function getScrollContainer(node, direction = 'vertical') {
|
|
|
43
22
|
if (node.ownerDocument === node.parentNode) {
|
|
44
23
|
return node;
|
|
45
24
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
25
|
+
return getScrollContainer(
|
|
26
|
+
/** @type {Element} */
|
|
27
|
+
node.parentNode,
|
|
28
|
+
direction
|
|
29
|
+
);
|
|
49
30
|
}
|
|
50
|
-
|
|
31
|
+
export {
|
|
32
|
+
getScrollContainer as default
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=get-scroll-container.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/get-scroll-container.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Given a DOM node, finds the closest scrollable container node or the node\n * itself, if scrollable.\n *\n * @param {Element | null} node Node from which to start.\n * @param {?string} direction Direction of scrollable container to search for ('vertical', 'horizontal', 'all').\n * Defaults to 'vertical'.\n * @return {Element | undefined} Scrollable container node, if found.\n */\nexport default function getScrollContainer( node, direction = 'vertical' ) {\n\tif ( ! node ) {\n\t\treturn undefined;\n\t}\n\n\tif ( direction === 'vertical' || direction === 'all' ) {\n\t\t// Scrollable if scrollable height exceeds displayed...\n\t\tif ( node.scrollHeight > node.clientHeight ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowY } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowY ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( direction === 'horizontal' || direction === 'all' ) {\n\t\t// Scrollable if scrollable width exceeds displayed...\n\t\tif ( node.scrollWidth > node.clientWidth ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowX } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowX ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( node.ownerDocument === node.parentNode ) {\n\t\treturn node;\n\t}\n\n\t// Continue traversing.\n\treturn getScrollContainer(\n\t\t/** @type {Element} */ ( node.parentNode ),\n\t\tdirection\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,sBAAsB;AAWd,SAAR,mBAAqC,MAAM,YAAY,YAAa;AAC1E,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,MAAK,cAAc,cAAc,cAAc,OAAQ;AAEtD,QAAK,KAAK,eAAe,KAAK,cAAe;AAE5C,YAAM,EAAE,UAAU,IAAI,iBAAkB,IAAK;AAE7C,UAAK,gBAAgB,KAAM,SAAU,GAAI;AACxC,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,MAAK,cAAc,gBAAgB,cAAc,OAAQ;AAExD,QAAK,KAAK,cAAc,KAAK,aAAc;AAE1C,YAAM,EAAE,UAAU,IAAI,iBAAkB,IAAK;AAE7C,UAAK,gBAAgB,KAAM,SAAU,GAAI;AACxC,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,MAAK,KAAK,kBAAkB,KAAK,YAAa;AAC7C,WAAO;AAAA,EACR;AAGA,SAAO;AAAA;AAAA,IACmB,KAAK;AAAA,IAC9B;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,36 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import caretRangeFromPoint from './caret-range-from-point';
|
|
5
|
-
import getComputedStyle from './get-computed-style';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Get a collapsed range for a given point.
|
|
9
|
-
* Gives the container a temporary high z-index (above any UI).
|
|
10
|
-
* This is preferred over getting the UI nodes and set styles there.
|
|
11
|
-
*
|
|
12
|
-
* @param {Document} doc The document of the range.
|
|
13
|
-
* @param {number} x Horizontal position within the current viewport.
|
|
14
|
-
* @param {number} y Vertical position within the current viewport.
|
|
15
|
-
* @param {HTMLElement} container Container in which the range is expected to be found.
|
|
16
|
-
*
|
|
17
|
-
* @return {?Range} The best range for the given point.
|
|
18
|
-
*/
|
|
19
|
-
export default function hiddenCaretRangeFromPoint(doc, x, y, container) {
|
|
1
|
+
import caretRangeFromPoint from "./caret-range-from-point";
|
|
2
|
+
import getComputedStyle from "./get-computed-style";
|
|
3
|
+
function hiddenCaretRangeFromPoint(doc, x, y, container) {
|
|
20
4
|
const originalZIndex = container.style.zIndex;
|
|
21
5
|
const originalPosition = container.style.position;
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// A z-index only works if the element position is not static.
|
|
27
|
-
if (position === 'static') {
|
|
28
|
-
container.style.position = 'relative';
|
|
6
|
+
const { position = "static" } = getComputedStyle(container);
|
|
7
|
+
if (position === "static") {
|
|
8
|
+
container.style.position = "relative";
|
|
29
9
|
}
|
|
30
|
-
container.style.zIndex =
|
|
10
|
+
container.style.zIndex = "10000";
|
|
31
11
|
const range = caretRangeFromPoint(doc, x, y);
|
|
32
12
|
container.style.zIndex = originalZIndex;
|
|
33
13
|
container.style.position = originalPosition;
|
|
34
14
|
return range;
|
|
35
15
|
}
|
|
36
|
-
|
|
16
|
+
export {
|
|
17
|
+
hiddenCaretRangeFromPoint as default
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=hidden-caret-range-from-point.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/hidden-caret-range-from-point.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport caretRangeFromPoint from './caret-range-from-point';\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Get a collapsed range for a given point.\n * Gives the container a temporary high z-index (above any UI).\n * This is preferred over getting the UI nodes and set styles there.\n *\n * @param {Document} doc The document of the range.\n * @param {number} x Horizontal position within the current viewport.\n * @param {number} y Vertical position within the current viewport.\n * @param {HTMLElement} container Container in which the range is expected to be found.\n *\n * @return {?Range} The best range for the given point.\n */\nexport default function hiddenCaretRangeFromPoint( doc, x, y, container ) {\n\tconst originalZIndex = container.style.zIndex;\n\tconst originalPosition = container.style.position;\n\n\tconst { position = 'static' } = getComputedStyle( container );\n\n\t// A z-index only works if the element position is not static.\n\tif ( position === 'static' ) {\n\t\tcontainer.style.position = 'relative';\n\t}\n\n\tcontainer.style.zIndex = '10000';\n\n\tconst range = caretRangeFromPoint( doc, x, y );\n\n\tcontainer.style.zIndex = originalZIndex;\n\tcontainer.style.position = originalPosition;\n\n\treturn range;\n}\n"],
|
|
5
|
+
"mappings": "AAGA,OAAO,yBAAyB;AAChC,OAAO,sBAAsB;AAcd,SAAR,0BAA4C,KAAK,GAAG,GAAG,WAAY;AACzE,QAAM,iBAAiB,UAAU,MAAM;AACvC,QAAM,mBAAmB,UAAU,MAAM;AAEzC,QAAM,EAAE,WAAW,SAAS,IAAI,iBAAkB,SAAU;AAG5D,MAAK,aAAa,UAAW;AAC5B,cAAU,MAAM,WAAW;AAAA,EAC5B;AAEA,YAAU,MAAM,SAAS;AAEzB,QAAM,QAAQ,oBAAqB,KAAK,GAAG,CAAE;AAE7C,YAAU,MAAM,SAAS;AACzB,YAAU,MAAM,WAAW;AAE3B,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,28 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
import { default as default2 } from "./compute-caret-rect";
|
|
2
|
+
import { default as default3 } from "./document-has-text-selection";
|
|
3
|
+
import { default as default4 } from "./document-has-uncollapsed-selection";
|
|
4
|
+
import { default as default5 } from "./document-has-selection";
|
|
5
|
+
import { default as default6 } from "./get-rectangle-from-range";
|
|
6
|
+
import { default as default7 } from "./get-scroll-container";
|
|
7
|
+
import { default as default8 } from "./get-offset-parent";
|
|
8
|
+
import { default as default9 } from "./is-entirely-selected";
|
|
9
|
+
import { default as default10 } from "./is-form-element";
|
|
10
|
+
import { default as default11 } from "./is-horizontal-edge";
|
|
11
|
+
import { default as default12 } from "./is-number-input";
|
|
12
|
+
import { default as default13 } from "./is-text-field";
|
|
13
|
+
import { default as default14 } from "./is-vertical-edge";
|
|
14
|
+
import { default as default15 } from "./place-caret-at-horizontal-edge";
|
|
15
|
+
import { default as default16 } from "./place-caret-at-vertical-edge";
|
|
16
|
+
import { default as default17 } from "./replace";
|
|
17
|
+
import { default as default18 } from "./remove";
|
|
18
|
+
import { default as default19 } from "./insert-after";
|
|
19
|
+
import { default as default20 } from "./unwrap";
|
|
20
|
+
import { default as default21 } from "./replace-tag";
|
|
21
|
+
import { default as default22 } from "./wrap";
|
|
22
|
+
import { default as default23 } from "./strip-html";
|
|
23
|
+
import { default as default24 } from "./is-empty";
|
|
24
|
+
import { default as default25 } from "./remove-invalid-html";
|
|
25
|
+
import { default as default26 } from "./is-rtl";
|
|
26
|
+
import { default as default27 } from "./safe-html";
|
|
27
|
+
import { default as default28 } from "./is-selection-forward";
|
|
28
|
+
export {
|
|
29
|
+
default23 as __unstableStripHTML,
|
|
30
|
+
default2 as computeCaretRect,
|
|
31
|
+
default5 as documentHasSelection,
|
|
32
|
+
default3 as documentHasTextSelection,
|
|
33
|
+
default4 as documentHasUncollapsedSelection,
|
|
34
|
+
default8 as getOffsetParent,
|
|
35
|
+
default6 as getRectangleFromRange,
|
|
36
|
+
default7 as getScrollContainer,
|
|
37
|
+
default19 as insertAfter,
|
|
38
|
+
default24 as isEmpty,
|
|
39
|
+
default9 as isEntirelySelected,
|
|
40
|
+
default10 as isFormElement,
|
|
41
|
+
default11 as isHorizontalEdge,
|
|
42
|
+
default12 as isNumberInput,
|
|
43
|
+
default26 as isRTL,
|
|
44
|
+
default28 as isSelectionForward,
|
|
45
|
+
default13 as isTextField,
|
|
46
|
+
default14 as isVerticalEdge,
|
|
47
|
+
default15 as placeCaretAtHorizontalEdge,
|
|
48
|
+
default16 as placeCaretAtVerticalEdge,
|
|
49
|
+
default18 as remove,
|
|
50
|
+
default25 as removeInvalidHTML,
|
|
51
|
+
default17 as replace,
|
|
52
|
+
default21 as replaceTag,
|
|
53
|
+
default27 as safeHTML,
|
|
54
|
+
default20 as unwrap,
|
|
55
|
+
default22 as wrap
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/dom/index.js"],
|
|
4
|
+
"sourcesContent": ["export { default as computeCaretRect } from './compute-caret-rect';\nexport { default as documentHasTextSelection } from './document-has-text-selection';\nexport { default as documentHasUncollapsedSelection } from './document-has-uncollapsed-selection';\nexport { default as documentHasSelection } from './document-has-selection';\nexport { default as getRectangleFromRange } from './get-rectangle-from-range';\nexport { default as getScrollContainer } from './get-scroll-container';\nexport { default as getOffsetParent } from './get-offset-parent';\nexport { default as isEntirelySelected } from './is-entirely-selected';\nexport { default as isFormElement } from './is-form-element';\nexport { default as isHorizontalEdge } from './is-horizontal-edge';\nexport { default as isNumberInput } from './is-number-input';\nexport { default as isTextField } from './is-text-field';\nexport { default as isVerticalEdge } from './is-vertical-edge';\nexport { default as placeCaretAtHorizontalEdge } from './place-caret-at-horizontal-edge';\nexport { default as placeCaretAtVerticalEdge } from './place-caret-at-vertical-edge';\nexport { default as replace } from './replace';\nexport { default as remove } from './remove';\nexport { default as insertAfter } from './insert-after';\nexport { default as unwrap } from './unwrap';\nexport { default as replaceTag } from './replace-tag';\nexport { default as wrap } from './wrap';\nexport { default as __unstableStripHTML } from './strip-html';\nexport { default as isEmpty } from './is-empty';\nexport { default as removeInvalidHTML } from './remove-invalid-html';\nexport { default as isRTL } from './is-rtl';\nexport { default as safeHTML } from './safe-html';\nexport { default as isSelectionForward } from './is-selection-forward';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAA2C;AACpD,SAAoB,WAAXA,gBAAkD;AAC3D,SAAoB,WAAXA,gBAAuC;AAChD,SAAoB,WAAXA,gBAAwC;AACjD,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,iBAAgC;AACzC,SAAoB,WAAXA,iBAAmC;AAC5C,SAAoB,WAAXA,iBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAA6C;AACtD,SAAoB,WAAXA,iBAA2C;AACpD,SAAoB,WAAXA,iBAA0B;AACnC,SAAoB,WAAXA,iBAAyB;AAClC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAyB;AAClC,SAAoB,WAAXA,iBAA6B;AACtC,SAAoB,WAAXA,iBAAuB;AAChC,SAAoB,WAAXA,iBAAsC;AAC/C,SAAoB,WAAXA,iBAA0B;AACnC,SAAoB,WAAXA,iBAAoC;AAC7C,SAAoB,WAAXA,iBAAwB;AACjC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAAqC;",
|
|
6
|
+
"names": ["default"]
|
|
7
|
+
}
|
|
@@ -1,51 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import isTextField from './is-text-field';
|
|
5
|
-
import isHTMLInputElement from './is-html-input-element';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Check whether the given input field or textarea contains a (uncollapsed)
|
|
9
|
-
* selection of text.
|
|
10
|
-
*
|
|
11
|
-
* CAVEAT: Only specific text-based HTML inputs support the selection APIs
|
|
12
|
-
* needed to determine whether they have a collapsed or uncollapsed selection.
|
|
13
|
-
* This function defaults to returning `true` when the selection cannot be
|
|
14
|
-
* inspected, such as with `<input type="time">`. The rationale is that this
|
|
15
|
-
* should cause the block editor to defer to the browser's native selection
|
|
16
|
-
* handling (e.g. copying and pasting), thereby reducing friction for the user.
|
|
17
|
-
*
|
|
18
|
-
* See: https://html.spec.whatwg.org/multipage/input.html#do-not-apply
|
|
19
|
-
*
|
|
20
|
-
* @param {Element} element The HTML element.
|
|
21
|
-
*
|
|
22
|
-
* @return {boolean} Whether the input/textarea element has some "selection".
|
|
23
|
-
*/
|
|
24
|
-
export default function inputFieldHasUncollapsedSelection(element) {
|
|
1
|
+
import isTextField from "./is-text-field";
|
|
2
|
+
import isHTMLInputElement from "./is-html-input-element";
|
|
3
|
+
function inputFieldHasUncollapsedSelection(element) {
|
|
25
4
|
if (!isHTMLInputElement(element) && !isTextField(element)) {
|
|
26
5
|
return false;
|
|
27
6
|
}
|
|
28
|
-
|
|
29
|
-
// Safari throws a type error when trying to get `selectionStart` and
|
|
30
|
-
// `selectionEnd` on non-text <input> elements, so a try/catch construct is
|
|
31
|
-
// necessary.
|
|
32
7
|
try {
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
8
|
+
const { selectionStart, selectionEnd } = (
|
|
9
|
+
/** @type {HTMLInputElement | HTMLTextAreaElement} */
|
|
10
|
+
element
|
|
11
|
+
);
|
|
37
12
|
return (
|
|
38
13
|
// `null` means the input type doesn't implement selection, thus we
|
|
39
14
|
// cannot determine whether the selection is collapsed, so we
|
|
40
15
|
// default to true.
|
|
41
|
-
selectionStart === null ||
|
|
42
|
-
// when not null, compare the two points
|
|
16
|
+
selectionStart === null || // when not null, compare the two points
|
|
43
17
|
selectionStart !== selectionEnd
|
|
44
18
|
);
|
|
45
19
|
} catch (error) {
|
|
46
|
-
// This is Safari's way of saying that the input type doesn't implement
|
|
47
|
-
// selection, so we default to true.
|
|
48
20
|
return true;
|
|
49
21
|
}
|
|
50
22
|
}
|
|
51
|
-
|
|
23
|
+
export {
|
|
24
|
+
inputFieldHasUncollapsedSelection as default
|
|
25
|
+
};
|
|
26
|
+
//# 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": "AAGA,OAAO,iBAAiB;AACxB,OAAO,wBAAwB;AAmBhB,SAAR,kCAAoD,SAAU;AACpE,MAAK,CAAE,mBAAoB,OAAQ,KAAK,CAAE,YAAa,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": []
|
|
7
|
+
}
|
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { assertIsDefined } from '../utils/assert-is-defined';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Given two DOM nodes, inserts the former in the DOM as the next sibling of
|
|
8
|
-
* the latter.
|
|
9
|
-
*
|
|
10
|
-
* @param {Node} newNode Node to be inserted.
|
|
11
|
-
* @param {Node} referenceNode Node after which to perform the insertion.
|
|
12
|
-
* @return {void}
|
|
13
|
-
*/
|
|
14
|
-
export default function insertAfter(newNode, referenceNode) {
|
|
15
|
-
assertIsDefined(referenceNode.parentNode, 'referenceNode.parentNode');
|
|
1
|
+
import { assertIsDefined } from "../utils/assert-is-defined";
|
|
2
|
+
function insertAfter(newNode, referenceNode) {
|
|
3
|
+
assertIsDefined(referenceNode.parentNode, "referenceNode.parentNode");
|
|
16
4
|
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
|
|
17
5
|
}
|
|
18
|
-
|
|
6
|
+
export {
|
|
7
|
+
insertAfter as default
|
|
8
|
+
};
|
|
9
|
+
//# 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": "AAGA,SAAS,uBAAuB;AAUjB,SAAR,YAA8B,SAAS,eAAgB;AAC7D,kBAAiB,cAAc,YAAY,0BAA2B;AACtE,gBAAc,WAAW,aAAc,SAAS,cAAc,WAAY;AAC3E;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|