@wordpress/dom 3.38.0 → 3.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +2 -2
  3. package/build/data-transfer.js +0 -2
  4. package/build/data-transfer.js.map +1 -1
  5. package/build/dom/caret-range-from-point.js +3 -5
  6. package/build/dom/caret-range-from-point.js.map +1 -1
  7. package/build/dom/clean-node-list.js +25 -42
  8. package/build/dom/clean-node-list.js.map +1 -1
  9. package/build/dom/compute-caret-rect.js +0 -6
  10. package/build/dom/compute-caret-rect.js.map +1 -1
  11. package/build/dom/document-has-selection.js +0 -5
  12. package/build/dom/document-has-selection.js.map +1 -1
  13. package/build/dom/document-has-text-selection.js +0 -2
  14. package/build/dom/document-has-text-selection.js.map +1 -1
  15. package/build/dom/document-has-uncollapsed-selection.js +0 -4
  16. package/build/dom/document-has-uncollapsed-selection.js.map +1 -1
  17. package/build/dom/get-computed-style.js +0 -3
  18. package/build/dom/get-computed-style.js.map +1 -1
  19. package/build/dom/get-offset-parent.js +8 -19
  20. package/build/dom/get-offset-parent.js.map +1 -1
  21. package/build/dom/get-range-height.js +0 -3
  22. package/build/dom/get-range-height.js.map +1 -1
  23. package/build/dom/get-rectangle-from-range.js +15 -22
  24. package/build/dom/get-rectangle-from-range.js.map +1 -1
  25. package/build/dom/get-scroll-container.js +3 -13
  26. package/build/dom/get-scroll-container.js.map +1 -1
  27. package/build/dom/hidden-caret-range-from-point.js +2 -6
  28. package/build/dom/hidden-caret-range-from-point.js.map +1 -1
  29. package/build/dom/index.js +0 -27
  30. package/build/dom/index.js.map +1 -1
  31. package/build/dom/input-field-has-uncollapsed-selection.js +8 -12
  32. package/build/dom/input-field-has-uncollapsed-selection.js.map +1 -1
  33. package/build/dom/insert-after.js +0 -2
  34. package/build/dom/insert-after.js.map +1 -1
  35. package/build/dom/is-edge.js +18 -40
  36. package/build/dom/is-edge.js.map +1 -1
  37. package/build/dom/is-element.js +0 -2
  38. package/build/dom/is-element.js.map +1 -1
  39. package/build/dom/is-empty.js +1 -7
  40. package/build/dom/is-empty.js.map +1 -1
  41. package/build/dom/is-entirely-selected.js +2 -18
  42. package/build/dom/is-entirely-selected.js.map +1 -1
  43. package/build/dom/is-form-element.js +0 -4
  44. package/build/dom/is-form-element.js.map +1 -1
  45. package/build/dom/is-horizontal-edge.js +2 -5
  46. package/build/dom/is-horizontal-edge.js.map +1 -1
  47. package/build/dom/is-html-input-element.js +0 -2
  48. package/build/dom/is-html-input-element.js.map +1 -1
  49. package/build/dom/is-input-or-text-area.js +0 -2
  50. package/build/dom/is-input-or-text-area.js.map +1 -1
  51. package/build/dom/is-number-input.js +0 -6
  52. package/build/dom/is-number-input.js.map +1 -1
  53. package/build/dom/is-rtl.js +0 -3
  54. package/build/dom/is-rtl.js.map +1 -1
  55. package/build/dom/is-selection-forward.js +6 -10
  56. package/build/dom/is-selection-forward.js.map +1 -1
  57. package/build/dom/is-text-field.js +1 -7
  58. package/build/dom/is-text-field.js.map +1 -1
  59. package/build/dom/is-vertical-edge.js +2 -5
  60. package/build/dom/is-vertical-edge.js.map +1 -1
  61. package/build/dom/place-caret-at-edge.js +8 -31
  62. package/build/dom/place-caret-at-edge.js.map +1 -1
  63. package/build/dom/place-caret-at-horizontal-edge.js +0 -3
  64. package/build/dom/place-caret-at-horizontal-edge.js.map +1 -1
  65. package/build/dom/place-caret-at-vertical-edge.js +0 -3
  66. package/build/dom/place-caret-at-vertical-edge.js.map +1 -1
  67. package/build/dom/remove-invalid-html.js +0 -3
  68. package/build/dom/remove-invalid-html.js.map +1 -1
  69. package/build/dom/remove.js +0 -2
  70. package/build/dom/remove.js.map +1 -1
  71. package/build/dom/replace-tag.js +0 -4
  72. package/build/dom/replace-tag.js.map +1 -1
  73. package/build/dom/replace.js +0 -5
  74. package/build/dom/replace.js.map +1 -1
  75. package/build/dom/safe-html.js +0 -8
  76. package/build/dom/safe-html.js.map +1 -1
  77. package/build/dom/scroll-if-no-range.js +31 -0
  78. package/build/dom/scroll-if-no-range.js.map +1 -0
  79. package/build/dom/strip-html.js +0 -3
  80. package/build/dom/strip-html.js.map +1 -1
  81. package/build/dom/unwrap.js +0 -4
  82. package/build/dom/unwrap.js.map +1 -1
  83. package/build/dom/wrap.js +0 -2
  84. package/build/dom/wrap.js.map +1 -1
  85. package/build/focusable.js +5 -18
  86. package/build/focusable.js.map +1 -1
  87. package/build/index.js +0 -11
  88. package/build/index.js.map +1 -1
  89. package/build/phrasing-content.js +13 -14
  90. package/build/phrasing-content.js.map +1 -1
  91. package/build/tabbable.js +21 -37
  92. package/build/tabbable.js.map +1 -1
  93. package/build/utils/assert-is-defined.js +0 -1
  94. package/build/utils/assert-is-defined.js.map +1 -1
  95. package/build-module/data-transfer.js +0 -1
  96. package/build-module/data-transfer.js.map +1 -1
  97. package/build-module/dom/caret-range-from-point.js +3 -4
  98. package/build-module/dom/caret-range-from-point.js.map +1 -1
  99. package/build-module/dom/clean-node-list.js +24 -35
  100. package/build-module/dom/clean-node-list.js.map +1 -1
  101. package/build-module/dom/compute-caret-rect.js +1 -3
  102. package/build-module/dom/compute-caret-rect.js.map +1 -1
  103. package/build-module/dom/document-has-selection.js +1 -1
  104. package/build-module/dom/document-has-selection.js.map +1 -1
  105. package/build-module/dom/document-has-text-selection.js +1 -1
  106. package/build-module/dom/document-has-text-selection.js.map +1 -1
  107. package/build-module/dom/document-has-uncollapsed-selection.js +1 -1
  108. package/build-module/dom/document-has-uncollapsed-selection.js.map +1 -1
  109. package/build-module/dom/get-computed-style.js +1 -2
  110. package/build-module/dom/get-computed-style.js.map +1 -1
  111. package/build-module/dom/get-offset-parent.js +9 -17
  112. package/build-module/dom/get-offset-parent.js.map +1 -1
  113. package/build-module/dom/get-range-height.js +0 -2
  114. package/build-module/dom/get-range-height.js.map +1 -1
  115. package/build-module/dom/get-rectangle-from-range.js +16 -21
  116. package/build-module/dom/get-rectangle-from-range.js.map +1 -1
  117. package/build-module/dom/get-scroll-container.js +4 -11
  118. package/build-module/dom/get-scroll-container.js.map +1 -1
  119. package/build-module/dom/hidden-caret-range-from-point.js +3 -3
  120. package/build-module/dom/hidden-caret-range-from-point.js.map +1 -1
  121. package/build-module/dom/index.js.map +1 -1
  122. package/build-module/dom/input-field-has-uncollapsed-selection.js +9 -9
  123. package/build-module/dom/input-field-has-uncollapsed-selection.js.map +1 -1
  124. package/build-module/dom/insert-after.js +1 -1
  125. package/build-module/dom/insert-after.js.map +1 -1
  126. package/build-module/dom/is-edge.js +19 -32
  127. package/build-module/dom/is-edge.js.map +1 -1
  128. package/build-module/dom/is-element.js +0 -1
  129. package/build-module/dom/is-element.js.map +1 -1
  130. package/build-module/dom/is-empty.js +1 -6
  131. package/build-module/dom/is-empty.js.map +1 -1
  132. package/build-module/dom/is-entirely-selected.js +3 -14
  133. package/build-module/dom/is-entirely-selected.js.map +1 -1
  134. package/build-module/dom/is-form-element.js +1 -2
  135. package/build-module/dom/is-form-element.js.map +1 -1
  136. package/build-module/dom/is-horizontal-edge.js +3 -3
  137. package/build-module/dom/is-horizontal-edge.js.map +1 -1
  138. package/build-module/dom/is-html-input-element.js +0 -1
  139. package/build-module/dom/is-html-input-element.js.map +1 -1
  140. package/build-module/dom/is-input-or-text-area.js +0 -1
  141. package/build-module/dom/is-input-or-text-area.js.map +1 -1
  142. package/build-module/dom/is-number-input.js +2 -4
  143. package/build-module/dom/is-number-input.js.map +1 -1
  144. package/build-module/dom/is-rtl.js +1 -1
  145. package/build-module/dom/is-rtl.js.map +1 -1
  146. package/build-module/dom/is-selection-forward.js +7 -9
  147. package/build-module/dom/is-selection-forward.js.map +1 -1
  148. package/build-module/dom/is-text-field.js +2 -5
  149. package/build-module/dom/is-text-field.js.map +1 -1
  150. package/build-module/dom/is-vertical-edge.js +3 -3
  151. package/build-module/dom/is-vertical-edge.js.map +1 -1
  152. package/build-module/dom/place-caret-at-edge.js +9 -26
  153. package/build-module/dom/place-caret-at-edge.js.map +1 -1
  154. package/build-module/dom/place-caret-at-horizontal-edge.js +1 -1
  155. package/build-module/dom/place-caret-at-horizontal-edge.js.map +1 -1
  156. package/build-module/dom/place-caret-at-vertical-edge.js +1 -1
  157. package/build-module/dom/place-caret-at-vertical-edge.js.map +1 -1
  158. package/build-module/dom/remove-invalid-html.js +1 -1
  159. package/build-module/dom/remove-invalid-html.js.map +1 -1
  160. package/build-module/dom/remove.js +1 -1
  161. package/build-module/dom/remove.js.map +1 -1
  162. package/build-module/dom/replace-tag.js +1 -3
  163. package/build-module/dom/replace-tag.js.map +1 -1
  164. package/build-module/dom/replace.js +1 -1
  165. package/build-module/dom/replace.js.map +1 -1
  166. package/build-module/dom/safe-html.js +1 -6
  167. package/build-module/dom/safe-html.js.map +1 -1
  168. package/build-module/dom/scroll-if-no-range.js +25 -0
  169. package/build-module/dom/scroll-if-no-range.js.map +1 -0
  170. package/build-module/dom/strip-html.js +1 -1
  171. package/build-module/dom/strip-html.js.map +1 -1
  172. package/build-module/dom/unwrap.js +1 -3
  173. package/build-module/dom/unwrap.js.map +1 -1
  174. package/build-module/dom/wrap.js +1 -1
  175. package/build-module/dom/wrap.js.map +1 -1
  176. package/build-module/focusable.js +5 -17
  177. package/build-module/focusable.js.map +1 -1
  178. package/build-module/index.js +1 -1
  179. package/build-module/index.js.map +1 -1
  180. package/build-module/phrasing-content.js +13 -11
  181. package/build-module/phrasing-content.js.map +1 -1
  182. package/build-module/tabbable.js +22 -33
  183. package/build-module/tabbable.js.map +1 -1
  184. package/build-module/utils/assert-is-defined.js.map +1 -1
  185. package/build-types/dom/is-edge.d.ts +4 -4
  186. package/build-types/dom/is-edge.d.ts.map +1 -1
  187. package/build-types/dom/is-horizontal-edge.d.ts +3 -3
  188. package/build-types/dom/is-horizontal-edge.d.ts.map +1 -1
  189. package/build-types/dom/is-vertical-edge.d.ts +3 -3
  190. package/build-types/dom/is-vertical-edge.d.ts.map +1 -1
  191. package/build-types/dom/place-caret-at-edge.d.ts.map +1 -1
  192. package/build-types/dom/scroll-if-no-range.d.ts +12 -0
  193. package/build-types/dom/scroll-if-no-range.d.ts.map +1 -0
  194. package/build-types/index.d.ts +2 -2
  195. package/build-types/index.d.ts.map +1 -1
  196. package/package.json +3 -3
  197. package/src/dom/is-edge.js +6 -8
  198. package/src/dom/is-horizontal-edge.js +2 -2
  199. package/src/dom/is-vertical-edge.js +2 -2
  200. package/src/dom/place-caret-at-edge.js +5 -19
  201. package/src/dom/scroll-if-no-range.js +34 -0
  202. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.40.0 (2023-08-16)
