@wordpress/dom 4.57.0 → 5.1.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 (334) hide show
  1. package/README.md +23 -23
  2. package/build/data-transfer.cjs +20 -38
  3. package/build/data-transfer.cjs.map +1 -7
  4. package/build/dom/caret-range-from-point.cjs +31 -38
  5. package/build/dom/caret-range-from-point.cjs.map +1 -7
  6. package/build/dom/clean-node-list.cjs +88 -133
  7. package/build/dom/clean-node-list.cjs.map +1 -7
  8. package/build/dom/compute-caret-rect.cjs +36 -36
  9. package/build/dom/compute-caret-rect.cjs.map +1 -7
  10. package/build/dom/document-has-selection.cjs +36 -31
  11. package/build/dom/document-has-selection.cjs.map +1 -7
  12. package/build/dom/document-has-text-selection.cjs +24 -30
  13. package/build/dom/document-has-text-selection.cjs.map +1 -7
  14. package/build/dom/document-has-uncollapsed-selection.cjs +35 -30
  15. package/build/dom/document-has-uncollapsed-selection.cjs.map +1 -7
  16. package/build/dom/get-computed-style.cjs +14 -30
  17. package/build/dom/get-computed-style.cjs.map +1 -7
  18. package/build/dom/get-offset-parent.cjs +41 -48
  19. package/build/dom/get-offset-parent.cjs.map +1 -7
  20. package/build/dom/get-range-height.cjs +18 -31
  21. package/build/dom/get-range-height.cjs.map +1 -7
  22. package/build/dom/get-rectangle-from-range.cjs +82 -133
  23. package/build/dom/get-rectangle-from-range.cjs.map +1 -7
  24. package/build/dom/get-scroll-container.cjs +47 -55
  25. package/build/dom/get-scroll-container.cjs.map +1 -7
  26. package/build/dom/hidden-caret-range-from-point.cjs +49 -43
  27. package/build/dom/hidden-caret-range-from-point.cjs.map +1 -7
  28. package/build/dom/index.cjs +233 -110
  29. package/build/dom/input-field-has-uncollapsed-selection.cjs +49 -47
  30. package/build/dom/input-field-has-uncollapsed-selection.cjs.map +1 -7
  31. package/build/dom/insert-after.cjs +17 -27
  32. package/build/dom/insert-after.cjs.map +1 -7
  33. package/build/dom/is-edge.cjs +83 -98
  34. package/build/dom/is-edge.cjs.map +1 -7
  35. package/build/dom/is-element.cjs +12 -25
  36. package/build/dom/is-element.cjs.map +1 -7
  37. package/build/dom/is-empty.cjs +23 -40
  38. package/build/dom/is-empty.cjs.map +1 -7
  39. package/build/dom/is-entirely-selected.cjs +71 -71
  40. package/build/dom/is-entirely-selected.cjs.map +1 -7
  41. package/build/dom/is-form-element.cjs +34 -34
  42. package/build/dom/is-form-element.cjs.map +1 -7
  43. package/build/dom/is-horizontal-edge.cjs +32 -29
  44. package/build/dom/is-horizontal-edge.cjs.map +1 -7
  45. package/build/dom/is-html-input-element.cjs +12 -25
  46. package/build/dom/is-html-input-element.cjs.map +1 -7
  47. package/build/dom/is-input-or-text-area.cjs +12 -25
  48. package/build/dom/is-input-or-text-area.cjs.map +1 -7
  49. package/build/dom/is-number-input.cjs +37 -34
  50. package/build/dom/is-number-input.cjs.map +1 -7
  51. package/build/dom/is-rtl.cjs +31 -29
  52. package/build/dom/is-rtl.cjs.map +1 -7
  53. package/build/dom/is-selection-forward.cjs +26 -39
  54. package/build/dom/is-selection-forward.cjs.map +1 -7
  55. package/build/dom/is-text-field.cjs +46 -44
  56. package/build/dom/is-text-field.cjs.map +1 -7
  57. package/build/dom/is-vertical-edge.cjs +32 -29
  58. package/build/dom/is-vertical-edge.cjs.map +1 -7
  59. package/build/dom/place-caret-at-edge.cjs +76 -79
  60. package/build/dom/place-caret-at-edge.cjs.map +1 -7
  61. package/build/dom/place-caret-at-horizontal-edge.cjs +30 -29
  62. package/build/dom/place-caret-at-horizontal-edge.cjs.map +1 -7
  63. package/build/dom/place-caret-at-vertical-edge.cjs +31 -29
  64. package/build/dom/place-caret-at-vertical-edge.cjs.map +1 -7
  65. package/build/dom/remove-invalid-html.cjs +36 -32
  66. package/build/dom/remove-invalid-html.cjs.map +1 -7
  67. package/build/dom/remove.cjs +15 -27
  68. package/build/dom/remove.cjs.map +1 -7
  69. package/build/dom/replace-tag.cjs +21 -32
  70. package/build/dom/replace-tag.cjs.map +1 -7
  71. package/build/dom/replace.cjs +35 -33
  72. package/build/dom/replace.cjs.map +1 -7
  73. package/build/dom/safe-html.cjs +46 -47
  74. package/build/dom/safe-html.cjs.map +1 -7
  75. package/build/dom/scroll-if-no-range.cjs +24 -37
  76. package/build/dom/scroll-if-no-range.cjs.map +1 -7
  77. package/build/dom/strip-html.cjs +34 -32
  78. package/build/dom/strip-html.cjs.map +1 -7
  79. package/build/dom/types.cjs +5 -0
  80. package/build/dom/unwrap.cjs +17 -31
  81. package/build/dom/unwrap.cjs.map +1 -7
  82. package/build/dom/wrap.cjs +17 -28
  83. package/build/dom/wrap.cjs.map +1 -7
  84. package/build/focusable.cjs +99 -77
  85. package/build/focusable.cjs.map +1 -7
  86. package/build/index.cjs +58 -39
  87. package/build/index.cjs.map +1 -7
  88. package/build/phrasing-content.cjs +163 -159
  89. package/build/phrasing-content.cjs.map +1 -7
  90. package/build/tabbable.cjs +123 -78
  91. package/build/tabbable.cjs.map +1 -7
  92. package/build/types.cjs +5 -0
  93. package/build/utils/assert-is-defined.cjs +8 -33
  94. package/build/utils/assert-is-defined.cjs.map +1 -7
  95. package/build-module/data-transfer.mjs +17 -15
  96. package/build-module/data-transfer.mjs.map +1 -7
  97. package/build-module/dom/caret-range-from-point.mjs +28 -19
  98. package/build-module/dom/caret-range-from-point.mjs.map +1 -7
  99. package/build-module/dom/clean-node-list.mjs +60 -105
  100. package/build-module/dom/clean-node-list.mjs.map +1 -7
  101. package/build-module/dom/compute-caret-rect.mjs +16 -12
  102. package/build-module/dom/compute-caret-rect.mjs.map +1 -7
  103. package/build-module/dom/document-has-selection.mjs +13 -6
  104. package/build-module/dom/document-has-selection.mjs.map +1 -7
  105. package/build-module/dom/document-has-text-selection.mjs +20 -10
  106. package/build-module/dom/document-has-text-selection.mjs.map +1 -7
  107. package/build-module/dom/document-has-uncollapsed-selection.mjs +14 -6
  108. package/build-module/dom/document-has-uncollapsed-selection.mjs.map +1 -7
  109. package/build-module/dom/get-computed-style.mjs +10 -10
  110. package/build-module/dom/get-computed-style.mjs.map +1 -7
  111. package/build-module/dom/get-offset-parent.mjs +21 -25
  112. package/build-module/dom/get-offset-parent.mjs.map +1 -7
  113. package/build-module/dom/get-range-height.mjs +15 -12
  114. package/build-module/dom/get-range-height.mjs.map +1 -7
  115. package/build-module/dom/get-rectangle-from-range.mjs +78 -113
  116. package/build-module/dom/get-rectangle-from-range.mjs.map +1 -7
  117. package/build-module/dom/get-scroll-container.mjs +28 -32
  118. package/build-module/dom/get-scroll-container.mjs.map +1 -7
  119. package/build-module/dom/hidden-caret-range-from-point.mjs +28 -19
  120. package/build-module/dom/hidden-caret-range-from-point.mjs.map +1 -7
  121. package/build-module/dom/index.mjs +28 -58
  122. package/build-module/dom/input-field-has-uncollapsed-selection.mjs +28 -23
  123. package/build-module/dom/input-field-has-uncollapsed-selection.mjs.map +1 -7
  124. package/build-module/dom/insert-after.mjs +13 -7
  125. package/build-module/dom/insert-after.mjs.map +1 -7
  126. package/build-module/dom/is-edge.mjs +53 -69
  127. package/build-module/dom/is-edge.mjs.map +1 -7
  128. package/build-module/dom/is-element.mjs +9 -6
  129. package/build-module/dom/is-element.mjs.map +1 -7
  130. package/build-module/dom/is-empty.mjs +20 -21
  131. package/build-module/dom/is-empty.mjs.map +1 -7
  132. package/build-module/dom/is-entirely-selected.mjs +51 -47
  133. package/build-module/dom/is-entirely-selected.mjs.map +1 -7
  134. package/build-module/dom/is-form-element.mjs +15 -11
  135. package/build-module/dom/is-form-element.mjs.map +1 -7
  136. package/build-module/dom/is-horizontal-edge.mjs +13 -6
  137. package/build-module/dom/is-horizontal-edge.mjs.map +1 -7
  138. package/build-module/dom/is-html-input-element.mjs +9 -6
  139. package/build-module/dom/is-html-input-element.mjs.map +1 -7
  140. package/build-module/dom/is-input-or-text-area.mjs +9 -6
  141. package/build-module/dom/is-input-or-text-area.mjs.map +1 -7
  142. package/build-module/dom/is-number-input.mjs +16 -10
  143. package/build-module/dom/is-number-input.mjs.map +1 -7
  144. package/build-module/dom/is-rtl.mjs +12 -6
  145. package/build-module/dom/is-rtl.mjs.map +1 -7
  146. package/build-module/dom/is-selection-forward.mjs +22 -19
  147. package/build-module/dom/is-selection-forward.mjs.map +1 -7
  148. package/build-module/dom/is-text-field.mjs +27 -21
  149. package/build-module/dom/is-text-field.mjs.map +1 -7
  150. package/build-module/dom/is-vertical-edge.mjs +13 -6
  151. package/build-module/dom/is-vertical-edge.mjs.map +1 -7
  152. package/build-module/dom/place-caret-at-edge.mjs +51 -52
  153. package/build-module/dom/place-caret-at-edge.mjs.map +1 -7
  154. package/build-module/dom/place-caret-at-horizontal-edge.mjs +11 -6
  155. package/build-module/dom/place-caret-at-horizontal-edge.mjs.map +1 -7
  156. package/build-module/dom/place-caret-at-vertical-edge.mjs +12 -6
  157. package/build-module/dom/place-caret-at-vertical-edge.mjs.map +1 -7
  158. package/build-module/dom/remove-invalid-html.mjs +17 -9
  159. package/build-module/dom/remove-invalid-html.mjs.map +1 -7
  160. package/build-module/dom/remove.mjs +11 -7
  161. package/build-module/dom/remove.mjs.map +1 -7
  162. package/build-module/dom/replace-tag.mjs +17 -12
  163. package/build-module/dom/replace-tag.mjs.map +1 -7
  164. package/build-module/dom/replace.mjs +13 -8
  165. package/build-module/dom/replace.mjs.map +1 -7
  166. package/build-module/dom/safe-html.mjs +27 -24
  167. package/build-module/dom/safe-html.mjs.map +1 -7
  168. package/build-module/dom/scroll-if-no-range.mjs +21 -14
  169. package/build-module/dom/scroll-if-no-range.mjs.map +1 -7
  170. package/build-module/dom/strip-html.mjs +15 -9
  171. package/build-module/dom/strip-html.mjs.map +1 -7
  172. package/build-module/dom/types.mjs +0 -0
  173. package/build-module/dom/unwrap.mjs +13 -11
  174. package/build-module/dom/unwrap.mjs.map +1 -7
  175. package/build-module/dom/wrap.mjs +13 -8
  176. package/build-module/dom/wrap.mjs.map +1 -7
  177. package/build-module/focusable.mjs +96 -54
  178. package/build-module/focusable.mjs.map +1 -7
  179. package/build-module/index.mjs +11 -5
  180. package/build-module/index.mjs.map +1 -7
  181. package/build-module/phrasing-content.mjs +158 -134
  182. package/build-module/phrasing-content.mjs.map +1 -7
  183. package/build-module/tabbable.mjs +117 -52
  184. package/build-module/tabbable.mjs.map +1 -7
  185. package/build-module/types.mjs +0 -0
  186. package/build-module/utils/assert-is-defined.mjs +4 -9
  187. package/build-module/utils/assert-is-defined.mjs.map +1 -7
  188. package/build-types/data-transfer.d.ts +2 -2
  189. package/build-types/data-transfer.d.ts.map +1 -1
  190. package/build-types/dom/caret-range-from-point.d.ts +4 -4
  191. package/build-types/dom/caret-range-from-point.d.ts.map +1 -1
  192. package/build-types/dom/clean-node-list.d.ts +6 -46
  193. package/build-types/dom/clean-node-list.d.ts.map +1 -1
  194. package/build-types/dom/compute-caret-rect.d.ts +2 -2
  195. package/build-types/dom/compute-caret-rect.d.ts.map +1 -1
  196. package/build-types/dom/document-has-selection.d.ts +2 -2
  197. package/build-types/dom/document-has-selection.d.ts.map +1 -1
  198. package/build-types/dom/document-has-text-selection.d.ts +2 -2
  199. package/build-types/dom/document-has-text-selection.d.ts.map +1 -1
  200. package/build-types/dom/document-has-uncollapsed-selection.d.ts +2 -2
  201. package/build-types/dom/document-has-uncollapsed-selection.d.ts.map +1 -1
  202. package/build-types/dom/get-computed-style.d.ts +3 -3
  203. package/build-types/dom/get-computed-style.d.ts.map +1 -1
  204. package/build-types/dom/get-offset-parent.d.ts +2 -2
  205. package/build-types/dom/get-offset-parent.d.ts.map +1 -1
  206. package/build-types/dom/get-range-height.d.ts +2 -2
  207. package/build-types/dom/get-range-height.d.ts.map +1 -1
  208. package/build-types/dom/get-rectangle-from-range.d.ts +2 -2
  209. package/build-types/dom/get-rectangle-from-range.d.ts.map +1 -1
  210. package/build-types/dom/get-scroll-container.d.ts +5 -5
  211. package/build-types/dom/get-scroll-container.d.ts.map +1 -1
  212. package/build-types/dom/hidden-caret-range-from-point.d.ts +5 -5
  213. package/build-types/dom/hidden-caret-range-from-point.d.ts.map +1 -1
  214. package/build-types/dom/index.d.ts.map +1 -1
  215. package/build-types/dom/input-field-has-uncollapsed-selection.d.ts +2 -2
  216. package/build-types/dom/input-field-has-uncollapsed-selection.d.ts.map +1 -1
  217. package/build-types/dom/insert-after.d.ts +2 -3
  218. package/build-types/dom/insert-after.d.ts.map +1 -1
  219. package/build-types/dom/is-edge.d.ts +4 -4
  220. package/build-types/dom/is-edge.d.ts.map +1 -1
  221. package/build-types/dom/is-element.d.ts.map +1 -1
  222. package/build-types/dom/is-empty.d.ts +3 -3
  223. package/build-types/dom/is-empty.d.ts.map +1 -1
  224. package/build-types/dom/is-entirely-selected.d.ts +2 -2
  225. package/build-types/dom/is-entirely-selected.d.ts.map +1 -1
  226. package/build-types/dom/is-form-element.d.ts +3 -3
  227. package/build-types/dom/is-form-element.d.ts.map +1 -1
  228. package/build-types/dom/is-horizontal-edge.d.ts.map +1 -1
  229. package/build-types/dom/is-html-input-element.d.ts +1 -1
  230. package/build-types/dom/is-html-input-element.d.ts.map +1 -1
  231. package/build-types/dom/is-input-or-text-area.d.ts.map +1 -1
  232. package/build-types/dom/is-number-input.d.ts +2 -2
  233. package/build-types/dom/is-number-input.d.ts.map +1 -1
  234. package/build-types/dom/is-rtl.d.ts +2 -2
  235. package/build-types/dom/is-rtl.d.ts.map +1 -1
  236. package/build-types/dom/is-selection-forward.d.ts +2 -2
  237. package/build-types/dom/is-selection-forward.d.ts.map +1 -1
  238. package/build-types/dom/is-text-field.d.ts +2 -2
  239. package/build-types/dom/is-text-field.d.ts.map +1 -1
  240. package/build-types/dom/is-vertical-edge.d.ts.map +1 -1
  241. package/build-types/dom/place-caret-at-edge.d.ts +3 -3
  242. package/build-types/dom/place-caret-at-edge.d.ts.map +1 -1
  243. package/build-types/dom/place-caret-at-horizontal-edge.d.ts.map +1 -1
  244. package/build-types/dom/place-caret-at-vertical-edge.d.ts.map +1 -1
  245. package/build-types/dom/remove-invalid-html.d.ts +5 -4
  246. package/build-types/dom/remove-invalid-html.d.ts.map +1 -1
  247. package/build-types/dom/remove.d.ts +1 -2
  248. package/build-types/dom/remove.d.ts.map +1 -1
  249. package/build-types/dom/replace-tag.d.ts +3 -3
  250. package/build-types/dom/replace-tag.d.ts.map +1 -1
  251. package/build-types/dom/replace.d.ts +2 -3
  252. package/build-types/dom/replace.d.ts.map +1 -1
  253. package/build-types/dom/safe-html.d.ts +2 -2
  254. package/build-types/dom/safe-html.d.ts.map +1 -1
  255. package/build-types/dom/scroll-if-no-range.d.ts +5 -5
  256. package/build-types/dom/scroll-if-no-range.d.ts.map +1 -1
  257. package/build-types/dom/strip-html.d.ts +2 -2
  258. package/build-types/dom/strip-html.d.ts.map +1 -1
  259. package/build-types/dom/types.d.ts +32 -0
  260. package/build-types/dom/types.d.ts.map +1 -0
  261. package/build-types/dom/unwrap.d.ts +1 -3
  262. package/build-types/dom/unwrap.d.ts.map +1 -1
  263. package/build-types/dom/wrap.d.ts +2 -2
  264. package/build-types/dom/wrap.d.ts.map +1 -1
  265. package/build-types/focusable.d.ts +11 -30
  266. package/build-types/focusable.d.ts.map +1 -1
  267. package/build-types/index.d.ts +17 -0
  268. package/build-types/index.d.ts.map +1 -1
  269. package/build-types/phrasing-content.d.ts +9 -24
  270. package/build-types/phrasing-content.d.ts.map +1 -1
  271. package/build-types/tabbable.d.ts +10 -15
  272. package/build-types/tabbable.d.ts.map +1 -1
  273. package/build-types/types.d.ts +29 -0
  274. package/build-types/types.d.ts.map +1 -0
  275. package/package.json +6 -7
  276. package/src/{data-transfer.js → data-transfer.ts} +3 -3
  277. package/src/dom/{caret-range-from-point.js → caret-range-from-point.ts} +9 -5
  278. package/src/dom/{clean-node-list.js → clean-node-list.ts} +16 -24
  279. package/src/dom/{compute-caret-rect.js → compute-caret-rect.ts} +3 -3
  280. package/src/dom/{document-has-selection.js → document-has-selection.ts} +3 -3
  281. package/src/dom/{document-has-text-selection.js → document-has-text-selection.ts} +3 -3
  282. package/src/dom/{document-has-uncollapsed-selection.js → document-has-uncollapsed-selection.ts} +5 -3
  283. package/src/dom/{get-computed-style.js → get-computed-style.ts} +5 -3
  284. package/src/dom/{get-offset-parent.js → get-offset-parent.ts} +9 -14
  285. package/src/dom/{get-range-height.js → get-range-height.ts} +3 -3
  286. package/src/dom/{get-rectangle-from-range.js → get-rectangle-from-range.ts} +6 -12
  287. package/src/dom/{get-scroll-container.js → get-scroll-container.ts} +9 -9
  288. package/src/dom/{hidden-caret-range-from-point.js → hidden-caret-range-from-point.ts} +11 -6
  289. package/src/dom/{input-field-has-uncollapsed-selection.js → input-field-has-uncollapsed-selection.ts} +7 -5
  290. package/src/dom/{insert-after.js → insert-after.ts} +6 -4
  291. package/src/dom/{is-edge.js → is-edge.ts} +44 -48
  292. package/src/dom/{is-element.js → is-element.ts} +3 -1
  293. package/src/dom/{is-empty.js → is-empty.ts} +5 -7
  294. package/src/dom/{is-entirely-selected.js → is-entirely-selected.ts} +14 -11
  295. package/src/dom/{is-form-element.js → is-form-element.ts} +5 -3
  296. package/src/dom/{is-horizontal-edge.js → is-horizontal-edge.ts} +4 -1
  297. package/src/dom/{is-html-input-element.js → is-html-input-element.ts} +3 -1
  298. package/src/dom/{is-input-or-text-area.js → is-input-or-text-area.ts} +3 -1
  299. package/src/dom/{is-number-input.js → is-number-input.ts} +3 -3
  300. package/src/dom/{is-rtl.js → is-rtl.ts} +3 -3
  301. package/src/dom/{is-selection-forward.js → is-selection-forward.ts} +3 -3
  302. package/src/dom/{is-text-field.js → is-text-field.ts} +4 -4
  303. package/src/dom/{is-vertical-edge.js → is-vertical-edge.ts} +4 -1
  304. package/src/dom/{place-caret-at-edge.js → place-caret-at-edge.ts} +17 -9
  305. package/src/dom/{place-caret-at-horizontal-edge.js → place-caret-at-horizontal-edge.ts} +4 -1
  306. package/src/dom/{place-caret-at-vertical-edge.js → place-caret-at-vertical-edge.ts} +5 -1
  307. package/src/dom/{remove-invalid-html.js → remove-invalid-html.ts} +9 -4
  308. package/src/dom/{remove.js → remove.ts} +2 -3
  309. package/src/dom/{replace-tag.js → replace-tag.ts} +4 -4
  310. package/src/dom/{replace.js → replace.ts} +6 -4
  311. package/src/dom/{safe-html.js → safe-html.ts} +3 -3
  312. package/src/dom/{scroll-if-no-range.js → scroll-if-no-range.ts} +9 -5
  313. package/src/dom/{strip-html.js → strip-html.ts} +3 -3
  314. package/src/dom/test/{get-rectangle-from-range.browser.test.js → get-rectangle-from-range.browser.test.ts} +25 -25
  315. package/src/dom/types.ts +28 -0
  316. package/src/dom/{unwrap.js → unwrap.ts} +2 -4
  317. package/src/dom/{wrap.js → wrap.ts} +3 -3
  318. package/src/{focusable.js → focusable.ts} +34 -32
  319. package/src/index.ts +33 -0
  320. package/src/{phrasing-content.js → phrasing-content.ts} +15 -30
  321. package/src/{tabbable.js → tabbable.ts} +48 -39
  322. package/src/test/{dom.jsdom.test.js → dom.jsdom.test.ts} +30 -6
  323. package/src/test/{focusable.browser.test.js → focusable.browser.test.ts} +14 -13
  324. package/src/test/{tabbable.browser.test.js → tabbable.browser.test.ts} +3 -2
  325. package/src/types.ts +32 -0
  326. package/CHANGELOG.md +0 -317
  327. package/build/dom/index.cjs.map +0 -7
  328. package/build-module/dom/index.mjs.map +0 -7
  329. package/src/index.js +0 -12
  330. /package/src/dom/{index.js → index.ts} +0 -0
  331. /package/src/dom/test/{safe-html.jsdom.test.js → safe-html.jsdom.test.ts} +0 -0
  332. /package/src/dom/test/{strip-html.jsdom.test.js → strip-html.jsdom.test.ts} +0 -0
  333. /package/src/test/{focusable-area.jsdom.test.js → focusable-area.jsdom.test.ts} +0 -0
  334. /package/src/test/{utils.js → utils.ts} +0 -0
