@wordpress/dom 4.56.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -22
- package/build/data-transfer.cjs +1 -1
- package/build/data-transfer.cjs.map +3 -3
- package/build/dom/caret-range-from-point.cjs +1 -1
- package/build/dom/caret-range-from-point.cjs.map +3 -3
- package/build/dom/clean-node-list.cjs +1 -1
- package/build/dom/clean-node-list.cjs.map +3 -3
- package/build/dom/compute-caret-rect.cjs +1 -1
- package/build/dom/compute-caret-rect.cjs.map +3 -3
- package/build/dom/document-has-selection.cjs +1 -1
- package/build/dom/document-has-selection.cjs.map +3 -3
- package/build/dom/document-has-text-selection.cjs +1 -1
- package/build/dom/document-has-text-selection.cjs.map +3 -3
- package/build/dom/document-has-uncollapsed-selection.cjs +1 -1
- package/build/dom/document-has-uncollapsed-selection.cjs.map +3 -3
- package/build/dom/get-computed-style.cjs +1 -1
- package/build/dom/get-computed-style.cjs.map +3 -3
- package/build/dom/get-offset-parent.cjs +7 -15
- package/build/dom/get-offset-parent.cjs.map +4 -4
- package/build/dom/get-range-height.cjs +1 -1
- package/build/dom/get-range-height.cjs.map +3 -3
- package/build/dom/get-rectangle-from-range.cjs +3 -8
- package/build/dom/get-rectangle-from-range.cjs.map +3 -3
- package/build/dom/get-scroll-container.cjs +2 -6
- package/build/dom/get-scroll-container.cjs.map +3 -3
- package/build/dom/hidden-caret-range-from-point.cjs +1 -1
- package/build/dom/hidden-caret-range-from-point.cjs.map +3 -3
- package/build/dom/index.cjs +1 -1
- package/build/dom/index.cjs.map +1 -1
- package/build/dom/input-field-has-uncollapsed-selection.cjs +2 -5
- package/build/dom/input-field-has-uncollapsed-selection.cjs.map +3 -3
- package/build/dom/insert-after.cjs +1 -1
- package/build/dom/insert-after.cjs.map +3 -3
- package/build/dom/is-edge.cjs +1 -1
- package/build/dom/is-edge.cjs.map +3 -3
- package/build/dom/is-element.cjs +1 -1
- package/build/dom/is-element.cjs.map +3 -3
- package/build/dom/is-empty.cjs +2 -5
- package/build/dom/is-empty.cjs.map +3 -3
- package/build/dom/is-entirely-selected.cjs +2 -5
- package/build/dom/is-entirely-selected.cjs.map +3 -3
- package/build/dom/is-form-element.cjs +1 -1
- package/build/dom/is-form-element.cjs.map +3 -3
- package/build/dom/is-horizontal-edge.cjs +1 -1
- package/build/dom/is-horizontal-edge.cjs.map +3 -3
- package/build/dom/is-html-input-element.cjs +1 -1
- package/build/dom/is-html-input-element.cjs.map +3 -3
- package/build/dom/is-input-or-text-area.cjs +1 -1
- package/build/dom/is-input-or-text-area.cjs.map +3 -3
- package/build/dom/is-number-input.cjs +1 -1
- package/build/dom/is-number-input.cjs.map +3 -3
- package/build/dom/is-rtl.cjs +1 -1
- package/build/dom/is-rtl.cjs.map +3 -3
- package/build/dom/is-selection-forward.cjs +1 -1
- package/build/dom/is-selection-forward.cjs.map +3 -3
- package/build/dom/is-text-field.cjs +2 -3
- package/build/dom/is-text-field.cjs.map +3 -3
- package/build/dom/is-vertical-edge.cjs +1 -1
- package/build/dom/is-vertical-edge.cjs.map +3 -3
- package/build/dom/place-caret-at-edge.cjs +1 -1
- package/build/dom/place-caret-at-edge.cjs.map +3 -3
- package/build/dom/place-caret-at-horizontal-edge.cjs +1 -1
- package/build/dom/place-caret-at-horizontal-edge.cjs.map +3 -3
- package/build/dom/place-caret-at-vertical-edge.cjs +1 -1
- package/build/dom/place-caret-at-vertical-edge.cjs.map +3 -3
- package/build/dom/remove-invalid-html.cjs +1 -1
- package/build/dom/remove-invalid-html.cjs.map +3 -3
- package/build/dom/remove.cjs +1 -1
- package/build/dom/remove.cjs.map +3 -3
- package/build/dom/replace-tag.cjs +1 -1
- package/build/dom/replace-tag.cjs.map +3 -3
- package/build/dom/replace.cjs +1 -1
- package/build/dom/replace.cjs.map +3 -3
- package/build/dom/safe-html.cjs +1 -1
- package/build/dom/safe-html.cjs.map +3 -3
- package/build/dom/scroll-if-no-range.cjs +1 -1
- package/build/dom/scroll-if-no-range.cjs.map +3 -3
- package/build/dom/strip-html.cjs +1 -1
- package/build/dom/strip-html.cjs.map +3 -3
- package/build/dom/types.cjs +19 -0
- package/build/dom/types.cjs.map +7 -0
- package/build/dom/unwrap.cjs +1 -1
- package/build/dom/unwrap.cjs.map +3 -3
- package/build/dom/wrap.cjs +1 -1
- package/build/dom/wrap.cjs.map +3 -3
- package/build/focusable.cjs +5 -6
- package/build/focusable.cjs.map +3 -3
- package/build/index.cjs +1 -1
- package/build/index.cjs.map +2 -2
- package/build/phrasing-content.cjs +1 -1
- package/build/phrasing-content.cjs.map +3 -3
- package/build/tabbable.cjs +1 -1
- package/build/tabbable.cjs.map +3 -3
- package/build/types.cjs +19 -0
- package/build/types.cjs.map +7 -0
- package/build-module/data-transfer.mjs +1 -1
- package/build-module/data-transfer.mjs.map +3 -3
- package/build-module/dom/caret-range-from-point.mjs +1 -1
- package/build-module/dom/caret-range-from-point.mjs.map +3 -3
- package/build-module/dom/clean-node-list.mjs +1 -1
- package/build-module/dom/clean-node-list.mjs.map +3 -3
- package/build-module/dom/compute-caret-rect.mjs +1 -1
- package/build-module/dom/compute-caret-rect.mjs.map +3 -3
- package/build-module/dom/document-has-selection.mjs +1 -1
- package/build-module/dom/document-has-selection.mjs.map +3 -3
- package/build-module/dom/document-has-text-selection.mjs +1 -1
- package/build-module/dom/document-has-text-selection.mjs.map +3 -3
- package/build-module/dom/document-has-uncollapsed-selection.mjs +1 -1
- package/build-module/dom/document-has-uncollapsed-selection.mjs.map +3 -3
- package/build-module/dom/get-computed-style.mjs +1 -1
- package/build-module/dom/get-computed-style.mjs.map +3 -3
- package/build-module/dom/get-offset-parent.mjs +7 -15
- package/build-module/dom/get-offset-parent.mjs.map +3 -3
- package/build-module/dom/get-range-height.mjs +1 -1
- package/build-module/dom/get-range-height.mjs.map +3 -3
- package/build-module/dom/get-rectangle-from-range.mjs +3 -8
- package/build-module/dom/get-rectangle-from-range.mjs.map +3 -3
- package/build-module/dom/get-scroll-container.mjs +2 -6
- package/build-module/dom/get-scroll-container.mjs.map +3 -3
- package/build-module/dom/hidden-caret-range-from-point.mjs +1 -1
- package/build-module/dom/hidden-caret-range-from-point.mjs.map +3 -3
- package/build-module/dom/index.mjs +1 -1
- package/build-module/dom/index.mjs.map +1 -1
- package/build-module/dom/input-field-has-uncollapsed-selection.mjs +2 -5
- package/build-module/dom/input-field-has-uncollapsed-selection.mjs.map +3 -3
- package/build-module/dom/insert-after.mjs +1 -1
- package/build-module/dom/insert-after.mjs.map +3 -3
- package/build-module/dom/is-edge.mjs +1 -1
- package/build-module/dom/is-edge.mjs.map +3 -3
- package/build-module/dom/is-element.mjs +1 -1
- package/build-module/dom/is-element.mjs.map +3 -3
- package/build-module/dom/is-empty.mjs +2 -5
- package/build-module/dom/is-empty.mjs.map +3 -3
- package/build-module/dom/is-entirely-selected.mjs +2 -5
- package/build-module/dom/is-entirely-selected.mjs.map +3 -3
- package/build-module/dom/is-form-element.mjs +1 -1
- package/build-module/dom/is-form-element.mjs.map +3 -3
- package/build-module/dom/is-horizontal-edge.mjs +1 -1
- package/build-module/dom/is-horizontal-edge.mjs.map +3 -3
- package/build-module/dom/is-html-input-element.mjs +1 -1
- package/build-module/dom/is-html-input-element.mjs.map +3 -3
- package/build-module/dom/is-input-or-text-area.mjs +1 -1
- package/build-module/dom/is-input-or-text-area.mjs.map +3 -3
- package/build-module/dom/is-number-input.mjs +1 -1
- package/build-module/dom/is-number-input.mjs.map +3 -3
- package/build-module/dom/is-rtl.mjs +1 -1
- package/build-module/dom/is-rtl.mjs.map +3 -3
- package/build-module/dom/is-selection-forward.mjs +1 -1
- package/build-module/dom/is-selection-forward.mjs.map +3 -3
- package/build-module/dom/is-text-field.mjs +2 -3
- package/build-module/dom/is-text-field.mjs.map +3 -3
- package/build-module/dom/is-vertical-edge.mjs +1 -1
- package/build-module/dom/is-vertical-edge.mjs.map +3 -3
- package/build-module/dom/place-caret-at-edge.mjs +1 -1
- package/build-module/dom/place-caret-at-edge.mjs.map +3 -3
- package/build-module/dom/place-caret-at-horizontal-edge.mjs +1 -1
- package/build-module/dom/place-caret-at-horizontal-edge.mjs.map +3 -3
- package/build-module/dom/place-caret-at-vertical-edge.mjs +1 -1
- package/build-module/dom/place-caret-at-vertical-edge.mjs.map +3 -3
- package/build-module/dom/remove-invalid-html.mjs +1 -1
- package/build-module/dom/remove-invalid-html.mjs.map +3 -3
- package/build-module/dom/remove.mjs +1 -1
- package/build-module/dom/remove.mjs.map +3 -3
- package/build-module/dom/replace-tag.mjs +1 -1
- package/build-module/dom/replace-tag.mjs.map +3 -3
- package/build-module/dom/replace.mjs +1 -1
- package/build-module/dom/replace.mjs.map +3 -3
- package/build-module/dom/safe-html.mjs +1 -1
- package/build-module/dom/safe-html.mjs.map +3 -3
- package/build-module/dom/scroll-if-no-range.mjs +1 -1
- package/build-module/dom/scroll-if-no-range.mjs.map +3 -3
- package/build-module/dom/strip-html.mjs +1 -1
- package/build-module/dom/strip-html.mjs.map +3 -3
- package/build-module/dom/types.mjs +1 -0
- package/build-module/dom/types.mjs.map +7 -0
- package/build-module/dom/unwrap.mjs +1 -1
- package/build-module/dom/unwrap.mjs.map +3 -3
- package/build-module/dom/wrap.mjs +1 -1
- package/build-module/dom/wrap.mjs.map +3 -3
- package/build-module/focusable.mjs +5 -6
- package/build-module/focusable.mjs.map +3 -3
- package/build-module/index.mjs +1 -1
- package/build-module/index.mjs.map +2 -2
- package/build-module/phrasing-content.mjs +1 -1
- package/build-module/phrasing-content.mjs.map +3 -3
- package/build-module/tabbable.mjs +1 -1
- package/build-module/tabbable.mjs.map +3 -3
- package/build-module/types.mjs +1 -0
- package/build-module/types.mjs.map +7 -0
- package/build-types/data-transfer.d.ts +2 -2
- package/build-types/data-transfer.d.ts.map +1 -1
- package/build-types/dom/caret-range-from-point.d.ts +4 -4
- package/build-types/dom/caret-range-from-point.d.ts.map +1 -1
- package/build-types/dom/clean-node-list.d.ts +5 -45
- package/build-types/dom/clean-node-list.d.ts.map +1 -1
- package/build-types/dom/compute-caret-rect.d.ts +2 -2
- package/build-types/dom/compute-caret-rect.d.ts.map +1 -1
- package/build-types/dom/document-has-selection.d.ts +2 -2
- package/build-types/dom/document-has-selection.d.ts.map +1 -1
- package/build-types/dom/document-has-text-selection.d.ts +2 -2
- package/build-types/dom/document-has-text-selection.d.ts.map +1 -1
- package/build-types/dom/document-has-uncollapsed-selection.d.ts +2 -2
- package/build-types/dom/document-has-uncollapsed-selection.d.ts.map +1 -1
- package/build-types/dom/get-computed-style.d.ts +3 -3
- package/build-types/dom/get-computed-style.d.ts.map +1 -1
- package/build-types/dom/get-offset-parent.d.ts +2 -2
- package/build-types/dom/get-offset-parent.d.ts.map +1 -1
- package/build-types/dom/get-range-height.d.ts +2 -2
- package/build-types/dom/get-range-height.d.ts.map +1 -1
- package/build-types/dom/get-rectangle-from-range.d.ts +2 -2
- package/build-types/dom/get-rectangle-from-range.d.ts.map +1 -1
- package/build-types/dom/get-scroll-container.d.ts +5 -5
- package/build-types/dom/get-scroll-container.d.ts.map +1 -1
- package/build-types/dom/hidden-caret-range-from-point.d.ts +5 -5
- package/build-types/dom/hidden-caret-range-from-point.d.ts.map +1 -1
- package/build-types/dom/index.d.ts.map +1 -1
- package/build-types/dom/input-field-has-uncollapsed-selection.d.ts +2 -2
- package/build-types/dom/input-field-has-uncollapsed-selection.d.ts.map +1 -1
- package/build-types/dom/insert-after.d.ts +2 -3
- package/build-types/dom/insert-after.d.ts.map +1 -1
- package/build-types/dom/is-edge.d.ts +4 -4
- package/build-types/dom/is-edge.d.ts.map +1 -1
- package/build-types/dom/is-element.d.ts.map +1 -1
- package/build-types/dom/is-empty.d.ts +3 -3
- package/build-types/dom/is-empty.d.ts.map +1 -1
- package/build-types/dom/is-entirely-selected.d.ts +2 -2
- package/build-types/dom/is-entirely-selected.d.ts.map +1 -1
- package/build-types/dom/is-form-element.d.ts +3 -3
- package/build-types/dom/is-form-element.d.ts.map +1 -1
- package/build-types/dom/is-horizontal-edge.d.ts.map +1 -1
- package/build-types/dom/is-html-input-element.d.ts +1 -1
- package/build-types/dom/is-html-input-element.d.ts.map +1 -1
- package/build-types/dom/is-input-or-text-area.d.ts.map +1 -1
- package/build-types/dom/is-number-input.d.ts +2 -2
- package/build-types/dom/is-number-input.d.ts.map +1 -1
- package/build-types/dom/is-rtl.d.ts +2 -2
- package/build-types/dom/is-rtl.d.ts.map +1 -1
- package/build-types/dom/is-selection-forward.d.ts +2 -2
- package/build-types/dom/is-selection-forward.d.ts.map +1 -1
- package/build-types/dom/is-text-field.d.ts +2 -2
- package/build-types/dom/is-text-field.d.ts.map +1 -1
- package/build-types/dom/is-vertical-edge.d.ts.map +1 -1
- package/build-types/dom/place-caret-at-edge.d.ts +3 -3
- package/build-types/dom/place-caret-at-edge.d.ts.map +1 -1
- package/build-types/dom/place-caret-at-horizontal-edge.d.ts.map +1 -1
- package/build-types/dom/place-caret-at-vertical-edge.d.ts.map +1 -1
- package/build-types/dom/remove-invalid-html.d.ts +5 -4
- package/build-types/dom/remove-invalid-html.d.ts.map +1 -1
- package/build-types/dom/remove.d.ts +1 -2
- package/build-types/dom/remove.d.ts.map +1 -1
- package/build-types/dom/replace-tag.d.ts +3 -3
- package/build-types/dom/replace-tag.d.ts.map +1 -1
- package/build-types/dom/replace.d.ts +2 -3
- package/build-types/dom/replace.d.ts.map +1 -1
- package/build-types/dom/safe-html.d.ts +2 -2
- package/build-types/dom/safe-html.d.ts.map +1 -1
- package/build-types/dom/scroll-if-no-range.d.ts +5 -5
- package/build-types/dom/scroll-if-no-range.d.ts.map +1 -1
- package/build-types/dom/strip-html.d.ts +2 -2
- package/build-types/dom/strip-html.d.ts.map +1 -1
- package/build-types/dom/types.d.ts +32 -0
- package/build-types/dom/types.d.ts.map +1 -0
- package/build-types/dom/unwrap.d.ts +1 -3
- package/build-types/dom/unwrap.d.ts.map +1 -1
- package/build-types/dom/wrap.d.ts +2 -2
- package/build-types/dom/wrap.d.ts.map +1 -1
- package/build-types/focusable.d.ts +11 -30
- package/build-types/focusable.d.ts.map +1 -1
- package/build-types/index.d.ts +17 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/phrasing-content.d.ts +9 -24
- package/build-types/phrasing-content.d.ts.map +1 -1
- package/build-types/tabbable.d.ts +10 -15
- package/build-types/tabbable.d.ts.map +1 -1
- package/build-types/types.d.ts +29 -0
- package/build-types/types.d.ts.map +1 -0
- package/package.json +6 -7
- package/src/{data-transfer.js → data-transfer.ts} +3 -3
- package/src/dom/{caret-range-from-point.js → caret-range-from-point.ts} +9 -5
- package/src/dom/{clean-node-list.js → clean-node-list.ts} +16 -24
- package/src/dom/{compute-caret-rect.js → compute-caret-rect.ts} +3 -3
- package/src/dom/{document-has-selection.js → document-has-selection.ts} +3 -3
- package/src/dom/{document-has-text-selection.js → document-has-text-selection.ts} +3 -3
- package/src/dom/{document-has-uncollapsed-selection.js → document-has-uncollapsed-selection.ts} +5 -3
- package/src/dom/{get-computed-style.js → get-computed-style.ts} +5 -3
- package/src/dom/{get-offset-parent.js → get-offset-parent.ts} +9 -14
- package/src/dom/{get-range-height.js → get-range-height.ts} +3 -3
- package/src/dom/{get-rectangle-from-range.js → get-rectangle-from-range.ts} +6 -12
- package/src/dom/{get-scroll-container.js → get-scroll-container.ts} +9 -9
- package/src/dom/{hidden-caret-range-from-point.js → hidden-caret-range-from-point.ts} +11 -6
- package/src/dom/{input-field-has-uncollapsed-selection.js → input-field-has-uncollapsed-selection.ts} +7 -5
- package/src/dom/{insert-after.js → insert-after.ts} +6 -4
- package/src/dom/{is-edge.js → is-edge.ts} +9 -5
- package/src/dom/{is-element.js → is-element.ts} +3 -1
- package/src/dom/{is-empty.js → is-empty.ts} +5 -7
- package/src/dom/{is-entirely-selected.js → is-entirely-selected.ts} +14 -11
- package/src/dom/{is-form-element.js → is-form-element.ts} +5 -3
- package/src/dom/{is-horizontal-edge.js → is-horizontal-edge.ts} +4 -1
- package/src/dom/{is-html-input-element.js → is-html-input-element.ts} +3 -1
- package/src/dom/{is-input-or-text-area.js → is-input-or-text-area.ts} +3 -1
- package/src/dom/{is-number-input.js → is-number-input.ts} +3 -3
- package/src/dom/{is-rtl.js → is-rtl.ts} +3 -3
- package/src/dom/{is-selection-forward.js → is-selection-forward.ts} +3 -3
- package/src/dom/{is-text-field.js → is-text-field.ts} +4 -4
- package/src/dom/{is-vertical-edge.js → is-vertical-edge.ts} +4 -1
- package/src/dom/{place-caret-at-edge.js → place-caret-at-edge.ts} +17 -9
- package/src/dom/{place-caret-at-horizontal-edge.js → place-caret-at-horizontal-edge.ts} +4 -1
- package/src/dom/{place-caret-at-vertical-edge.js → place-caret-at-vertical-edge.ts} +5 -1
- package/src/dom/{remove-invalid-html.js → remove-invalid-html.ts} +9 -4
- package/src/dom/{remove.js → remove.ts} +2 -3
- package/src/dom/{replace-tag.js → replace-tag.ts} +4 -4
- package/src/dom/{replace.js → replace.ts} +6 -4
- package/src/dom/{safe-html.js → safe-html.ts} +3 -3
- package/src/dom/{scroll-if-no-range.js → scroll-if-no-range.ts} +9 -5
- package/src/dom/{strip-html.js → strip-html.ts} +3 -3
- package/src/dom/types.ts +28 -0
- package/src/dom/{unwrap.js → unwrap.ts} +2 -4
- package/src/dom/{wrap.js → wrap.ts} +3 -3
- package/src/{focusable.js → focusable.ts} +34 -32
- package/src/index.ts +33 -0
- package/src/{phrasing-content.js → phrasing-content.ts} +15 -30
- package/src/{tabbable.js → tabbable.ts} +48 -39
- package/src/test/dom.jsdom.test.js +21 -0
- package/src/types.ts +32 -0
- package/CHANGELOG.md +0 -315
- package/src/index.js +0 -12
- /package/src/dom/{index.js → index.ts} +0 -0
package/README.md
CHANGED
|
@@ -26,6 +26,10 @@ _Returns_
|
|
|
26
26
|
|
|
27
27
|
- `DOMRect | null`: The rectangle.
|
|
28
28
|
|
|
29
|
+
### ContentSchema
|
|
30
|
+
|
|
31
|
+
Schema of the content allowed inside an element, keyed by tag name.
|
|
32
|
+
|
|
29
33
|
### documentHasSelection
|
|
30
34
|
|
|
31
35
|
Check whether the current document has a selection. This includes focus in input fields, textareas, and general rich-text selection.
|
|
@@ -110,7 +114,7 @@ _Parameters_
|
|
|
110
114
|
|
|
111
115
|
_Returns_
|
|
112
116
|
|
|
113
|
-
- `
|
|
117
|
+
- `ContentSchema`: Schema.
|
|
114
118
|
|
|
115
119
|
### getRectangleFromRange
|
|
116
120
|
|
|
@@ -122,7 +126,7 @@ _Parameters_
|
|
|
122
126
|
|
|
123
127
|
_Returns_
|
|
124
128
|
|
|
125
|
-
- `DOMRect
|
|
129
|
+
- `DOMRect | null`: The rectangle.
|
|
126
130
|
|
|
127
131
|
### getScrollContainer
|
|
128
132
|
|
|
@@ -131,7 +135,7 @@ Given a DOM node, finds the closest scrollable container node or the node itself
|
|
|
131
135
|
_Parameters_
|
|
132
136
|
|
|
133
137
|
- _node_ `Element | null`: Node from which to start.
|
|
134
|
-
- _direction_
|
|
138
|
+
- _direction_ `'vertical' | 'horizontal' | 'all'`: Direction of scrollable container to search for ('vertical', 'horizontal', 'all'). Defaults to 'vertical'.
|
|
135
139
|
|
|
136
140
|
_Returns_
|
|
137
141
|
|
|
@@ -146,17 +150,13 @@ _Parameters_
|
|
|
146
150
|
- _newNode_ `Node`: Node to be inserted.
|
|
147
151
|
- _referenceNode_ `Node`: Node after which to perform the insertion.
|
|
148
152
|
|
|
149
|
-
_Returns_
|
|
150
|
-
|
|
151
|
-
- `void`:
|
|
152
|
-
|
|
153
153
|
### isEmpty
|
|
154
154
|
|
|
155
155
|
Recursively checks if an element is empty. An element is not empty if it contains text or contains elements with attributes such as images.
|
|
156
156
|
|
|
157
157
|
_Parameters_
|
|
158
158
|
|
|
159
|
-
- _element_ `
|
|
159
|
+
- _element_ `Node`: The element to check.
|
|
160
160
|
|
|
161
161
|
_Returns_
|
|
162
162
|
|
|
@@ -180,7 +180,7 @@ Detects if element is a form element.
|
|
|
180
180
|
|
|
181
181
|
_Parameters_
|
|
182
182
|
|
|
183
|
-
- _element_ `Element`: The element to check.
|
|
183
|
+
- _element_ `Element | null | undefined`: The element to check.
|
|
184
184
|
|
|
185
185
|
_Returns_
|
|
186
186
|
|
|
@@ -319,10 +319,6 @@ _Parameters_
|
|
|
319
319
|
|
|
320
320
|
- _node_ `Node`: Node to be removed.
|
|
321
321
|
|
|
322
|
-
_Returns_
|
|
323
|
-
|
|
324
|
-
- `void`:
|
|
325
|
-
|
|
326
322
|
### removeInvalidHTML
|
|
327
323
|
|
|
328
324
|
Given a schema, unwraps or removes nodes, attributes and classes on HTML.
|
|
@@ -330,7 +326,7 @@ Given a schema, unwraps or removes nodes, attributes and classes on HTML.
|
|
|
330
326
|
_Parameters_
|
|
331
327
|
|
|
332
328
|
- _HTML_ `string`: The HTML to clean up.
|
|
333
|
-
- _schema_ `
|
|
329
|
+
- _schema_ `Schema`: Schema for the HTML.
|
|
334
330
|
- _inline_ `boolean`: Whether to clean for inline mode.
|
|
335
331
|
|
|
336
332
|
_Returns_
|
|
@@ -346,10 +342,6 @@ _Parameters_
|
|
|
346
342
|
- _processedNode_ `Element`: Node to be removed.
|
|
347
343
|
- _newNode_ `Element`: Node to be inserted in its place.
|
|
348
344
|
|
|
349
|
-
_Returns_
|
|
350
|
-
|
|
351
|
-
- `void`:
|
|
352
|
-
|
|
353
345
|
### replaceTag
|
|
354
346
|
|
|
355
347
|
Replaces the given node with a new node with the given tag name.
|
|
@@ -375,6 +367,18 @@ _Returns_
|
|
|
375
367
|
|
|
376
368
|
- `string`: The sanitized HTML.
|
|
377
369
|
|
|
370
|
+
### Schema
|
|
371
|
+
|
|
372
|
+
Schema that `cleanNodeList` and `removeInvalidHTML` clean HTML against, keyed by tag name.
|
|
373
|
+
|
|
374
|
+
### SchemaItem
|
|
375
|
+
|
|
376
|
+
The rules for a single tag in a `Schema`.
|
|
377
|
+
|
|
378
|
+
### SemanticElementDefinition
|
|
379
|
+
|
|
380
|
+
The attributes and children allowed for an element in a `ContentSchema`.
|
|
381
|
+
|
|
378
382
|
### unwrap
|
|
379
383
|
|
|
380
384
|
Unwrap the given node. This means any child nodes are moved to the parent.
|
|
@@ -383,10 +387,6 @@ _Parameters_
|
|
|
383
387
|
|
|
384
388
|
- _node_ `Node`: The node to unwrap.
|
|
385
389
|
|
|
386
|
-
_Returns_
|
|
387
|
-
|
|
388
|
-
- `void`:
|
|
389
|
-
|
|
390
390
|
### wrap
|
|
391
391
|
|
|
392
392
|
Wraps the given node with a new node with the given tag name.
|
package/build/data-transfer.cjs
CHANGED
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/dom/src/data-transfer.
|
|
20
|
+
// packages/dom/src/data-transfer.ts
|
|
21
21
|
var data_transfer_exports = {};
|
|
22
22
|
__export(data_transfer_exports, {
|
|
23
23
|
getFilesFromDataTransfer: () => getFilesFromDataTransfer
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/data-transfer.
|
|
4
|
-
"sourcesContent": ["/**\n * Gets all files from a DataTransfer object.\n *\n * @param
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,yBAA0B,
|
|
3
|
+
"sources": ["../src/data-transfer.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Gets all files from a DataTransfer object.\n *\n * @param dataTransfer DataTransfer object to inspect.\n *\n * @return An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer: DataTransfer ): File[] {\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,yBAA0B,cAAqC;AAC9E,QAAM,QAAQ,MAAM,KAAM,aAAa,KAAM;AAE7C,QAAM,KAAM,aAAa,KAAM,EAAE,QAAS,CAAE,SAAU;AACrD,UAAM,OAAO,KAAK,UAAU;AAE5B,QACC,QACA,CAAE,MAAM;AAAA,MACP,CAAE,EAAE,MAAM,MAAM,KAAK,MACpB,SAAS,KAAK,QACd,SAAS,KAAK,QACd,SAAS,KAAK;AAAA,IAChB,GACC;AACD,YAAM,KAAM,IAAK;AAAA,IAClB;AAAA,EACD,CAAE;AAEF,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/dom/src/dom/caret-range-from-point.
|
|
20
|
+
// packages/dom/src/dom/caret-range-from-point.ts
|
|
21
21
|
var caret_range_from_point_exports = {};
|
|
22
22
|
__export(caret_range_from_point_exports, {
|
|
23
23
|
default: () => caretRangeFromPoint
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/caret-range-from-point.
|
|
4
|
-
"sourcesContent": ["/**\n * Get a collapsed range for a given point.\n *\n * Prefers the standard `caretPositionFromPoint` API and falls back to the\n * non-standard, WebKit-originated `caretRangeFromPoint` for older browsers.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n *\n * @param
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAce,SAAR,
|
|
3
|
+
"sources": ["../../src/dom/caret-range-from-point.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Get a collapsed range for a given point.\n *\n * Prefers the standard `caretPositionFromPoint` API and falls back to the\n * non-standard, WebKit-originated `caretRangeFromPoint` for older browsers.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\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 *\n * @return The best range for the given point.\n */\nexport default function caretRangeFromPoint(\n\tdoc: Document,\n\tx: number,\n\ty: number\n): Range | null {\n\tif ( doc.caretPositionFromPoint ) {\n\t\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint\n\t\tif ( ! point ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst range = doc.createRange();\n\n\t\trange.setStart( point.offsetNode, point.offset );\n\t\trange.collapse( true );\n\n\t\treturn range;\n\t}\n\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\treturn null;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAce,SAAR,oBACN,KACA,GACA,GACe;AACf,MAAK,IAAI,wBAAyB;AACjC,UAAM,QAAQ,IAAI,uBAAwB,GAAG,CAAE;AAI/C,QAAK,CAAE,OAAQ;AACd,aAAO;AAAA,IACR;AAEA,UAAM,QAAQ,IAAI,YAAY;AAE9B,UAAM,SAAU,MAAM,YAAY,MAAM,MAAO;AAC/C,UAAM,SAAU,IAAK;AAErB,WAAO;AAAA,EACR;AAEA,MAAK,IAAI,qBAAsB;AAC9B,WAAO,IAAI,oBAAqB,GAAG,CAAE;AAAA,EACtC;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/dom/src/dom/clean-node-list.
|
|
30
|
+
// packages/dom/src/dom/clean-node-list.ts
|
|
31
31
|
var clean_node_list_exports = {};
|
|
32
32
|
__export(clean_node_list_exports, {
|
|
33
33
|
default: () => cleanNodeList
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/clean-node-list.
|
|
4
|
-
"sourcesContent": ["import 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';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAoB;AACpB,oBAAmB;AACnB,oBAAmB;AACnB,8BAAkC;AAClC,0BAAwB;AACxB,wBAAsB;
|
|
3
|
+
"sources": ["../../src/dom/clean-node-list.ts"],
|
|
4
|
+
"sourcesContent": ["import 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';\nimport type { Schema } from './types';\n\nconst noop = () => {};\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param nodeList The nodeList to filter.\n * @param doc The document of the nodeList.\n * @param schema Schema for the HTML.\n * @param inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList(\n\tnodeList: NodeList,\n\tdoc: Document,\n\tschema: Schema,\n\tinline: boolean\n) {\n\tArray.from( nodeList ).forEach(\n\t\t( node: Node & { nextElementSibling?: unknown } ) => {\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. For phrasing content nodes that contain\n\t\t\t\t\t// only whitespace, unwrap instead to preserve the text.\n\t\t\t\t\t// See https://github.com/WordPress/gutenberg/issues/50898\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tisPhrasingContent( node ) &&\n\t\t\t\t\t\t\tnode.hasChildNodes()\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\t}\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 ( item === '*' ) {\n\t\t\t\t\t\t\t\t\t// Keep all classes.\n\t\t\t\t\t\t\t\t\treturn () => true;\n\t\t\t\t\t\t\t\t} else if ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn ( className: string ) =>\n\t\t\t\t\t\t\t\t\t\tclassName === 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 ( className: string ) =>\n\t\t\t\t\t\t\t\t\t\titem.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"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["isElement", "require", "isEmpty", "unwrap", "remove", "insertAfter"]
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/dom/src/dom/compute-caret-rect.
|
|
30
|
+
// packages/dom/src/dom/compute-caret-rect.ts
|
|
31
31
|
var compute_caret_rect_exports = {};
|
|
32
32
|
__export(compute_caret_rect_exports, {
|
|
33
33
|
default: () => computeCaretRect
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/compute-caret-rect.
|
|
4
|
-
"sourcesContent": ["import 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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAkC;AAClC,+BAAgC;AASjB,SAAR,iBAAmC,
|
|
3
|
+
"sources": ["../../src/dom/compute-caret-rect.ts"],
|
|
4
|
+
"sourcesContent": ["import 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 win The window of the selection.\n *\n * @return The rectangle.\n */\nexport default function computeCaretRect( win: Window ): DOMRect | null {\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAkC;AAClC,+BAAgC;AASjB,SAAR,iBAAmC,KAA8B;AACvE,QAAM,YAAY,IAAI,aAAa;AACnC,gDAAiB,WAAW,WAAY;AACxC,QAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;AAEjE,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,aAAO,gCAAAA,SAAuB,KAAM;AACrC;",
|
|
6
6
|
"names": ["getRectangleFromRange"]
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/dom/src/dom/document-has-selection.
|
|
30
|
+
// packages/dom/src/dom/document-has-selection.ts
|
|
31
31
|
var document_has_selection_exports = {};
|
|
32
32
|
__export(document_has_selection_exports, {
|
|
33
33
|
default: () => documentHasSelection
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/document-has-selection.
|
|
4
|
-
"sourcesContent": ["import 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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAwB;AACxB,mCAA+B;AAC/B,yCAAqC;AAUtB,SAAR,qBAAuC,
|
|
3
|
+
"sources": ["../../src/dom/document-has-selection.ts"],
|
|
4
|
+
"sourcesContent": ["import 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 doc The document to check.\n *\n * @return True if there is selection, false if not.\n */\nexport default function documentHasSelection( doc: Document ): boolean {\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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAwB;AACxB,mCAA+B;AAC/B,yCAAqC;AAUtB,SAAR,qBAAuC,KAAyB;AACtE,SACC,CAAC,CAAE,IAAI,sBACL,6BAAAA,SAAoB,IAAI,aAAc,SACvC,qBAAAC,SAAa,IAAI,aAAc,SAC/B,mCAAAC,SAA0B,GAAI;AAEjC;",
|
|
6
6
|
"names": ["isHTMLInputElement", "isTextField", "documentHasTextSelection"]
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/dom/src/dom/document-has-text-selection.
|
|
20
|
+
// packages/dom/src/dom/document-has-text-selection.ts
|
|
21
21
|
var document_has_text_selection_exports = {};
|
|
22
22
|
__export(document_has_text_selection_exports, {
|
|
23
23
|
default: () => documentHasTextSelection
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/document-has-text-selection.
|
|
4
|
-
"sourcesContent": ["import { 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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAgC;AAajB,SAAR,yBAA2C,
|
|
3
|
+
"sources": ["../../src/dom/document-has-text-selection.ts"],
|
|
4
|
+
"sourcesContent": ["import { 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 doc The document to check.\n *\n * @return True if there is selection, false if not.\n */\nexport default function documentHasTextSelection( doc: Document ): boolean {\n\tassertIsDefined( doc.defaultView, 'doc.defaultView' );\n\tconst selection = doc.defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\treturn !! range && ! range.collapsed;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAgC;AAajB,SAAR,yBAA2C,KAAyB;AAC1E,gDAAiB,IAAI,aAAa,iBAAkB;AACpD,QAAM,YAAY,IAAI,YAAY,aAAa;AAC/C,gDAAiB,WAAW,WAAY;AACxC,QAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;AACjE,SAAO,CAAC,CAAE,SAAS,CAAE,MAAM;AAC5B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/dom/src/dom/document-has-uncollapsed-selection.
|
|
30
|
+
// packages/dom/src/dom/document-has-uncollapsed-selection.ts
|
|
31
31
|
var document_has_uncollapsed_selection_exports = {};
|
|
32
32
|
__export(document_has_uncollapsed_selection_exports, {
|
|
33
33
|
default: () => documentHasUncollapsedSelection
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/document-has-uncollapsed-selection.
|
|
4
|
-
"sourcesContent": ["import 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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAAqC;AACrC,mDAA8C;AAW/B,SAAR,
|
|
3
|
+
"sources": ["../../src/dom/document-has-uncollapsed-selection.ts"],
|
|
4
|
+
"sourcesContent": ["import 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 doc The document to check.\n *\n * @return Whether there is any recognizable text selection in the document.\n */\nexport default function documentHasUncollapsedSelection(\n\tdoc: Document\n): boolean {\n\treturn (\n\t\tdocumentHasTextSelection( doc ) ||\n\t\t( !! doc.activeElement &&\n\t\t\tinputFieldHasUncollapsedSelection( doc.activeElement ) )\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAAqC;AACrC,mDAA8C;AAW/B,SAAR,gCACN,KACU;AACV,aACC,mCAAAA,SAA0B,GAAI,KAC5B,CAAC,CAAE,IAAI,qBACR,6CAAAC,SAAmC,IAAI,aAAc;AAExD;",
|
|
6
6
|
"names": ["documentHasTextSelection", "inputFieldHasUncollapsedSelection"]
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/dom/src/dom/get-computed-style.
|
|
20
|
+
// packages/dom/src/dom/get-computed-style.ts
|
|
21
21
|
var get_computed_style_exports = {};
|
|
22
22
|
__export(get_computed_style_exports, {
|
|
23
23
|
default: () => getComputedStyle
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/get-computed-style.
|
|
4
|
-
"sourcesContent": ["import { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * @param
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAgC;AAMjB,SAAR,
|
|
3
|
+
"sources": ["../../src/dom/get-computed-style.ts"],
|
|
4
|
+
"sourcesContent": ["import { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * @param element\n * @return The computed style for the element.\n */\nexport default function getComputedStyle(\n\telement: Element\n): CSSStyleDeclaration {\n\tassertIsDefined(\n\t\telement.ownerDocument.defaultView,\n\t\t'element.ownerDocument.defaultView'\n\t);\n\treturn element.ownerDocument.defaultView.getComputedStyle( element );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAgC;AAMjB,SAAR,iBACN,SACsB;AACtB;AAAA,IACC,QAAQ,cAAc;AAAA,IACtB;AAAA,EACD;AACA,SAAO,QAAQ,cAAc,YAAY,iBAAkB,OAAQ;AACpE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -27,33 +27,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/dom/src/dom/get-offset-parent.
|
|
30
|
+
// packages/dom/src/dom/get-offset-parent.ts
|
|
31
31
|
var get_offset_parent_exports = {};
|
|
32
32
|
__export(get_offset_parent_exports, {
|
|
33
33
|
default: () => getOffsetParent
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(get_offset_parent_exports);
|
|
36
36
|
var import_get_computed_style = __toESM(require("./get-computed-style.cjs"));
|
|
37
|
+
var import_is_element = __toESM(require("./is-element.cjs"));
|
|
37
38
|
function getOffsetParent(node) {
|
|
38
|
-
let closestElement;
|
|
39
|
-
while (closestElement
|
|
40
|
-
|
|
41
|
-
if (closestElement.nodeType === closestElement.ELEMENT_NODE) {
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
39
|
+
let closestElement = node.parentNode;
|
|
40
|
+
while (closestElement && !(0, import_is_element.default)(closestElement)) {
|
|
41
|
+
closestElement = closestElement.parentNode;
|
|
44
42
|
}
|
|
45
43
|
if (!closestElement) {
|
|
46
44
|
return null;
|
|
47
45
|
}
|
|
48
|
-
if ((0, import_get_computed_style.default)(
|
|
49
|
-
/** @type {Element} */
|
|
50
|
-
closestElement
|
|
51
|
-
).position !== "static") {
|
|
46
|
+
if ((0, import_get_computed_style.default)(closestElement).position !== "static") {
|
|
52
47
|
return closestElement;
|
|
53
48
|
}
|
|
54
|
-
return
|
|
55
|
-
/** @type {Node & { offsetParent: Node }} */
|
|
56
|
-
closestElement.offsetParent
|
|
57
|
-
);
|
|
49
|
+
return closestElement.offsetParent;
|
|
58
50
|
}
|
|
59
51
|
//# sourceMappingURL=get-offset-parent.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/get-offset-parent.
|
|
4
|
-
"sourcesContent": ["import 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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAA6B;
|
|
6
|
-
"names": ["getComputedStyle"]
|
|
3
|
+
"sources": ["../../src/dom/get-offset-parent.ts"],
|
|
4
|
+
"sourcesContent": ["import getComputedStyle from './get-computed-style';\nimport isElement from './is-element';\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 from which to find offset parent.\n *\n * @return Offset parent.\n */\nexport default function getOffsetParent( node: Node ): Node | null {\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 = node.parentNode;\n\twhile ( closestElement && ! isElement( closestElement ) ) {\n\t\tclosestElement = closestElement.parentNode;\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 ( getComputedStyle( closestElement ).position !== 'static' ) {\n\t\treturn closestElement;\n\t}\n\n\t// offsetParent is undocumented/draft.\n\treturn ( closestElement as HTMLElement ).offsetParent;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAA6B;AAC7B,wBAAsB;AAaP,SAAR,gBAAkC,MAA0B;AAGlE,MAAI,iBAAiB,KAAK;AAC1B,SAAQ,kBAAkB,KAAE,kBAAAA,SAAW,cAAe,GAAI;AACzD,qBAAiB,eAAe;AAAA,EACjC;AAEA,MAAK,CAAE,gBAAiB;AACvB,WAAO;AAAA,EACR;AAIA,UAAK,0BAAAC,SAAkB,cAAe,EAAE,aAAa,UAAW;AAC/D,WAAO;AAAA,EACR;AAGA,SAAS,eAAgC;AAC1C;",
|
|
6
|
+
"names": ["isElement", "getComputedStyle"]
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/dom/src/dom/get-range-height.
|
|
20
|
+
// packages/dom/src/dom/get-range-height.ts
|
|
21
21
|
var get_range_height_exports = {};
|
|
22
22
|
__export(get_range_height_exports, {
|
|
23
23
|
default: () => getRangeHeight
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/get-range-height.
|
|
4
|
-
"sourcesContent": ["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOe,SAAR,eAAiC,
|
|
3
|
+
"sources": ["../../src/dom/get-range-height.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param range The range to check.\n * @return Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range: Range ): number | undefined {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOe,SAAR,eAAiC,OAAmC;AAC1E,QAAM,QAAQ,MAAM,KAAM,MAAM,eAAe,CAAE;AAEjD,MAAK,CAAE,MAAM,QAAS;AACrB;AAAA,EACD;AAEA,QAAM,aAAa,KAAK,IAAK,GAAG,MAAM,IAAK,CAAE,EAAE,IAAI,MAAO,GAAI,CAAE;AAChE,QAAM,eAAe,KAAK,IAAK,GAAG,MAAM,IAAK,CAAE,EAAE,OAAO,MAAO,MAAO,CAAE;AAExE,SAAO,eAAe;AACvB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/dom/src/dom/get-rectangle-from-range.
|
|
20
|
+
// packages/dom/src/dom/get-rectangle-from-range.ts
|
|
21
21
|
var get_rectangle_from_range_exports = {};
|
|
22
22
|
__export(get_rectangle_from_range_exports, {
|
|
23
23
|
default: () => getRectangleFromRange
|
|
@@ -85,11 +85,7 @@ function getRectangleFromRange(range) {
|
|
|
85
85
|
let beforeRange;
|
|
86
86
|
if (before && before.nodeType === before.TEXT_NODE) {
|
|
87
87
|
beforeRange = ownerDocument.createRange();
|
|
88
|
-
beforeRange.setStart(
|
|
89
|
-
before,
|
|
90
|
-
/** @type {Text} */
|
|
91
|
-
before.length
|
|
92
|
-
);
|
|
88
|
+
beforeRange.setStart(before, before.length);
|
|
93
89
|
beforeRange.collapse(true);
|
|
94
90
|
}
|
|
95
91
|
let afterRange;
|
|
@@ -117,8 +113,7 @@ function getRectangleFromRange(range) {
|
|
|
117
113
|
if (rects.length > 1) {
|
|
118
114
|
return null;
|
|
119
115
|
}
|
|
120
|
-
if (rects.length === 1 && startContainer.nodeType === startContainer.TEXT_NODE && range.startOffset > 0 && range.startOffset <
|
|
121
|
-
startContainer.length) {
|
|
116
|
+
if (rects.length === 1 && startContainer.nodeType === startContainer.TEXT_NODE && range.startOffset > 0 && range.startOffset < startContainer.length) {
|
|
122
117
|
(0, import_assert_is_defined.assertIsDefined)(ownerDocument, "ownerDocument");
|
|
123
118
|
const measure = (start, end) => {
|
|
124
119
|
const charRange = ownerDocument.createRange();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/get-rectangle-from-range.
|
|
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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAgC;AAWjB,SAAR,sBAAwC,
|
|
3
|
+
"sources": ["../../src/dom/get-rectangle-from-range.ts"],
|
|
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 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"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["rects"]
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/dom/src/dom/get-scroll-container.
|
|
30
|
+
// packages/dom/src/dom/get-scroll-container.ts
|
|
31
31
|
var get_scroll_container_exports = {};
|
|
32
32
|
__export(get_scroll_container_exports, {
|
|
33
33
|
default: () => getScrollContainer
|
|
@@ -57,10 +57,6 @@ function getScrollContainer(node, direction = "vertical") {
|
|
|
57
57
|
if (node.ownerDocument === node.parentNode) {
|
|
58
58
|
return node;
|
|
59
59
|
}
|
|
60
|
-
return getScrollContainer(
|
|
61
|
-
/** @type {Element} */
|
|
62
|
-
node.parentNode,
|
|
63
|
-
direction
|
|
64
|
-
);
|
|
60
|
+
return getScrollContainer(node.parentNode, direction);
|
|
65
61
|
}
|
|
66
62
|
//# sourceMappingURL=get-scroll-container.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/get-scroll-container.
|
|
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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAA6B;AAWd,SAAR,
|
|
3
|
+
"sources": ["../../src/dom/get-scroll-container.ts"],
|
|
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 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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAA6B;AAWd,SAAR,mBACN,MACA,YAA+C,YACzB;AACtB,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,mBAAoB,KAAK,YAAuB,SAAU;AAClE;",
|
|
6
6
|
"names": ["getComputedStyle"]
|
|
7
7
|
}
|
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/dom/src/dom/hidden-caret-range-from-point.
|
|
30
|
+
// packages/dom/src/dom/hidden-caret-range-from-point.ts
|
|
31
31
|
var hidden_caret_range_from_point_exports = {};
|
|
32
32
|
__export(hidden_caret_range_from_point_exports, {
|
|
33
33
|
default: () => hiddenCaretRangeFromPoint
|