@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.
Files changed (185) hide show
  1. package/build/data-transfer.js +30 -18
  2. package/build/data-transfer.js.map +7 -1
  3. package/build/dom/caret-range-from-point.js +22 -25
  4. package/build/dom/caret-range-from-point.js.map +7 -1
  5. package/build/dom/clean-node-list.js +122 -129
  6. package/build/dom/clean-node-list.js.map +7 -1
  7. package/build/dom/compute-caret-rect.js +36 -21
  8. package/build/dom/compute-caret-rect.js.map +7 -1
  9. package/build/dom/document-has-selection.js +36 -22
  10. package/build/dom/document-has-selection.js.map +7 -1
  11. package/build/dom/document-has-text-selection.js +25 -23
  12. package/build/dom/document-has-text-selection.js.map +7 -1
  13. package/build/dom/document-has-uncollapsed-selection.js +35 -22
  14. package/build/dom/document-has-uncollapsed-selection.js.map +7 -1
  15. package/build/dom/get-computed-style.js +27 -17
  16. package/build/dom/get-computed-style.js.map +7 -1
  17. package/build/dom/get-offset-parent.js +43 -32
  18. package/build/dom/get-offset-parent.js.map +7 -1
  19. package/build/dom/get-range-height.js +24 -18
  20. package/build/dom/get-range-height.js.map +7 -1
  21. package/build/dom/get-rectangle-from-range.js +47 -68
  22. package/build/dom/get-rectangle-from-range.js.map +7 -1
  23. package/build/dom/get-scroll-container.js +44 -37
  24. package/build/dom/get-scroll-container.js.map +7 -1
  25. package/build/dom/hidden-caret-range-from-point.js +39 -33
  26. package/build/dom/hidden-caret-range-from-point.js.map +7 -1
  27. package/build/dom/index.js +116 -195
  28. package/build/dom/index.js.map +7 -1
  29. package/build/dom/input-field-has-uncollapsed-selection.js +40 -42
  30. package/build/dom/input-field-has-uncollapsed-selection.js.map +7 -1
  31. package/build/dom/insert-after.js +24 -19
  32. package/build/dom/insert-after.js.map +7 -1
  33. package/build/dom/is-edge.js +57 -67
  34. package/build/dom/is-edge.js.map +7 -1
  35. package/build/dom/is-element.js +22 -11
  36. package/build/dom/is-element.js.map +7 -1
  37. package/build/dom/is-empty.js +27 -17
  38. package/build/dom/is-empty.js.map +7 -1
  39. package/build/dom/is-entirely-selected.js +46 -50
  40. package/build/dom/is-entirely-selected.js.map +7 -1
  41. package/build/dom/is-form-element.js +36 -24
  42. package/build/dom/is-form-element.js.map +7 -1
  43. package/build/dom/is-horizontal-edge.js +34 -20
  44. package/build/dom/is-horizontal-edge.js.map +7 -1
  45. package/build/dom/is-html-input-element.js +23 -12
  46. package/build/dom/is-html-input-element.js.map +7 -1
  47. package/build/dom/is-input-or-text-area.js +23 -12
  48. package/build/dom/is-input-or-text-area.js.map +7 -1
  49. package/build/dom/is-number-input.js +38 -29
  50. package/build/dom/is-number-input.js.map +7 -1
  51. package/build/dom/is-rtl.js +34 -19
  52. package/build/dom/is-rtl.js.map +7 -1
  53. package/build/dom/is-selection-forward.js +26 -40
  54. package/build/dom/is-selection-forward.js.map +7 -1
  55. package/build/dom/is-text-field.js +49 -24
  56. package/build/dom/is-text-field.js.map +7 -1
  57. package/build/dom/is-vertical-edge.js +34 -20
  58. package/build/dom/is-vertical-edge.js.map +7 -1
  59. package/build/dom/place-caret-at-edge.js +52 -55
  60. package/build/dom/place-caret-at-edge.js.map +7 -1
  61. package/build/dom/place-caret-at-horizontal-edge.js +34 -18
  62. package/build/dom/place-caret-at-horizontal-edge.js.map +7 -1
  63. package/build/dom/place-caret-at-vertical-edge.js +34 -19
  64. package/build/dom/place-caret-at-vertical-edge.js.map +7 -1
  65. package/build/dom/remove-invalid-html.js +35 -22
  66. package/build/dom/remove-invalid-html.js.map +7 -1
  67. package/build/dom/remove.js +24 -17
  68. package/build/dom/remove.js.map +7 -1
  69. package/build/dom/replace-tag.js +24 -19
  70. package/build/dom/replace-tag.js.map +7 -1
  71. package/build/dom/replace.js +38 -23
  72. package/build/dom/replace.js.map +7 -1
  73. package/build/dom/safe-html.js +39 -28
  74. package/build/dom/safe-html.js.map +7 -1
  75. package/build/dom/scroll-if-no-range.js +26 -18
  76. package/build/dom/scroll-if-no-range.js.map +7 -1
  77. package/build/dom/strip-html.js +36 -23
  78. package/build/dom/strip-html.js.map +7 -1
  79. package/build/dom/unwrap.js +24 -18
  80. package/build/dom/unwrap.js.map +7 -1
  81. package/build/dom/wrap.js +24 -17
  82. package/build/dom/wrap.js.map +7 -1
  83. package/build/focusable.js +52 -85
  84. package/build/focusable.js.map +7 -1
  85. package/build/index.js +44 -58
  86. package/build/index.js.map +7 -1
  87. package/build/phrasing-content.js +88 -128
  88. package/build/phrasing-content.js.map +7 -1
  89. package/build/tabbable.js +52 -137
  90. package/build/tabbable.js.map +7 -1
  91. package/build/utils/assert-is-defined.js +30 -7
  92. package/build/utils/assert-is-defined.js.map +7 -1
  93. package/build-module/data-transfer.js +9 -15
  94. package/build-module/data-transfer.js.map +7 -1
  95. package/build-module/dom/caret-range-from-point.js +5 -22
  96. package/build-module/dom/caret-range-from-point.js.map +7 -1
  97. package/build-module/dom/clean-node-list.js +94 -123
  98. package/build-module/dom/clean-node-list.js.map +7 -1
  99. package/build-module/dom/compute-caret-rect.js +8 -16
  100. package/build-module/dom/compute-caret-rect.js.map +7 -1
  101. package/build-module/dom/document-has-selection.js +8 -17
  102. package/build-module/dom/document-has-selection.js.map +7 -1
  103. package/build-module/dom/document-has-text-selection.js +8 -20
  104. package/build-module/dom/document-has-text-selection.js.map +7 -1
  105. package/build-module/dom/document-has-uncollapsed-selection.js +7 -17
  106. package/build-module/dom/document-has-uncollapsed-selection.js.map +7 -1
  107. package/build-module/dom/get-computed-style.js +10 -14
  108. package/build-module/dom/get-computed-style.js.map +7 -1
  109. package/build-module/dom/get-offset-parent.js +16 -28
  110. package/build-module/dom/get-offset-parent.js.map +7 -1
  111. package/build-module/dom/get-range-height.js +7 -15
  112. package/build-module/dom/get-range-height.js.map +7 -1
  113. package/build-module/dom/get-rectangle-from-range.js +30 -65
  114. package/build-module/dom/get-rectangle-from-range.js.map +7 -1
  115. package/build-module/dom/get-scroll-container.js +16 -32
  116. package/build-module/dom/get-scroll-container.js.map +7 -1
  117. package/build-module/dom/hidden-caret-range-from-point.js +11 -28
  118. package/build-module/dom/hidden-caret-range-from-point.js.map +7 -1
  119. package/build-module/dom/index.js +57 -28
  120. package/build-module/dom/index.js.map +7 -1
  121. package/build-module/dom/input-field-has-uncollapsed-selection.js +12 -37
  122. package/build-module/dom/input-field-has-uncollapsed-selection.js.map +7 -1
  123. package/build-module/dom/insert-after.js +7 -16
  124. package/build-module/dom/insert-after.js.map +7 -1
  125. package/build-module/dom/is-edge.js +24 -57
  126. package/build-module/dom/is-edge.js.map +7 -1
  127. package/build-module/dom/is-element.js +5 -8
  128. package/build-module/dom/is-element.js.map +7 -1
  129. package/build-module/dom/is-empty.js +10 -14
  130. package/build-module/dom/is-empty.js.map +7 -1
  131. package/build-module/dom/is-entirely-selected.js +18 -45
  132. package/build-module/dom/is-entirely-selected.js.map +7 -1
  133. package/build-module/dom/is-form-element.js +8 -19
  134. package/build-module/dom/is-form-element.js.map +7 -1
  135. package/build-module/dom/is-horizontal-edge.js +6 -15
  136. package/build-module/dom/is-horizontal-edge.js.map +7 -1
  137. package/build-module/dom/is-html-input-element.js +6 -9
  138. package/build-module/dom/is-html-input-element.js.map +7 -1
  139. package/build-module/dom/is-input-or-text-area.js +6 -9
  140. package/build-module/dom/is-input-or-text-area.js.map +7 -1
  141. package/build-module/dom/is-number-input.js +11 -25
  142. package/build-module/dom/is-number-input.js.map +7 -1
  143. package/build-module/dom/is-rtl.js +7 -15
  144. package/build-module/dom/is-rtl.js.map +7 -1
  145. package/build-module/dom/is-selection-forward.js +9 -37
  146. package/build-module/dom/is-selection-forward.js.map +7 -1
  147. package/build-module/dom/is-text-field.js +22 -20
  148. package/build-module/dom/is-text-field.js.map +7 -1
  149. package/build-module/dom/is-vertical-edge.js +6 -15
  150. package/build-module/dom/is-vertical-edge.js.map +7 -1
  151. package/build-module/dom/place-caret-at-edge.js +22 -48
  152. package/build-module/dom/place-caret-at-edge.js.map +7 -1
  153. package/build-module/dom/place-caret-at-horizontal-edge.js +7 -14
  154. package/build-module/dom/place-caret-at-horizontal-edge.js.map +7 -1
  155. package/build-module/dom/place-caret-at-vertical-edge.js +6 -14
  156. package/build-module/dom/place-caret-at-vertical-edge.js.map +7 -1
  157. package/build-module/dom/remove-invalid-html.js +7 -17
  158. package/build-module/dom/remove-invalid-html.js.map +7 -1
  159. package/build-module/dom/remove.js +7 -14
  160. package/build-module/dom/remove.js.map +7 -1
  161. package/build-module/dom/replace-tag.js +7 -16
  162. package/build-module/dom/replace-tag.js.map +7 -1
  163. package/build-module/dom/replace.js +9 -17
  164. package/build-module/dom/replace.js.map +7 -1
  165. package/build-module/dom/safe-html.js +11 -23
  166. package/build-module/dom/safe-html.js.map +7 -1
  167. package/build-module/dom/scroll-if-no-range.js +5 -15
  168. package/build-module/dom/scroll-if-no-range.js.map +7 -1
  169. package/build-module/dom/strip-html.js +8 -18
  170. package/build-module/dom/strip-html.js.map +7 -1
  171. package/build-module/dom/unwrap.js +7 -15
  172. package/build-module/dom/unwrap.js.map +7 -1
  173. package/build-module/dom/wrap.js +7 -14
  174. package/build-module/dom/wrap.js.map +7 -1
  175. package/build-module/focusable.js +30 -81
  176. package/build-module/focusable.js.map +7 -1
  177. package/build-module/index.js +9 -17
  178. package/build-module/index.js.map +7 -1
  179. package/build-module/phrasing-content.js +67 -125
  180. package/build-module/phrasing-content.js.map +7 -1
  181. package/build-module/tabbable.js +30 -133
  182. package/build-module/tabbable.js.map +7 -1
  183. package/build-module/utils/assert-is-defined.js +9 -4
  184. package/build-module/utils/assert-is-defined.js.map +7 -1
  185. package/package.json +11 -4
