@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.
- package/README.md +23 -23
- package/build/data-transfer.cjs +20 -38
- package/build/data-transfer.cjs.map +1 -7
- package/build/dom/caret-range-from-point.cjs +31 -38
- package/build/dom/caret-range-from-point.cjs.map +1 -7
- package/build/dom/clean-node-list.cjs +88 -133
- package/build/dom/clean-node-list.cjs.map +1 -7
- package/build/dom/compute-caret-rect.cjs +36 -36
- package/build/dom/compute-caret-rect.cjs.map +1 -7
- package/build/dom/document-has-selection.cjs +36 -31
- package/build/dom/document-has-selection.cjs.map +1 -7
- package/build/dom/document-has-text-selection.cjs +24 -30
- package/build/dom/document-has-text-selection.cjs.map +1 -7
- package/build/dom/document-has-uncollapsed-selection.cjs +35 -30
- package/build/dom/document-has-uncollapsed-selection.cjs.map +1 -7
- package/build/dom/get-computed-style.cjs +14 -30
- package/build/dom/get-computed-style.cjs.map +1 -7
- package/build/dom/get-offset-parent.cjs +41 -48
- package/build/dom/get-offset-parent.cjs.map +1 -7
- package/build/dom/get-range-height.cjs +18 -31
- package/build/dom/get-range-height.cjs.map +1 -7
- package/build/dom/get-rectangle-from-range.cjs +82 -133
- package/build/dom/get-rectangle-from-range.cjs.map +1 -7
- package/build/dom/get-scroll-container.cjs +47 -55
- package/build/dom/get-scroll-container.cjs.map +1 -7
- package/build/dom/hidden-caret-range-from-point.cjs +49 -43
- package/build/dom/hidden-caret-range-from-point.cjs.map +1 -7
- package/build/dom/index.cjs +233 -110
- package/build/dom/input-field-has-uncollapsed-selection.cjs +49 -47
- package/build/dom/input-field-has-uncollapsed-selection.cjs.map +1 -7
- package/build/dom/insert-after.cjs +17 -27
- package/build/dom/insert-after.cjs.map +1 -7
- package/build/dom/is-edge.cjs +83 -98
- package/build/dom/is-edge.cjs.map +1 -7
- package/build/dom/is-element.cjs +12 -25
- package/build/dom/is-element.cjs.map +1 -7
- package/build/dom/is-empty.cjs +23 -40
- package/build/dom/is-empty.cjs.map +1 -7
- package/build/dom/is-entirely-selected.cjs +71 -71
- package/build/dom/is-entirely-selected.cjs.map +1 -7
- package/build/dom/is-form-element.cjs +34 -34
- package/build/dom/is-form-element.cjs.map +1 -7
- package/build/dom/is-horizontal-edge.cjs +32 -29
- package/build/dom/is-horizontal-edge.cjs.map +1 -7
- package/build/dom/is-html-input-element.cjs +12 -25
- package/build/dom/is-html-input-element.cjs.map +1 -7
- package/build/dom/is-input-or-text-area.cjs +12 -25
- package/build/dom/is-input-or-text-area.cjs.map +1 -7
- package/build/dom/is-number-input.cjs +37 -34
- package/build/dom/is-number-input.cjs.map +1 -7
- package/build/dom/is-rtl.cjs +31 -29
- package/build/dom/is-rtl.cjs.map +1 -7
- package/build/dom/is-selection-forward.cjs +26 -39
- package/build/dom/is-selection-forward.cjs.map +1 -7
- package/build/dom/is-text-field.cjs +46 -44
- package/build/dom/is-text-field.cjs.map +1 -7
- package/build/dom/is-vertical-edge.cjs +32 -29
- package/build/dom/is-vertical-edge.cjs.map +1 -7
- package/build/dom/place-caret-at-edge.cjs +76 -79
- package/build/dom/place-caret-at-edge.cjs.map +1 -7
- package/build/dom/place-caret-at-horizontal-edge.cjs +30 -29
- package/build/dom/place-caret-at-horizontal-edge.cjs.map +1 -7
- package/build/dom/place-caret-at-vertical-edge.cjs +31 -29
- package/build/dom/place-caret-at-vertical-edge.cjs.map +1 -7
- package/build/dom/remove-invalid-html.cjs +36 -32
- package/build/dom/remove-invalid-html.cjs.map +1 -7
- package/build/dom/remove.cjs +15 -27
- package/build/dom/remove.cjs.map +1 -7
- package/build/dom/replace-tag.cjs +21 -32
- package/build/dom/replace-tag.cjs.map +1 -7
- package/build/dom/replace.cjs +35 -33
- package/build/dom/replace.cjs.map +1 -7
- package/build/dom/safe-html.cjs +46 -47
- package/build/dom/safe-html.cjs.map +1 -7
- package/build/dom/scroll-if-no-range.cjs +24 -37
- package/build/dom/scroll-if-no-range.cjs.map +1 -7
- package/build/dom/strip-html.cjs +34 -32
- package/build/dom/strip-html.cjs.map +1 -7
- package/build/dom/types.cjs +5 -0
- package/build/dom/unwrap.cjs +17 -31
- package/build/dom/unwrap.cjs.map +1 -7
- package/build/dom/wrap.cjs +17 -28
- package/build/dom/wrap.cjs.map +1 -7
- package/build/focusable.cjs +99 -77
- package/build/focusable.cjs.map +1 -7
- package/build/index.cjs +58 -39
- package/build/index.cjs.map +1 -7
- package/build/phrasing-content.cjs +163 -159
- package/build/phrasing-content.cjs.map +1 -7
- package/build/tabbable.cjs +123 -78
- package/build/tabbable.cjs.map +1 -7
- package/build/types.cjs +5 -0
- package/build/utils/assert-is-defined.cjs +8 -33
- package/build/utils/assert-is-defined.cjs.map +1 -7
- package/build-module/data-transfer.mjs +17 -15
- package/build-module/data-transfer.mjs.map +1 -7
- package/build-module/dom/caret-range-from-point.mjs +28 -19
- package/build-module/dom/caret-range-from-point.mjs.map +1 -7
- package/build-module/dom/clean-node-list.mjs +60 -105
- package/build-module/dom/clean-node-list.mjs.map +1 -7
- package/build-module/dom/compute-caret-rect.mjs +16 -12
- package/build-module/dom/compute-caret-rect.mjs.map +1 -7
- package/build-module/dom/document-has-selection.mjs +13 -6
- package/build-module/dom/document-has-selection.mjs.map +1 -7
- package/build-module/dom/document-has-text-selection.mjs +20 -10
- package/build-module/dom/document-has-text-selection.mjs.map +1 -7
- package/build-module/dom/document-has-uncollapsed-selection.mjs +14 -6
- package/build-module/dom/document-has-uncollapsed-selection.mjs.map +1 -7
- package/build-module/dom/get-computed-style.mjs +10 -10
- package/build-module/dom/get-computed-style.mjs.map +1 -7
- package/build-module/dom/get-offset-parent.mjs +21 -25
- package/build-module/dom/get-offset-parent.mjs.map +1 -7
- package/build-module/dom/get-range-height.mjs +15 -12
- package/build-module/dom/get-range-height.mjs.map +1 -7
- package/build-module/dom/get-rectangle-from-range.mjs +78 -113
- package/build-module/dom/get-rectangle-from-range.mjs.map +1 -7
- package/build-module/dom/get-scroll-container.mjs +28 -32
- package/build-module/dom/get-scroll-container.mjs.map +1 -7
- package/build-module/dom/hidden-caret-range-from-point.mjs +28 -19
- package/build-module/dom/hidden-caret-range-from-point.mjs.map +1 -7
- package/build-module/dom/index.mjs +28 -58
- package/build-module/dom/input-field-has-uncollapsed-selection.mjs +28 -23
- package/build-module/dom/input-field-has-uncollapsed-selection.mjs.map +1 -7
- package/build-module/dom/insert-after.mjs +13 -7
- package/build-module/dom/insert-after.mjs.map +1 -7
- package/build-module/dom/is-edge.mjs +53 -69
- package/build-module/dom/is-edge.mjs.map +1 -7
- package/build-module/dom/is-element.mjs +9 -6
- package/build-module/dom/is-element.mjs.map +1 -7
- package/build-module/dom/is-empty.mjs +20 -21
- package/build-module/dom/is-empty.mjs.map +1 -7
- package/build-module/dom/is-entirely-selected.mjs +51 -47
- package/build-module/dom/is-entirely-selected.mjs.map +1 -7
- package/build-module/dom/is-form-element.mjs +15 -11
- package/build-module/dom/is-form-element.mjs.map +1 -7
- package/build-module/dom/is-horizontal-edge.mjs +13 -6
- package/build-module/dom/is-horizontal-edge.mjs.map +1 -7
- package/build-module/dom/is-html-input-element.mjs +9 -6
- package/build-module/dom/is-html-input-element.mjs.map +1 -7
- package/build-module/dom/is-input-or-text-area.mjs +9 -6
- package/build-module/dom/is-input-or-text-area.mjs.map +1 -7
- package/build-module/dom/is-number-input.mjs +16 -10
- package/build-module/dom/is-number-input.mjs.map +1 -7
- package/build-module/dom/is-rtl.mjs +12 -6
- package/build-module/dom/is-rtl.mjs.map +1 -7
- package/build-module/dom/is-selection-forward.mjs +22 -19
- package/build-module/dom/is-selection-forward.mjs.map +1 -7
- package/build-module/dom/is-text-field.mjs +27 -21
- package/build-module/dom/is-text-field.mjs.map +1 -7
- package/build-module/dom/is-vertical-edge.mjs +13 -6
- package/build-module/dom/is-vertical-edge.mjs.map +1 -7
- package/build-module/dom/place-caret-at-edge.mjs +51 -52
- package/build-module/dom/place-caret-at-edge.mjs.map +1 -7
- package/build-module/dom/place-caret-at-horizontal-edge.mjs +11 -6
- package/build-module/dom/place-caret-at-horizontal-edge.mjs.map +1 -7
- package/build-module/dom/place-caret-at-vertical-edge.mjs +12 -6
- package/build-module/dom/place-caret-at-vertical-edge.mjs.map +1 -7
- package/build-module/dom/remove-invalid-html.mjs +17 -9
- package/build-module/dom/remove-invalid-html.mjs.map +1 -7
- package/build-module/dom/remove.mjs +11 -7
- package/build-module/dom/remove.mjs.map +1 -7
- package/build-module/dom/replace-tag.mjs +17 -12
- package/build-module/dom/replace-tag.mjs.map +1 -7
- package/build-module/dom/replace.mjs +13 -8
- package/build-module/dom/replace.mjs.map +1 -7
- package/build-module/dom/safe-html.mjs +27 -24
- package/build-module/dom/safe-html.mjs.map +1 -7
- package/build-module/dom/scroll-if-no-range.mjs +21 -14
- package/build-module/dom/scroll-if-no-range.mjs.map +1 -7
- package/build-module/dom/strip-html.mjs +15 -9
- package/build-module/dom/strip-html.mjs.map +1 -7
- package/build-module/dom/types.mjs +0 -0
- package/build-module/dom/unwrap.mjs +13 -11
- package/build-module/dom/unwrap.mjs.map +1 -7
- package/build-module/dom/wrap.mjs +13 -8
- package/build-module/dom/wrap.mjs.map +1 -7
- package/build-module/focusable.mjs +96 -54
- package/build-module/focusable.mjs.map +1 -7
- package/build-module/index.mjs +11 -5
- package/build-module/index.mjs.map +1 -7
- package/build-module/phrasing-content.mjs +158 -134
- package/build-module/phrasing-content.mjs.map +1 -7
- package/build-module/tabbable.mjs +117 -52
- package/build-module/tabbable.mjs.map +1 -7
- package/build-module/types.mjs +0 -0
- package/build-module/utils/assert-is-defined.mjs +4 -9
- package/build-module/utils/assert-is-defined.mjs.map +1 -7
- 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 +6 -46
- 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} +44 -48
- 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/test/{get-rectangle-from-range.browser.test.js → get-rectangle-from-range.browser.test.ts} +25 -25
- 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 → dom.jsdom.test.ts} +30 -6
- package/src/test/{focusable.browser.test.js → focusable.browser.test.ts} +14 -13
- package/src/test/{tabbable.browser.test.js → tabbable.browser.test.ts} +3 -2
- package/src/types.ts +32 -0
- package/CHANGELOG.md +0 -317
- package/build/dom/index.cjs.map +0 -7
- package/build-module/dom/index.mjs.map +0 -7
- package/src/index.js +0 -12
- /package/src/dom/{index.js → index.ts} +0 -0
- /package/src/dom/test/{safe-html.jsdom.test.js → safe-html.jsdom.test.ts} +0 -0
- /package/src/dom/test/{strip-html.jsdom.test.js → strip-html.jsdom.test.ts} +0 -0
- /package/src/test/{focusable-area.jsdom.test.js → focusable-area.jsdom.test.ts} +0 -0
- /package/src/test/{utils.js → utils.ts} +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Given two DOM nodes, replaces the former with the latter in the DOM.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @return {void}
|
|
4
|
+
* @param processedNode Node to be removed.
|
|
5
|
+
* @param newNode Node to be inserted in its place.
|
|
7
6
|
*/
|
|
8
7
|
export default function replace(processedNode: Element, newNode: Element): void;
|
|
9
8
|
//# sourceMappingURL=replace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../src/dom/replace.
|
|
1
|
+
{"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../src/dom/replace.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAC9B,aAAa,EAAE,OAAO,EACtB,OAAO,EAAE,OAAO,GACd,IAAI,CAIN"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Strips scripts and on* attributes from HTML.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
4
|
+
* @param html HTML to sanitize.
|
|
5
5
|
*
|
|
6
|
-
* @return
|
|
6
|
+
* @return The sanitized HTML.
|
|
7
7
|
*/
|
|
8
8
|
export default function safeHTML(html: string): string;
|
|
9
9
|
//# sourceMappingURL=safe-html.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-html.d.ts","sourceRoot":"","sources":["../../src/dom/safe-html.
|
|
1
|
+
{"version":3,"file":"safe-html.d.ts","sourceRoot":"","sources":["../../src/dom/safe-html.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAE,IAAI,EAAE,MAAM,GAAI,MAAM,CAyBvD"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* If no range range can be created or it is outside the container, the element
|
|
3
3
|
* may be out of view, so scroll it into view and try again.
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
5
|
+
* @param container The container to scroll.
|
|
6
|
+
* @param alignToTop True to align to top, false to bottom.
|
|
7
|
+
* @param callback The callback to create the range.
|
|
8
8
|
*
|
|
9
|
-
* @return
|
|
9
|
+
* @return The range returned by the callback.
|
|
10
10
|
*/
|
|
11
|
-
export declare function scrollIfNoRange(container: HTMLElement, alignToTop: boolean, callback:
|
|
11
|
+
export declare function scrollIfNoRange(container: HTMLElement, alignToTop: boolean, callback: () => Range | null): Range | null;
|
|
12
12
|
//# sourceMappingURL=scroll-if-no-range.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-if-no-range.d.ts","sourceRoot":"","sources":["../../src/dom/scroll-if-no-range.
|
|
1
|
+
{"version":3,"file":"scroll-if-no-range.d.ts","sourceRoot":"","sources":["../../src/dom/scroll-if-no-range.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC9B,SAAS,EAAE,WAAW,EACtB,UAAU,EAAE,OAAO,EACnB,QAAQ,EAAE,MAAM,KAAK,GAAG,IAAI,GAC1B,KAAK,GAAG,IAAI,CAuBd"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Removes any HTML tags from the provided string.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
4
|
+
* @param html The string containing html.
|
|
5
5
|
*
|
|
6
|
-
* @return
|
|
6
|
+
* @return The text content with any html removed.
|
|
7
7
|
*/
|
|
8
8
|
export default function stripHTML(html: string): string;
|
|
9
9
|
//# sourceMappingURL=strip-html.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strip-html.d.ts","sourceRoot":"","sources":["../../src/dom/strip-html.
|
|
1
|
+
{"version":3,"file":"strip-html.d.ts","sourceRoot":"","sources":["../../src/dom/strip-html.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,IAAI,EAAE,MAAM,GAAI,MAAM,CAQxD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface SchemaItem {
|
|
2
|
+
/**
|
|
3
|
+
* Attributes.
|
|
4
|
+
*/
|
|
5
|
+
attributes?: string[];
|
|
6
|
+
/**
|
|
7
|
+
* Classnames or RegExp to test against. Use '*' to keep all classes.
|
|
8
|
+
*/
|
|
9
|
+
classes?: (string | RegExp)[];
|
|
10
|
+
/**
|
|
11
|
+
* Child schemas.
|
|
12
|
+
*/
|
|
13
|
+
children?: '*' | {
|
|
14
|
+
[tag: string]: SchemaItem;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Selectors to test required children against. Leave empty or undefined if there are no requirements.
|
|
18
|
+
*/
|
|
19
|
+
require?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Whether to allow nodes without children.
|
|
22
|
+
*/
|
|
23
|
+
allowEmpty?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Function to test whether a node is a match. If left undefined any node will be assumed to match.
|
|
26
|
+
*/
|
|
27
|
+
isMatch?: (node: Node) => boolean;
|
|
28
|
+
}
|
|
29
|
+
export type Schema = {
|
|
30
|
+
[tag: string]: SchemaItem;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dom/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAE,MAAM,GAAG,MAAM,CAAE,EAAE,CAAC;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,GAAG,GAAG;QAAE,CAAE,GAAG,EAAE,MAAM,GAAI,UAAU,CAAA;KAAE,CAAC;IACjD;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,OAAO,CAAC;CACpC;AAED,MAAM,MAAM,MAAM,GAAG;IAAE,CAAE,GAAG,EAAE,MAAM,GAAI,UAAU,CAAA;CAAE,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unwrap the given node. This means any child nodes are moved to the parent.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
*
|
|
6
|
-
* @return {void}
|
|
4
|
+
* @param node The node to unwrap.
|
|
7
5
|
*/
|
|
8
6
|
export default function unwrap(node: Node): void;
|
|
9
7
|
//# sourceMappingURL=unwrap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unwrap.d.ts","sourceRoot":"","sources":["../../src/dom/unwrap.
|
|
1
|
+
{"version":3,"file":"unwrap.d.ts","sourceRoot":"","sources":["../../src/dom/unwrap.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAE,IAAI,EAAE,IAAI,GAAI,IAAI,CAUjD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Wraps the given node with a new node with the given tag name.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param newNode The node to insert.
|
|
5
|
+
* @param referenceNode The node to wrap.
|
|
6
6
|
*/
|
|
7
7
|
export default function wrap(newNode: Element, referenceNode: Element): void;
|
|
8
8
|
//# sourceMappingURL=wrap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../src/dom/wrap.
|
|
1
|
+
{"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../src/dom/wrap.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,IAAI,CAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,QAIrE"}
|
|
@@ -1,36 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
* References:
|
|
3
|
-
*
|
|
4
|
-
* Focusable:
|
|
5
|
-
* - https://www.w3.org/TR/html5/editing.html#focus-management
|
|
6
|
-
*
|
|
7
|
-
* Sequential focus navigation:
|
|
8
|
-
* - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute
|
|
9
|
-
*
|
|
10
|
-
* Disabled elements:
|
|
11
|
-
* - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements
|
|
12
|
-
*
|
|
13
|
-
* getClientRects algorithm (requiring layout box):
|
|
14
|
-
* - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface
|
|
15
|
-
*
|
|
16
|
-
* AREA elements associated with an IMG:
|
|
17
|
-
* - https://w3c.github.io/html/editing.html#data-model
|
|
18
|
-
*/
|
|
1
|
+
import type { FindFocusableOptions } from './types';
|
|
19
2
|
/**
|
|
20
3
|
* Returns all focusable elements within a given context.
|
|
21
4
|
*
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
5
|
+
* @param context Element in which to search.
|
|
6
|
+
* @param options
|
|
7
|
+
* @param [options.sequential] If set, only return elements that are
|
|
8
|
+
* sequentially focusable.
|
|
9
|
+
* Non-interactive elements with a
|
|
10
|
+
* negative `tabindex` are focusable but
|
|
11
|
+
* not sequentially focusable.
|
|
12
|
+
* https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
|
|
30
13
|
*
|
|
31
|
-
* @return
|
|
14
|
+
* @return Focusable elements.
|
|
32
15
|
*/
|
|
33
|
-
export declare function find(context: Element, { sequential }?:
|
|
34
|
-
sequential?: boolean;
|
|
35
|
-
}): HTMLElement[];
|
|
16
|
+
export declare function find(context: Element, { sequential }?: FindFocusableOptions): HTMLElement[];
|
|
36
17
|
//# sourceMappingURL=focusable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focusable.d.ts","sourceRoot":"","sources":["../src/focusable.
|
|
1
|
+
{"version":3,"file":"focusable.d.ts","sourceRoot":"","sources":["../src/focusable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAoGpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,CACnB,OAAO,EAAE,OAAO,EAChB,EAAE,UAAkB,EAAE,GAAE,oBAAyB,GAC/C,WAAW,EAAE,CAmBf"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -11,4 +11,21 @@ export declare const focus: {
|
|
|
11
11
|
export * from './dom';
|
|
12
12
|
export * from './phrasing-content';
|
|
13
13
|
export * from './data-transfer';
|
|
14
|
+
/**
|
|
15
|
+
* Schema of the content allowed inside an element, keyed by tag name.
|
|
16
|
+
*/
|
|
17
|
+
export type { ContentSchema } from './types';
|
|
18
|
+
/**
|
|
19
|
+
* The attributes and children allowed for an element in a `ContentSchema`.
|
|
20
|
+
*/
|
|
21
|
+
export type { SemanticElementDefinition } from './types';
|
|
22
|
+
/**
|
|
23
|
+
* Schema that `cleanNodeList` and `removeInvalidHTML` clean HTML against,
|
|
24
|
+
* keyed by tag name.
|
|
25
|
+
*/
|
|
26
|
+
export type { Schema } from './dom/types';
|
|
27
|
+
/**
|
|
28
|
+
* The rules for a single tag in a `Schema`.
|
|
29
|
+
*/
|
|
30
|
+
export type { SchemaItem } from './dom/types';
|
|
14
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AAEvC;;;GAGG;AACH,eAAO,MAAM,KAAK;;;CAA0B,CAAC;AAE7C,cAAc,OAAO,CAAC;AACtB,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAEhC;;GAEG;AACH,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;GAEG;AACH,YAAY,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEzD;;;GAGG;AACH,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;GAEG;AACH,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -1,43 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
* All phrasing content elements.
|
|
3
|
-
*
|
|
4
|
-
* @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
|
|
5
|
-
*/
|
|
6
|
-
export type ContentSchema = Record<string, SemanticElementDefinition>;
|
|
7
|
-
export type SemanticElementDefinition = {
|
|
8
|
-
/**
|
|
9
|
-
* Content attributes
|
|
10
|
-
*/
|
|
11
|
-
attributes?: string[];
|
|
12
|
-
/**
|
|
13
|
-
* Content attributes
|
|
14
|
-
*/
|
|
15
|
-
children?: ContentSchema | '*';
|
|
16
|
-
};
|
|
1
|
+
import type { ContentSchema } from './types';
|
|
17
2
|
/**
|
|
18
3
|
* Get schema of possible paths for phrasing content.
|
|
19
4
|
*
|
|
20
5
|
* @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
|
|
21
6
|
*
|
|
22
|
-
* @param
|
|
23
|
-
*
|
|
7
|
+
* @param [context] Set to "paste" to exclude invisible elements and
|
|
8
|
+
* sensitive data.
|
|
24
9
|
*
|
|
25
|
-
* @return
|
|
10
|
+
* @return Schema.
|
|
26
11
|
*/
|
|
27
|
-
export declare function getPhrasingContentSchema(context?: string):
|
|
12
|
+
export declare function getPhrasingContentSchema(context?: string): ContentSchema;
|
|
28
13
|
/**
|
|
29
14
|
* Find out whether or not the given node is phrasing content.
|
|
30
15
|
*
|
|
31
16
|
* @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
|
|
32
17
|
*
|
|
33
|
-
* @param
|
|
18
|
+
* @param node The node to test.
|
|
34
19
|
*
|
|
35
|
-
* @return
|
|
20
|
+
* @return True if phrasing content, false if not.
|
|
36
21
|
*/
|
|
37
22
|
export declare function isPhrasingContent(node: Node): boolean;
|
|
38
23
|
/**
|
|
39
|
-
* @param
|
|
40
|
-
* @return
|
|
24
|
+
* @param node
|
|
25
|
+
* @return Node is text content
|
|
41
26
|
*/
|
|
42
27
|
export declare function isTextContent(node: Node): boolean;
|
|
43
28
|
//# sourceMappingURL=phrasing-content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phrasing-content.d.ts","sourceRoot":"","sources":["../src/phrasing-content.
|
|
1
|
+
{"version":3,"file":"phrasing-content.d.ts","sourceRoot":"","sources":["../src/phrasing-content.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAuI7C;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAE,OAAO,CAAC,EAAE,MAAM,GAAI,aAAa,CAuB1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAE,IAAI,EAAE,IAAI,GAAI,OAAO,CAGvD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAE,IAAI,EAAE,IAAI,GAAI,OAAO,CAGnD"}
|
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns true if the specified element is tabbable, or false otherwise.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
4
|
+
* @param element Element to test.
|
|
5
5
|
*
|
|
6
|
-
* @return
|
|
6
|
+
* @return Whether element is tabbable.
|
|
7
7
|
*/
|
|
8
8
|
export declare function isTabbableIndex(element: Element): boolean;
|
|
9
|
-
export type MaybeHTMLInputElement = HTMLElement & {
|
|
10
|
-
type?: string;
|
|
11
|
-
checked?: boolean;
|
|
12
|
-
name?: string;
|
|
13
|
-
};
|
|
14
9
|
/**
|
|
15
|
-
* @param
|
|
16
|
-
* @return
|
|
10
|
+
* @param context
|
|
11
|
+
* @return Tabbable elements within the context.
|
|
17
12
|
*/
|
|
18
13
|
export declare function find(context: Element): HTMLElement[];
|
|
19
14
|
/**
|
|
20
15
|
* Given a focusable element, find the preceding tabbable element.
|
|
21
16
|
*
|
|
22
|
-
* @param
|
|
23
|
-
*
|
|
17
|
+
* @param element The focusable element before which to look. Defaults
|
|
18
|
+
* to the active element.
|
|
24
19
|
*
|
|
25
|
-
* @return
|
|
20
|
+
* @return Preceding tabbable element.
|
|
26
21
|
*/
|
|
27
22
|
export declare function findPrevious(element: Element): HTMLElement | undefined;
|
|
28
23
|
/**
|
|
29
24
|
* Given a focusable element, find the next tabbable element.
|
|
30
25
|
*
|
|
31
|
-
* @param
|
|
32
|
-
*
|
|
26
|
+
* @param element The focusable element after which to look. Defaults
|
|
27
|
+
* to the active element.
|
|
33
28
|
*
|
|
34
|
-
* @return
|
|
29
|
+
* @return Next tabbable element.
|
|
35
30
|
*/
|
|
36
31
|
export declare function findNext(element: Element): HTMLElement | undefined;
|
|
37
32
|
//# sourceMappingURL=tabbable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabbable.d.ts","sourceRoot":"","sources":["../src/tabbable.
|
|
1
|
+
{"version":3,"file":"tabbable.d.ts","sourceRoot":"","sources":["../src/tabbable.ts"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAE,OAAO,EAAE,OAAO,GAAI,OAAO,CAE3D;AAyHD;;;GAGG;AACH,wBAAgB,IAAI,CAAE,OAAO,EAAE,OAAO,GAAI,WAAW,EAAE,CAEtD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAE,OAAO,EAAE,OAAO,GAAI,WAAW,GAAG,SAAS,CASxE;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAE,OAAO,EAAE,OAAO,GAAI,WAAW,GAAG,SAAS,CAOpE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface SemanticElementDefinition {
|
|
2
|
+
/**
|
|
3
|
+
* Content attributes
|
|
4
|
+
*/
|
|
5
|
+
attributes?: string[];
|
|
6
|
+
/**
|
|
7
|
+
* Allowed child elements, or `'*'` for any
|
|
8
|
+
*/
|
|
9
|
+
children?: ContentSchema | '*';
|
|
10
|
+
}
|
|
11
|
+
export type ContentSchema = Record<string, SemanticElementDefinition>;
|
|
12
|
+
export interface FindFocusableOptions {
|
|
13
|
+
/**
|
|
14
|
+
* If set, only return elements that are sequentially focusable.
|
|
15
|
+
* Non-interactive elements with a negative `tabindex` are focusable but
|
|
16
|
+
* not sequentially focusable.
|
|
17
|
+
*/
|
|
18
|
+
sequential?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type MaybeHTMLInputElement = HTMLElement & {
|
|
21
|
+
type?: string;
|
|
22
|
+
checked?: boolean;
|
|
23
|
+
name?: string;
|
|
24
|
+
};
|
|
25
|
+
export interface ObjectTabbable {
|
|
26
|
+
element: HTMLElement;
|
|
27
|
+
index: number;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,aAAa,GAAG,GAAG,CAAC;CAC/B;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAE,MAAM,EAAE,yBAAyB,CAAE,CAAC;AAExE,MAAM,WAAW,oBAAoB;IACpC;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/dom",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "DOM utilities module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -20,14 +20,13 @@
|
|
|
20
20
|
"url": "https://github.com/WordPress/gutenberg/issues"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": ">=
|
|
23
|
+
"node": ">=22.13.0"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"src",
|
|
27
27
|
"build",
|
|
28
28
|
"build-module",
|
|
29
|
-
"build-types"
|
|
30
|
-
"*.md"
|
|
29
|
+
"build-types"
|
|
31
30
|
],
|
|
32
31
|
"main": "build/index.cjs",
|
|
33
32
|
"module": "build-module/index.mjs",
|
|
@@ -43,13 +42,13 @@
|
|
|
43
42
|
"types": "build-types",
|
|
44
43
|
"sideEffects": false,
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"@wordpress/deprecated": "^
|
|
45
|
+
"@wordpress/deprecated": "^5.1.0"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"vitest": "^5.0.
|
|
48
|
+
"vitest": "^5.0.5"
|
|
50
49
|
},
|
|
51
50
|
"publishConfig": {
|
|
52
51
|
"access": "public"
|
|
53
52
|
},
|
|
54
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "9b70363b9f93cff0583a1f3153738d383cf5a49e"
|
|
55
54
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Gets all files from a DataTransfer object.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
4
|
+
* @param dataTransfer DataTransfer object to inspect.
|
|
5
5
|
*
|
|
6
|
-
* @return
|
|
6
|
+
* @return An array containing all files.
|
|
7
7
|
*/
|
|
8
|
-
export function getFilesFromDataTransfer( dataTransfer ) {
|
|
8
|
+
export function getFilesFromDataTransfer( dataTransfer: DataTransfer ): File[] {
|
|
9
9
|
const files = Array.from( dataTransfer.files );
|
|
10
10
|
|
|
11
11
|
Array.from( dataTransfer.items ).forEach( ( item ) => {
|
|
@@ -6,13 +6,17 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
9
|
+
* @param doc The document of the range.
|
|
10
|
+
* @param x Horizontal position within the current viewport.
|
|
11
|
+
* @param y Vertical position within the current viewport.
|
|
12
12
|
*
|
|
13
|
-
* @return
|
|
13
|
+
* @return The best range for the given point.
|
|
14
14
|
*/
|
|
15
|
-
export default function caretRangeFromPoint(
|
|
15
|
+
export default function caretRangeFromPoint(
|
|
16
|
+
doc: Document,
|
|
17
|
+
x: number,
|
|
18
|
+
y: number
|
|
19
|
+
): Range | null {
|
|
16
20
|
if ( doc.caretPositionFromPoint ) {
|
|
17
21
|
const point = doc.caretPositionFromPoint( x, y );
|
|
18
22
|
|
|
@@ -4,33 +4,27 @@ import unwrap from './unwrap';
|
|
|
4
4
|
import { isPhrasingContent } from '../phrasing-content';
|
|
5
5
|
import insertAfter from './insert-after';
|
|
6
6
|
import isElement from './is-element';
|
|
7
|
+
import type { Schema } from './types';
|
|
7
8
|
|
|
8
9
|
const noop = () => {};
|
|
9
10
|
|
|
10
|
-
/**
|
|
11
|
-
* @typedef SchemaItem
|
|
12
|
-
* @property {string[]} [attributes] Attributes.
|
|
13
|
-
* @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against. Use '*' to keep all classes.
|
|
14
|
-
* @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.
|
|
15
|
-
* @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.
|
|
16
|
-
* @property {boolean} allowEmpty Whether to allow nodes without children.
|
|
17
|
-
* @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/** @typedef {{ [tag: string]: SchemaItem }} Schema */
|
|
21
|
-
|
|
22
11
|
/**
|
|
23
12
|
* Given a schema, unwraps or removes nodes, attributes and classes on a node
|
|
24
13
|
* list.
|
|
25
14
|
*
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
15
|
+
* @param nodeList The nodeList to filter.
|
|
16
|
+
* @param doc The document of the nodeList.
|
|
17
|
+
* @param schema Schema for the HTML.
|
|
18
|
+
* @param [inline] Whether to clean for inline mode.
|
|
30
19
|
*/
|
|
31
|
-
export default function cleanNodeList(
|
|
20
|
+
export default function cleanNodeList(
|
|
21
|
+
nodeList: NodeList,
|
|
22
|
+
doc: Document,
|
|
23
|
+
schema: Schema,
|
|
24
|
+
inline?: boolean
|
|
25
|
+
) {
|
|
32
26
|
Array.from( nodeList ).forEach(
|
|
33
|
-
(
|
|
27
|
+
( node: Node & { nextElementSibling?: unknown } ) => {
|
|
34
28
|
const tag = node.nodeName.toLowerCase();
|
|
35
29
|
|
|
36
30
|
// It's a valid child, if the tag exists in the schema without an isMatch
|
|
@@ -84,13 +78,11 @@ export default function cleanNodeList( nodeList, doc, schema, inline ) {
|
|
|
84
78
|
// Keep all classes.
|
|
85
79
|
return () => true;
|
|
86
80
|
} else if ( typeof item === 'string' ) {
|
|
87
|
-
return (
|
|
88
|
-
|
|
89
|
-
) => className === item;
|
|
81
|
+
return ( className: string ) =>
|
|
82
|
+
className === item;
|
|
90
83
|
} else if ( item instanceof RegExp ) {
|
|
91
|
-
return (
|
|
92
|
-
|
|
93
|
-
) => item.test( className );
|
|
84
|
+
return ( className: string ) =>
|
|
85
|
+
item.test( className );
|
|
94
86
|
}
|
|
95
87
|
|
|
96
88
|
return noop;
|
|
@@ -4,11 +4,11 @@ import { assertIsDefined } from '../utils/assert-is-defined';
|
|
|
4
4
|
/**
|
|
5
5
|
* Get the rectangle for the selection in a container.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
7
|
+
* @param win The window of the selection.
|
|
8
8
|
*
|
|
9
|
-
* @return
|
|
9
|
+
* @return The rectangle.
|
|
10
10
|
*/
|
|
11
|
-
export default function computeCaretRect( win ) {
|
|
11
|
+
export default function computeCaretRect( win: Window ): DOMRect | null {
|
|
12
12
|
const selection = win.getSelection();
|
|
13
13
|
assertIsDefined( selection, 'selection' );
|
|
14
14
|
const range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;
|
|
@@ -6,11 +6,11 @@ import documentHasTextSelection from './document-has-text-selection';
|
|
|
6
6
|
* Check whether the current document has a selection. This includes focus in
|
|
7
7
|
* input fields, textareas, and general rich-text selection.
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
9
|
+
* @param doc The document to check.
|
|
10
10
|
*
|
|
11
|
-
* @return
|
|
11
|
+
* @return True if there is selection, false if not.
|
|
12
12
|
*/
|
|
13
|
-
export default function documentHasSelection( doc ) {
|
|
13
|
+
export default function documentHasSelection( doc: Document ): boolean {
|
|
14
14
|
return (
|
|
15
15
|
!! doc.activeElement &&
|
|
16
16
|
( isHTMLInputElement( doc.activeElement ) ||
|
|
@@ -7,11 +7,11 @@ import { assertIsDefined } from '../utils/assert-is-defined';
|
|
|
7
7
|
*
|
|
8
8
|
* See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.
|
|
9
9
|
*
|
|
10
|
-
* @param
|
|
10
|
+
* @param doc The document to check.
|
|
11
11
|
*
|
|
12
|
-
* @return
|
|
12
|
+
* @return True if there is selection, false if not.
|
|
13
13
|
*/
|
|
14
|
-
export default function documentHasTextSelection( doc ) {
|
|
14
|
+
export default function documentHasTextSelection( doc: Document ): boolean {
|
|
15
15
|
assertIsDefined( doc.defaultView, 'doc.defaultView' );
|
|
16
16
|
const selection = doc.defaultView.getSelection();
|
|
17
17
|
assertIsDefined( selection, 'selection' );
|
package/src/dom/{document-has-uncollapsed-selection.js → document-has-uncollapsed-selection.ts}
RENAMED
|
@@ -6,11 +6,13 @@ import inputFieldHasUncollapsedSelection from './input-field-has-uncollapsed-sel
|
|
|
6
6
|
* This includes ranges of text across elements and any selection inside
|
|
7
7
|
* textual `<input>` and `<textarea>` elements.
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
9
|
+
* @param doc The document to check.
|
|
10
10
|
*
|
|
11
|
-
* @return
|
|
11
|
+
* @return Whether there is any recognizable text selection in the document.
|
|
12
12
|
*/
|
|
13
|
-
export default function documentHasUncollapsedSelection(
|
|
13
|
+
export default function documentHasUncollapsedSelection(
|
|
14
|
+
doc: Document
|
|
15
|
+
): boolean {
|
|
14
16
|
return (
|
|
15
17
|
documentHasTextSelection( doc ) ||
|
|
16
18
|
( !! doc.activeElement &&
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { assertIsDefined } from '../utils/assert-is-defined';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @param
|
|
5
|
-
* @return
|
|
4
|
+
* @param element
|
|
5
|
+
* @return The computed style for the element.
|
|
6
6
|
*/
|
|
7
|
-
export default function getComputedStyle(
|
|
7
|
+
export default function getComputedStyle(
|
|
8
|
+
element: Element
|
|
9
|
+
): CSSStyleDeclaration {
|
|
8
10
|
assertIsDefined(
|
|
9
11
|
element.ownerDocument.defaultView,
|
|
10
12
|
'element.ownerDocument.defaultView'
|