6
+
7
+ ## 3.39.0 (2023-08-10)
8
+
5
9
  ## 3.38.0 (2023-07-20)
6
10
 
7
11
  ## 3.37.0 (2023-07-05)
package/README.md CHANGED
@@ -192,7 +192,7 @@ Check whether the selection is horizontally at the edge of the container.
192
192
 
193
193
  _Parameters_
194
194
 
195
- - _container_ `Element`: Focusable element.
195
+ - _container_ `HTMLElement`: Focusable element.
196
196
  - _isReverse_ `boolean`: Set to true to check left, false for right.
197
197
 
198
198
  _Returns_
@@ -269,7 +269,7 @@ Check whether the selection is vertically at the edge of the container.
269
269
 
270
270
  _Parameters_
271
271
 
272
- - _container_ `Element`: Focusable element.
272
+ - _container_ `HTMLElement`: Focusable element.
273
273
  - _isReverse_ `boolean`: Set to true to check top, false for bottom.
274
274
 
275
275
  _Returns_
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getFilesFromDataTransfer = getFilesFromDataTransfer;
7
-
8
7
  /**
9
8
  * Gets all files from a DataTransfer object.
10
9
  *
@@ -16,7 +15,6 @@ function getFilesFromDataTransfer(dataTransfer) {
16
15
  const files = Array.from(dataTransfer.files);
17
16
  Array.from(dataTransfer.items).forEach(item => {
18
17
  const file = item.getAsFile();
19
-
20
18
  if (file && !files.find(({
21
19
  name,
22
20
  type,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/data-transfer.js"],"names":["getFilesFromDataTransfer","dataTransfer","files","Array","from","items","forEach","item","file","getAsFile","find","name","type","size","push"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAT,CAAmCC,YAAnC,EAAkD;AACxD,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACC,KAAzB,CAAd;AAEAC,EAAAA,KAAK,CAACC,IAAN,CAAYH,YAAY,CAACI,KAAzB,EAAiCC,OAAjC,CAA4CC,IAAF,IAAY;AACrD,UAAMC,IAAI,GAAGD,IAAI,CAACE,SAAL,EAAb;;AAEA,QACCD,IAAI,IACJ,CAAEN,KAAK,CAACQ,IAAN,CACD,CAAE;AAAEC,MAAAA,IAAF;AAAQC,MAAAA,IAAR;AAAcC,MAAAA;AAAd,KAAF,KACCF,IAAI,KAAKH,IAAI,CAACG,IAAd,IACAC,IAAI,KAAKJ,IAAI,CAACI,IADd,IAEAC,IAAI,KAAKL,IAAI,CAACK,IAJd,CAFH,EAQE;AACDX,MAAAA,KAAK,CAACY,IAAN,CAAYN,IAAZ;AACA;AACD,GAdD;AAgBA,SAAON,KAAP;AACA","sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"]}
1
+ {"version":3,"names":["getFilesFromDataTransfer","dataTransfer","files","Array","from","items","forEach","item","file","getAsFile","find","name","type","size","push"],"sources":["@wordpress/dom/src/data-transfer.js"],"sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAwBA,CAAEC,YAAY,EAAG;EACxD,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAAEH,YAAY,CAACC,KAAM,CAAC;EAE9CC,KAAK,CAACC,IAAI,CAAEH,YAAY,CAACI,KAAM,CAAC,CAACC,OAAO,CAAIC,IAAI,IAAM;IACrD,MAAMC,IAAI,GAAGD,IAAI,CAACE,SAAS,CAAC,CAAC;IAE7B,IACCD,IAAI,IACJ,CAAEN,KAAK,CAACQ,IAAI,CACX,CAAE;MAAEC,IAAI;MAAEC,IAAI;MAAEC;IAAK,CAAC,KACrBF,IAAI,KAAKH,IAAI,CAACG,IAAI,IAClBC,IAAI,KAAKJ,IAAI,CAACI,IAAI,IAClBC,IAAI,KAAKL,IAAI,CAACK,IAChB,CAAC,EACA;MACDX,KAAK,CAACY,IAAI,CAAEN,IAAK,CAAC;IACnB;EACD,CAAE,CAAC;EAEH,OAAON,KAAK;AACb"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = caretRangeFromPoint;
7
-
8
7
  /**
9
8
  * Polyfill.
10
9
  * Get a collapsed range for a given point.
@@ -21,23 +20,22 @@ function caretRangeFromPoint(doc, x, y) {
21
20
  if (doc.caretRangeFromPoint) {
22
21
  return doc.caretRangeFromPoint(x, y);
23
22
  }
24
-
25
23
  if (!doc.caretPositionFromPoint) {
26
24
  return null;
27
25
  }
26
+ const point = doc.caretPositionFromPoint(x, y);
28
27
 
29
- const point = doc.caretPositionFromPoint(x, y); // If x or y are negative, outside viewport, or there is no text entry node.
28
+ // If x or y are negative, outside viewport, or there is no text entry node.
30
29
  // https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
31
-
32
30
  if (!point) {
33
31
  return null;
34
32
  }
35
-
36
33
  const range = doc.createRange();
37
34
  range.setStart(point.offsetNode, point.offset);
38
35
  range.collapse(true);
39
36
  return range;
40
37
  }
38
+
41
39
  /**
42
40
  * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint
43
41
  * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/caret-range-from-point.js"],"names":["caretRangeFromPoint","doc","x","y","caretPositionFromPoint","point","range","createRange","setStart","offsetNode","offset","collapse"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,mBAAT,CAA8BC,GAA9B,EAAmCC,CAAnC,EAAsCC,CAAtC,EAA0C;AACxD,MAAKF,GAAG,CAACD,mBAAT,EAA+B;AAC9B,WAAOC,GAAG,CAACD,mBAAJ,CAAyBE,CAAzB,EAA4BC,CAA5B,CAAP;AACA;;AAED,MAAK,CAAEF,GAAG,CAACG,sBAAX,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,QAAMC,KAAK,GAAGJ,GAAG,CAACG,sBAAJ,CAA4BF,CAA5B,EAA+BC,CAA/B,CAAd,CATwD,CAWxD;AACA;;AACA,MAAK,CAAEE,KAAP,EAAe;AACd,WAAO,IAAP;AACA;;AAED,QAAMC,KAAK,GAAGL,GAAG,CAACM,WAAJ,EAAd;AAEAD,EAAAA,KAAK,CAACE,QAAN,CAAgBH,KAAK,CAACI,UAAtB,EAAkCJ,KAAK,CAACK,MAAxC;AACAJ,EAAAA,KAAK,CAACK,QAAN,CAAgB,IAAhB;AAEA,SAAOL,KAAP;AACA;AAED;AACA;AACA;AACA","sourcesContent":["/**\n * Polyfill.\n * Get a collapsed range for a given point.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n *\n * @param {DocumentMaybeWithCaretPositionFromPoint} 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 *\n * @return {Range | null} The best range for the given point.\n */\nexport default function caretRangeFromPoint( doc, x, y ) {\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\tif ( ! doc.caretPositionFromPoint ) {\n\t\treturn null;\n\t}\n\n\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n\tif ( ! point ) {\n\t\treturn null;\n\t}\n\n\tconst range = doc.createRange();\n\n\trange.setStart( point.offsetNode, point.offset );\n\trange.collapse( true );\n\n\treturn range;\n}\n\n/**\n * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint\n * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition\n */\n"]}