@@ -1,30 +1,32 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 document_has_text_selection_exports = {};
20
+ __export(document_has_text_selection_exports, {
21
+ default: () => documentHasTextSelection
5
22
  });
6
- exports.default = documentHasTextSelection;
7
- var _assertIsDefined = require("../utils/assert-is-defined");
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- /**
13
- * Check whether the current document has selected text. This applies to ranges
14
- * of text in the document, and not selection inside `<input>` and `<textarea>`
15
- * elements.
16
- *
17
- * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.
18
- *
19
- * @param {Document} doc The document to check.
20
- *
21
- * @return {boolean} True if there is selection, false if not.
22
- */
23
+ module.exports = __toCommonJS(document_has_text_selection_exports);
24
+ var import_assert_is_defined = require("../utils/assert-is-defined");
23
25
  function documentHasTextSelection(doc) {
24
- (0, _assertIsDefined.assertIsDefined)(doc.defaultView, 'doc.defaultView');
26
+ (0, import_assert_is_defined.assertIsDefined)(doc.defaultView, "doc.defaultView");
25
27
  const selection = doc.defaultView.getSelection();
26
- (0, _assertIsDefined.assertIsDefined)(selection, 'selection');
28
+ (0, import_assert_is_defined.assertIsDefined)(selection, "selection");
27
29
  const range = selection.rangeCount ? selection.getRangeAt(0) : null;
28
30
  return !!range && !range.collapsed;
29
31
  }
