@wordpress/block-editor 17.0.2-next.v.202608281122.0 → 17.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/CHANGELOG.md +29 -1
- package/build/components/background-image-control/index.cjs +18 -1
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-allowed-blocks/modal.cjs +2 -1
- package/build/components/block-allowed-blocks/modal.cjs.map +3 -3
- package/build/components/block-edit/edit.cjs.map +1 -1
- package/build/components/block-inspector/index.cjs +3 -12
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-is-hovered.cjs +17 -4
- package/build/components/block-list/use-block-props/use-is-hovered.cjs.map +2 -2
- package/build/components/block-preview/index.cjs +1 -2
- package/build/components/block-preview/index.cjs.map +2 -2
- package/build/components/block-switcher/index.cjs +2 -1
- package/build/components/block-switcher/index.cjs.map +3 -3
- package/build/components/block-toolbar/pattern-overrides-dropdown.cjs +2 -1
- package/build/components/block-toolbar/pattern-overrides-dropdown.cjs.map +3 -3
- package/build/components/global-styles/border-panel.cjs +19 -42
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/image-settings-panel.cjs.map +1 -1
- package/build/components/iframe/index.cjs.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.cjs.map +1 -1
- package/build/components/inserter-draggable-blocks/index.cjs.map +1 -1
- package/build/components/inspector-controls-tabs/content-tab.cjs +2 -3
- package/build/components/inspector-controls-tabs/content-tab.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +1 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/inspector-popover-header/index.cjs +5 -4
- package/build/components/inspector-popover-header/index.cjs.map +3 -3
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/link-control/search-input.cjs.map +1 -1
- package/build/components/list-view/block-select-button.cjs +9 -1
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/list-view/use-list-view-drop-zone.cjs.map +1 -1
- package/build/components/media-replace-flow/index.cjs +4 -1
- package/build/components/media-replace-flow/index.cjs.map +2 -2
- package/build/components/navigable-toolbar/index.cjs +3 -0
- package/build/components/navigable-toolbar/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/enter.cjs +23 -11
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/index.cjs +0 -2
- package/build/components/rich-text/event-listeners/index.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-rules.cjs +4 -2
- package/build/components/rich-text/event-listeners/input-rules.cjs.map +2 -2
- package/build/components/use-block-drop-zone/index.cjs.map +1 -1
- package/build/components/writing-flow/index.cjs +5 -0
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs.map +1 -1
- package/build/components/writing-flow/use-input.cjs +12 -2
- package/build/components/writing-flow/use-input.cjs.map +2 -2
- package/build/components/writing-flow/use-tab-nav.cjs +84 -41
- package/build/components/writing-flow/use-tab-nav.cjs.map +3 -3
- package/build/components/{rich-text/event-listeners/undo-automatic-change.cjs → writing-flow/use-undo-automatic-change.cjs} +18 -15
- package/build/components/writing-flow/use-undo-automatic-change.cjs.map +7 -0
- package/build/hooks/border.cjs +2 -46
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/generate-fields-from-attributes.cjs.map +1 -1
- package/build/hooks/index.cjs +0 -2
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/style.cjs +2 -2
- package/build/hooks/style.cjs.map +2 -2
- package/build/layouts/flex.cjs +3 -0
- package/build/layouts/flex.cjs.map +2 -2
- package/build/store/actions.cjs +12 -9
- package/build/store/actions.cjs.map +3 -3
- package/build-module/components/background-image-control/index.mjs +18 -1
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-allowed-blocks/modal.mjs +2 -2
- package/build-module/components/block-allowed-blocks/modal.mjs.map +2 -2
- package/build-module/components/block-edit/edit.mjs.map +1 -1
- package/build-module/components/block-inspector/index.mjs +3 -12
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs +17 -4
- package/build-module/components/block-list/use-block-props/use-is-hovered.mjs.map +2 -2
- package/build-module/components/block-preview/index.mjs +1 -2
- package/build-module/components/block-preview/index.mjs.map +2 -2
- package/build-module/components/block-switcher/index.mjs +2 -2
- package/build-module/components/block-switcher/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs +3 -6
- package/build-module/components/block-toolbar/pattern-overrides-dropdown.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +19 -42
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/image-settings-panel.mjs.map +1 -1
- package/build-module/components/iframe/index.mjs.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.mjs.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.mjs.map +1 -1
- package/build-module/components/inspector-controls-tabs/content-tab.mjs +3 -4
- package/build-module/components/inspector-controls-tabs/content-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -3
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +1 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/inspector-popover-header/index.mjs +6 -7
- package/build-module/components/inspector-popover-header/index.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/link-control/search-input.mjs.map +1 -1
- package/build-module/components/list-view/block-select-button.mjs +9 -1
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-drop-zone.mjs.map +1 -1
- package/build-module/components/media-replace-flow/index.mjs +4 -1
- package/build-module/components/media-replace-flow/index.mjs.map +2 -2
- package/build-module/components/navigable-toolbar/index.mjs +3 -0
- package/build-module/components/navigable-toolbar/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +23 -11
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/index.mjs +0 -2
- package/build-module/components/rich-text/event-listeners/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs +4 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
- package/build-module/components/use-block-drop-zone/index.mjs.map +1 -1
- package/build-module/components/writing-flow/index.mjs +5 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +1 -1
- package/build-module/components/writing-flow/use-input.mjs +12 -2
- package/build-module/components/writing-flow/use-input.mjs.map +2 -2
- package/build-module/components/writing-flow/use-tab-nav.mjs +86 -43
- package/build-module/components/writing-flow/use-tab-nav.mjs.map +3 -3
- package/build-module/components/writing-flow/use-undo-automatic-change.mjs +36 -0
- package/build-module/components/writing-flow/use-undo-automatic-change.mjs.map +7 -0
- package/build-module/hooks/border.mjs +1 -45
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/generate-fields-from-attributes.mjs.map +1 -1
- package/build-module/hooks/index.mjs +0 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/style.mjs +3 -2
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +3 -0
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/store/actions.mjs +12 -9
- package/build-module/store/actions.mjs.map +2 -2
- package/build-style/content-rtl.css +9 -20
- package/build-style/content.css +9 -20
- package/build-style/style-rtl.css +100 -221
- package/build-style/style.css +100 -221
- package/package.json +42 -41
- package/src/autocompleters/test/block.js +1 -0
- package/src/components/alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +34 -16
- package/src/components/alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/background-image-control/index.jsx +32 -1
- package/src/components/background-image-control/style.scss +5 -3
- package/src/components/background-image-control/test/{index.js → index.jsdom.test.js} +1 -0
- package/src/components/block-alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +68 -13
- package/src/components/block-alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/block-allowed-blocks/modal.jsx +3 -3
- package/src/components/block-bindings/test/{use-block-bindings-utils.js → use-block-bindings-utils.jsdom.test.js} +2 -1
- package/src/components/block-breadcrumb/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +2 -2
- package/src/components/block-breadcrumb/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/block-compare/test/__snapshots__/{block-view.jsx.snap → block-view.jsdom.test.jsx.snap} +2 -2
- package/src/components/block-compare/test/{block-view.jsx → block-view.jsdom.test.jsx} +1 -0
- package/src/components/block-controls/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/block-edit/edit.jsx +1 -1
- package/src/components/block-edit/test/{edit.jsx → edit.jsdom.test.jsx} +1 -0
- package/src/components/block-icon/content.scss +0 -6
- package/src/components/block-icon/style.scss +0 -6
- package/src/components/block-icon/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +6 -2
- package/src/components/block-inspector/index.jsx +3 -11
- package/src/components/block-list/content.scss +4 -1
- package/src/components/block-list/use-block-props/use-is-hovered.js +24 -5
- package/src/components/block-manager/style.scss +2 -0
- package/src/components/block-mover/test/mover-description.js +1 -0
- package/src/components/block-preview/index.jsx +1 -2
- package/src/components/block-preview/test/{index.jsx → index.jsdom.test.jsx} +10 -6
- package/src/components/block-selection-clearer/test/{index.jsx → index.jsdom.test.jsx} +24 -19
- package/src/components/block-settings-menu/test/{block-mode-toggle.jsx → block-mode-toggle.jsdom.test.jsx} +5 -1
- package/src/components/block-styles/test/utils.js +1 -0
- package/src/components/block-switcher/index.jsx +3 -3
- package/src/components/block-switcher/test/{index.jsx → index.jsdom.test.jsx} +8 -4
- package/src/components/block-switcher/test/use-transformed.patterns.js +1 -0
- package/src/components/block-switcher/test/utils.js +1 -0
- package/src/components/block-title/test/{index.jsx → index.jsdom.test.jsx} +7 -3
- package/src/components/block-toolbar/pattern-overrides-dropdown.jsx +3 -6
- package/src/components/block-toolbar/style.scss +1 -1
- package/src/components/block-toolbar/test/{block-toolbar-icon.jsx → block-toolbar-icon.jsdom.test.jsx} +25 -21
- package/src/components/block-variation-picker/content.scss +5 -3
- package/src/components/block-vertical-alignment-control/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +55 -11
- package/src/components/block-vertical-alignment-control/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/block-visibility/test/{use-block-visibility.js → use-block-visibility.jsdom.test.js} +6 -5
- package/src/components/block-visibility/test/utils.js +2 -1
- package/src/components/border-radius-control/test/{index.jsx → index.jsdom.test.jsx} +8 -1
- package/src/components/border-radius-control/test/utils.js +1 -0
- package/src/components/button-block-appender/content.scss +1 -1
- package/src/components/child-layout-control/test/{index.jsx → index.jsdom.test.jsx} +18 -15
- package/src/components/color-palette/test/{control.jsx → control.jsdom.test.jsx} +15 -4
- package/src/components/colors/test/utils.js +1 -0
- package/src/components/colors/test/{with-colors.jsx → with-colors.jsdom.test.jsx} +4 -3
- package/src/components/colors-gradients/test/{control.jsx → control.jsdom.test.jsx} +8 -3
- package/src/components/contrast-checker/test/{index.jsx → index.jsdom.test.jsx} +2 -1
- package/src/components/default-block-appender/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +4 -4
- package/src/components/default-block-appender/test/{index.jsx → index.jsdom.test.jsx} +8 -7
- package/src/components/dimensions-tool/test/{index.jsx → index.jsdom.test.jsx} +27 -22
- package/src/components/dimensions-tool/test/utils.js +1 -0
- package/src/components/duotone-control/test/{index.jsx → index.jsdom.test.jsx} +6 -3
- package/src/components/font-sizes/test/fluid-utils.js +1 -0
- package/src/components/font-sizes/test/utils.js +1 -0
- package/src/components/global-styles/border-panel.jsx +17 -40
- package/src/components/global-styles/image-settings-panel.jsx +1 -1
- package/src/components/global-styles/inheritance/test/{index.jsx → index.jsdom.test.jsx} +5 -2
- package/src/components/global-styles/test/{background-panel.jsx → background-panel.jsdom.test.jsx} +10 -5
- package/src/components/global-styles/test/{border-panel.jsx → border-panel.jsdom.test.jsx} +113 -13
- package/src/components/global-styles/test/{color-panel.jsx → color-panel.jsdom.test.jsx} +5 -0
- package/src/components/global-styles/test/{dimensions-panel.jsx → dimensions-panel.jsdom.test.jsx} +14 -14
- package/src/components/global-styles/test/{filters-panel.jsx → filters-panel.jsdom.test.jsx} +7 -4
- package/src/components/global-styles/test/{inherited-value-context-core.js → inherited-value-context-core.jsdom.test.js} +10 -9
- package/src/components/global-styles/test/{inherited-value-context.jsx → inherited-value-context.jsdom.test.jsx} +18 -17
- package/src/components/global-styles/test/{state-control-badges.jsx → state-control-badges.jsdom.test.jsx} +3 -2
- package/src/components/global-styles/test/{typography-panel-core.jsx → typography-panel-core.jsdom.test.jsx} +5 -2
- package/src/components/global-styles/test/{typography-panel.jsx → typography-panel.jsdom.test.jsx} +17 -12
- package/src/components/global-styles/test/typography-utils.js +1 -0
- package/src/components/global-styles/test/utils.js +1 -0
- package/src/components/grid/style.scss +0 -10
- package/src/components/iframe/index.jsx +3 -3
- package/src/components/image-editor/test/index.js +1 -0
- package/src/components/image-size-control/test/{index.jsx → index.jsdom.test.jsx} +8 -3
- package/src/components/inner-blocks/test/__snapshots__/index.jsdom.test.jsx.snap +15 -0
- package/src/components/inner-blocks/test/{index.jsx → index.jsdom.test.jsx} +2 -0
- package/src/components/inner-content/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/inserter/hooks/use-patterns-paging.js +1 -1
- package/src/components/inserter/media-tab/test/{hooks.js → hooks.jsdom.test.js} +12 -11
- package/src/components/inserter/media-tab/test/{media-panel.jsx → media-panel.jsdom.test.jsx} +15 -12
- package/src/components/inserter/style.scss +2 -2
- package/src/components/inserter/test/get-appender-label.js +12 -11
- package/src/components/inserter/test/search-items.js +1 -0
- package/src/components/inserter-draggable-blocks/index.jsx +1 -1
- package/src/components/inserter-list-item/style.scss +1 -0
- package/src/components/inspector-controls-tabs/content-tab.jsx +7 -14
- package/src/components/inspector-controls-tabs/styles-tab.jsx +1 -4
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +1 -8
- package/src/components/inspector-popover-header/index.jsx +6 -7
- package/src/components/line-height-control/test/{index.jsx → index.jsdom.test.jsx} +3 -0
- package/src/components/link-control/index.jsx +3 -0
- package/src/components/link-control/search-input.jsx +1 -1
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/{index.jsx → index.jsdom.test.jsx} +52 -42
- package/src/components/link-control/test/is-url-like.js +1 -0
- package/src/components/link-control/test/{url-normalization.test.jsx → url-normalization.jsdom.test.jsx} +21 -20
- package/src/components/link-picker/test/{index.jsx → index.jsdom.test.jsx} +31 -30
- package/src/components/list-view/block-select-button.jsx +6 -1
- package/src/components/list-view/block.jsx +6 -4
- package/src/components/list-view/style.scss +55 -35
- package/src/components/list-view/test/use-list-view-drop-zone.js +1 -0
- package/src/components/list-view/test/utils.js +1 -0
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/media-placeholder/test/get-computed-accept-attribute.js +1 -0
- package/src/components/media-placeholder/test/{index.jsx → index.jsdom.test.jsx} +8 -2
- package/src/components/media-replace-flow/index.jsx +6 -1
- package/src/components/media-replace-flow/test/{index.jsx → index.jsdom.test.jsx} +3 -0
- package/src/components/navigable-toolbar/index.jsx +4 -0
- package/src/components/navigable-toolbar/test/index.browser.test.js +50 -0
- package/src/components/panel-color-settings/test/{index.jsx → index.jsdom.test.jsx} +3 -0
- package/src/components/preset-input-control/test/{index.jsx → index.jsdom.test.jsx} +8 -2
- package/src/components/preset-input-control/test/utils.js +1 -0
- package/src/components/provider/test/{experimental-provider.jsx → experimental-provider.jsdom.test.jsx} +3 -2
- package/src/components/provider/test/{use-block-sync.jsx → use-block-sync.jsdom.test.jsx} +45 -44
- package/src/components/recursion-provider/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/responsive-block-control/style.scss +1 -0
- package/src/components/responsive-block-control/test/{index.jsx → index.jsdom.test.jsx} +6 -3
- package/src/components/rich-text/event-listeners/enter.js +29 -14
- package/src/components/rich-text/event-listeners/index.js +0 -2
- package/src/components/rich-text/event-listeners/input-rules.js +7 -2
- package/src/components/spacing-sizes-control/test/{index.jsx → index.jsdom.test.jsx} +23 -20
- package/src/components/spacing-sizes-control/test/utils.js +1 -0
- package/src/components/url-input/test/{button.jsx → button.jsdom.test.jsx} +4 -1
- package/src/components/url-input/test/fixtures/validated-input-control-deprecation.js +2 -0
- package/src/components/url-input/test/{index.jsx → index.jsdom.test.jsx} +23 -13
- package/src/components/use-block-display-information/test/{index.jsx → index.jsdom.test.jsx} +14 -10
- package/src/components/use-block-drop-zone/index.js +2 -2
- package/src/components/use-block-drop-zone/test/index.js +1 -0
- package/src/components/use-on-block-drop/test/index.js +28 -31
- package/src/components/warning/test/__snapshots__/{index.jsx.snap → index.jsdom.test.jsx.snap} +2 -2
- package/src/components/warning/test/{index.jsx → index.jsdom.test.jsx} +1 -0
- package/src/components/writing-flow/index.jsx +5 -0
- package/src/components/writing-flow/style.scss +48 -0
- package/src/components/writing-flow/test/{index.js → index.jsdom.test.js} +1 -0
- package/src/components/writing-flow/use-arrow-nav.js +2 -2
- package/src/components/writing-flow/use-input.js +29 -2
- package/src/components/writing-flow/use-tab-nav.jsx +155 -70
- package/src/components/writing-flow/use-undo-automatic-change.js +40 -0
- package/src/elements/test/{index.js → index.jsdom.test.js} +1 -0
- package/src/hooks/border.jsx +0 -53
- package/src/hooks/generate-fields-from-attributes.js +1 -1
- package/src/hooks/index.js +0 -2
- package/src/hooks/style.jsx +3 -2
- package/src/hooks/test/{align.jsx → align.jsdom.test.jsx} +1 -0
- package/src/hooks/test/allowed-blocks.js +1 -0
- package/src/hooks/test/{anchor.js → anchor.jsdom.test.js} +1 -0
- package/src/hooks/test/{auto-inspector-controls.js → auto-inspector-controls.jsdom.test.js} +1 -0
- package/src/hooks/test/{background.jsx → background.jsdom.test.jsx} +5 -2
- package/src/hooks/test/{block-style-state.js → block-style-state.jsdom.test.js} +4 -3
- package/src/hooks/test/{cross-origin-isolation.js → cross-origin-isolation.jsdom.test.js} +18 -25
- package/src/hooks/test/{custom-class-name.jsx → custom-class-name.jsdom.test.jsx} +1 -0
- package/src/hooks/test/{dimensions.js → dimensions.jsdom.test.js} +1 -0
- package/src/hooks/test/{duotone.js → duotone.jsdom.test.js} +1 -0
- package/src/hooks/test/{font-size.js → font-size.jsdom.test.js} +1 -0
- package/src/hooks/test/gap.js +1 -0
- package/src/hooks/test/generate-fields-from-attributes.js +1 -0
- package/src/hooks/test/generated-class-name.js +1 -0
- package/src/hooks/test/{inherited-value-wiring.jsx → inherited-value-wiring.jsdom.test.jsx} +49 -51
- package/src/hooks/test/{layout-child.js → layout-child.jsdom.test.js} +1 -0
- package/src/hooks/test/{layout.js → layout.jsdom.test.js} +1 -0
- package/src/hooks/test/metadata.js +1 -0
- package/src/hooks/test/preset-round-trip.js +2 -0
- package/src/hooks/test/settings.jsx +1 -0
- package/src/hooks/test/state-utils.js +1 -0
- package/src/hooks/test/{style.jsx → style.jsdom.test.jsx} +1 -0
- package/src/hooks/test/{text-align.jsx → text-align.jsdom.test.jsx} +1 -0
- package/src/hooks/test/{use-typography-props.js → use-typography-props.jsdom.test.js} +1 -0
- package/src/hooks/test/{utils.js → utils.jsdom.test.js} +1 -0
- package/src/layouts/flex.jsx +7 -0
- package/src/layouts/test/{constrained.jsx → constrained.jsdom.test.jsx} +6 -3
- package/src/layouts/test/{flex.jsx → flex.jsdom.test.jsx} +52 -2
- package/src/layouts/test/{flow.js → flow.jsdom.test.js} +1 -0
- package/src/layouts/test/{grid.jsx → grid.jsdom.test.jsx} +5 -2
- package/src/layouts/test/utils.js +1 -0
- package/src/store/actions.js +14 -12
- package/src/store/test/{actions.js → actions.jsdom.test.js} +50 -49
- package/src/store/test/array.js +1 -0
- package/src/store/test/get-block-settings.js +1 -0
- package/src/store/test/performance.js +2 -1
- package/src/store/test/private-actions.js +1 -0
- package/src/store/test/private-selectors.js +13 -3
- package/src/store/test/reducer.js +37 -8
- package/src/store/test/{registry-selectors.js → registry-selectors.jsdom.test.js} +9 -0
- package/src/store/test/{selectors.jsx → selectors.jsdom.test.jsx} +13 -3
- package/src/style.scss +1 -1
- package/src/utils/test/block-bindings.js +1 -0
- package/src/utils/test/color-values.js +1 -0
- package/src/utils/test/{dom.jsx → dom.jsdom.test.jsx} +38 -43
- package/src/utils/test/format-font-style.js +1 -0
- package/src/utils/test/format-font-weight.js +1 -0
- package/src/utils/test/get-font-styles-and-weights.js +1 -0
- package/src/utils/test/math.js +1 -0
- package/src/utils/test/object.js +1 -0
- package/src/utils/test/pasting.js +1 -0
- package/src/utils/test/selection.js +1 -0
- package/src/utils/test/sorting.js +1 -0
- package/src/utils/test/transform-styles.js +2 -1
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +0 -7
- package/build/hooks/block-fields/fields-dropdown-menu.cjs +0 -67
- package/build/hooks/block-fields/fields-dropdown-menu.cjs.map +0 -7
- package/build/hooks/block-fields/index.cjs +0 -238
- package/build/hooks/block-fields/index.cjs.map +0 -7
- package/build/hooks/block-fields/link/index.cjs +0 -174
- package/build/hooks/block-fields/link/index.cjs.map +0 -7
- package/build/hooks/block-fields/media/index.cjs +0 -262
- package/build/hooks/block-fields/media/index.cjs.map +0 -7
- package/build/hooks/block-fields/rich-text/index.cjs +0 -146
- package/build/hooks/block-fields/rich-text/index.cjs.map +0 -7
- package/build/hooks/block-fields/use-inspector-popover-placement.cjs +0 -41
- package/build/hooks/block-fields/use-inspector-popover-placement.cjs.map +0 -7
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +0 -33
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +0 -7
- package/build-module/hooks/block-fields/fields-dropdown-menu.mjs +0 -46
- package/build-module/hooks/block-fields/fields-dropdown-menu.mjs.map +0 -7
- package/build-module/hooks/block-fields/index.mjs +0 -210
- package/build-module/hooks/block-fields/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/link/index.mjs +0 -141
- package/build-module/hooks/block-fields/link/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/media/index.mjs +0 -241
- package/build-module/hooks/block-fields/media/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/rich-text/index.mjs +0 -115
- package/build-module/hooks/block-fields/rich-text/index.mjs.map +0 -7
- package/build-module/hooks/block-fields/use-inspector-popover-placement.mjs +0 -16
- package/build-module/hooks/block-fields/use-inspector-popover-placement.mjs.map +0 -7
- package/src/components/color-palette/test/__snapshots__/control.jsx.snap +0 -143
- package/src/components/inner-blocks/test/__snapshots__/index.jsx.snap +0 -15
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +0 -39
- package/src/hooks/block-fields/fields-dropdown-menu.jsx +0 -47
- package/src/hooks/block-fields/index.jsx +0 -302
- package/src/hooks/block-fields/link/index.jsx +0 -155
- package/src/hooks/block-fields/link/styles.scss +0 -18
- package/src/hooks/block-fields/media/index.jsx +0 -269
- package/src/hooks/block-fields/media/styles.scss +0 -77
- package/src/hooks/block-fields/rich-text/index.jsx +0 -123
- package/src/hooks/block-fields/rich-text/styles.scss +0 -24
- package/src/hooks/block-fields/styles.scss +0 -33
- package/src/hooks/block-fields/use-inspector-popover-placement.js +0 -16
- /package/src/components/block-icon/test/{index.jsx → index.jsdom.test.jsx} +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/colors" as *;
|
|
2
|
+
@use "@wordpress/base-styles/variables" as *;
|
|
3
|
+
|
|
4
|
+
/* The stop element is invisible, so its focus indication is drawn around the
|
|
5
|
+
canvas it stands for. For the iframed canvas it is an overlay instead of
|
|
6
|
+
an outline, because Safari paints an outline on an iframe element
|
|
7
|
+
underneath the iframe's content. */
|
|
8
|
+
.block-editor-iframe__scale-container > .block-editor-writing-flow__canvas-stop:focus::after {
|
|
9
|
+
content: "";
|
|
10
|
+
position: absolute;
|
|
11
|
+
inset: 0;
|
|
12
|
+
z-index: 1;
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
border: var(--wp-admin-border-width-focus) solid var(--wp-admin-theme-color);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.block-editor-writing-flow__canvas-stop:focus + .block-editor-writing-flow {
|
|
18
|
+
outline: var(--wp-admin-border-width-focus) solid var(--wp-admin-theme-color);
|
|
19
|
+
outline-offset: calc(-1 * var(--wp-admin-border-width-focus));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Looks like a tooltip. Shown at the top of the canvas while the stop is
|
|
23
|
+
focused. Sticky, because on the widgets screen the stop spans scrolling
|
|
24
|
+
content and the hint must stay in view; anywhere else there is nothing
|
|
25
|
+
to scroll and it stays at the top of the canvas. */
|
|
26
|
+
.block-editor-writing-flow__canvas-stop-hint {
|
|
27
|
+
display: none;
|
|
28
|
+
position: sticky;
|
|
29
|
+
top: $grid-unit-20;
|
|
30
|
+
margin-inline: auto;
|
|
31
|
+
width: fit-content;
|
|
32
|
+
z-index: 2;
|
|
33
|
+
background: $black;
|
|
34
|
+
font-family: $default-font;
|
|
35
|
+
border-radius: $radius-medium;
|
|
36
|
+
color: $gray-100;
|
|
37
|
+
text-align: center;
|
|
38
|
+
line-height: 1.4;
|
|
39
|
+
font-size: 12px;
|
|
40
|
+
padding: $grid-unit-05 $grid-unit-10;
|
|
41
|
+
box-shadow: $elevation-small;
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
pointer-events: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.block-editor-writing-flow__canvas-stop:focus > .block-editor-writing-flow__canvas-stop-hint {
|
|
47
|
+
display: block;
|
|
48
|
+
}
|
|
@@ -327,9 +327,9 @@ export default function useArrowNav() {
|
|
|
327
327
|
return;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
// When
|
|
330
|
+
// When pressing any key other than up or down, the initial vertical
|
|
331
331
|
// position must ALWAYS be reset. The vertical position is saved so
|
|
332
|
-
// it can be restored as well as possible on
|
|
332
|
+
// it can be restored as well as possible on subsequent vertical
|
|
333
333
|
// arrow key presses. It may not always be possible to restore the
|
|
334
334
|
// exact same position (such as at an empty line), so it wouldn't be
|
|
335
335
|
// good to compute the position right before any vertical arrow key
|
|
@@ -47,6 +47,20 @@ export default function useInput() {
|
|
|
47
47
|
|
|
48
48
|
return useRefEffect( ( node ) => {
|
|
49
49
|
function onBeforeInput( event ) {
|
|
50
|
+
// Enter in an editable is handled here instead of on keydown:
|
|
51
|
+
// moving focus while the keydown is still being handled leaves
|
|
52
|
+
// the iOS keyboard's auto-capitalization stale.
|
|
53
|
+
if (
|
|
54
|
+
event.inputType === 'insertParagraph' &&
|
|
55
|
+
! event.defaultPrevented &&
|
|
56
|
+
! hasMultiSelection()
|
|
57
|
+
) {
|
|
58
|
+
onKeyDown( event );
|
|
59
|
+
if ( event.defaultPrevented ) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
50
64
|
// If writing flow is editable, never allow the browser to alter
|
|
51
65
|
// the DOM outside of an editable element within a block. This
|
|
52
66
|
// will cause React errors (and the DOM should only be altered in
|
|
@@ -76,12 +90,25 @@ export default function useInput() {
|
|
|
76
90
|
}
|
|
77
91
|
|
|
78
92
|
if ( ! hasMultiSelection() ) {
|
|
79
|
-
if (
|
|
80
|
-
|
|
93
|
+
if (
|
|
94
|
+
event.keyCode === ENTER ||
|
|
95
|
+
event.inputType === 'insertParagraph'
|
|
96
|
+
) {
|
|
97
|
+
if (
|
|
98
|
+
event.shiftKey ||
|
|
99
|
+
// Editables are handled on beforeinput.
|
|
100
|
+
( event.type === 'keydown' &&
|
|
101
|
+
event.target.ownerDocument.activeElement
|
|
102
|
+
.isContentEditable )
|
|
103
|
+
) {
|
|
81
104
|
return;
|
|
82
105
|
}
|
|
83
106
|
|
|
84
107
|
const clientId = getSelectedBlockClientId();
|
|
108
|
+
if ( ! clientId ) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
85
112
|
const blockName = getBlockName( clientId );
|
|
86
113
|
const selectionStart = getSelectionStart();
|
|
87
114
|
const selectionEnd = getSelectionEnd();
|
|
@@ -1,16 +1,37 @@
|
|
|
1
1
|
import { focus, isFormElement } from '@wordpress/dom';
|
|
2
|
-
import { TAB } from '@wordpress/keycodes';
|
|
2
|
+
import { TAB, withIgnoreIMEEvents } from '@wordpress/keycodes';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
3
4
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
4
|
-
import { useRefEffect, useMergeRefs } from '@wordpress/compose';
|
|
5
|
+
import { useRefEffect, useMergeRefs, useInstanceId } from '@wordpress/compose';
|
|
5
6
|
import { useRef } from '@wordpress/element';
|
|
6
7
|
import { store as blockEditorStore } from '../../store';
|
|
7
8
|
import { isInSameBlock, isInsideRootBlock } from '../../utils/dom';
|
|
8
9
|
import { unlock } from '../../lock-unlock';
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Spans the element over the canvas, so it is always at least partially in
|
|
13
|
+
* view and focussing it never scrolls the content. Fixed positioning would
|
|
14
|
+
* achieve that too, but makes Safari composite the scrollable canvas on a
|
|
15
|
+
* layer sized to the whole document instead of the visible pane.
|
|
16
|
+
*/
|
|
17
|
+
const PREVENT_SCROLL_ON_FOCUS = {
|
|
18
|
+
position: 'absolute',
|
|
19
|
+
inset: 0,
|
|
20
|
+
pointerEvents: 'none',
|
|
21
|
+
outline: 'none',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Keys that move focus from the canvas stop into the canvas.
|
|
25
|
+
const ENTRY_KEYS = [ 'Enter', ' ', 'F2', 'Escape' ];
|
|
26
|
+
|
|
10
27
|
export default function useTabNav() {
|
|
11
28
|
const containerRef = /** @type {typeof useRef<HTMLElement>} */ ( useRef )();
|
|
12
29
|
const focusCaptureBeforeRef = useRef();
|
|
13
30
|
const focusCaptureAfterRef = useRef();
|
|
31
|
+
const hintId = useInstanceId(
|
|
32
|
+
useTabNav,
|
|
33
|
+
'block-editor-writing-flow__canvas-stop-hint'
|
|
34
|
+
);
|
|
14
35
|
|
|
15
36
|
const {
|
|
16
37
|
hasMultiSelection,
|
|
@@ -19,6 +40,7 @@ export default function useTabNav() {
|
|
|
19
40
|
getBlockOrder,
|
|
20
41
|
getLastFocus,
|
|
21
42
|
getSectionRootClientId,
|
|
43
|
+
getEditedContentOnlySection,
|
|
22
44
|
isZoomOut,
|
|
23
45
|
} = unlock( useSelect( blockEditorStore ) );
|
|
24
46
|
const { setLastFocus } = unlock( useDispatch( blockEditorStore ) );
|
|
@@ -27,16 +49,17 @@ export default function useTabNav() {
|
|
|
27
49
|
// capturing on the focus capture elements.
|
|
28
50
|
const noCaptureRef = useRef();
|
|
29
51
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
// The canvas is a single stop in the page's tab order, and going in is
|
|
53
|
+
// an explicit action on it. Focus returns to the place it last left the
|
|
54
|
+
// canvas from.
|
|
55
|
+
function enterCanvas() {
|
|
56
|
+
// Focus the canvas window first. The stop is in the parent document,
|
|
57
|
+
// and when Firefox focuses an element in another document, it does
|
|
58
|
+
// not move window focus, so the caret would be restored but key
|
|
59
|
+
// presses would keep going to the parent page.
|
|
60
|
+
containerRef.current.ownerDocument.defaultView.focus();
|
|
35
61
|
|
|
36
|
-
|
|
37
|
-
if ( noCaptureRef.current ) {
|
|
38
|
-
noCaptureRef.current = null;
|
|
39
|
-
} else if ( hasMultiSelection() ) {
|
|
62
|
+
if ( hasMultiSelection() ) {
|
|
40
63
|
containerRef.current.focus();
|
|
41
64
|
} else if ( getSelectedBlockClientId() ) {
|
|
42
65
|
if ( getLastFocus()?.current ) {
|
|
@@ -68,36 +91,107 @@ export default function useTabNav() {
|
|
|
68
91
|
.focus();
|
|
69
92
|
} else {
|
|
70
93
|
// If we don't have any section root, focus the canvas.
|
|
71
|
-
|
|
94
|
+
containerRef.current.focus();
|
|
72
95
|
}
|
|
73
96
|
} else {
|
|
74
|
-
const isBefore =
|
|
75
|
-
// eslint-disable-next-line no-bitwise
|
|
76
|
-
event.target.compareDocumentPosition( canvasElement ) &
|
|
77
|
-
event.target.DOCUMENT_POSITION_FOLLOWING;
|
|
78
97
|
const tabbables = focus.tabbable.find( containerRef.current );
|
|
79
98
|
if ( tabbables.length ) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
tabbables[ 0 ].focus();
|
|
100
|
+
} else {
|
|
101
|
+
// Nothing in the canvas is tabbable. Entering still enters:
|
|
102
|
+
// keys go to the canvas, and a block can be selected with
|
|
103
|
+
// the arrow keys or a click.
|
|
104
|
+
containerRef.current.focus();
|
|
84
105
|
}
|
|
85
106
|
}
|
|
86
107
|
}
|
|
87
108
|
|
|
109
|
+
function onStopKeyDown( event ) {
|
|
110
|
+
if (
|
|
111
|
+
event.defaultPrevented ||
|
|
112
|
+
event.ctrlKey ||
|
|
113
|
+
event.metaKey ||
|
|
114
|
+
event.altKey
|
|
115
|
+
) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const { key } = event;
|
|
120
|
+
|
|
121
|
+
if ( ! event.shiftKey && ENTRY_KEYS.includes( key ) ) {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
enterCanvas();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Shift+Tab leaves the canvas on its own, because the stop is the
|
|
128
|
+
// first element before it. Plain Tab would move into the content,
|
|
129
|
+
// so move focus to the first tabbable element past the canvas.
|
|
130
|
+
if ( key === 'Tab' && ! event.shiftKey ) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
focus.tabbable.findNext( focusCaptureAfterRef.current )?.focus();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Focus arriving on the stop engages the canvas right away, like a
|
|
137
|
+
// text field that starts editing when focused. Only Escape parks
|
|
138
|
+
// focus on the stop, giving Tab traction again: from a parked stop,
|
|
139
|
+
// Tab moves to the interface around the canvas, not the content.
|
|
140
|
+
function onStopFocus() {
|
|
141
|
+
if ( noCaptureRef.current ) {
|
|
142
|
+
noCaptureRef.current = null;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
enterCanvas();
|
|
146
|
+
}
|
|
147
|
+
|
|
88
148
|
const before = (
|
|
89
149
|
<div
|
|
90
150
|
ref={ focusCaptureBeforeRef }
|
|
91
151
|
tabIndex="0"
|
|
92
|
-
|
|
93
|
-
|
|
152
|
+
role="button"
|
|
153
|
+
aria-label={ __( 'Editor canvas' ) }
|
|
154
|
+
aria-describedby={ hintId }
|
|
155
|
+
className="block-editor-writing-flow__canvas-stop"
|
|
156
|
+
style={ PREVENT_SCROLL_ON_FOCUS }
|
|
157
|
+
onFocus={ onStopFocus }
|
|
158
|
+
onKeyDown={ onStopKeyDown }
|
|
159
|
+
// Assistive technology activates a button with a click event,
|
|
160
|
+
// not a key press. Pointer clicks pass through the element, so
|
|
161
|
+
// a click can only come from such an activation.
|
|
162
|
+
onClick={ enterCanvas }
|
|
163
|
+
>
|
|
164
|
+
{ /* The hint is also the button's description for assistive
|
|
165
|
+
technology. Content hidden with `display: none` still
|
|
166
|
+
works for `aria-describedby`. */ }
|
|
167
|
+
<div
|
|
168
|
+
className="block-editor-writing-flow__canvas-stop-hint"
|
|
169
|
+
id={ hintId }
|
|
170
|
+
>
|
|
171
|
+
{ __( 'Press Enter to edit the document' ) }
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
94
174
|
);
|
|
95
175
|
|
|
176
|
+
// Focus landing on the element after the canvas enters it, the same
|
|
177
|
+
// as focus landing on the stop before it.
|
|
178
|
+
function onFocusCapture() {
|
|
179
|
+
// Do not act on focus set by the tab handler below, which moves
|
|
180
|
+
// focus here so that the default behaviour (moving focus to the
|
|
181
|
+
// next tabbable element) continues from this element.
|
|
182
|
+
if ( noCaptureRef.current ) {
|
|
183
|
+
noCaptureRef.current = null;
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
enterCanvas();
|
|
187
|
+
}
|
|
188
|
+
|
|
96
189
|
const after = (
|
|
97
190
|
<div
|
|
98
191
|
ref={ focusCaptureAfterRef }
|
|
99
192
|
tabIndex="0"
|
|
100
193
|
onFocus={ onFocusCapture }
|
|
194
|
+
style={ PREVENT_SCROLL_ON_FOCUS }
|
|
101
195
|
/>
|
|
102
196
|
);
|
|
103
197
|
|
|
@@ -107,12 +201,39 @@ export default function useTabNav() {
|
|
|
107
201
|
return;
|
|
108
202
|
}
|
|
109
203
|
|
|
204
|
+
// Escape steps out of the canvas onto its stop. Everything with
|
|
205
|
+
// a stronger claim on the key runs first: handlers deeper in
|
|
206
|
+
// the tree, capture handlers, and listeners registered earlier
|
|
207
|
+
// on this node, like the automatic change undo. If the key is
|
|
208
|
+
// still unclaimed here, nothing else wants it.
|
|
209
|
+
if (
|
|
210
|
+
event.key === 'Escape' &&
|
|
211
|
+
! event.shiftKey &&
|
|
212
|
+
! event.ctrlKey &&
|
|
213
|
+
! event.metaKey &&
|
|
214
|
+
! event.altKey
|
|
215
|
+
) {
|
|
216
|
+
// While a content-only section is being edited, Escape first
|
|
217
|
+
// stops editing it. That handler lives in the parent
|
|
218
|
+
// document and runs after this one, so leave the key to it.
|
|
219
|
+
if ( getEditedContentOnlySection() ) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if ( focusCaptureBeforeRef.current ) {
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
// Park on the stop instead of engaging the canvas,
|
|
225
|
+
// which is what focus arriving on it normally does.
|
|
226
|
+
noCaptureRef.current = true;
|
|
227
|
+
focusCaptureBeforeRef.current.focus();
|
|
228
|
+
}
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
110
232
|
// In Edit mode, Tab should focus the first tabbable element after
|
|
111
233
|
// the content, which is normally the sidebar (with block controls)
|
|
112
234
|
// and Shift+Tab should focus the first tabbable element before the
|
|
113
235
|
// content, which is normally the block toolbar.
|
|
114
|
-
// Arrow keys can be used
|
|
115
|
-
// Navigation mode (press Esc), to navigate through blocks.
|
|
236
|
+
// Arrow keys can be used to navigate through blocks.
|
|
116
237
|
if ( event.keyCode !== TAB ) {
|
|
117
238
|
return;
|
|
118
239
|
}
|
|
@@ -155,17 +276,15 @@ export default function useTabNav() {
|
|
|
155
276
|
) {
|
|
156
277
|
return;
|
|
157
278
|
}
|
|
279
|
+
|
|
158
280
|
const next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;
|
|
159
281
|
|
|
160
|
-
// Disable focus
|
|
161
|
-
//
|
|
162
|
-
//
|
|
282
|
+
// Disable the focus forwarding on the focus capture element, so
|
|
283
|
+
// it allows default behaviour (moving focus to the next tabbable
|
|
284
|
+
// element).
|
|
163
285
|
noCaptureRef.current = true;
|
|
164
286
|
|
|
165
|
-
|
|
166
|
-
// below the editor, should not scroll the page all the way up or
|
|
167
|
-
// down.
|
|
168
|
-
next.current.focus( { preventScroll: true } );
|
|
287
|
+
next.current.focus();
|
|
169
288
|
}
|
|
170
289
|
|
|
171
290
|
function onFocusOut( event ) {
|
|
@@ -191,48 +310,14 @@ export default function useTabNav() {
|
|
|
191
310
|
}
|
|
192
311
|
}
|
|
193
312
|
|
|
194
|
-
//
|
|
195
|
-
//
|
|
196
|
-
|
|
197
|
-
// top or bottom of the document.
|
|
198
|
-
//
|
|
199
|
-
// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this
|
|
200
|
-
// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.
|
|
201
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters
|
|
202
|
-
function preventScrollOnTab( event ) {
|
|
203
|
-
if ( event.keyCode !== TAB ) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if ( event.target?.getAttribute( 'role' ) === 'region' ) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if ( containerRef.current === event.target ) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const isShift = event.shiftKey;
|
|
216
|
-
const direction = isShift ? 'findPrevious' : 'findNext';
|
|
217
|
-
const target = focus.tabbable[ direction ]( event.target );
|
|
218
|
-
// Only do something when the next tabbable is a focus capture div (before/after)
|
|
219
|
-
if (
|
|
220
|
-
target === focusCaptureBeforeRef.current ||
|
|
221
|
-
target === focusCaptureAfterRef.current
|
|
222
|
-
) {
|
|
223
|
-
event.preventDefault();
|
|
224
|
-
target.focus( { preventScroll: true } );
|
|
225
|
-
}
|
|
226
|
-
}
|
|
313
|
+
// During an IME composition, Escape and Tab control the input
|
|
314
|
+
// method, not the editor.
|
|
315
|
+
const onKeyDownOutsideIME = withIgnoreIMEEvents( onKeyDown );
|
|
227
316
|
|
|
228
|
-
|
|
229
|
-
const { defaultView } = ownerDocument;
|
|
230
|
-
defaultView.addEventListener( 'keydown', preventScrollOnTab );
|
|
231
|
-
node.addEventListener( 'keydown', onKeyDown );
|
|
317
|
+
node.addEventListener( 'keydown', onKeyDownOutsideIME );
|
|
232
318
|
node.addEventListener( 'focusout', onFocusOut );
|
|
233
319
|
return () => {
|
|
234
|
-
|
|
235
|
-
node.removeEventListener( 'keydown', onKeyDown );
|
|
320
|
+
node.removeEventListener( 'keydown', onKeyDownOutsideIME );
|
|
236
321
|
node.removeEventListener( 'focusout', onFocusOut );
|
|
237
322
|
};
|
|
238
323
|
}, [] );
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BACKSPACE, ESCAPE } from '@wordpress/keycodes';
|
|
2
|
+
import { useSelect } from '@wordpress/data';
|
|
3
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
4
|
+
import { store as blockEditorStore } from '../../store';
|
|
5
|
+
|
|
6
|
+
export default function useUndoAutomaticChange() {
|
|
7
|
+
const { didAutomaticChange, getSettings } = useSelect( blockEditorStore );
|
|
8
|
+
|
|
9
|
+
function onKeyDown( event ) {
|
|
10
|
+
const { keyCode } = event;
|
|
11
|
+
|
|
12
|
+
if ( event.defaultPrevented ) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if ( keyCode !== BACKSPACE && keyCode !== ESCAPE ) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { __experimentalUndo } = getSettings();
|
|
21
|
+
|
|
22
|
+
if ( ! __experimentalUndo ) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if ( ! didAutomaticChange() ) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
__experimentalUndo();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return useRefEffect( ( element ) => {
|
|
35
|
+
element.addEventListener( 'keydown', onKeyDown );
|
|
36
|
+
return () => {
|
|
37
|
+
element.removeEventListener( 'keydown', onKeyDown );
|
|
38
|
+
};
|
|
39
|
+
}, [] );
|
|
40
|
+
}
|
package/src/hooks/border.jsx
CHANGED
|
@@ -4,14 +4,12 @@ import { __experimentalHasSplitBorders as hasSplitBorders } from '@wordpress/com
|
|
|
4
4
|
import { useCallback, useMemo } from '@wordpress/element';
|
|
5
5
|
import { addFilter } from '@wordpress/hooks';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
7
|
import { getColorClassName } from '../components/colors';
|
|
9
8
|
import InspectorControls from '../components/inspector-controls';
|
|
10
9
|
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
11
10
|
import { cleanEmptyObject, shouldSkipSerialization } from './utils';
|
|
12
11
|
import {
|
|
13
12
|
useHasBorderPanel,
|
|
14
|
-
useHasBorderPanelControls,
|
|
15
13
|
BorderPanel as StylesBorderPanel,
|
|
16
14
|
} from '../components/global-styles';
|
|
17
15
|
import { useResolvedStyle } from '../components/global-styles/inherited-value-context';
|
|
@@ -22,13 +20,10 @@ import {
|
|
|
22
20
|
setStyleForState,
|
|
23
21
|
useBlockStyleState,
|
|
24
22
|
} from './block-style-state';
|
|
25
|
-
import { unlock } from '../lock-unlock';
|
|
26
23
|
|
|
27
24
|
export const BORDER_SUPPORT_KEY = '__experimentalBorder';
|
|
28
25
|
export const SHADOW_SUPPORT_KEY = 'shadow';
|
|
29
26
|
|
|
30
|
-
const EMPTY_ARRAY = [];
|
|
31
|
-
|
|
32
27
|
const getColorByProperty = ( colors, property, value ) => {
|
|
33
28
|
let matchedColor;
|
|
34
29
|
|
|
@@ -249,54 +244,6 @@ export function hasShadowSupport( blockName ) {
|
|
|
249
244
|
return hasBlockSupport( blockName, SHADOW_SUPPORT_KEY );
|
|
250
245
|
}
|
|
251
246
|
|
|
252
|
-
export function useBorderPanelLabel( {
|
|
253
|
-
clientId,
|
|
254
|
-
hasBorderControl,
|
|
255
|
-
hasShadowControl,
|
|
256
|
-
} = {} ) {
|
|
257
|
-
const [ color, radius, style, width, shadow ] = useSelect(
|
|
258
|
-
( select ) => {
|
|
259
|
-
if ( ! clientId ) {
|
|
260
|
-
return EMPTY_ARRAY;
|
|
261
|
-
}
|
|
262
|
-
const { getBlockSettings } = unlock( select( blockEditorStore ) );
|
|
263
|
-
return getBlockSettings(
|
|
264
|
-
clientId,
|
|
265
|
-
'border.color',
|
|
266
|
-
'border.radius',
|
|
267
|
-
'border.style',
|
|
268
|
-
'border.width',
|
|
269
|
-
'shadow'
|
|
270
|
-
);
|
|
271
|
-
},
|
|
272
|
-
[ clientId ]
|
|
273
|
-
);
|
|
274
|
-
const settings = useMemo(
|
|
275
|
-
() => ( { border: { color, radius, style, width }, shadow } ),
|
|
276
|
-
[ color, radius, style, width, shadow ]
|
|
277
|
-
);
|
|
278
|
-
const controls = useHasBorderPanelControls( settings );
|
|
279
|
-
|
|
280
|
-
if ( ! hasBorderControl && ! hasShadowControl && clientId ) {
|
|
281
|
-
hasBorderControl =
|
|
282
|
-
controls?.hasBorderColor ||
|
|
283
|
-
controls?.hasBorderStyle ||
|
|
284
|
-
controls?.hasBorderWidth ||
|
|
285
|
-
controls?.hasBorderRadius;
|
|
286
|
-
hasShadowControl = controls?.hasShadow;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if ( hasBorderControl && hasShadowControl ) {
|
|
290
|
-
return __( 'Border & Shadow' );
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if ( hasShadowControl ) {
|
|
294
|
-
return __( 'Shadow' );
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
return __( 'Border' );
|
|
298
|
-
}
|
|
299
|
-
|
|
300
247
|
/**
|
|
301
248
|
* Returns a new style object where the specified border attribute has been
|
|
302
249
|
* removed.
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* See https://github.com/WordPress/wordpress-develop/blob/8f6d31266deecd7eea258bd3d45597355cce13d0/src/wp-includes/block-supports/auto-register.php#L30
|
|
11
11
|
*
|
|
12
12
|
* @param {Object} attributes - Block type attributes from block registration
|
|
13
|
-
* @return {{ fields: Array, form: Object }}
|
|
13
|
+
* @return {{ fields: Array, form: Object }} DataForm fields and form definitions
|
|
14
14
|
*/
|
|
15
15
|
export function generateFieldsFromAttributes( attributes ) {
|
|
16
16
|
const fields = [];
|
package/src/hooks/index.js
CHANGED
|
@@ -11,7 +11,6 @@ import './lock';
|
|
|
11
11
|
import allowedBlocks from './allowed-blocks';
|
|
12
12
|
import anchor from './anchor';
|
|
13
13
|
import ariaLabel from './aria-label';
|
|
14
|
-
import blockFields from './block-fields';
|
|
15
14
|
import customClassName from './custom-class-name';
|
|
16
15
|
import './generated-class-name';
|
|
17
16
|
import style from './style';
|
|
@@ -53,7 +52,6 @@ createBlockEditFilter(
|
|
|
53
52
|
blockBindingsPanel,
|
|
54
53
|
childLayout,
|
|
55
54
|
allowedBlocks,
|
|
56
|
-
blockFields,
|
|
57
55
|
listView,
|
|
58
56
|
AutoRegisterControls,
|
|
59
57
|
].filter( Boolean )
|
package/src/hooks/style.jsx
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
cleanEmptyObject,
|
|
37
37
|
shouldSkipSerialization,
|
|
38
38
|
useStyleOverride,
|
|
39
|
+
usePrivateStyleOverride,
|
|
39
40
|
useBlockSettings,
|
|
40
41
|
} from './utils';
|
|
41
42
|
import {
|
|
@@ -993,7 +994,7 @@ function getElementCSSRules( blockElementStyles, blockName, baseSelector ) {
|
|
|
993
994
|
return rules.length > 0 ? rules.join( '' ) : undefined;
|
|
994
995
|
}
|
|
995
996
|
|
|
996
|
-
function useBlockProps( { name, style } ) {
|
|
997
|
+
function useBlockProps( { clientId, name, style } ) {
|
|
997
998
|
const blockElementsContainerIdentifier = useInstanceId(
|
|
998
999
|
STYLE_BLOCK_PROPS_REFERENCE,
|
|
999
1000
|
'wp-elements'
|
|
@@ -1037,7 +1038,7 @@ function useBlockProps( { name, style } ) {
|
|
|
1037
1038
|
viewportSettings,
|
|
1038
1039
|
] );
|
|
1039
1040
|
|
|
1040
|
-
|
|
1041
|
+
usePrivateStyleOverride( { css: styles, clientId } );
|
|
1041
1042
|
|
|
1042
1043
|
return addSaveProps(
|
|
1043
1044
|
{ className: blockElementsContainerIdentifier },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
|
|
1
2
|
import { render, screen } from '@testing-library/react';
|
|
2
3
|
import userEvent from '@testing-library/user-event';
|
|
3
4
|
import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
|
|
@@ -9,6 +10,8 @@ import {
|
|
|
9
10
|
} from '../background';
|
|
10
11
|
import { BackgroundToolsPanel } from '../../components/global-styles/background-panel';
|
|
11
12
|
|
|
13
|
+
globalThis.wpVitest.mockMatchMedia();
|
|
14
|
+
|
|
12
15
|
describe( 'background', () => {
|
|
13
16
|
describe( 'backgroundResetAllFilter', () => {
|
|
14
17
|
it( 'clears every background-owned value, including a custom legacy color.gradient', () => {
|
|
@@ -164,7 +167,7 @@ describe( 'background', () => {
|
|
|
164
167
|
background: { gradient: true },
|
|
165
168
|
};
|
|
166
169
|
const user = userEvent.setup();
|
|
167
|
-
const setAttributes =
|
|
170
|
+
const setAttributes = vi.fn();
|
|
168
171
|
|
|
169
172
|
render(
|
|
170
173
|
<BackgroundImagePanel
|
|
@@ -201,7 +204,7 @@ describe( 'background', () => {
|
|
|
201
204
|
background: { gradient: false },
|
|
202
205
|
};
|
|
203
206
|
const user = userEvent.setup();
|
|
204
|
-
const setAttributes =
|
|
207
|
+
const setAttributes = vi.fn();
|
|
205
208
|
|
|
206
209
|
render(
|
|
207
210
|
<BackgroundImagePanel
|