1
+ {"version":3,"names":["caretRangeFromPoint","doc","x","y","caretPositionFromPoint","point","range","createRange","setStart","offsetNode","offset","collapse"],"sources":["@wordpress/dom/src/dom/caret-range-from-point.js"],"sourcesContent":["/**\n * Polyfill.\n * Get a collapsed range for a given point.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n *\n * @param {DocumentMaybeWithCaretPositionFromPoint} 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 *\n * @return {Range | null} The best range for the given point.\n */\nexport default function caretRangeFromPoint( doc, x, y ) {\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\tif ( ! doc.caretPositionFromPoint ) {\n\t\treturn null;\n\t}\n\n\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n\tif ( ! point ) {\n\t\treturn null;\n\t}\n\n\tconst range = doc.createRange();\n\n\trange.setStart( point.offsetNode, point.offset );\n\trange.collapse( true );\n\n\treturn range;\n}\n\n/**\n * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint\n * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition\n */\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,mBAAmBA,CAAEC,GAAG,EAAEC,CAAC,EAAEC,CAAC,EAAG;EACxD,IAAKF,GAAG,CAACD,mBAAmB,EAAG;IAC9B,OAAOC,GAAG,CAACD,mBAAmB,CAAEE,CAAC,EAAEC,CAAE,CAAC;EACvC;EAEA,IAAK,CAAEF,GAAG,CAACG,sBAAsB,EAAG;IACnC,OAAO,IAAI;EACZ;EAEA,MAAMC,KAAK,GAAGJ,GAAG,CAACG,sBAAsB,CAAEF,CAAC,EAAEC,CAAE,CAAC;;EAEhD;EACA;EACA,IAAK,CAAEE,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,MAAMC,KAAK,GAAGL,GAAG,CAACM,WAAW,CAAC,CAAC;EAE/BD,KAAK,CAACE,QAAQ,CAAEH,KAAK,CAACI,UAAU,EAAEJ,KAAK,CAACK,MAAO,CAAC;EAChDJ,KAAK,CAACK,QAAQ,CAAE,IAAK,CAAC;EAEtB,OAAOL,KAAK;AACb;;AAEA;AACA;AACA;AACA"}
@@ -1,30 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = cleanNodeList;
9
-
10
8
  var _isEmpty = _interopRequireDefault(require("./is-empty"));
11
-
12
9
  var _remove = _interopRequireDefault(require("./remove"));
13
-
14
10
  var _unwrap = _interopRequireDefault(require("./unwrap"));
15
-
16
11
  var _phrasingContent = require("../phrasing-content");
17
-
18
12
  var _insertAfter = _interopRequireDefault(require("./insert-after"));
19
-
20
13
  var _isElement = _interopRequireDefault(require("./is-element"));
21
-
22
14
  /**
23
15
  * Internal dependencies
24
16
  */
17
+
25
18
  const noop = () => {};
26
- /* eslint-disable jsdoc/valid-types */
27
19
 
20
+ /* eslint-disable jsdoc/valid-types */
28
21
  /**
29
22
  * @typedef SchemaItem
30
23
  * @property {string[]} [attributes] Attributes.
@@ -36,7 +29,6 @@ const noop = () => {};
36
29
  */
37
30
 
38
31
  /** @typedef {{ [tag: string]: SchemaItem }} Schema */
39
-
40
32
  /* eslint-enable jsdoc/valid-types */
41
33
 
42
34
  /**
@@ -48,15 +40,12 @@ const noop = () => {};
48
40
  * @param {Schema} schema An array of functions that can mutate with the provided node.
49
41
  * @param {boolean} inline Whether to clean for inline mode.
50
42
  */
51
-
52
-
53
43
  function cleanNodeList(nodeList, doc, schema, inline) {
54
- Array.from(nodeList).forEach((
55
- /** @type {Node & { nextElementSibling?: unknown }} */
56
- node) => {
57
- const tag = node.nodeName.toLowerCase(); // It's a valid child, if the tag exists in the schema without an isMatch
58
- // function, or with an isMatch function that matches the node.
44
+ Array.from(nodeList).forEach(( /** @type {Node & { nextElementSibling?: unknown }} */node) => {
45
+ const tag = node.nodeName.toLowerCase();
59
46
 
47
+ // It's a valid child, if the tag exists in the schema without an isMatch
48
+ // function, or with an isMatch function that matches the node.
60
49
  if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
61
50
  if ((0, _isElement.default)(node)) {
62
51
  const {
@@ -65,14 +54,14 @@ function cleanNodeList(nodeList, doc, schema, inline) {
65
54
  children,
66
55
  require = [],
67
56
  allowEmpty
68
- } = schema[tag]; // If the node is empty and it's supposed to have children,
69
- // remove the node.
57
+ } = schema[tag];
70
58
 
59
+ // If the node is empty and it's supposed to have children,
60
+ // remove the node.
71
61
  if (children && !allowEmpty && (0, _isEmpty.default)(node)) {
72
62
  (0, _remove.default)(node);
73
63
  return;
74
64
  }
75
-
76
65
  if (node.hasAttributes()) {
77
66
  // Strip invalid attributes.
78
67
  Array.from(node.attributes).forEach(({
@@ -81,22 +70,18 @@ function cleanNodeList(nodeList, doc, schema, inline) {
81
70
  if (name !== 'class' && !attributes.includes(name)) {
82
71
  node.removeAttribute(name);
83
72
  }
84
- }); // Strip invalid classes.
73
+ });
74
+
75
+ // Strip invalid classes.
85
76
  // In jsdom-jscore, 'node.classList' can be undefined.
86
77
  // TODO: Explore patching this in jsdom-jscore.
87
-
88
78
  if (node.classList && node.classList.length) {
89
79
  const mattchers = classes.map(item => {
90
80
  if (typeof item === 'string') {
91
- return (
92
- /** @type {string} */
93
- className) => className === item;
81
+ return ( /** @type {string} */className) => className === item;
94
82
  } else if (item instanceof RegExp) {
95
- return (
96
- /** @type {string} */
97
- className) => item.test(className);
83
+ return ( /** @type {string} */className) => item.test(className);
98
84
  }
99
-
100
85
  return noop;
101
86
  });
102
87
  Array.from(node.classList).forEach(name => {
@@ -104,54 +89,52 @@ function cleanNodeList(nodeList, doc, schema, inline) {
104
89
  node.classList.remove(name);
105
90
  }
106
91
  });
107
-
108
92
  if (!node.classList.length) {
109
93
  node.removeAttribute('class');
110
94
  }
111
95
  }
112
96
  }
113
-
114
97
  if (node.hasChildNodes()) {
115
98
  // Do not filter any content.
116
99
  if (children === '*') {
117
100
  return;
118
- } // Continue if the node is supposed to have children.
119
-
101
+ }
120
102
 
103
+ // Continue if the node is supposed to have children.
121
104
  if (children) {
122
105
  // If a parent requires certain children, but it does
123
106
  // not have them, drop the parent and continue.
124
107
  if (require.length && !node.querySelector(require.join(','))) {
125
108
  cleanNodeList(node.childNodes, doc, schema, inline);
126
- (0, _unwrap.default)(node); // If the node is at the top, phrasing content, and
109
+ (0, _unwrap.default)(node);
110
+ // If the node is at the top, phrasing content, and
127
111
  // contains children that are block content, unwrap
128
112
  // the node because it is invalid.
129
113
  } else if (node.parentNode && node.parentNode.nodeName === 'BODY' && (0, _phrasingContent.isPhrasingContent)(node)) {
130
114
  cleanNodeList(node.childNodes, doc, schema, inline);
131
-
132
115
  if (Array.from(node.childNodes).some(child => !(0, _phrasingContent.isPhrasingContent)(child))) {
133
116
  (0, _unwrap.default)(node);
134
117
  }
135
118
  } else {
136
119
  cleanNodeList(node.childNodes, doc, children, inline);
137
- } // Remove children if the node is not supposed to have any.
138
-
120
+ }
121
+ // Remove children if the node is not supposed to have any.
139
122
  } else {
140
123
  while (node.firstChild) {
141
124
  (0, _remove.default)(node.firstChild);
142
125
  }
143
126
  }
144
127
  }
145
- } // Invalid child. Continue with schema at the same place and unwrap.
146
-
128
+ }
129
+ // Invalid child. Continue with schema at the same place and unwrap.
147
130
  } else {
148
- cleanNodeList(node.childNodes, doc, schema, inline); // For inline mode, insert a line break when unwrapping nodes that
149
- // are not phrasing content.
131
+ cleanNodeList(node.childNodes, doc, schema, inline);
150
132
 
133
+ // For inline mode, insert a line break when unwrapping nodes that
134
+ // are not phrasing content.
151
135
  if (inline && !(0, _phrasingContent.isPhrasingContent)(node) && node.nextElementSibling) {
152
136
  (0, _insertAfter.default)(doc.createElement('br'), node);
153
137
  }
154
-
155
138
  (0, _unwrap.default)(node);
156
139
  }
157
140
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/clean-node-list.js"],"names":["noop","cleanNodeList","nodeList","doc","schema","inline","Array","from","forEach","node","tag","nodeName","toLowerCase","hasOwnProperty","isMatch","attributes","classes","children","require","allowEmpty","hasAttributes","name","includes","removeAttribute","classList","length","mattchers","map","item","className","RegExp","test","some","remove","hasChildNodes","querySelector","join","childNodes","parentNode","child","firstChild","nextElementSibling","createElement"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AARA;AACA;AACA;AAQA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASC,aAAT,CAAwBC,QAAxB,EAAkCC,GAAlC,EAAuCC,MAAvC,EAA+CC,MAA/C,EAAwD;AACtEC,EAAAA,KAAK,CAACC,IAAN,CAAYL,QAAZ,EAAuBM,OAAvB,CACC;AAAE;AAAuDC,EAAAA,IAAzD,KAAmE;AAClE,UAAMC,GAAG,GAAGD,IAAI,CAACE,QAAL,CAAcC,WAAd,EAAZ,CADkE,CAGlE;AACA;;AACA,QACCR,MAAM,CAACS,cAAP,CAAuBH,GAAvB,MACE,CAAEN,MAAM,CAAEM,GAAF,CAAN,CAAcI,OAAhB,IAA2BV,MAAM,CAAEM,GAAF,CAAN,CAAcI,OAAd,GAAyBL,IAAzB,CAD7B,CADD,EAGE;AACD,UAAK,wBAAWA,IAAX,CAAL,EAAyB;AACxB,cAAM;AACLM,UAAAA,UAAU,GAAG,EADR;AAELC,UAAAA,OAAO,GAAG,EAFL;AAGLC,UAAAA,QAHK;AAILC,UAAAA,OAAO,GAAG,EAJL;AAKLC,UAAAA;AALK,YAMFf,MAAM,CAAEM,GAAF,CANV,CADwB,CASxB;AACA;;AACA,YAAKO,QAAQ,IAAI,CAAEE,UAAd,IAA4B,sBAASV,IAAT,CAAjC,EAAmD;AAClD,+BAAQA,IAAR;AACA;AACA;;AAED,YAAKA,IAAI,CAACW,aAAL,EAAL,EAA4B;AAC3B;AACAd,UAAAA,KAAK,CAACC,IAAN,CAAYE,IAAI,CAACM,UAAjB,EAA8BP,OAA9B,CAAuC,CAAE;AAAEa,YAAAA;AAAF,WAAF,KAAgB;AACtD,gBACCA,IAAI,KAAK,OAAT,IACA,CAAEN,UAAU,CAACO,QAAX,CAAqBD,IAArB,CAFH,EAGE;AACDZ,cAAAA,IAAI,CAACc,eAAL,CAAsBF,IAAtB;AACA;AACD,WAPD,EAF2B,CAW3B;AACA;AACA;;AACA,cAAKZ,IAAI,CAACe,SAAL,IAAkBf,IAAI,CAACe,SAAL,CAAeC,MAAtC,EAA+C;AAC9C,kBAAMC,SAAS,GAAGV,OAAO,CAACW,GAAR,CAAeC,IAAF,IAAY;AAC1C,kBAAK,OAAOA,IAAP,KAAgB,QAArB,EAAgC;AAC/B,uBAAO;AACN;AAAsBC,gBAAAA,SADhB,KAEFA,SAAS,KAAKD,IAFnB;AAGA,eAJD,MAIO,IAAKA,IAAI,YAAYE,MAArB,EAA8B;AACpC,uBAAO;AACN;AAAsBD,gBAAAA,SADhB,KAEFD,IAAI,CAACG,IAAL,CAAWF,SAAX,CAFL;AAGA;;AAED,qBAAO7B,IAAP;AACA,aAZiB,CAAlB;AAcAM,YAAAA,KAAK,CAACC,IAAN,CAAYE,IAAI,CAACe,SAAjB,EAA6BhB,OAA7B,CAAwCa,IAAF,IAAY;AACjD,kBACC,CAAEK,SAAS,CAACM,IAAV,CAAkBlB,OAAF,IACjBA,OAAO,CAAEO,IAAF,CADN,CADH,EAIE;AACDZ,gBAAAA,IAAI,CAACe,SAAL,CAAeS,MAAf,CAAuBZ,IAAvB;AACA;AACD,aARD;;AAUA,gBAAK,CAAEZ,IAAI,CAACe,SAAL,CAAeC,MAAtB,EAA+B;AAC9BhB,cAAAA,IAAI,CAACc,eAAL,CAAsB,OAAtB;AACA;AACD;AACD;;AAED,YAAKd,IAAI,CAACyB,aAAL,EAAL,EAA4B;AAC3B;AACA,cAAKjB,QAAQ,KAAK,GAAlB,EAAwB;AACvB;AACA,WAJ0B,CAM3B;;;AACA,cAAKA,QAAL,EAAgB;AACf;AACA;AACA,gBACCC,OAAO,CAACO,MAAR,IACA,CAAEhB,IAAI,CAAC0B,aAAL,CAAoBjB,OAAO,CAACkB,IAAR,CAAc,GAAd,CAApB,CAFH,EAGE;AACDnC,cAAAA,aAAa,CACZQ,IAAI,CAAC4B,UADO,EAEZlC,GAFY,EAGZC,MAHY,EAIZC,MAJY,CAAb;AAMA,mCAAQI,IAAR,EAPC,CAQD;AACA;AACA;AACA,aAdD,MAcO,IACNA,IAAI,CAAC6B,UAAL,IACA7B,IAAI,CAAC6B,UAAL,CAAgB3B,QAAhB,KAA6B,MAD7B,IAEA,wCAAmBF,IAAnB,CAHM,EAIL;AACDR,cAAAA,aAAa,CACZQ,IAAI,CAAC4B,UADO,EAEZlC,GAFY,EAGZC,MAHY,EAIZC,MAJY,CAAb;;AAOA,kBACCC,KAAK,CAACC,IAAN,CAAYE,IAAI,CAAC4B,UAAjB,EAA8BL,IAA9B,CACGO,KAAF,IACC,CAAE,wCAAmBA,KAAnB,CAFJ,CADD,EAKE;AACD,qCAAQ9B,IAAR;AACA;AACD,aApBM,MAoBA;AACNR,cAAAA,aAAa,CACZQ,IAAI,CAAC4B,UADO,EAEZlC,GAFY,EAGZc,QAHY,EAIZZ,MAJY,CAAb;AAMA,aA5Cc,CA6Cf;;AACA,WA9CD,MA8CO;AACN,mBAAQI,IAAI,CAAC+B,UAAb,EAA0B;AACzB,mCAAQ/B,IAAI,CAAC+B,UAAb;AACA;AACD;AACD;AACD,OAzHA,CA0HD;;AACA,KA9HD,MA8HO;AACNvC,MAAAA,aAAa,CAAEQ,IAAI,CAAC4B,UAAP,EAAmBlC,GAAnB,EAAwBC,MAAxB,EAAgCC,MAAhC,CAAb,CADM,CAGN;AACA;;AACA,UACCA,MAAM,IACN,CAAE,wCAAmBI,IAAnB,CADF,IAEAA,IAAI,CAACgC,kBAHN,EAIE;AACD,kCAAatC,GAAG,CAACuC,aAAJ,CAAmB,IAAnB,CAAb,EAAwCjC,IAAxC;AACA;;AAED,2BAAQA,IAAR;AACA;AACD,GAnJF;AAqJA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\n\nconst noop = () => {};\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach(\n\t\t( /** @type {Node & { nextElementSibling?: unknown }} */ node ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node.\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => className === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => item.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"]}
1
+ {"version":3,"names":["_isEmpty","_interopRequireDefault","require","_remove","_unwrap","_phrasingContent","_insertAfter","_isElement","noop","cleanNodeList","nodeList","doc","schema","inline","Array","from","forEach","node","tag","nodeName","toLowerCase","hasOwnProperty","isMatch","isElement","attributes","classes","children","allowEmpty","isEmpty","remove","hasAttributes","name","includes","removeAttribute","classList","length","mattchers","map","item","className","RegExp","test","some","hasChildNodes","querySelector","join","childNodes","unwrap","parentNode","isPhrasingContent","child","firstChild","nextElementSibling","insertAfter","createElement"],"sources":["@wordpress/dom/src/dom/clean-node-list.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\n\nconst noop = () => {};\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach(\n\t\t( /** @type {Node & { nextElementSibling?: unknown }} */ node ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node.\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => className === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => item.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"],"mappings":"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"}
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = computeCaretRect;
9
-
10
8
  var _getRectangleFromRange = _interopRequireDefault(require("./get-rectangle-from-range"));