30
- //# sourceMappingURL=document-has-text-selection.js.map
32
+ //# sourceMappingURL=document-has-text-selection.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_assertIsDefined","require","documentHasTextSelection","doc","assertIsDefined","defaultView","selection","getSelection","range","rangeCount","getRangeAt","collapsed"],"sources":["@wordpress/dom/src/dom/document-has-text-selection.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Check whether the current document has selected text. This applies to ranges\n * of text in the document, and not selection inside `<input>` and `<textarea>`\n * elements.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} True if there is selection, false if not.\n */\nexport default function documentHasTextSelection( doc ) {\n\tassertIsDefined( doc.defaultView, 'doc.defaultView' );\n\tconst selection = doc.defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\treturn !! range && ! range.collapsed;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,wBAAwBA,CAAEC,GAAG,EAAG;EACvD,IAAAC,gCAAe,EAAED,GAAG,CAACE,WAAW,EAAE,iBAAkB,CAAC;EACrD,MAAMC,SAAS,GAAGH,GAAG,CAACE,WAAW,CAACE,YAAY,CAAC,CAAC;EAChD,IAAAH,gCAAe,EAAEE,SAAS,EAAE,WAAY,CAAC;EACzC,MAAME,KAAK,GAAGF,SAAS,CAACG,UAAU,GAAGH,SAAS,CAACI,UAAU,CAAE,CAAE,CAAC,GAAG,IAAI;EACrE,OAAO,CAAC,CAAEF,KAAK,IAAI,CAAEA,KAAK,CAACG,SAAS;AACrC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/document-has-text-selection.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Check whether the current document has selected text. This applies to ranges\n * of text in the document, and not selection inside `<input>` and `<textarea>`\n * elements.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} True if there is selection, false if not.\n */\nexport default function documentHasTextSelection( doc ) {\n\tassertIsDefined( doc.defaultView, 'doc.defaultView' );\n\tconst selection = doc.defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\treturn !! range && ! range.collapsed;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAAgC;AAajB,SAAR,yBAA2C,KAAM;AACvD,gDAAiB,IAAI,aAAa,iBAAkB;AACpD,QAAM,YAAY,IAAI,YAAY,aAAa;AAC/C,gDAAiB,WAAW,WAAY;AACxC,QAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;AACjE,SAAO,CAAC,CAAE,SAAS,CAAE,MAAM;AAC5B;",
6
+ "names": []
7
+ }
@@ -1,26 +1,39 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
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 document_has_uncollapsed_selection_exports = {};
30
+ __export(document_has_uncollapsed_selection_exports, {
31
+ default: () => documentHasUncollapsedSelection
6
32
  });
7
- exports.default = documentHasUncollapsedSelection;
8
- var _documentHasTextSelection = _interopRequireDefault(require("./document-has-text-selection"));
9
- var _inputFieldHasUncollapsedSelection = _interopRequireDefault(require("./input-field-has-uncollapsed-selection"));
10
- /**
11
- * Internal dependencies
12
- */
13
-
14
- /**
15
- * Check whether the current document has any sort of (uncollapsed) selection.
16
- * This includes ranges of text across elements and any selection inside
17
- * textual `<input>` and `<textarea>` elements.
18
- *
19
- * @param {Document} doc The document to check.
20
- *
21
- * @return {boolean} Whether there is any recognizable text selection in the document.
22
- */
33
+ module.exports = __toCommonJS(document_has_uncollapsed_selection_exports);
34
+ var import_document_has_text_selection = __toESM(require("./document-has-text-selection"));
35
+ var import_input_field_has_uncollapsed_selection = __toESM(require("./input-field-has-uncollapsed-selection"));
23
36
  function documentHasUncollapsedSelection(doc) {
24
- return (0, _documentHasTextSelection.default)(doc) || !!doc.activeElement && (0, _inputFieldHasUncollapsedSelection.default)(doc.activeElement);
37
+ return (0, import_document_has_text_selection.default)(doc) || !!doc.activeElement && (0, import_input_field_has_uncollapsed_selection.default)(doc.activeElement);
25
38
  }
