@wordpress/dom 4.57.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 +5 -6
- 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 -317
- package/src/index.js +0 -12
- /package/src/dom/{index.js → index.ts} +0 -0
|
@@ -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,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,YAAY;AACnB,SAAS,yBAAyB;AAClC,OAAO,iBAAiB;AACxB,OAAO,eAAe;
|
|
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": ";AAAA,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,YAAY;AACn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;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["require"]
|
|
7
7
|
}
|
|
@@ -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,OAAO,2BAA2B;AAClC,SAAS,uBAAuB;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,OAAO,2BAA2B;AAClC,SAAS,uBAAuB;AASjB,SAAR,iBAAmC,KAA8B;AACvE,QAAM,YAAY,IAAI,aAAa;AACnC,kBAAiB,WAAW,WAAY;AACxC,QAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;AAEjE,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,SAAO,sBAAuB,KAAM;AACrC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// packages/dom/src/dom/document-has-selection.
|
|
1
|
+
// packages/dom/src/dom/document-has-selection.ts
|
|
2
2
|
import isTextField from "./is-text-field.mjs";
|
|
3
3
|
import isHTMLInputElement from "./is-html-input-element.mjs";
|
|
4
4
|
import documentHasTextSelection from "./document-has-text-selection.mjs";
|
|
@@ -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,OAAO,iBAAiB;AACxB,OAAO,wBAAwB;AAC/B,OAAO,8BAA8B;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,OAAO,iBAAiB;AACxB,OAAO,wBAAwB;AAC/B,OAAO,8BAA8B;AAUtB,SAAR,qBAAuC,KAAyB;AACtE,SACC,CAAC,CAAE,IAAI,kBACL,mBAAoB,IAAI,aAAc,KACvC,YAAa,IAAI,aAAc,KAC/B,yBAA0B,GAAI;AAEjC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// packages/dom/src/dom/document-has-text-selection.
|
|
1
|
+
// packages/dom/src/dom/document-has-text-selection.ts
|
|
2
2
|
import { assertIsDefined } from "../utils/assert-is-defined.mjs";
|
|
3
3
|
function documentHasTextSelection(doc) {
|
|
4
4
|
assertIsDefined(doc.defaultView, "doc.defaultView");
|
|
@@ -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,SAAS,uBAAuB;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,SAAS,uBAAuB;AAajB,SAAR,yBAA2C,KAAyB;AAC1E,kBAAiB,IAAI,aAAa,iBAAkB;AACpD,QAAM,YAAY,IAAI,YAAY,aAAa;AAC/C,kBAAiB,WAAW,WAAY;AACxC,QAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;AACjE,SAAO,CAAC,CAAE,SAAS,CAAE,MAAM;AAC5B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// packages/dom/src/dom/document-has-uncollapsed-selection.
|
|
1
|
+
// packages/dom/src/dom/document-has-uncollapsed-selection.ts
|
|
2
2
|
import documentHasTextSelection from "./document-has-text-selection.mjs";
|
|
3
3
|
import inputFieldHasUncollapsedSelection from "./input-field-has-uncollapsed-selection.mjs";
|
|
4
4
|
function documentHasUncollapsedSelection(doc) {
|
|
@@ -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,OAAO,8BAA8B;AACrC,OAAO,uCAAuC;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,OAAO,8BAA8B;AACrC,OAAO,uCAAuC;AAW/B,SAAR,gCACN,KACU;AACV,SACC,yBAA0B,GAAI,KAC5B,CAAC,CAAE,IAAI,iBACR,kCAAmC,IAAI,aAAc;AAExD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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,SAAS,uBAAuB;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,SAAS,uBAAuB;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
|
}
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
// packages/dom/src/dom/get-offset-parent.
|
|
1
|
+
// packages/dom/src/dom/get-offset-parent.ts
|
|
2
2
|
import getComputedStyle from "./get-computed-style.mjs";
|
|
3
|
+
import isElement from "./is-element.mjs";
|
|
3
4
|
function getOffsetParent(node) {
|
|
4
|
-
let closestElement;
|
|
5
|
-
while (closestElement
|
|
6
|
-
|
|
7
|
-
if (closestElement.nodeType === closestElement.ELEMENT_NODE) {
|
|
8
|
-
break;
|
|
9
|
-
}
|
|
5
|
+
let closestElement = node.parentNode;
|
|
6
|
+
while (closestElement && !isElement(closestElement)) {
|
|
7
|
+
closestElement = closestElement.parentNode;
|
|
10
8
|
}
|
|
11
9
|
if (!closestElement) {
|
|
12
10
|
return null;
|
|
13
11
|
}
|
|
14
|
-
if (getComputedStyle(
|
|
15
|
-
/** @type {Element} */
|
|
16
|
-
closestElement
|
|
17
|
-
).position !== "static") {
|
|
12
|
+
if (getComputedStyle(closestElement).position !== "static") {
|
|
18
13
|
return closestElement;
|
|
19
14
|
}
|
|
20
|
-
return
|
|
21
|
-
/** @type {Node & { offsetParent: Node }} */
|
|
22
|
-
closestElement.offsetParent
|
|
23
|
-
);
|
|
15
|
+
return closestElement.offsetParent;
|
|
24
16
|
}
|
|
25
17
|
export {
|
|
26
18
|
getOffsetParent as default
|
|
@@ -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,OAAO,sBAAsB;
|
|
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,OAAO,sBAAsB;AAC7B,OAAO,eAAe;AAaP,SAAR,gBAAkC,MAA0B;AAGlE,MAAI,iBAAiB,KAAK;AAC1B,SAAQ,kBAAkB,CAAE,UAAW,cAAe,GAAI;AACzD,qBAAiB,eAAe;AAAA,EACjC;AAEA,MAAK,CAAE,gBAAiB;AACvB,WAAO;AAAA,EACR;AAIA,MAAK,iBAAkB,cAAe,EAAE,aAAa,UAAW;AAC/D,WAAO;AAAA,EACR;AAGA,SAAS,eAAgC;AAC1C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -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": ";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": ";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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// packages/dom/src/dom/get-rectangle-from-range.
|
|
1
|
+
// packages/dom/src/dom/get-rectangle-from-range.ts
|
|
2
2
|
import { assertIsDefined } from "../utils/assert-is-defined.mjs";
|
|
3
3
|
function getRectangleFromRange(range) {
|
|
4
4
|
if (!range.collapsed) {
|
|
@@ -61,11 +61,7 @@ function getRectangleFromRange(range) {
|
|
|
61
61
|
let beforeRange;
|
|
62
62
|
if (before && before.nodeType === before.TEXT_NODE) {
|
|
63
63
|
beforeRange = ownerDocument.createRange();
|
|
64
|
-
beforeRange.setStart(
|
|
65
|
-
before,
|
|
66
|
-
/** @type {Text} */
|
|
67
|
-
before.length
|
|
68
|
-
);
|
|
64
|
+
beforeRange.setStart(before, before.length);
|
|
69
65
|
beforeRange.collapse(true);
|
|
70
66
|
}
|
|
71
67
|
let afterRange;
|
|
@@ -93,8 +89,7 @@ function getRectangleFromRange(range) {
|
|
|
93
89
|
if (rects.length > 1) {
|
|
94
90
|
return null;
|
|
95
91
|
}
|
|
96
|
-
if (rects.length === 1 && startContainer.nodeType === startContainer.TEXT_NODE && range.startOffset > 0 && range.startOffset <
|
|
97
|
-
startContainer.length) {
|
|
92
|
+
if (rects.length === 1 && startContainer.nodeType === startContainer.TEXT_NODE && range.startOffset > 0 && range.startOffset < startContainer.length) {
|
|
98
93
|
assertIsDefined(ownerDocument, "ownerDocument");
|
|
99
94
|
const measure = (start, end) => {
|
|
100
95
|
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,SAAS,uBAAuB;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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,UAAM,SAAS,QAAS,MAAM,cAAc,GAAG,MAAM,WAAY;AACjE,UAAM,QAAQ,QAAS,MAAM,aAAa,MAAM,cAAc,CAAE;AAEhE,QAAK,OAAO,UAAU,MAAM,KAAM;AACjC,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO,MAAO,CAAE,KAAK;AACtB;",
|
|
6
6
|
"names": ["rects"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// packages/dom/src/dom/get-scroll-container.
|
|
1
|
+
// packages/dom/src/dom/get-scroll-container.ts
|
|
2
2
|
import getComputedStyle from "./get-computed-style.mjs";
|
|
3
3
|
function getScrollContainer(node, direction = "vertical") {
|
|
4
4
|
if (!node) {
|
|
@@ -23,11 +23,7 @@ function getScrollContainer(node, direction = "vertical") {
|
|
|
23
23
|
if (node.ownerDocument === node.parentNode) {
|
|
24
24
|
return node;
|
|
25
25
|
}
|
|
26
|
-
return getScrollContainer(
|
|
27
|
-
/** @type {Element} */
|
|
28
|
-
node.parentNode,
|
|
29
|
-
direction
|
|
30
|
-
);
|
|
26
|
+
return getScrollContainer(node.parentNode, direction);
|
|
31
27
|
}
|
|
32
28
|
export {
|
|
33
29
|
getScrollContainer as default
|
|
@@ -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,OAAO,sBAAsB;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,OAAO,sBAAsB;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,IAAI,iBAAkB,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,IAAI,iBAAkB,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": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// packages/dom/src/dom/hidden-caret-range-from-point.
|
|
1
|
+
// packages/dom/src/dom/hidden-caret-range-from-point.ts
|
|
2
2
|
import caretRangeFromPoint from "./caret-range-from-point.mjs";
|
|
3
3
|
import getComputedStyle from "./get-computed-style.mjs";
|
|
4
4
|
function hiddenCaretRangeFromPoint(doc, x, y, container) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/hidden-caret-range-from-point.
|
|
4
|
-
"sourcesContent": ["import caretRangeFromPoint from './caret-range-from-point';\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Get a collapsed range for a given point.\n * Gives the container a temporary high z-index (above any UI).\n * This is preferred over getting the UI nodes and set styles there.\n *\n * @param
|
|
5
|
-
"mappings": ";AAAA,OAAO,yBAAyB;AAChC,OAAO,sBAAsB;AAcd,SAAR,
|
|
3
|
+
"sources": ["../../src/dom/hidden-caret-range-from-point.ts"],
|
|
4
|
+
"sourcesContent": ["import caretRangeFromPoint from './caret-range-from-point';\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Get a collapsed range for a given point.\n * Gives the container a temporary high z-index (above any UI).\n * This is preferred over getting the UI nodes and set styles there.\n *\n * @param doc The document of the range.\n * @param x Horizontal position within the current viewport.\n * @param y Vertical position within the current viewport.\n * @param container Container in which the range is expected to be found.\n *\n * @return The best range for the given point.\n */\nexport default function hiddenCaretRangeFromPoint(\n\tdoc: Document,\n\tx: number,\n\ty: number,\n\tcontainer: HTMLElement\n): Range | null {\n\tconst originalZIndex = container.style.zIndex;\n\tconst originalPosition = container.style.position;\n\tconst originalBorderRadius = container.style.borderRadius;\n\n\tconst { position = 'static' } = getComputedStyle( container );\n\n\t// A z-index only works if the element position is not static.\n\tif ( position === 'static' ) {\n\t\tcontainer.style.position = 'relative';\n\t}\n\n\tcontainer.style.zIndex = '10000';\n\n\t// When an element has border radius, the x/y coordinates can incorrectly fall\n\t// outside the element because of the radius. Temporarily reset the value\n\t// to ensure the coordinates are tested against a rectangle and not a pill-shaped\n\t// element. See https://github.com/WordPress/gutenberg/issues/72053 for more info.\n\tcontainer.style.borderRadius = '0';\n\n\tconst range = caretRangeFromPoint( doc, x, y );\n\n\tcontainer.style.zIndex = originalZIndex;\n\tcontainer.style.position = originalPosition;\n\tcontainer.style.borderRadius = originalBorderRadius;\n\n\treturn range;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,yBAAyB;AAChC,OAAO,sBAAsB;AAcd,SAAR,0BACN,KACA,GACA,GACA,WACe;AACf,QAAM,iBAAiB,UAAU,MAAM;AACvC,QAAM,mBAAmB,UAAU,MAAM;AACzC,QAAM,uBAAuB,UAAU,MAAM;AAE7C,QAAM,EAAE,WAAW,SAAS,IAAI,iBAAkB,SAAU;AAG5D,MAAK,aAAa,UAAW;AAC5B,cAAU,MAAM,WAAW;AAAA,EAC5B;AAEA,YAAU,MAAM,SAAS;AAMzB,YAAU,MAAM,eAAe;AAE/B,QAAM,QAAQ,oBAAqB,KAAK,GAAG,CAAE;AAE7C,YAAU,MAAM,SAAS;AACzB,YAAU,MAAM,WAAW;AAC3B,YAAU,MAAM,eAAe;AAE/B,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// packages/dom/src/dom/index.
|
|
1
|
+
// packages/dom/src/dom/index.ts
|
|
2
2
|
import { default as default2 } from "./compute-caret-rect.mjs";
|
|
3
3
|
import { default as default3 } from "./document-has-text-selection.mjs";
|
|
4
4
|
import { default as default4 } from "./document-has-uncollapsed-selection.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/index.
|
|
3
|
+
"sources": ["../../src/dom/index.ts"],
|
|
4
4
|
"sourcesContent": ["export { default as computeCaretRect } from './compute-caret-rect';\nexport { default as documentHasTextSelection } from './document-has-text-selection';\nexport { default as documentHasUncollapsedSelection } from './document-has-uncollapsed-selection';\nexport { default as documentHasSelection } from './document-has-selection';\nexport { default as getRectangleFromRange } from './get-rectangle-from-range';\nexport { default as getScrollContainer } from './get-scroll-container';\nexport { default as getOffsetParent } from './get-offset-parent';\nexport { default as isEntirelySelected } from './is-entirely-selected';\nexport { default as isFormElement } from './is-form-element';\nexport { default as isHorizontalEdge } from './is-horizontal-edge';\nexport { default as isNumberInput } from './is-number-input';\nexport { default as isTextField } from './is-text-field';\nexport { default as isVerticalEdge } from './is-vertical-edge';\nexport { default as placeCaretAtHorizontalEdge } from './place-caret-at-horizontal-edge';\nexport { default as placeCaretAtVerticalEdge } from './place-caret-at-vertical-edge';\nexport { default as replace } from './replace';\nexport { default as remove } from './remove';\nexport { default as insertAfter } from './insert-after';\nexport { default as unwrap } from './unwrap';\nexport { default as replaceTag } from './replace-tag';\nexport { default as wrap } from './wrap';\nexport { default as __unstableStripHTML } from './strip-html';\nexport { default as isEmpty } from './is-empty';\nexport { default as removeInvalidHTML } from './remove-invalid-html';\nexport { default as isRTL } from './is-rtl';\nexport { default as safeHTML } from './safe-html';\nexport { default as isSelectionForward } from './is-selection-forward';\n"],
|
|
5
5
|
"mappings": ";AAAA,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAA2C;AACpD,SAAoB,WAAXA,gBAAkD;AAC3D,SAAoB,WAAXA,gBAAuC;AAChD,SAAoB,WAAXA,gBAAwC;AACjD,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAAqC;AAC9C,SAAoB,WAAXA,iBAAgC;AACzC,SAAoB,WAAXA,iBAAmC;AAC5C,SAAoB,WAAXA,iBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAA6C;AACtD,SAAoB,WAAXA,iBAA2C;AACpD,SAAoB,WAAXA,iBAA0B;AACnC,SAAoB,WAAXA,iBAAyB;AAClC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAyB;AAClC,SAAoB,WAAXA,iBAA6B;AACtC,SAAoB,WAAXA,iBAAuB;AAChC,SAAoB,WAAXA,iBAAsC;AAC/C,SAAoB,WAAXA,iBAA0B;AACnC,SAAoB,WAAXA,iBAAoC;AAC7C,SAAoB,WAAXA,iBAAwB;AACjC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAAqC;",
|
|
6
6
|
"names": ["default"]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// packages/dom/src/dom/input-field-has-uncollapsed-selection.
|
|
1
|
+
// packages/dom/src/dom/input-field-has-uncollapsed-selection.ts
|
|
2
2
|
import isTextField from "./is-text-field.mjs";
|
|
3
3
|
import isHTMLInputElement from "./is-html-input-element.mjs";
|
|
4
4
|
function inputFieldHasUncollapsedSelection(element) {
|
|
@@ -6,10 +6,7 @@ function inputFieldHasUncollapsedSelection(element) {
|
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
try {
|
|
9
|
-
const { selectionStart, selectionEnd } =
|
|
10
|
-
/** @type {HTMLInputElement | HTMLTextAreaElement} */
|
|
11
|
-
element
|
|
12
|
-
);
|
|
9
|
+
const { selectionStart, selectionEnd } = element;
|
|
13
10
|
return (
|
|
14
11
|
// `null` means the input type doesn't implement selection, thus we
|
|
15
12
|
// cannot determine whether the selection is collapsed, so we
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/input-field-has-uncollapsed-selection.
|
|
4
|
-
"sourcesContent": ["import isTextField from './is-text-field';\nimport isHTMLInputElement from './is-html-input-element';\n\n/**\n * Check whether the given input field or textarea contains a (uncollapsed)\n * selection of text.\n *\n * CAVEAT: Only specific text-based HTML inputs support the selection APIs\n * needed to determine whether they have a collapsed or uncollapsed selection.\n * This function defaults to returning `true` when the selection cannot be\n * inspected, such as with `<input type=\"time\">`. The rationale is that this\n * should cause the block editor to defer to the browser's native selection\n * handling (e.g. copying and pasting), thereby reducing friction for the user.\n *\n * See: https://html.spec.whatwg.org/multipage/input.html#do-not-apply\n *\n * @param
|
|
5
|
-
"mappings": ";AAAA,OAAO,iBAAiB;AACxB,OAAO,wBAAwB;AAmBhB,SAAR,
|
|
3
|
+
"sources": ["../../src/dom/input-field-has-uncollapsed-selection.ts"],
|
|
4
|
+
"sourcesContent": ["import isTextField from './is-text-field';\nimport isHTMLInputElement from './is-html-input-element';\n\n/**\n * Check whether the given input field or textarea contains a (uncollapsed)\n * selection of text.\n *\n * CAVEAT: Only specific text-based HTML inputs support the selection APIs\n * needed to determine whether they have a collapsed or uncollapsed selection.\n * This function defaults to returning `true` when the selection cannot be\n * inspected, such as with `<input type=\"time\">`. The rationale is that this\n * should cause the block editor to defer to the browser's native selection\n * handling (e.g. copying and pasting), thereby reducing friction for the user.\n *\n * See: https://html.spec.whatwg.org/multipage/input.html#do-not-apply\n *\n * @param element The HTML element.\n *\n * @return Whether the input/textarea element has some \"selection\".\n */\nexport default function inputFieldHasUncollapsedSelection(\n\telement: Element\n): boolean {\n\tif ( ! isHTMLInputElement( element ) && ! isTextField( element ) ) {\n\t\treturn false;\n\t}\n\n\t// Safari throws a type error when trying to get `selectionStart` and\n\t// `selectionEnd` on non-text <input> elements, so a try/catch construct is\n\t// necessary.\n\ttry {\n\t\tconst { selectionStart, selectionEnd } = element as\n\t\t\tHTMLInputElement | HTMLTextAreaElement;\n\t\treturn (\n\t\t\t// `null` means the input type doesn't implement selection, thus we\n\t\t\t// cannot determine whether the selection is collapsed, so we\n\t\t\t// default to true.\n\t\t\tselectionStart === null ||\n\t\t\t// when not null, compare the two points\n\t\t\tselectionStart !== selectionEnd\n\t\t);\n\t} catch {\n\t\t// This is Safari's way of saying that the input type doesn't implement\n\t\t// selection, so we default to true.\n\t\treturn true;\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,iBAAiB;AACxB,OAAO,wBAAwB;AAmBhB,SAAR,kCACN,SACU;AACV,MAAK,CAAE,mBAAoB,OAAQ,KAAK,CAAE,YAAa,OAAQ,GAAI;AAClE,WAAO;AAAA,EACR;AAKA,MAAI;AACH,UAAM,EAAE,gBAAgB,aAAa,IAAI;AAEzC;AAAA;AAAA;AAAA;AAAA,MAIC,mBAAmB;AAAA,MAEnB,mBAAmB;AAAA;AAAA,EAErB,QAAQ;AAGP,WAAO;AAAA,EACR;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/insert-after.
|
|
4
|
-
"sourcesContent": ["import { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Given two DOM nodes, inserts the former in the DOM as the next sibling of\n * the latter.\n *\n * @param
|
|
5
|
-
"mappings": ";AAAA,SAAS,uBAAuB;
|
|
3
|
+
"sources": ["../../src/dom/insert-after.ts"],
|
|
4
|
+
"sourcesContent": ["import { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Given two DOM nodes, inserts the former in the DOM as the next sibling of\n * the latter.\n *\n * @param newNode Node to be inserted.\n * @param referenceNode Node after which to perform the insertion.\n */\nexport default function insertAfter(\n\tnewNode: Node,\n\treferenceNode: Node\n): void {\n\tassertIsDefined( referenceNode.parentNode, 'referenceNode.parentNode' );\n\treferenceNode.parentNode.insertBefore( newNode, referenceNode.nextSibling );\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,uBAAuB;AASjB,SAAR,YACN,SACA,eACO;AACP,kBAAiB,cAAc,YAAY,0BAA2B;AACtE,gBAAc,WAAW,aAAc,SAAS,cAAc,WAAY;AAC3E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/is-edge.
|
|
4
|
-
"sourcesContent": ["import isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\nimport { scrollIfNoRange } from './scroll-if-no-range';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param
|
|
5
|
-
"mappings": ";AAAA,OAAO,WAAW;AAClB,OAAO,oBAAoB;AAC3B,OAAO,2BAA2B;AAClC,OAAO,wBAAwB;AAC/B,OAAO,+BAA+B;AACtC,SAAS,uBAAuB;AAChC,OAAO,uBAAuB;AAC9B,SAAS,uBAAuB;AAajB,SAAR,
|
|
3
|
+
"sources": ["../../src/dom/is-edge.ts"],
|
|
4
|
+
"sourcesContent": ["import isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\nimport { scrollIfNoRange } from './scroll-if-no-range';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param container Focusable element.\n * @param isReverse Set to true to check left, false to check right.\n * @param onlyVertical Set to true to check only vertical position.\n *\n * @return True if at the edge, false if not.\n */\nexport default function isEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean,\n\tonlyVertical: boolean = false\n): boolean {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! container.isContentEditable ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\n\t// The test point can only be hit-tested when it is within the viewport\n\t// (`caretRangeFromPoint` returns nothing for a point outside it, upon\n\t// which `scrollIfNoRange` scrolls the container's edge into view to\n\t// measure, e.g. on every arrow press within a container taller than the\n\t// viewport). When the edge is outside the viewport and the selection is\n\t// within it, they are at least a viewport boundary apart along that\n\t// axis, so the selection cannot be at the edge. Check each axis\n\t// separately: the vertical check must not be short-circuited by a\n\t// horizontally overflowing container, and vice versa.\n\tconst isFarFromVerticalEdge =\n\t\t( y < 0 || y > defaultView.innerHeight ) &&\n\t\trangeRect.top >= 0 &&\n\t\trangeRect.bottom <= defaultView.innerHeight;\n\tconst isFarFromHorizontalEdge =\n\t\t( x < 0 || x > defaultView.innerWidth ) &&\n\t\trangeRect.left >= 0 &&\n\t\trangeRect.right <= defaultView.innerWidth;\n\n\tif (\n\t\tisFarFromVerticalEdge ||\n\t\t( ! onlyVertical && isFarFromHorizontalEdge )\n\t) {\n\t\treturn false;\n\t}\n\n\tconst testRange = scrollIfNoRange( container, isReverse, () =>\n\t\thiddenCaretRangeFromPoint( ownerDocument, x, y, container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,WAAW;AAClB,OAAO,oBAAoB;AAC3B,OAAO,2BAA2B;AAClC,OAAO,wBAAwB;AAC/B,OAAO,+BAA+B;AACtC,SAAS,uBAAuB;AAChC,OAAO,uBAAuB;AAC9B,SAAS,uBAAuB;AAajB,SAAR,OACN,WACA,WACA,eAAwB,OACd;AACV,MACC,kBAAmB,SAAU,KAC7B,OAAO,UAAU,mBAAmB,UACnC;AACD,QAAK,UAAU,mBAAmB,UAAU,cAAe;AAC1D,aAAO;AAAA,IACR;AAEA,QAAK,WAAY;AAChB,aAAO,UAAU,mBAAmB;AAAA,IACrC;AAEA,WAAO,UAAU,MAAM,WAAW,UAAU;AAAA,EAC7C;AAEA,MAAK,CAAE,UAAU,mBAAoB;AACpC,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,cAAc,IAAI;AAC1B,QAAM,EAAE,YAAY,IAAI;AAExB,kBAAiB,aAAa,aAAc;AAC5C,QAAM,YAAY,YAAY,aAAa;AAE3C,MAAK,CAAE,aAAa,CAAE,UAAU,YAAa;AAC5C,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,UAAU,WAAY,CAAE;AACtC,QAAM,iBAAiB,MAAM,WAAW;AACxC,QAAM,YAAY,mBAAoB,SAAU;AAChD,QAAM,cAAc,UAAU;AAG9B,MAAK,CAAE,aAAc;AACpB,mBAAe,SAAU,CAAE,SAAU;AAAA,EACtC;AAEA,QAAM,qBAAqB,sBAAuB,cAAe;AACjE,QAAM,YAAY,sBAAuB,KAAM;AAE/C,MAAK,CAAE,sBAAsB,CAAE,WAAY;AAC1C,WAAO;AAAA,EACR;AAKA,Q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ined} node\n * @return {node is Element} True if node is an Element node\n */\nexport default function isElement(
|
|
5
|
-
"mappings": ";AAIe,SAAR,
|
|
3
|
+
"sources": ["../../src/dom/is-element.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @param {Node | null | undefined} node\n * @return {node is Element} True if node is an Element node\n */\nexport default function isElement(\n\tnode: Node | null | undefined\n): node is Element {\n\treturn !! node && node.nodeType === node.ELEMENT_NODE;\n}\n"],
|
|
5
|
+
"mappings": ";AAIe,SAAR,UACN,MACkB;AAClB,SAAO,CAAC,CAAE,QAAQ,KAAK,aAAa,KAAK;AAC1C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// packages/dom/src/dom/is-empty.
|
|
1
|
+
// packages/dom/src/dom/is-empty.ts
|
|
2
2
|
function isEmpty(element) {
|
|
3
3
|
switch (element.nodeType) {
|
|
4
4
|
case element.TEXT_NODE:
|
|
@@ -9,10 +9,7 @@ function isEmpty(element) {
|
|
|
9
9
|
} else if (!element.hasChildNodes()) {
|
|
10
10
|
return true;
|
|
11
11
|
}
|
|
12
|
-
return (
|
|
13
|
-
/** @type {Element[]} */
|
|
14
|
-
Array.from(element.childNodes).every(isEmpty)
|
|
15
|
-
);
|
|
12
|
+
return Array.from(element.childNodes).every(isEmpty);
|
|
16
13
|
default:
|
|
17
14
|
return true;
|
|
18
15
|
}
|