11
-
12
9
  var _assertIsDefined = require("../utils/assert-is-defined");
13
-
14
10
  /**
15
11
  * Internal dependencies
16
12
  */
@@ -26,11 +22,9 @@ function computeCaretRect(win) {
26
22
  const selection = win.getSelection();
27
23
  (0, _assertIsDefined.assertIsDefined)(selection, 'selection');
28
24
  const range = selection.rangeCount ? selection.getRangeAt(0) : null;
29
-
30
25
  if (!range) {
31
26
  return null;
32
27
  }
33
-
34
28
  return (0, _getRectangleFromRange.default)(range);
35
29
  }
36
30
  //# sourceMappingURL=compute-caret-rect.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/compute-caret-rect.js"],"names":["computeCaretRect","win","selection","getSelection","range","rangeCount","getRangeAt"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,gBAAT,CAA2BC,GAA3B,EAAiC;AAC/C,QAAMC,SAAS,GAAGD,GAAG,CAACE,YAAJ,EAAlB;AACA,wCAAiBD,SAAjB,EAA4B,WAA5B;AACA,QAAME,KAAK,GAAGF,SAAS,CAACG,UAAV,GAAuBH,SAAS,CAACI,UAAV,CAAsB,CAAtB,CAAvB,GAAmD,IAAjE;;AAEA,MAAK,CAAEF,KAAP,EAAe;AACd,WAAO,IAAP;AACA;;AAED,SAAO,oCAAuBA,KAAvB,CAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle for the selection in a container.\n *\n * @param {Window} win The window of the selection.\n *\n * @return {DOMRect | null} The rectangle.\n */\nexport default function computeCaretRect( win ) {\n\tconst selection = win.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\n\tif ( ! range ) {\n\t\treturn null;\n\t}\n\n\treturn getRectangleFromRange( range );\n}\n"]}