26
- //# sourceMappingURL=document-has-uncollapsed-selection.js.map
39
+ //# sourceMappingURL=document-has-uncollapsed-selection.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_documentHasTextSelection","_interopRequireDefault","require","_inputFieldHasUncollapsedSelection","documentHasUncollapsedSelection","doc","documentHasTextSelection","activeElement","inputFieldHasUncollapsedSelection"],"sources":["@wordpress/dom/src/dom/document-has-uncollapsed-selection.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport documentHasTextSelection from './document-has-text-selection';\nimport inputFieldHasUncollapsedSelection from './input-field-has-uncollapsed-selection';\n\n/**\n * Check whether the current document has any sort of (uncollapsed) selection.\n * This includes ranges of text across elements and any selection inside\n * textual `<input>` and `<textarea>` elements.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} Whether there is any recognizable text selection in the document.\n */\nexport default function documentHasUncollapsedSelection( doc ) {\n\treturn (\n\t\tdocumentHasTextSelection( doc ) ||\n\t\t( !! doc.activeElement &&\n\t\t\tinputFieldHasUncollapsedSelection( doc.activeElement ) )\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,yBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kCAAA,GAAAF,sBAAA,CAAAC,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,+BAA+BA,CAAEC,GAAG,EAAG;EAC9D,OACC,IAAAC,iCAAwB,EAAED,GAAI,CAAC,IAC7B,CAAC,CAAEA,GAAG,CAACE,aAAa,IACrB,IAAAC,0CAAiC,EAAEH,GAAG,CAACE,aAAc,CAAG;AAE3D","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/document-has-uncollapsed-selection.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport documentHasTextSelection from './document-has-text-selection';\nimport inputFieldHasUncollapsedSelection from './input-field-has-uncollapsed-selection';\n\n/**\n * Check whether the current document has any sort of (uncollapsed) selection.\n * This includes ranges of text across elements and any selection inside\n * textual `<input>` and `<textarea>` elements.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} Whether there is any recognizable text selection in the document.\n */\nexport default function documentHasUncollapsedSelection( doc ) {\n\treturn (\n\t\tdocumentHasTextSelection( doc ) ||\n\t\t( !! doc.activeElement &&\n\t\t\tinputFieldHasUncollapsedSelection( doc.activeElement ) )\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yCAAqC;AACrC,mDAA8C;AAW/B,SAAR,gCAAkD,KAAM;AAC9D,aACC,mCAAAA,SAA0B,GAAI,KAC5B,CAAC,CAAE,IAAI,qBACR,6CAAAC,SAAmC,IAAI,aAAc;AAExD;",
6
+ "names": ["documentHasTextSelection", "inputFieldHasUncollapsedSelection"]
7
+ }
@@ -1,22 +1,32 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 get_computed_style_exports = {};
20
+ __export(get_computed_style_exports, {
21
+ default: () => getComputedStyle
5
22
  });
6
- exports.default = getComputedStyle;
7
- var _assertIsDefined = require("../utils/assert-is-defined");
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- /* eslint-disable jsdoc/valid-types */
13
- /**
14
- * @param {Element} element
15
- * @return {ReturnType<Window['getComputedStyle']>} The computed style for the element.
16
- */
23
+ module.exports = __toCommonJS(get_computed_style_exports);
24
+ var import_assert_is_defined = require("../utils/assert-is-defined");
17
25
  function getComputedStyle(element) {
18
- /* eslint-enable jsdoc/valid-types */
19
- (0, _assertIsDefined.assertIsDefined)(element.ownerDocument.defaultView, 'element.ownerDocument.defaultView');
26
+ (0, import_assert_is_defined.assertIsDefined)(
27
+ element.ownerDocument.defaultView,
28
+ "element.ownerDocument.defaultView"
29
+ );
20
30
  return element.ownerDocument.defaultView.getComputedStyle(element);
21
31
  }
22
- //# sourceMappingURL=get-computed-style.js.map
32
+ //# sourceMappingURL=get-computed-style.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_assertIsDefined","require","getComputedStyle","element","assertIsDefined","ownerDocument","defaultView"],"sources":["@wordpress/dom/src/dom/get-computed-style.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Element} element\n * @return {ReturnType<Window['getComputedStyle']>} The computed style for the element.\n */\nexport default function getComputedStyle( element ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tassertIsDefined(\n\t\telement.ownerDocument.defaultView,\n\t\t'element.ownerDocument.defaultView'\n\t);\n\treturn element.ownerDocument.defaultView.getComputedStyle( element );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACe,SAASC,gBAAgBA,CAAEC,OAAO,EAAG;EACnD;EACA,IAAAC,gCAAe,EACdD,OAAO,CAACE,aAAa,CAACC,WAAW,EACjC,mCACD,CAAC;EACD,OAAOH,OAAO,CAACE,aAAa,CAACC,WAAW,CAACJ,gBAAgB,CAAEC,OAAQ,CAAC;AACrE","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/get-computed-style.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Element} element\n * @return {ReturnType<Window['getComputedStyle']>} The computed style for the element.\n */\nexport default function getComputedStyle( element ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tassertIsDefined(\n\t\telement.ownerDocument.defaultView,\n\t\t'element.ownerDocument.defaultView'\n\t);\n\treturn element.ownerDocument.defaultView.getComputedStyle( element );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAAgC;AAOjB,SAAR,iBAAmC,SAAU;AAEnD;AAAA,IACC,QAAQ,cAAc;AAAA,IACtB;AAAA,EACD;AACA,SAAO,QAAQ,cAAc,YAAY,iBAAkB,OAAQ;AACpE;",
6
+ "names": []
7
+ }
@@ -1,31 +1,41 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
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 get_offset_parent_exports = {};
30
+ __export(get_offset_parent_exports, {
31
+ default: () => getOffsetParent
6
32
  });