@@ -1,137 +1,86 @@
1
1
  "use strict";
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
-
20
- // packages/dom/src/dom/get-rectangle-from-range.js
21
- var get_rectangle_from_range_exports = {};
22
- __export(get_rectangle_from_range_exports, {
23
- default: () => getRectangleFromRange
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(get_rectangle_from_range_exports);
26
- var import_assert_is_defined = require("../utils/assert-is-defined.cjs");
6
+ let ___utils_assert_is_defined_ts = require("../utils/assert-is-defined.cjs");
7
+ // packages/dom/src/dom/get-rectangle-from-range.ts
8
+ /**
9
+ * Get the rectangle of a given Range. Returns `null` if no suitable rectangle
10
+ * can be found. Use instead of `Range.getBoundingClientRect()`, which is often
11
+ * broken, especially for collapsed ranges.
12
+ *
13
+ * @param range The range.
14
+ *
15
+ * @return The rectangle.
16
+ */
27
17
  function getRectangleFromRange(range) {
28
- if (!range.collapsed) {
29
- const rects2 = Array.from(range.getClientRects());
30
- if (rects2.length === 1) {
31
- return rects2[0];
32
- }
33
- const filteredRects = rects2.filter(({ width }) => width > 1);
34
- if (filteredRects.length === 0) {
35
- return range.getBoundingClientRect();
36
- }
37
- if (filteredRects.length === 1) {
38
- return filteredRects[0];
39
- }
40
- let {
41
- top: furthestTop,
42
- bottom: furthestBottom,
43
- left: furthestLeft,
44
- right: furthestRight
45
- } = filteredRects[0];
46
- for (const { top, bottom, left, right } of filteredRects) {
47
- if (top < furthestTop) {
48
- furthestTop = top;
49
- }
50
- if (bottom > furthestBottom) {
51
- furthestBottom = bottom;
52
- }
53
- if (left < furthestLeft) {
54
- furthestLeft = left;
55
- }
56
- if (right > furthestRight) {
57
- furthestRight = right;
58
- }
59
- }
60
- return new window.DOMRect(
61
- furthestLeft,
62
- furthestTop,
63
- furthestRight - furthestLeft,
64
- furthestBottom - furthestTop
65
- );
66
- }
67
- const { startContainer, startOffset } = range;
68
- const { ownerDocument } = startContainer;
69
- (0, import_assert_is_defined.assertIsDefined)(ownerDocument, "ownerDocument");
70
- if (startContainer.nodeType !== startContainer.TEXT_NODE && !startContainer.childNodes.length && startContainer.parentNode) {
71
- range = ownerDocument.createRange();
72
- range.setStartBefore(startContainer);
73
- range.collapse(true);
74
- return getRectangleFromRange(range);
75
- }
76
- if (startContainer.nodeType !== startContainer.TEXT_NODE) {
77
- let before = startContainer.childNodes[startOffset - 1];
78
- while (before?.lastChild) {
79
- before = before.lastChild;
80
- }
81
- let after = startContainer.childNodes[startOffset];
82
- while (after?.firstChild) {
83
- after = after.firstChild;
84
- }
85
- let beforeRange;
86
- if (before && before.nodeType === before.TEXT_NODE) {
87
- beforeRange = ownerDocument.createRange();
88
- beforeRange.setStart(
89
- before,
90
- /** @type {Text} */
91
- before.length
92
- );
93
- beforeRange.collapse(true);
94
- }
95
- let afterRange;
96
- if (after && after.nodeType === after.TEXT_NODE) {
97
- afterRange = ownerDocument.createRange();
98
- afterRange.setStart(after, 0);
99
- afterRange.collapse(true);
100
- }
101
- if (beforeRange && afterRange) {
102
- const beforeRect = beforeRange.getClientRects()[0];
103
- const afterRect = afterRange.getClientRects()[0];
104
- if (beforeRect && afterRect && beforeRect.bottom <= afterRect.top) {
105
- return null;
106
- }
107
- }
108
- if (afterRange) {
109
- range = afterRange;
110
- } else if (beforeRange) {
111
- range = beforeRange;
112
- } else {
113
- return null;
114
- }
115
- }
116
- const rects = range.getClientRects();
117
- if (rects.length > 1) {
118
- return null;
119
- }
120
- if (rects.length === 1 && startContainer.nodeType === startContainer.TEXT_NODE && range.startOffset > 0 && range.startOffset < /** @type {Text} */
121
- startContainer.length) {
122
- (0, import_assert_is_defined.assertIsDefined)(ownerDocument, "ownerDocument");
123
- const measure = (start, end) => {
124
- const charRange = ownerDocument.createRange();
125
- charRange.setStart(startContainer, start);
126
- charRange.setEnd(startContainer, end);
127
- return charRange.getBoundingClientRect();
128
- };
129
- const before = measure(range.startOffset - 1, range.startOffset);
130
- const after = measure(range.startOffset, range.startOffset + 1);
131
- if (before.bottom <= after.top) {
132
- return null;
133
- }
134
- }
135
- return rects[0] ?? null;
18
+ if (!range.collapsed) {
19
+ const rects = Array.from(range.getClientRects());
20
+ if (rects.length === 1) return rects[0];
21
+ const filteredRects = rects.filter(({ width }) => width > 1);
22
+ if (filteredRects.length === 0) return range.getBoundingClientRect();
23
+ if (filteredRects.length === 1) return filteredRects[0];
24
+ let { top: furthestTop, bottom: furthestBottom, left: furthestLeft, right: furthestRight } = filteredRects[0];
25
+ for (const { top, bottom, left, right } of filteredRects) {
26
+ if (top < furthestTop) furthestTop = top;
27
+ if (bottom > furthestBottom) furthestBottom = bottom;
28
+ if (left < furthestLeft) furthestLeft = left;
29
+ if (right > furthestRight) furthestRight = right;
30
+ }
31
+ return new window.DOMRect(furthestLeft, furthestTop, furthestRight - furthestLeft, furthestBottom - furthestTop);
32
+ }
33
+ const { startContainer, startOffset } = range;
34
+ const { ownerDocument } = startContainer;
35
+ (0, ___utils_assert_is_defined_ts.assertIsDefined)(ownerDocument, "ownerDocument");
36
+ if (startContainer.nodeType !== startContainer.TEXT_NODE && !startContainer.childNodes.length && startContainer.parentNode) {
37
+ range = ownerDocument.createRange();
38
+ range.setStartBefore(startContainer);
39
+ range.collapse(true);
40
+ return getRectangleFromRange(range);
41
+ }
42
+ if (startContainer.nodeType !== startContainer.TEXT_NODE) {
43
+ let before = startContainer.childNodes[startOffset - 1];
44
+ while (before?.lastChild) before = before.lastChild;
45
+ let after = startContainer.childNodes[startOffset];
46
+ while (after?.firstChild) after = after.firstChild;
47
+ let beforeRange;
48
+ if (before && before.nodeType === before.TEXT_NODE) {
49
+ beforeRange = ownerDocument.createRange();
50
+ beforeRange.setStart(before, before.length);
51
+ beforeRange.collapse(true);
52
+ }
53
+ let afterRange;
54
+ if (after && after.nodeType === after.TEXT_NODE) {
55
+ afterRange = ownerDocument.createRange();
56
+ afterRange.setStart(after, 0);
57
+ afterRange.collapse(true);
58
+ }
59
+ if (beforeRange && afterRange) {
60
+ const beforeRect = beforeRange.getClientRects()[0];
61
+ const afterRect = afterRange.getClientRects()[0];
62
+ if (beforeRect && afterRect && beforeRect.bottom <= afterRect.top) return null;
63
+ }
64
+ if (afterRange) range = afterRange;
65
+ else if (beforeRange) range = beforeRange;
66
+ else return null;
67
+ }
68
+ const rects = range.getClientRects();
69
+ if (rects.length > 1) return null;
70
+ if (rects.length === 1 && startContainer.nodeType === startContainer.TEXT_NODE && range.startOffset > 0 && range.startOffset < startContainer.length) {
71
+ (0, ___utils_assert_is_defined_ts.assertIsDefined)(ownerDocument, "ownerDocument");
72
+ const measure = (start, end) => {
73
+ const charRange = ownerDocument.createRange();
74
+ charRange.setStart(startContainer, start);
75
+ charRange.setEnd(startContainer, end);
76
+ return charRange.getBoundingClientRect();
77
+ };
78
+ const before = measure(range.startOffset - 1, range.startOffset);
79
+ const after = measure(range.startOffset, range.startOffset + 1);
80
+ if (before.bottom <= after.top) return null;
81
+ }
82
+ return rects[0] ?? null;
136
83
  }
137
- //# sourceMappingURL=get-rectangle-from-range.cjs.map
84
+ exports.default = getRectangleFromRange;
85
+
86
+ //# sourceMappingURL=get-rectangle-from-range.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/dom/get-rectangle-from-range.js"],
4
- "sourcesContent": ["import { 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. Use instead of `Range.getBoundingClientRect()`, which is often\n * broken, especially for collapsed ranges.\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, startOffset } = range;\n\tconst { ownerDocument } = startContainer;\n\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\n\t// A range inside an element with no children, like a line break or the\n\t// placeholder, is the same spot as the position before that element.\n\tif (\n\t\tstartContainer.nodeType !== startContainer.TEXT_NODE &&\n\t\t! startContainer.childNodes.length &&\n\t\tstartContainer.parentNode\n\t) {\n\t\trange = ownerDocument.createRange();\n\t\trange.setStartBefore( startContainer );\n\t\trange.collapse( true );\n\t\treturn getRectangleFromRange( range );\n\t}\n\n\t// A collapsed range at an element offset has no rectangle. Translate it\n\t// to the text offset next to it: the end of the text before or the start\n\t// of the text after. When those sit on different lines the caret could\n\t// be on either, so return null.\n\tif ( startContainer.nodeType !== startContainer.TEXT_NODE ) {\n\t\tlet before = startContainer.childNodes[ startOffset - 1 ];\n\t\twhile ( before?.lastChild ) {\n\t\t\tbefore = before.lastChild;\n\t\t}\n\t\tlet after = startContainer.childNodes[ startOffset ];\n\t\twhile ( after?.firstChild ) {\n\t\t\tafter = after.firstChild;\n\t\t}\n\n\t\tlet beforeRange;\n\t\tif ( before && before.nodeType === before.TEXT_NODE ) {\n\t\t\tbeforeRange = ownerDocument.createRange();\n\t\t\tbeforeRange.setStart(\n\t\t\t\tbefore,\n\t\t\t\t/** @type {Text} */ ( before ).length\n\t\t\t);\n\t\t\tbeforeRange.collapse( true );\n\t\t}\n\t\tlet afterRange;\n\t\tif ( after && after.nodeType === after.TEXT_NODE ) {\n\t\t\tafterRange = ownerDocument.createRange();\n\t\t\tafterRange.setStart( after, 0 );\n\t\t\tafterRange.collapse( true );\n\t\t}\n\n\t\tif ( beforeRange && afterRange ) {\n\t\t\tconst beforeRect = beforeRange.getClientRects()[ 0 ];\n\t\t\tconst afterRect = afterRange.getClientRects()[ 0 ];\n\t\t\tif (\n\t\t\t\tbeforeRect &&\n\t\t\t\tafterRect &&\n\t\t\t\tbeforeRect.bottom <= afterRect.top\n\t\t\t) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tif ( afterRange ) {\n\t\t\trange = afterRange;\n\t\t} else if ( beforeRange ) {\n\t\t\trange = beforeRange;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\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\t// A collapsed range at a soft line wrap is equally ambiguous: the same\n\t// position ends one line and starts the next. Some browsers (Gecko)\n\t// return a single rectangle for it, on the upper line, regardless of\n\t// where the caret is. Detect the boundary by measuring the characters\n\t// around the position: when they sit on different lines, there is no\n\t// way to know which line the caret is on, so don't return anything.\n\tif (\n\t\trects.length === 1 &&\n\t\tstartContainer.nodeType === startContainer.TEXT_NODE &&\n\t\trange.startOffset > 0 &&\n\t\trange.startOffset < /** @type {Text} */ ( startContainer ).length\n\t) {\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\tconst measure = (\n\t\t\t/** @type {number} */ start,\n\t\t\t/** @type {number} */ end\n\t\t) => {\n\t\t\tconst charRange = ownerDocument.createRange();\n\t\t\tcharRange.setStart( startContainer, start );\n\t\t\tcharRange.setEnd( startContainer, end );\n\t\t\treturn charRange.getBoundingClientRect();\n\t\t};\n\t\tconst before = measure( range.startOffset - 1, range.startOffset );\n\t\tconst after = measure( range.startOffset, range.startOffset + 1 );\n\n\t\tif ( before.bottom <= after.top ) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn rects[ 0 ] ?? null;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAgC;AAWjB,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,gBAAgB,YAAY,IAAI;AACxC,QAAM,EAAE,cAAc,IAAI;AAC1B,gDAAiB,eAAe,eAAgB;AAIhD,MACC,eAAe,aAAa,eAAe,aAC3C,CAAE,eAAe,WAAW,UAC5B,eAAe,YACd;AACD,YAAQ,cAAc,YAAY;AAClC,UAAM,eAAgB,cAAe;AACrC,UAAM,SAAU,IAAK;AACrB,WAAO,sBAAuB,KAAM;AAAA,EACrC;AAMA,MAAK,eAAe,aAAa,eAAe,WAAY;AAC3D,QAAI,SAAS,eAAe,WAAY,cAAc,CAAE;AACxD,WAAQ,QAAQ,WAAY;AAC3B,eAAS,OAAO;AAAA,IACjB;AACA,QAAI,QAAQ,eAAe,WAAY,WAAY;AACnD,WAAQ,OAAO,YAAa;AAC3B,cAAQ,MAAM;AAAA,IACf;AAEA,QAAI;AACJ,QAAK,UAAU,OAAO,aAAa,OAAO,WAAY;AACrD,oBAAc,cAAc,YAAY;AACxC,kBAAY;AAAA,QACX;AAAA;AAAA,QACsB,OAAS;AAAA,MAChC;AACA,kBAAY,SAAU,IAAK;AAAA,IAC5B;AACA,QAAI;AACJ,QAAK,SAAS,MAAM,aAAa,MAAM,WAAY;AAClD,mBAAa,cAAc,YAAY;AACvC,iBAAW,SAAU,OAAO,CAAE;AAC9B,iBAAW,SAAU,IAAK;AAAA,IAC3B;AAEA,QAAK,eAAe,YAAa;AAChC,YAAM,aAAa,YAAY,eAAe,EAAG,CAAE;AACnD,YAAM,YAAY,WAAW,eAAe,EAAG,CAAE;AACjD,UACC,cACA,aACA,WAAW,UAAU,UAAU,KAC9B;AACD,eAAO;AAAA,MACR;AAAA,IACD;AAEA,QAAK,YAAa;AACjB,cAAQ;AAAA,IACT,WAAY,aAAc;AACzB,cAAQ;AAAA,IACT,OAAO;AACN,aAAO;AAAA,IACR;AAAA,EACD;AAEA,QAAM,QAAQ,MAAM,eAAe;AAInC,MAAK,MAAM,SAAS,GAAI;AACvB,WAAO;AAAA,EACR;AAQA,MACC,MAAM,WAAW,KACjB,eAAe,aAAa,eAAe,aAC3C,MAAM,cAAc,KACpB,MAAM;AAAA,EAAoC,eAAiB,QAC1D;AACD,kDAAiB,eAAe,eAAgB;AAChD,UAAM,UAAU,CACO,OACA,QAClB;AACJ,YAAM,YAAY,cAAc,YAAY;AAC5C,gBAAU,SAAU,gBAAgB,KAAM;AAC1C,gBAAU,OAAQ,gBAAgB,GAAI;AACtC,aAAO,UAAU,sBAAsB;AAAA,IACxC;AACA,UAAM,SAAS,QAAS,MAAM,cAAc,GAAG,MAAM,WAAY;AACjE,UAAM,QAAQ,QAAS,MAAM,aAAa,MAAM,cAAc,CAAE;AAEhE,QAAK,OAAO,UAAU,MAAM,KAAM;AACjC,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO,MAAO,CAAE,KAAK;AACtB;",
6
- "names": ["rects"]
7
- }
1
+ {"version":3,"file":"get-rectangle-from-range.cjs","names":[],"sources":["../../src/dom/get-rectangle-from-range.ts"],"sourcesContent":["import { 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. Use instead of `Range.getBoundingClientRect()`, which is often\n * broken, especially for collapsed ranges.\n *\n * @param range The range.\n *\n * @return The rectangle.\n */\nexport default function getRectangleFromRange( range: Range ): DOMRect | null {\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, startOffset } = range;\n\tconst { ownerDocument } = startContainer;\n\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\n\t// A range inside an element with no children, like a line break or the\n\t// placeholder, is the same spot as the position before that element.\n\tif (\n\t\tstartContainer.nodeType !== startContainer.TEXT_NODE &&\n\t\t! startContainer.childNodes.length &&\n\t\tstartContainer.parentNode\n\t) {\n\t\trange = ownerDocument.createRange();\n\t\trange.setStartBefore( startContainer );\n\t\trange.collapse( true );\n\t\treturn getRectangleFromRange( range );\n\t}\n\n\t// A collapsed range at an element offset has no rectangle. Translate it\n\t// to the text offset next to it: the end of the text before or the start\n\t// of the text after. When those sit on different lines the caret could\n\t// be on either, so return null.\n\tif ( startContainer.nodeType !== startContainer.TEXT_NODE ) {\n\t\tlet before = startContainer.childNodes[ startOffset - 1 ];\n\t\twhile ( before?.lastChild ) {\n\t\t\tbefore = before.lastChild;\n\t\t}\n\t\tlet after = startContainer.childNodes[ startOffset ];\n\t\twhile ( after?.firstChild ) {\n\t\t\tafter = after.firstChild;\n\t\t}\n\n\t\tlet beforeRange;\n\t\tif ( before && before.nodeType === before.TEXT_NODE ) {\n\t\t\tbeforeRange = ownerDocument.createRange();\n\t\t\tbeforeRange.setStart( before, ( before as Text ).length );\n\t\t\tbeforeRange.collapse( true );\n\t\t}\n\t\tlet afterRange;\n\t\tif ( after && after.nodeType === after.TEXT_NODE ) {\n\t\t\tafterRange = ownerDocument.createRange();\n\t\t\tafterRange.setStart( after, 0 );\n\t\t\tafterRange.collapse( true );\n\t\t}\n\n\t\tif ( beforeRange && afterRange ) {\n\t\t\tconst beforeRect = beforeRange.getClientRects()[ 0 ];\n\t\t\tconst afterRect = afterRange.getClientRects()[ 0 ];\n\t\t\tif (\n\t\t\t\tbeforeRect &&\n\t\t\t\tafterRect &&\n\t\t\t\tbeforeRect.bottom <= afterRect.top\n\t\t\t) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\tif ( afterRange ) {\n\t\t\trange = afterRange;\n\t\t} else if ( beforeRange ) {\n\t\t\trange = beforeRange;\n\t\t} else {\n\t\t\treturn null;\n\t\t}\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\t// A collapsed range at a soft line wrap is equally ambiguous: the same\n\t// position ends one line and starts the next. Some browsers (Gecko)\n\t// return a single rectangle for it, on the upper line, regardless of\n\t// where the caret is. Detect the boundary by measuring the characters\n\t// around the position: when they sit on different lines, there is no\n\t// way to know which line the caret is on, so don't return anything.\n\tif (\n\t\trects.length === 1 &&\n\t\tstartContainer.nodeType === startContainer.TEXT_NODE &&\n\t\trange.startOffset > 0 &&\n\t\trange.startOffset < ( startContainer as Text ).length\n\t) {\n\t\tassertIsDefined( ownerDocument, 'ownerDocument' );\n\t\tconst measure = ( start: number, end: number ) => {\n\t\t\tconst charRange = ownerDocument.createRange();\n\t\t\tcharRange.setStart( startContainer, start );\n\t\t\tcharRange.setEnd( startContainer, end );\n\t\t\treturn charRange.getBoundingClientRect();\n\t\t};\n\t\tconst before = measure( range.startOffset - 1, range.startOffset );\n\t\tconst after = measure( range.startOffset, range.startOffset + 1 );\n\n\t\tif ( before.bottom <= after.top ) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn rects[ 0 ] ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,SAAwB,sBAAuB,OAA+B;CAI7E,IAAK,CAAE,MAAM,WAAY;EACxB,MAAM,QAAQ,MAAM,KAAM,MAAM,eAAe,CAAE;EAGjD,IAAK,MAAM,WAAW,GACrB,OAAO,MAAO;EAIf,MAAM,gBAAgB,MAAM,QAAU,EAAE,YAAa,QAAQ,CAAE;EAG/D,IAAK,cAAc,WAAW,GAC7B,OAAO,MAAM,sBAAsB;EAGpC,IAAK,cAAc,WAAW,GAC7B,OAAO,cAAe;EAGvB,IAAI,EACH,KAAK,aACL,QAAQ,gBACR,MAAM,cACN,OAAO,kBACJ,cAAe;EAEnB,KAAM,MAAM,EAAE,KAAK,QAAQ,MAAM,WAAW,eAAgB;GAC3D,IAAK,MAAM,aACV,cAAc;GAEf,IAAK,SAAS,gBACb,iBAAiB;GAElB,IAAK,OAAO,cACX,eAAe;GAEhB,IAAK,QAAQ,eACZ,gBAAgB;EAElB;EAEA,OAAO,IAAI,OAAO,QACjB,cACA,aACA,gBAAgB,cAChB,iBAAiB,WAClB;CACD;CAEA,MAAM,EAAE,gBAAgB,gBAAgB;CACxC,MAAM,EAAE,kBAAkB;CAC1B,CAAA,GAAA,8BAAA,gBAAA,CAAiB,eAAe,eAAgB;CAIhD,IACC,eAAe,aAAa,eAAe,aAC3C,CAAE,eAAe,WAAW,UAC5B,eAAe,YACd;EACD,QAAQ,cAAc,YAAY;EAClC,MAAM,eAAgB,cAAe;EACrC,MAAM,SAAU,IAAK;EACrB,OAAO,sBAAuB,KAAM;CACrC;CAMA,IAAK,eAAe,aAAa,eAAe,WAAY;EAC3D,IAAI,SAAS,eAAe,WAAY,cAAc;EACtD,OAAQ,QAAQ,WACf,SAAS,OAAO;EAEjB,IAAI,QAAQ,eAAe,WAAY;EACvC,OAAQ,OAAO,YACd,QAAQ,MAAM;EAGf,IAAI;EACJ,IAAK,UAAU,OAAO,aAAa,OAAO,WAAY;GACrD,cAAc,cAAc,YAAY;GACxC,YAAY,SAAU,QAAU,OAAiB,MAAO;GACxD,YAAY,SAAU,IAAK;EAC5B;EACA,IAAI;EACJ,IAAK,SAAS,MAAM,aAAa,MAAM,WAAY;GAClD,aAAa,cAAc,YAAY;GACvC,WAAW,SAAU,OAAO,CAAE;GAC9B,WAAW,SAAU,IAAK;EAC3B;EAEA,IAAK,eAAe,YAAa;GAChC,MAAM,aAAa,YAAY,eAAe,CAAC,CAAE;GACjD,MAAM,YAAY,WAAW,eAAe,CAAC,CAAE;GAC/C,IACC,cACA,aACA,WAAW,UAAU,UAAU,KAE/B,OAAO;EAET;EAEA,IAAK,YACJ,QAAQ;OACF,IAAK,aACX,QAAQ;OAER,OAAO;CAET;CAEA,MAAM,QAAQ,MAAM,eAAe;CAInC,IAAK,MAAM,SAAS,GACnB,OAAO;CASR,IACC,MAAM,WAAW,KACjB,eAAe,aAAa,eAAe,aAC3C,MAAM,cAAc,KACpB,MAAM,cAAgB,eAAyB,QAC9C;EACD,CAAA,GAAA,8BAAA,gBAAA,CAAiB,eAAe,eAAgB;EAChD,MAAM,WAAY,OAAe,QAAiB;GACjD,MAAM,YAAY,cAAc,YAAY;GAC5C,UAAU,SAAU,gBAAgB,KAAM;GAC1C,UAAU,OAAQ,gBAAgB,GAAI;GACtC,OAAO,UAAU,sBAAsB;EACxC;EACA,MAAM,SAAS,QAAS,MAAM,cAAc,GAAG,MAAM,WAAY;EACjE,MAAM,QAAQ,QAAS,MAAM,aAAa,MAAM,cAAc,CAAE;EAEhE,IAAK,OAAO,UAAU,MAAM,KAC3B,OAAO;CAET;CAEA,OAAO,MAAO,MAAO;AACtB"}
@@ -1,66 +1,58 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  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
13
  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;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
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
-
30
- // packages/dom/src/dom/get-scroll-container.js
31
- var get_scroll_container_exports = {};
32
- __export(get_scroll_container_exports, {
33
- default: () => getScrollContainer
34
- });
35
- module.exports = __toCommonJS(get_scroll_container_exports);
36
- var import_get_computed_style = __toESM(require("./get-computed-style.cjs"));
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let __get_computed_style_ts = require("./get-computed-style.cjs");
28
+ __get_computed_style_ts = __toESM(__get_computed_style_ts);
29
+ // packages/dom/src/dom/get-scroll-container.ts
30
+ /**
31
+ * Given a DOM node, finds the closest scrollable container node or the node
32
+ * itself, if scrollable.
33
+ *
34
+ * @param node Node from which to start.
35
+ * @param direction Direction of scrollable container to search for ('vertical', 'horizontal', 'all').
36
+ * Defaults to 'vertical'.
37
+ * @return Scrollable container node, if found.
38
+ */
37
39
  function getScrollContainer(node, direction = "vertical") {
38
- if (!node) {
39
- return void 0;
40
- }
41
- if (direction === "vertical" || direction === "all") {
42
- if (node.scrollHeight > node.clientHeight) {
43
- const { overflowY } = (0, import_get_computed_style.default)(node);
44
- if (/(auto|scroll)/.test(overflowY)) {
45
- return node;
46
- }
47
- }
48
- }
49
- if (direction === "horizontal" || direction === "all") {
50
- if (node.scrollWidth > node.clientWidth) {
51
- const { overflowX } = (0, import_get_computed_style.default)(node);
52
- if (/(auto|scroll)/.test(overflowX)) {
53
- return node;
54
- }
55
- }
56
- }
57
- if (node.ownerDocument === node.parentNode) {
58
- return node;
59
- }
60
- return getScrollContainer(
61
- /** @type {Element} */
62
- node.parentNode,
63
- direction
64
- );
40
+ if (!node) return;
41
+ if (direction === "vertical" || direction === "all") {
42
+ if (node.scrollHeight > node.clientHeight) {
43
+ const { overflowY } = (0, __get_computed_style_ts.default)(node);
44
+ if (/(auto|scroll)/.test(overflowY)) return node;
45
+ }
46
+ }
47
+ if (direction === "horizontal" || direction === "all") {
48
+ if (node.scrollWidth > node.clientWidth) {
49
+ const { overflowX } = (0, __get_computed_style_ts.default)(node);
50
+ if (/(auto|scroll)/.test(overflowX)) return node;
51
+ }
52
+ }
53
+ if (node.ownerDocument === node.parentNode) return node;
54
+ return getScrollContainer(node.parentNode, direction);
65
55
  }
66
- //# sourceMappingURL=get-scroll-container.cjs.map
56
+ exports.default = getScrollContainer;
57
+
58
+ //# sourceMappingURL=get-scroll-container.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/dom/get-scroll-container.js"],
4
- "sourcesContent": ["import getComputedStyle from './get-computed-style';\n\n/**\n * Given a DOM node, finds the closest scrollable container node or the node\n * itself, if scrollable.\n *\n * @param {Element | null} node Node from which to start.\n * @param {?string} direction Direction of scrollable container to search for ('vertical', 'horizontal', 'all').\n * Defaults to 'vertical'.\n * @return {Element | undefined} Scrollable container node, if found.\n */\nexport default function getScrollContainer( node, direction = 'vertical' ) {\n\tif ( ! node ) {\n\t\treturn undefined;\n\t}\n\n\tif ( direction === 'vertical' || direction === 'all' ) {\n\t\t// Scrollable if scrollable height exceeds displayed...\n\t\tif ( node.scrollHeight > node.clientHeight ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowY } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowY ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( direction === 'horizontal' || direction === 'all' ) {\n\t\t// Scrollable if scrollable width exceeds displayed...\n\t\tif ( node.scrollWidth > node.clientWidth ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowX } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowX ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( node.ownerDocument === node.parentNode ) {\n\t\treturn node;\n\t}\n\n\t// Continue traversing.\n\treturn getScrollContainer(\n\t\t/** @type {Element} */ ( node.parentNode ),\n\t\tdirection\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAA6B;AAWd,SAAR,mBAAqC,MAAM,YAAY,YAAa;AAC1E,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,MAAK,cAAc,cAAc,cAAc,OAAQ;AAEtD,QAAK,KAAK,eAAe,KAAK,cAAe;AAE5C,YAAM,EAAE,UAAU,QAAI,0BAAAA,SAAkB,IAAK;AAE7C,UAAK,gBAAgB,KAAM,SAAU,GAAI;AACxC,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,MAAK,cAAc,gBAAgB,cAAc,OAAQ;AAExD,QAAK,KAAK,cAAc,KAAK,aAAc;AAE1C,YAAM,EAAE,UAAU,QAAI,0BAAAA,SAAkB,IAAK;AAE7C,UAAK,gBAAgB,KAAM,SAAU,GAAI;AACxC,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,MAAK,KAAK,kBAAkB,KAAK,YAAa;AAC7C,WAAO;AAAA,EACR;AAGA,SAAO;AAAA;AAAA,IACmB,KAAK;AAAA,IAC9B;AAAA,EACD;AACD;",
6
- "names": ["getComputedStyle"]
7
- }
1
+ {"version":3,"file":"get-scroll-container.cjs","names":["getComputedStyle"],"sources":["../../src/dom/get-scroll-container.ts"],"sourcesContent":["import getComputedStyle from './get-computed-style';\n\n/**\n * Given a DOM node, finds the closest scrollable container node or the node\n * itself, if scrollable.\n *\n * @param node Node from which to start.\n * @param direction Direction of scrollable container to search for ('vertical', 'horizontal', 'all').\n * Defaults to 'vertical'.\n * @return Scrollable container node, if found.\n */\nexport default function getScrollContainer(\n\tnode: Element | null,\n\tdirection: 'vertical' | 'horizontal' | 'all' = 'vertical'\n): Element | undefined {\n\tif ( ! node ) {\n\t\treturn undefined;\n\t}\n\n\tif ( direction === 'vertical' || direction === 'all' ) {\n\t\t// Scrollable if scrollable height exceeds displayed...\n\t\tif ( node.scrollHeight > node.clientHeight ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowY } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowY ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( direction === 'horizontal' || direction === 'all' ) {\n\t\t// Scrollable if scrollable width exceeds displayed...\n\t\tif ( node.scrollWidth > node.clientWidth ) {\n\t\t\t// ...except when overflow is defined to be hidden or visible\n\t\t\tconst { overflowX } = getComputedStyle( node );\n\n\t\t\tif ( /(auto|scroll)/.test( overflowX ) ) {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( node.ownerDocument === node.parentNode ) {\n\t\treturn node;\n\t}\n\n\t// Continue traversing.\n\treturn getScrollContainer( node.parentNode as Element, direction );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,SAAwB,mBACvB,MACA,YAA+C,YACzB;CACtB,IAAK,CAAE,MACN;CAGD,IAAK,cAAc,cAAc,cAAc,OAEzC;MAAA,KAAK,eAAe,KAAK,cAAe;GAE5C,MAAM,EAAE,eAAA,GAAcA,wBAAAA,QAAAA,CAAkB,IAAK;GAE7C,IAAK,gBAAgB,KAAM,SAAU,GACpC,OAAO;EAET;;CAGD,IAAK,cAAc,gBAAgB,cAAc,OAE3C;MAAA,KAAK,cAAc,KAAK,aAAc;GAE1C,MAAM,EAAE,eAAA,GAAcA,wBAAAA,QAAAA,CAAkB,IAAK;GAE7C,IAAK,gBAAgB,KAAM,SAAU,GACpC,OAAO;EAET;;CAGD,IAAK,KAAK,kBAAkB,KAAK,YAChC,OAAO;CAIR,OAAO,mBAAoB,KAAK,YAAuB,SAAU;AAClE"}
@@ -1,54 +1,60 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  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
13
  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;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
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
-
30
- // packages/dom/src/dom/hidden-caret-range-from-point.js
31
- var hidden_caret_range_from_point_exports = {};
32
- __export(hidden_caret_range_from_point_exports, {
33
- default: () => hiddenCaretRangeFromPoint
34
- });
35
- module.exports = __toCommonJS(hidden_caret_range_from_point_exports);
36
- var import_caret_range_from_point = __toESM(require("./caret-range-from-point.cjs"));
37
- var import_get_computed_style = __toESM(require("./get-computed-style.cjs"));
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let __caret_range_from_point_ts = require("./caret-range-from-point.cjs");
28
+ __caret_range_from_point_ts = __toESM(__caret_range_from_point_ts);
29
+ let __get_computed_style_ts = require("./get-computed-style.cjs");
30
+ __get_computed_style_ts = __toESM(__get_computed_style_ts);
31
+ // packages/dom/src/dom/hidden-caret-range-from-point.ts
32
+ /**
33
+ * Get a collapsed range for a given point.
34
+ * Gives the container a temporary high z-index (above any UI).
35
+ * This is preferred over getting the UI nodes and set styles there.
36
+ *
37
+ * @param doc The document of the range.
38
+ * @param x Horizontal position within the current viewport.
39
+ * @param y Vertical position within the current viewport.
40
+ * @param container Container in which the range is expected to be found.
41
+ *
42
+ * @return The best range for the given point.
43
+ */
38
44
  function hiddenCaretRangeFromPoint(doc, x, y, container) {
39
- const originalZIndex = container.style.zIndex;
40
- const originalPosition = container.style.position;
41
- const originalBorderRadius = container.style.borderRadius;
42
- const { position = "static" } = (0, import_get_computed_style.default)(container);
43
- if (position === "static") {
44
- container.style.position = "relative";
45
- }
46
- container.style.zIndex = "10000";
47
- container.style.borderRadius = "0";
48
- const range = (0, import_caret_range_from_point.default)(doc, x, y);
49
- container.style.zIndex = originalZIndex;
50
- container.style.position = originalPosition;
51
- container.style.borderRadius = originalBorderRadius;
52
- return range;
45
+ const originalZIndex = container.style.zIndex;
46
+ const originalPosition = container.style.position;
47
+ const originalBorderRadius = container.style.borderRadius;
48
+ const { position = "static" } = (0, __get_computed_style_ts.default)(container);
49
+ if (position === "static") container.style.position = "relative";
50
+ container.style.zIndex = "10000";
51
+ container.style.borderRadius = "0";
52
+ const range = (0, __caret_range_from_point_ts.default)(doc, x, y);
53
+ container.style.zIndex = originalZIndex;
54
+ container.style.position = originalPosition;
55
+ container.style.borderRadius = originalBorderRadius;
56
+ return range;
53
57
  }
54
- //# sourceMappingURL=hidden-caret-range-from-point.cjs.map
58
+ exports.default = hiddenCaretRangeFromPoint;
59
+
60
+ //# sourceMappingURL=hidden-caret-range-from-point.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/dom/hidden-caret-range-from-point.js"],
4
- "sourcesContent": ["import caretRangeFromPoint from './caret-range-from-point';\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Get a collapsed range for a given point.\n * Gives the container a temporary high z-index (above any UI).\n * This is preferred over getting the UI nodes and set styles there.\n *\n * @param {Document} doc The document of the range.\n * @param {number} x Horizontal position within the current viewport.\n * @param {number} y Vertical position within the current viewport.\n * @param {HTMLElement} container Container in which the range is expected to be found.\n *\n * @return {?Range} The best range for the given point.\n */\nexport default function hiddenCaretRangeFromPoint( doc, x, y, container ) {\n\tconst originalZIndex = container.style.zIndex;\n\tconst originalPosition = container.style.position;\n\tconst originalBorderRadius = container.style.borderRadius;\n\n\tconst { position = 'static' } = getComputedStyle( container );\n\n\t// A z-index only works if the element position is not static.\n\tif ( position === 'static' ) {\n\t\tcontainer.style.position = 'relative';\n\t}\n\n\tcontainer.style.zIndex = '10000';\n\n\t// When an element has border radius, the x/y coordinates can incorrectly fall\n\t// outside the element because of the radius. Temporarily reset the value\n\t// to ensure the coordinates are tested against a rectangle and not a pill-shaped\n\t// element. See https://github.com/WordPress/gutenberg/issues/72053 for more info.\n\tcontainer.style.borderRadius = '0';\n\n\tconst range = caretRangeFromPoint( doc, x, y );\n\n\tcontainer.style.zIndex = originalZIndex;\n\tcontainer.style.position = originalPosition;\n\tcontainer.style.borderRadius = originalBorderRadius;\n\n\treturn range;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAgC;AAChC,gCAA6B;AAcd,SAAR,0BAA4C,KAAK,GAAG,GAAG,WAAY;AACzE,QAAM,iBAAiB,UAAU,MAAM;AACvC,QAAM,mBAAmB,UAAU,MAAM;AACzC,QAAM,uBAAuB,UAAU,MAAM;AAE7C,QAAM,EAAE,WAAW,SAAS,QAAI,0BAAAA,SAAkB,SAAU;AAG5D,MAAK,aAAa,UAAW;AAC5B,cAAU,MAAM,WAAW;AAAA,EAC5B;AAEA,YAAU,MAAM,SAAS;AAMzB,YAAU,MAAM,eAAe;AAE/B,QAAM,YAAQ,8BAAAC,SAAqB,KAAK,GAAG,CAAE;AAE7C,YAAU,MAAM,SAAS;AACzB,YAAU,MAAM,WAAW;AAC3B,YAAU,MAAM,eAAe;AAE/B,SAAO;AACR;",
6
- "names": ["getComputedStyle", "caretRangeFromPoint"]
7
- }
1
+ {"version":3,"file":"hidden-caret-range-from-point.cjs","names":["getComputedStyle","caretRangeFromPoint"],"sources":["../../src/dom/hidden-caret-range-from-point.ts"],"sourcesContent":["import caretRangeFromPoint from './caret-range-from-point';\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Get a collapsed range for a given point.\n * Gives the container a temporary high z-index (above any UI).\n * This is preferred over getting the UI nodes and set styles there.\n *\n * @param doc The document of the range.\n * @param x Horizontal position within the current viewport.\n * @param y Vertical position within the current viewport.\n * @param container Container in which the range is expected to be found.\n *\n * @return The best range for the given point.\n */\nexport default function hiddenCaretRangeFromPoint(\n\tdoc: Document,\n\tx: number,\n\ty: number,\n\tcontainer: HTMLElement\n): Range | null {\n\tconst originalZIndex = container.style.zIndex;\n\tconst originalPosition = container.style.position;\n\tconst originalBorderRadius = container.style.borderRadius;\n\n\tconst { position = 'static' } = getComputedStyle( container );\n\n\t// A z-index only works if the element position is not static.\n\tif ( position === 'static' ) {\n\t\tcontainer.style.position = 'relative';\n\t}\n\n\tcontainer.style.zIndex = '10000';\n\n\t// When an element has border radius, the x/y coordinates can incorrectly fall\n\t// outside the element because of the radius. Temporarily reset the value\n\t// to ensure the coordinates are tested against a rectangle and not a pill-shaped\n\t// element. See https://github.com/WordPress/gutenberg/issues/72053 for more info.\n\tcontainer.style.borderRadius = '0';\n\n\tconst range = caretRangeFromPoint( doc, x, y );\n\n\tcontainer.style.zIndex = originalZIndex;\n\tcontainer.style.position = originalPosition;\n\tcontainer.style.borderRadius = originalBorderRadius;\n\n\treturn range;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,SAAwB,0BACvB,KACA,GACA,GACA,WACe;CACf,MAAM,iBAAiB,UAAU,MAAM;CACvC,MAAM,mBAAmB,UAAU,MAAM;CACzC,MAAM,uBAAuB,UAAU,MAAM;CAE7C,MAAM,EAAE,WAAW,cAAA,GAAaA,wBAAAA,QAAAA,CAAkB,SAAU;CAG5D,IAAK,aAAa,UACjB,UAAU,MAAM,WAAW;CAG5B,UAAU,MAAM,SAAS;CAMzB,UAAU,MAAM,eAAe;CAE/B,MAAM,SAAA,GAAQC,4BAAAA,QAAAA,CAAqB,KAAK,GAAG,CAAE;CAE7C,UAAU,MAAM,SAAS;CACzB,UAAU,MAAM,WAAW;CAC3B,UAAU,MAAM,eAAe;CAE/B,OAAO;AACR"}