1
+ {"version":3,"names":["_getRectangleFromRange","_interopRequireDefault","require","_assertIsDefined","computeCaretRect","win","selection","getSelection","assertIsDefined","range","rangeCount","getRangeAt","getRectangleFromRange"],"sources":["@wordpress/dom/src/dom/compute-caret-rect.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle for the selection in a container.\n *\n * @param {Window} win The window of the selection.\n *\n * @return {DOMRect | null} The rectangle.\n */\nexport default function computeCaretRect( win ) {\n\tconst selection = win.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\n\tif ( ! range ) {\n\t\treturn null;\n\t}\n\n\treturn getRectangleFromRange( range );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,gBAAgBA,CAAEC,GAAG,EAAG;EAC/C,MAAMC,SAAS,GAAGD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,IAAAC,gCAAe,EAAEF,SAAS,EAAE,WAAY,CAAC;EACzC,MAAMG,KAAK,GAAGH,SAAS,CAACI,UAAU,GAAGJ,SAAS,CAACK,UAAU,CAAE,CAAE,CAAC,GAAG,IAAI;EAErE,IAAK,CAAEF,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,OAAO,IAAAG,8BAAqB,EAAEH,KAAM,CAAC;AACtC"}
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = documentHasSelection;
9
-
10
8
  var _isTextField = _interopRequireDefault(require("./is-text-field"));
11
-
12
9
  var _isHtmlInputElement = _interopRequireDefault(require("./is-html-input-element"));
13
-
14
10
  var _documentHasTextSelection = _interopRequireDefault(require("./document-has-text-selection"));
15
-
16
11
  /**
17
12
  * Internal dependencies
18
13
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/document-has-selection.js"],"names":["documentHasSelection","doc","activeElement"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,oBAAT,CAA+BC,GAA/B,EAAqC;AACnD,SACC,CAAC,CAAEA,GAAG,CAACC,aAAP,KACE,iCAAoBD,GAAG,CAACC,aAAxB,KACD,0BAAaD,GAAG,CAACC,aAAjB,CADC,IAED,uCAA0BD,GAA1B,CAHD,CADD;AAMA","sourcesContent":["/**\n * Internal dependencies\n */\nimport isTextField from './is-text-field';\nimport isHTMLInputElement from './is-html-input-element';\nimport documentHasTextSelection from './document-has-text-selection';\n\n/**\n * Check whether the current document has a selection. This includes focus in\n * input fields, textareas, and general rich-text selection.\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 documentHasSelection( doc ) {\n\treturn (\n\t\t!! doc.activeElement &&\n\t\t( isHTMLInputElement( doc.activeElement ) ||\n\t\t\tisTextField( doc.activeElement ) ||\n\t\t\tdocumentHasTextSelection( doc ) )\n\t);\n}\n"]}
1
+ {"version":3,"names":["_isTextField","_interopRequireDefault","require","_isHtmlInputElement","_documentHasTextSelection","documentHasSelection","doc","activeElement","isHTMLInputElement","isTextField","documentHasTextSelection"],"sources":["@wordpress/dom/src/dom/document-has-selection.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isTextField from './is-text-field';\nimport isHTMLInputElement from './is-html-input-element';\nimport documentHasTextSelection from './document-has-text-selection';\n\n/**\n * Check whether the current document has a selection. This includes focus in\n * input fields, textareas, and general rich-text selection.\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 documentHasSelection( doc ) {\n\treturn (\n\t\t!! doc.activeElement &&\n\t\t( isHTMLInputElement( doc.activeElement ) ||\n\t\t\tisTextField( doc.activeElement ) ||\n\t\t\tdocumentHasTextSelection( doc ) )\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,yBAAA,GAAAH,sBAAA,CAAAC,OAAA;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,oBAAoBA,CAAEC,GAAG,EAAG;EACnD,OACC,CAAC,CAAEA,GAAG,CAACC,aAAa,KAClB,IAAAC,2BAAkB,EAAEF,GAAG,CAACC,aAAc,CAAC,IACxC,IAAAE,oBAAW,EAAEH,GAAG,CAACC,aAAc,CAAC,IAChC,IAAAG,iCAAwB,EAAEJ,GAAI,CAAC,CAAE;AAEpC"}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = documentHasTextSelection;
7
-
8
7
  var _assertIsDefined = require("../utils/assert-is-defined");
9
-
10
8
  /**
11
9
  * Internal dependencies
12
10
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/document-has-text-selection.js"],"names":["documentHasTextSelection","doc","defaultView","selection","getSelection","range","rangeCount","getRangeAt","collapsed"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,wBAAT,CAAmCC,GAAnC,EAAyC;AACvD,wCAAiBA,GAAG,CAACC,WAArB,EAAkC,iBAAlC;AACA,QAAMC,SAAS,GAAGF,GAAG,CAACC,WAAJ,CAAgBE,YAAhB,EAAlB;AACA,wCAAiBD,SAAjB,EAA4B,WAA5B;AACA,QAAME,KAAK,GAAGF,SAAS,CAACG,UAAV,GAAuBH,SAAS,CAACI,UAAV,CAAsB,CAAtB,CAAvB,GAAmD,IAAjE;AACA,SAAO,CAAC,CAAEF,KAAH,IAAY,CAAEA,KAAK,CAACG,SAA3B;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Check whether the current document has selected text. This applies to ranges\n * of text in the document, and not selection inside `<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"]}
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"}
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = documentHasUncollapsedSelection;
9
-
10
8
  var _documentHasTextSelection = _interopRequireDefault(require("./document-has-text-selection"));
11
-
12
9
  var _inputFieldHasUncollapsedSelection = _interopRequireDefault(require("./input-field-has-uncollapsed-selection"));
13
-
14
10
  /**
15
11
  * Internal dependencies
16
12
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/document-has-uncollapsed-selection.js"],"names":["documentHasUncollapsedSelection","doc","activeElement"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,+BAAT,CAA0CC,GAA1C,EAAgD;AAC9D,SACC,uCAA0BA,GAA1B,KACE,CAAC,CAAEA,GAAG,CAACC,aAAP,IACD,gDAAmCD,GAAG,CAACC,aAAvC,CAHF;AAKA","sourcesContent":["/**\n * Internal dependencies\n */\nimport documentHasTextSelection from './document-has-text-selection';\nimport inputFieldHasUncollapsedSelection from './input-field-has-uncollapsed-selection';\n\n/**\n * Check whether the current document has any sort of (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"]}
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"}
@@ -4,15 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = getComputedStyle;
7
-
8
7
  var _assertIsDefined = require("../utils/assert-is-defined");
9
-
10
8
  /**
11
9
  * Internal dependencies
12
10
  */
13
11
 
14
12
  /* eslint-disable jsdoc/valid-types */
15
-
16
13
  /**
17
14
  * @param {Element} element
18
15
  * @return {ReturnType<Window['getComputedStyle']>} The computed style for the element.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/get-computed-style.js"],"names":["getComputedStyle","element","ownerDocument","defaultView"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;;AACA;AACA;AACA;AACA;AACe,SAASA,gBAAT,CAA2BC,OAA3B,EAAqC;AACnD;AACA,wCACCA,OAAO,CAACC,aAAR,CAAsBC,WADvB,EAEC,mCAFD;AAIA,SAAOF,OAAO,CAACC,aAAR,CAAsBC,WAAtB,CAAkCH,gBAAlC,CAAoDC,OAApD,CAAP;AACA","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"]}
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"}
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = getOffsetParent;
9
-
10
8
  var _getComputedStyle = _interopRequireDefault(require("./get-computed-style"));
11
-
12
9
  /**
13
10
  * Internal dependencies
14
11
  */
@@ -28,31 +25,23 @@ function getOffsetParent(node) {
28
25
  // Cannot retrieve computed style or offset parent only anything other than
29
26
  // an element node, so find the closest element node.
30
27
  let closestElement;
31
-
32
- while (closestElement =
33
- /** @type {Node} */
34
- node.parentNode) {
28
+ while (closestElement = /** @type {Node} */node.parentNode) {
35
29
  if (closestElement.nodeType === closestElement.ELEMENT_NODE) {
36
30
  break;
37
31
  }
38
32
  }
39
-
40
33
  if (!closestElement) {
41
34
  return null;
42
- } // If the closest element is already positioned, return it, as offsetParent
43
- // does not otherwise consider the node itself.
44
-
35
+ }
45
36
 
46
- if ((0, _getComputedStyle.default)(
47
- /** @type {Element} */
48
- closestElement).position !== 'static') {
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') {
49
40
  return closestElement;
50
- } // offsetParent is undocumented/draft.
51
-
41
+ }
52
42
 
53
- return (
54
- /** @type {Node & { offsetParent: Node }} */
55
- closestElement.offsetParent
43
+ // offsetParent is undocumented/draft.
44
+ return (/** @type {Node & { offsetParent: Node }} */closestElement.offsetParent
56
45
  );
57
46
  }
58
47
  //# sourceMappingURL=get-offset-parent.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/get-offset-parent.js"],"names":["getOffsetParent","node","closestElement","parentNode","nodeType","ELEMENT_NODE","position","offsetParent"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,eAAT,CAA0BC,IAA1B,EAAiC;AAC/C;AACA;AACA,MAAIC,cAAJ;;AACA,SAAUA,cAAc;AAAG;AAAsBD,EAAAA,IAAI,CAACE,UAAtD,EAAuE;AACtE,QAAKD,cAAc,CAACE,QAAf,KAA4BF,cAAc,CAACG,YAAhD,EAA+D;AAC9D;AACA;AACD;;AAED,MAAK,CAAEH,cAAP,EAAwB;AACvB,WAAO,IAAP;AACA,GAZ8C,CAc/C;AACA;;;AACA,MACC;AAAkB;AAAyBA,EAAAA,cAA3C,EACEI,QADF,KACe,QAFhB,EAGE;AACD,WAAOJ,cAAP;AACA,GArB8C,CAuB/C;;;AACA;AAAO;AAA+CA,IAAAA,cAAF,CAClDK;AADF;AAEA","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"]}
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,GAAE,sBAAyBJ,cAAiB,CAAC,CAC3DK,QAAQ,KAAK,QAAQ,EACtB;IACD,OAAOL,cAAc;EACtB;;EAEA;EACA,OAAO,6CAA+CA,cAAc,CAClEM;EAAY;AACf"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = getRangeHeight;
7
-
8
7
  /**
9
8
  * Gets the height of the range without ignoring zero width rectangles, which
10
9
  * some browsers ignore when creating a union.
@@ -14,11 +13,9 @@ exports.default = getRangeHeight;
14
13
  */
15
14
  function getRangeHeight(range) {
16
15
  const rects = Array.from(range.getClientRects());
17
-
18
16
  if (!rects.length) {
19
17
  return;
20
18
  }
21
-
22
19
  const highestTop = Math.min(...rects.map(({
23
20
  top
24
21
  }) => top));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/dom/src/dom/get-range-height.js"],"names":["getRangeHeight","range","rects","Array","from","getClientRects","length","highestTop","Math","min","map","top","lowestBottom","max","bottom"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAAyBC,KAAzB,EAAiC;AAC/C,QAAMC,KAAK,GAAGC,KAAK,CAACC,IAAN,CAAYH,KAAK,CAACI,cAAN,EAAZ,CAAd;;AAEA,MAAK,CAAEH,KAAK,CAACI,MAAb,EAAsB;AACrB;AACA;;AAED,QAAMC,UAAU,GAAGC,IAAI,CAACC,GAAL,CAAU,GAAGP,KAAK,CAACQ,GAAN,CAAW,CAAE;AAAEC,IAAAA;AAAF,GAAF,KAAeA,GAA1B,CAAb,CAAnB;AACA,QAAMC,YAAY,GAAGJ,IAAI,CAACK,GAAL,CAAU,GAAGX,KAAK,CAACQ,GAAN,CAAW,CAAE;AAAEI,IAAAA;AAAF,GAAF,KAAkBA,MAA7B,CAAb,CAArB;AAEA,SAAOF,YAAY,GAAGL,UAAtB;AACA","sourcesContent":["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param {Range} range The range to check.\n * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range ) {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"]}
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"}