7
- exports.default = getOffsetParent;
8
- var _getComputedStyle = _interopRequireDefault(require("./get-computed-style"));
9
- /**
10
- * Internal dependencies
11
- */
12
-
13
- /**
14
- * Returns the closest positioned element, or null under any of the conditions
15
- * of the offsetParent specification. Unlike offsetParent, this function is not
16
- * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).
17
- *
18
- * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent
19
- *
20
- * @param {Node} node Node from which to find offset parent.
21
- *
22
- * @return {Node | null} Offset parent.
23
- */
33
+ module.exports = __toCommonJS(get_offset_parent_exports);
34
+ var import_get_computed_style = __toESM(require("./get-computed-style"));
24
35
  function getOffsetParent(node) {
25
- // Cannot retrieve computed style or offset parent only anything other than
26
- // an element node, so find the closest element node.
27
36
  let closestElement;
28
- while (closestElement = /** @type {Node} */node.parentNode) {
37
+ while (closestElement = /** @type {Node} */
38
+ node.parentNode) {
29
39
  if (closestElement.nodeType === closestElement.ELEMENT_NODE) {
30
40
  break;
31
41
  }
@@ -33,14 +43,15 @@ function getOffsetParent(node) {
33
43
  if (!closestElement) {
34
44
  return null;
35
45
  }
36
-
37
- // If the closest element is already positioned, return it, as offsetParent
38
- // does not otherwise consider the node itself.
39
- if ((0, _getComputedStyle.default)(/** @type {Element} */closestElement).position !== 'static') {
46
+ if ((0, import_get_computed_style.default)(
47
+ /** @type {Element} */
48
+ closestElement
49
+ ).position !== "static") {
40
50
  return closestElement;
41
51
  }
42
-
43
- // offsetParent is undocumented/draft.
44
- return /** @type {Node & { offsetParent: Node }} */closestElement.offsetParent;
52
+ return (
53
+ /** @type {Node & { offsetParent: Node }} */
54
+ closestElement.offsetParent
55
+ );
45
56
  }
46
- //# sourceMappingURL=get-offset-parent.js.map
57
+ //# sourceMappingURL=get-offset-parent.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_getComputedStyle","_interopRequireDefault","require","getOffsetParent","node","closestElement","parentNode","nodeType","ELEMENT_NODE","getComputedStyle","position","offsetParent"],"sources":["@wordpress/dom/src/dom/get-offset-parent.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Returns the closest positioned element, or null under any of the conditions\n * of the offsetParent specification. Unlike offsetParent, this function is not\n * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).\n *\n * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent\n *\n * @param {Node} node Node from which to find offset parent.\n *\n * @return {Node | null} Offset parent.\n */\nexport default function getOffsetParent( node ) {\n\t// Cannot retrieve computed style or offset parent only anything other than\n\t// an element node, so find the closest element node.\n\tlet closestElement;\n\twhile ( ( closestElement = /** @type {Node} */ ( node.parentNode ) ) ) {\n\t\tif ( closestElement.nodeType === closestElement.ELEMENT_NODE ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( ! closestElement ) {\n\t\treturn null;\n\t}\n\n\t// If the closest element is already positioned, return it, as offsetParent\n\t// does not otherwise consider the node itself.\n\tif (\n\t\tgetComputedStyle( /** @type {Element} */ ( closestElement ) )\n\t\t\t.position !== 'static'\n\t) {\n\t\treturn closestElement;\n\t}\n\n\t// offsetParent is undocumented/draft.\n\treturn /** @type {Node & { offsetParent: Node }} */ ( closestElement )\n\t\t.offsetParent;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,eAAeA,CAAEC,IAAI,EAAG;EAC/C;EACA;EACA,IAAIC,cAAc;EAClB,OAAUA,cAAc,GAAG,mBAAsBD,IAAI,CAACE,UAAY,EAAK;IACtE,IAAKD,cAAc,CAACE,QAAQ,KAAKF,cAAc,CAACG,YAAY,EAAG;MAC9D;IACD;EACD;EAEA,IAAK,CAAEH,cAAc,EAAG;IACvB,OAAO,IAAI;EACZ;;EAEA;EACA;EACA,IACC,IAAAI,yBAAgB,EAAE,sBAAyBJ,cAAiB,CAAC,CAC3DK,QAAQ,KAAK,QAAQ,EACtB;IACD,OAAOL,cAAc;EACtB;;EAEA;EACA,OAAO,4CAA+CA,cAAc,CAClEM,YAAY;AACf","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/get-offset-parent.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Returns the closest positioned element, or null under any of the conditions\n * of the offsetParent specification. Unlike offsetParent, this function is not\n * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).\n *\n * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent\n *\n * @param {Node} node Node from which to find offset parent.\n *\n * @return {Node | null} Offset parent.\n */\nexport default function getOffsetParent( node ) {\n\t// Cannot retrieve computed style or offset parent only anything other than\n\t// an element node, so find the closest element node.\n\tlet closestElement;\n\twhile ( ( closestElement = /** @type {Node} */ ( node.parentNode ) ) ) {\n\t\tif ( closestElement.nodeType === closestElement.ELEMENT_NODE ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( ! closestElement ) {\n\t\treturn null;\n\t}\n\n\t// If the closest element is already positioned, return it, as offsetParent\n\t// does not otherwise consider the node itself.\n\tif (\n\t\tgetComputedStyle( /** @type {Element} */ ( closestElement ) )\n\t\t\t.position !== 'static'\n\t) {\n\t\treturn closestElement;\n\t}\n\n\t// offsetParent is undocumented/draft.\n\treturn /** @type {Node & { offsetParent: Node }} */ ( closestElement )\n\t\t.offsetParent;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gCAA6B;AAad,SAAR,gBAAkC,MAAO;AAG/C,MAAI;AACJ,SAAU;AAAA,EAAuC,KAAK,YAAiB;AACtE,QAAK,eAAe,aAAa,eAAe,cAAe;AAC9D;AAAA,IACD;AAAA,EACD;AAEA,MAAK,CAAE,gBAAiB;AACvB,WAAO;AAAA,EACR;AAIA,UACC,0BAAAA;AAAA;AAAA,IAA2C;AAAA,EAAiB,EAC1D,aAAa,UACd;AACD,WAAO;AAAA,EACR;AAGA;AAAA;AAAA,IAAsD,eACpD;AAAA;AACH;",
6
+ "names": ["getComputedStyle"]
7
+ }
@@ -1,27 +1,33 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 get_range_height_exports = {};
20
+ __export(get_range_height_exports, {
21
+ default: () => getRangeHeight
5
22
  });
6
- exports.default = getRangeHeight;
7
- /**
8
- * Gets the height of the range without ignoring zero width rectangles, which
9
- * some browsers ignore when creating a union.
10
- *
11
- * @param {Range} range The range to check.
12
- * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.
13
- */
23
+ module.exports = __toCommonJS(get_range_height_exports);
14
24
  function getRangeHeight(range) {
15
25
  const rects = Array.from(range.getClientRects());
16
26
  if (!rects.length) {
17
27
  return;
18
28
  }
19
- const highestTop = Math.min(...rects.map(({
20
- top
21
- }) => top));
22
- const lowestBottom = Math.max(...rects.map(({
23
- bottom
24
- }) => bottom));
29
+ const highestTop = Math.min(...rects.map(({ top }) => top));
30
+ const lowestBottom = Math.max(...rects.map(({ bottom }) => bottom));
25
31
  return lowestBottom - highestTop;
26
32
  }
27
- //# sourceMappingURL=get-range-height.js.map
33
+ //# sourceMappingURL=get-range-height.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getRangeHeight","range","rects","Array","from","getClientRects","length","highestTop","Math","min","map","top","lowestBottom","max","bottom"],"sources":["@wordpress/dom/src/dom/get-range-height.js"],"sourcesContent":["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param {Range} range The range to check.\n * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range ) {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAcA,CAAEC,KAAK,EAAG;EAC/C,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAAEH,KAAK,CAACI,cAAc,CAAC,CAAE,CAAC;EAElD,IAAK,CAAEH,KAAK,CAACI,MAAM,EAAG;IACrB;EACD;EAEA,MAAMC,UAAU,GAAGC,IAAI,CAACC,GAAG,CAAE,GAAGP,KAAK,CAACQ,GAAG,CAAE,CAAE;IAAEC;EAAI,CAAC,KAAMA,GAAI,CAAE,CAAC;EACjE,MAAMC,YAAY,GAAGJ,IAAI,CAACK,GAAG,CAAE,GAAGX,KAAK,CAACQ,GAAG,CAAE,CAAE;IAAEI;EAAO,CAAC,KAAMA,MAAO,CAAE,CAAC;EAEzE,OAAOF,YAAY,GAAGL,UAAU;AACjC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/get-range-height.js"],
4
+ "sourcesContent": ["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param {Range} range The range to check.\n * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range ) {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOe,SAAR,eAAiC,OAAQ;AAC/C,QAAM,QAAQ,MAAM,KAAM,MAAM,eAAe,CAAE;AAEjD,MAAK,CAAE,MAAM,QAAS;AACrB;AAAA,EACD;AAEA,QAAM,aAAa,KAAK,IAAK,GAAG,MAAM,IAAK,CAAE,EAAE,IAAI,MAAO,GAAI,CAAE;AAChE,QAAM,eAAe,KAAK,IAAK,GAAG,MAAM,IAAK,CAAE,EAAE,OAAO,MAAO,MAAO,CAAE;AAExE,SAAO,eAAe;AACvB;",
6
+ "names": []
7
+ }
@@ -1,40 +1,34 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 get_rectangle_from_range_exports = {};
20
+ __export(get_rectangle_from_range_exports, {
21
+ default: () => getRectangleFromRange
5
22
  });
6
- exports.default = getRectangleFromRange;
7
- var _assertIsDefined = require("../utils/assert-is-defined");
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- /**
13
- * Get the rectangle of a given Range. Returns `null` if no suitable rectangle
14
- * can be found.
15
- *
16
- * @param {Range} range The range.
17
- *
18
- * @return {DOMRect?} The rectangle.
19
- */
23
+ module.exports = __toCommonJS(get_rectangle_from_range_exports);
24
+ var import_assert_is_defined = require("../utils/assert-is-defined");
20
25
  function getRectangleFromRange(range) {
21
- // For uncollapsed ranges, get the rectangle that bounds the contents of the
22
- // range; this a rectangle enclosing the union of the bounding rectangles
23
- // for all the elements in the range.
24
26
  if (!range.collapsed) {
25
- const rects = Array.from(range.getClientRects());
26
-
27
- // If there's just a single rect, return it.
28
- if (rects.length === 1) {
29
- return rects[0];
27
+ const rects2 = Array.from(range.getClientRects());
28
+ if (rects2.length === 1) {
29
+ return rects2[0];
30
30
  }
31
-
32
- // Ignore tiny selection at the edge of a range.
33
- const filteredRects = rects.filter(({
34
- width
35
- }) => width > 1);
36
-
37
- // If it's full of tiny selections, return browser default.
31
+ const filteredRects = rects2.filter(({ width }) => width > 1);
38
32
  if (filteredRects.length === 0) {
39
33
  return range.getBoundingClientRect();
40
34
  }
@@ -47,12 +41,7 @@ function getRectangleFromRange(range) {
47
41
  left: furthestLeft,
48
42
  right: furthestRight
49
43
  } = filteredRects[0];
50
- for (const {
51
- top,
52
- bottom,
53
- left,
54
- right
55
- } of filteredRects) {
44
+ for (const { top, bottom, left, right } of filteredRects) {
56
45
  if (top < furthestTop) {
57
46
  furthestTop = top;
58
47
  }
@@ -66,51 +55,41 @@ function getRectangleFromRange(range) {
66
55
  furthestRight = right;
67
56
  }
68
57
  }
69
- return new window.DOMRect(furthestLeft, furthestTop, furthestRight - furthestLeft, furthestBottom - furthestTop);
58
+ return new window.DOMRect(
59
+ furthestLeft,
60
+ furthestTop,
61
+ furthestRight - furthestLeft,
62
+ furthestBottom - furthestTop
63
+ );
70
64
  }
71
- const {
72
- startContainer
73
- } = range;
74
- const {
75
- ownerDocument
76
- } = startContainer;
77
-
78
- // Correct invalid "BR" ranges. The cannot contain any children.
79
- if (startContainer.nodeName === 'BR') {
80
- const {
81
- parentNode
82
- } = startContainer;
83
- (0, _assertIsDefined.assertIsDefined)(parentNode, 'parentNode');
84
- const index = /** @type {Node[]} */Array.from(parentNode.childNodes).indexOf(startContainer);
85
- (0, _assertIsDefined.assertIsDefined)(ownerDocument, 'ownerDocument');
65
+ const { startContainer } = range;
66
+ const { ownerDocument } = startContainer;
67
+ if (startContainer.nodeName === "BR") {
68
+ const { parentNode } = startContainer;
69
+ (0, import_assert_is_defined.assertIsDefined)(parentNode, "parentNode");
70
+ const index = (
71
+ /** @type {Node[]} */
72
+ Array.from(parentNode.childNodes).indexOf(startContainer)
73
+ );
74
+ (0, import_assert_is_defined.assertIsDefined)(ownerDocument, "ownerDocument");
86
75
  range = ownerDocument.createRange();
87
76
  range.setStart(parentNode, index);
88
77
  range.setEnd(parentNode, index);
89
78
  }
90
79
  const rects = range.getClientRects();
91
-
92
- // If we have multiple rectangles for a collapsed range, there's no way to
93
- // know which it is, so don't return anything.
94
80
  if (rects.length > 1) {
95
81
  return null;
96
82
  }
97
83
  let rect = rects[0];
98
-
99
- // If the collapsed range starts (and therefore ends) at an element node,
100
- // `getClientRects` can be empty in some browsers. This can be resolved
101
- // by adding a temporary text node with zero-width space to the range.
102
- //
103
- // See: https://stackoverflow.com/a/6847328/995445
104
84
  if (!rect || rect.height === 0) {
105
- (0, _assertIsDefined.assertIsDefined)(ownerDocument, 'ownerDocument');
106
- const padNode = ownerDocument.createTextNode('\u200b');
107
- // Do not modify the live range.
85
+ (0, import_assert_is_defined.assertIsDefined)(ownerDocument, "ownerDocument");
86
+ const padNode = ownerDocument.createTextNode("\u200B");
108
87
  range = range.cloneRange();
109
88
  range.insertNode(padNode);
110
89
  rect = range.getClientRects()[0];
111
- (0, _assertIsDefined.assertIsDefined)(padNode.parentNode, 'padNode.parentNode');
90
+ (0, import_assert_is_defined.assertIsDefined)(padNode.parentNode, "padNode.parentNode");
112
91
  padNode.parentNode.removeChild(padNode);
113
92
  }
114
93
  return rect;
115
94
  }
116
- //# sourceMappingURL=get-rectangle-from-range.js.map
95
+ //# sourceMappingURL=get-rectangle-from-range.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_assertIsDefined","require","getRectangleFromRange","range","collapsed","rects","Array","from","getClientRects","length","filteredRects","filter","width","getBoundingClientRect","top","furthestTop","bottom","furthestBottom","left","furthestLeft","right","furthestRight","window","DOMRect","startContainer","ownerDocument","nodeName","parentNode","assertIsDefined","index","childNodes","indexOf","createRange","setStart","setEnd","rect","height","padNode","createTextNode","cloneRange","insertNode","removeChild"],"sources":["@wordpress/dom/src/dom/get-rectangle-from-range.js"],"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"],"mappings":";;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,qBAAqBA,CAAEC,KAAK,EAAG;EACtD;EACA;EACA;EACA,IAAK,CAAEA,KAAK,CAACC,SAAS,EAAG;IACxB,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAAEJ,KAAK,CAACK,cAAc,CAAC,CAAE,CAAC;;IAElD;IACA,IAAKH,KAAK,CAACI,MAAM,KAAK,CAAC,EAAG;MACzB,OAAOJ,KAAK,CAAE,CAAC,CAAE;IAClB;;IAEA;IACA,MAAMK,aAAa,GAAGL,KAAK,CAACM,MAAM,CAAE,CAAE;MAAEC;IAAM,CAAC,KAAMA,KAAK,GAAG,CAAE,CAAC;;IAEhE;IACA,IAAKF,aAAa,CAACD,MAAM,KAAK,CAAC,EAAG;MACjC,OAAON,KAAK,CAACU,qBAAqB,CAAC,CAAC;IACrC;IAEA,IAAKH,aAAa,CAACD,MAAM,KAAK,CAAC,EAAG;MACjC,OAAOC,aAAa,CAAE,CAAC,CAAE;IAC1B;IAEA,IAAI;MACHI,GAAG,EAAEC,WAAW;MAChBC,MAAM,EAAEC,cAAc;MACtBC,IAAI,EAAEC,YAAY;MAClBC,KAAK,EAAEC;IACR,CAAC,GAAGX,aAAa,CAAE,CAAC,CAAE;IAEtB,KAAM,MAAM;MAAEI,GAAG;MAAEE,MAAM;MAAEE,IAAI;MAAEE;IAAM,CAAC,IAAIV,aAAa,EAAG;MAC3D,IAAKI,GAAG,GAAGC,WAAW,EAAG;QACxBA,WAAW,GAAGD,GAAG;MAClB;MACA,IAAKE,MAAM,GAAGC,cAAc,EAAG;QAC9BA,cAAc,GAAGD,MAAM;MACxB;MACA,IAAKE,IAAI,GAAGC,YAAY,EAAG;QAC1BA,YAAY,GAAGD,IAAI;MACpB;MACA,IAAKE,KAAK,GAAGC,aAAa,EAAG;QAC5BA,aAAa,GAAGD,KAAK;MACtB;IACD;IAEA,OAAO,IAAIE,MAAM,CAACC,OAAO,CACxBJ,YAAY,EACZJ,WAAW,EACXM,aAAa,GAAGF,YAAY,EAC5BF,cAAc,GAAGF,WAClB,CAAC;EACF;EAEA,MAAM;IAAES;EAAe,CAAC,GAAGrB,KAAK;EAChC,MAAM;IAAEsB;EAAc,CAAC,GAAGD,cAAc;;EAExC;EACA,IAAKA,cAAc,CAACE,QAAQ,KAAK,IAAI,EAAG;IACvC,MAAM;MAAEC;IAAW,CAAC,GAAGH,cAAc;IACrC,IAAAI,gCAAe,EAAED,UAAU,EAAE,YAAa,CAAC;IAC3C,MAAME,KAAK,GAAG,qBACbvB,KAAK,CAACC,IAAI,CAAEoB,UAAU,CAACG,UAAW,CAAC,CAClCC,OAAO,CAAEP,cAAe,CAAC;IAE3B,IAAAI,gCAAe,EAAEH,aAAa,EAAE,eAAgB,CAAC;IACjDtB,KAAK,GAAGsB,aAAa,CAACO,WAAW,CAAC,CAAC;IACnC7B,KAAK,CAAC8B,QAAQ,CAAEN,UAAU,EAAEE,KAAM,CAAC;IACnC1B,KAAK,CAAC+B,MAAM,CAAEP,UAAU,EAAEE,KAAM,CAAC;EAClC;EAEA,MAAMxB,KAAK,GAAGF,KAAK,CAACK,cAAc,CAAC,CAAC;;EAEpC;EACA;EACA,IAAKH,KAAK,CAACI,MAAM,GAAG,CAAC,EAAG;IACvB,OAAO,IAAI;EACZ;EAEA,IAAI0B,IAAI,GAAG9B,KAAK,CAAE,CAAC,CAAE;;EAErB;EACA;EACA;EACA;EACA;EACA,IAAK,CAAE8B,IAAI,IAAIA,IAAI,CAACC,MAAM,KAAK,CAAC,EAAG;IAClC,IAAAR,gCAAe,EAAEH,aAAa,EAAE,eAAgB,CAAC;IACjD,MAAMY,OAAO,GAAGZ,aAAa,CAACa,cAAc,CAAE,QAAS,CAAC;IACxD;IACAnC,KAAK,GAAGA,KAAK,CAACoC,UAAU,CAAC,CAAC;IAC1BpC,KAAK,CAACqC,UAAU,CAAEH,OAAQ,CAAC;IAC3BF,IAAI,GAAGhC,KAAK,CAACK,cAAc,CAAC,CAAC,CAAE,CAAC,CAAE;IAClC,IAAAoB,gCAAe,EAAES,OAAO,CAACV,UAAU,EAAE,oBAAqB,CAAC;IAC3DU,OAAO,CAACV,UAAU,CAACc,WAAW,CAAEJ,OAAQ,CAAC;EAC1C;EAEA,OAAOF,IAAI;AACZ","ignoreList":[]}
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": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAAgC;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,kDAAiB,YAAY,YAAa;AAC1C,UAAM;AAAA;AAAA,MACL,MAAM,KAAM,WAAW,UAAW,EACjC,QAAS,cAAe;AAAA;AAE1B,kDAAiB,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,kDAAiB,eAAe,eAAgB;AAChD,UAAM,UAAU,cAAc,eAAgB,QAAS;AAEvD,YAAQ,MAAM,WAAW;AACzB,UAAM,WAAY,OAAQ;AAC1B,WAAO,MAAM,eAAe,EAAG,CAAE;AACjC,kDAAiB,QAAQ,YAAY,oBAAqB;AAC1D,YAAQ,WAAW,YAAa,OAAQ;AAAA,EACzC;AAEA,SAAO;AACR;",
6
+ "names": ["rects"]
7
+ }