@wordpress/block-editor 8.0.16 → 8.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 +2 -0
- package/LICENSE.md +1 -1
- package/README.md +12 -1
- package/build/components/block-caption/index.native.js +14 -3
- package/build/components/block-caption/index.native.js.map +1 -1
- package/build/components/block-edit/index.js +9 -0
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +8 -20
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +3 -11
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-media-update-progress/index.native.js +2 -1
- package/build/components/block-media-update-progress/index.native.js.map +1 -1
- package/build/components/block-preview/auto.js +10 -2
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings/container.native.js +2 -1
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +110 -134
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/menu-items.js +63 -0
- package/build/components/block-styles/menu-items.js.map +1 -0
- package/build/components/block-styles/preview-panel.js +45 -0
- package/build/components/block-styles/preview-panel.js.map +1 -0
- package/build/components/block-styles/preview.native.js +2 -2
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-styles/use-styles-for-block.js +119 -0
- package/build/components/block-styles/use-styles-for-block.js.map +1 -0
- package/build/components/block-styles/utils.js +39 -0
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +3 -23
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -1
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +5 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +11 -1
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-types-list/index.native.js +2 -2
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/button-block-appender/index.js +2 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +88 -0
- package/build/components/colors-gradients/dropdown.js.map +1 -0
- package/build/components/colors-gradients/panel-color-gradient-settings.js +6 -5
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.native.js +6 -3
- package/build/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
- package/build/components/contrast-checker/index.js +34 -9
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/contrast-checker/index.native.js +108 -0
- package/build/components/contrast-checker/index.native.js.map +1 -0
- package/build/components/default-block-appender/index.js +16 -19
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/default-style-picker/index.js +18 -3
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/iframe/index.js +4 -5
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +18 -9
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/default-block-appender.js +2 -4
- package/build/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +16 -14
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/index.js +61 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +1 -1
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/library.js +5 -3
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +11 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/tabs.native.js +7 -4
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +2 -1
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +11 -43
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +3 -5
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +1 -3
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +6 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-item.js +11 -1
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -1
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +18 -5
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-select-button.js +23 -3
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +8 -0
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/media-placeholder/index.js +2 -0
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +32 -6
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload-progress/index.native.js +2 -1
- package/build/components/media-upload-progress/index.native.js.map +1 -1
- package/build/components/panel-color-settings/index.js +7 -3
- package/build/components/panel-color-settings/index.js.map +1 -1
- package/build/components/provider/block-refs-provider.js +4 -1
- package/build/components/provider/block-refs-provider.js.map +1 -1
- package/build/components/rich-text/file-paste-handler.js +1 -1
- package/build/components/rich-text/file-paste-handler.js.map +1 -1
- package/build/components/rich-text/prevent-event-discovery.js +33 -0
- package/build/components/rich-text/prevent-event-discovery.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +3 -1
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/selection-scroll-into-view/index.js +2 -1
- package/build/components/selection-scroll-into-view/index.js.map +1 -1
- package/build/components/use-display-block-controls/index.native.js +45 -0
- package/build/components/use-display-block-controls/index.native.js.map +1 -0
- package/build/components/use-on-block-drop/index.js +7 -3
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +3 -1
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/hooks/border-color.js +74 -10
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/border-radius.js +47 -0
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border-style.js +41 -0
- package/build/hooks/border-style.js.map +1 -1
- package/build/hooks/border-width.js +70 -31
- package/build/hooks/border-width.js.map +1 -1
- package/build/hooks/border.js +81 -11
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +4 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color-panel.native.js +77 -0
- package/build/hooks/color-panel.native.js.map +1 -0
- package/build/hooks/color.js +6 -5
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/index.native.js +2 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout.native.js +20 -0
- package/build/hooks/layout.native.js.map +1 -0
- package/build/hooks/letter-spacing.js +1 -1
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/store/actions.js +1 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +5 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/defaults.native.js +2 -6
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/selectors.js +10 -5
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-paste-event-data.js +1 -1
- package/build/utils/get-paste-event-data.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +1 -1
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-caption/index.native.js +13 -3
- package/build-module/components/block-caption/index.native.js.map +1 -1
- package/build-module/components/block-edit/index.js +9 -0
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +8 -20
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +3 -10
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-media-update-progress/index.native.js +2 -1
- package/build-module/components/block-media-update-progress/index.native.js.map +1 -1
- package/build-module/components/block-preview/auto.js +10 -2
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +2 -1
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +112 -133
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/menu-items.js +50 -0
- package/build-module/components/block-styles/menu-items.js.map +1 -0
- package/build-module/components/block-styles/preview-panel.js +35 -0
- package/build-module/components/block-styles/preview-panel.js.map +1 -0
- package/build-module/components/block-styles/preview.native.js +2 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-styles/use-styles-for-block.js +107 -0
- package/build-module/components/block-styles/use-styles-for-block.js.map +1 -0
- package/build-module/components/block-styles/utils.js +34 -0
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +3 -21
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +2 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +5 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +11 -1
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -2
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +2 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +75 -0
- package/build-module/components/colors-gradients/dropdown.js.map +1 -0
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +8 -7
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js +7 -4
- package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +34 -9
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/contrast-checker/index.native.js +90 -0
- package/build-module/components/contrast-checker/index.native.js.map +1 -0
- package/build-module/components/default-block-appender/index.js +15 -18
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +17 -3
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -5
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +2 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/default-block-appender.js +2 -4
- package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +16 -14
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/index.js +61 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +2 -2
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/library.js +5 -3
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +11 -4
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +7 -4
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +2 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +12 -43
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +3 -5
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +1 -3
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +6 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-item.js +11 -1
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +2 -1
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +18 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +22 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +6 -0
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +2 -0
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +32 -6
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload-progress/index.native.js +2 -1
- package/build-module/components/media-upload-progress/index.native.js.map +1 -1
- package/build-module/components/panel-color-settings/index.js +7 -3
- package/build-module/components/panel-color-settings/index.js.map +1 -1
- package/build-module/components/provider/block-refs-provider.js +4 -1
- package/build-module/components/provider/block-refs-provider.js.map +1 -1
- package/build-module/components/rich-text/file-paste-handler.js +1 -1
- package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.js +25 -0
- package/build-module/components/rich-text/prevent-event-discovery.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +2 -1
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/selection-scroll-into-view/index.js +2 -1
- package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
- package/build-module/components/use-display-block-controls/index.native.js +34 -0
- package/build-module/components/use-display-block-controls/index.native.js.map +1 -0
- package/build-module/components/use-on-block-drop/index.js +7 -3
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +3 -4
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/hooks/border-color.js +72 -12
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/border-radius.js +42 -0
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border-style.js +36 -0
- package/build-module/hooks/border-style.js.map +1 -1
- package/build-module/hooks/border-width.js +66 -32
- package/build-module/hooks/border-width.js.map +1 -1
- package/build-module/hooks/border.js +80 -12
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +4 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color-panel.native.js +62 -0
- package/build-module/hooks/color-panel.native.js.map +1 -0
- package/build-module/hooks/color.js +6 -5
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout.native.js +16 -0
- package/build-module/hooks/layout.native.js.map +1 -0
- package/build-module/hooks/letter-spacing.js +1 -1
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/store/actions.js +1 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +5 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/defaults.native.js +2 -5
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/selectors.js +10 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-paste-event-data.js +1 -1
- package/build-module/utils/get-paste-event-data.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +1 -1
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +226 -181
- package/build-style/style.css +226 -181
- package/package.json +31 -27
- package/src/components/block-caption/index.native.js +22 -4
- package/src/components/block-card/README.md +1 -1
- package/src/components/block-edit/index.js +8 -0
- package/src/components/block-edit/test/edit.native.js +10 -9
- package/src/components/block-inspector/index.js +9 -16
- package/src/components/block-list-appender/index.js +5 -21
- package/src/components/block-media-update-progress/index.native.js +1 -1
- package/src/components/block-media-update-progress/test/index.native.js +136 -93
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +108 -47
- package/src/components/block-mover/test/index.native.js +5 -5
- package/src/components/block-preview/README.md +14 -26
- package/src/components/block-preview/auto.js +7 -2
- package/src/components/block-preview/test/index.js +2 -0
- package/src/components/block-settings/container.native.js +1 -0
- package/src/components/block-styles/index.js +125 -145
- package/src/components/block-styles/menu-items.js +49 -0
- package/src/components/block-styles/preview-panel.js +36 -0
- package/src/components/block-styles/preview.native.js +5 -2
- package/src/components/block-styles/style.scss +59 -51
- package/src/components/block-styles/test/{index.js → utils.js} +60 -1
- package/src/components/block-styles/use-styles-for-block.js +99 -0
- package/src/components/block-styles/utils.js +39 -0
- package/src/components/block-switcher/block-styles-menu.js +3 -38
- package/src/components/block-tools/back-compat.js +1 -0
- package/src/components/block-tools/block-selection-button.js +7 -1
- package/src/components/block-tools/insertion-point.js +10 -1
- package/src/components/block-types-list/index.native.js +5 -2
- package/src/components/border-radius-control/style.scss +1 -1
- package/src/components/border-style-control/style.scss +0 -1
- package/src/components/button-block-appender/index.js +1 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +9 -4
- package/src/components/colors-gradients/dropdown.js +96 -0
- package/src/components/colors-gradients/panel-color-gradient-settings.js +23 -19
- package/src/components/colors-gradients/panel-color-gradient-settings.native.js +13 -2
- package/src/components/colors-gradients/style.scss +59 -5
- package/src/components/contrast-checker/README.md +3 -1
- package/src/components/contrast-checker/index.js +48 -20
- package/src/components/contrast-checker/index.native.js +113 -0
- package/src/components/contrast-checker/style.native.scss +26 -0
- package/src/components/contrast-checker/test/index.js +65 -0
- package/src/components/default-block-appender/index.js +17 -24
- package/src/components/default-block-appender/style.scss +4 -0
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +12 -24
- package/src/components/default-block-appender/test/index.js +4 -14
- package/src/components/default-style-picker/index.js +18 -6
- package/src/components/iframe/index.js +7 -3
- package/src/components/index.js +2 -1
- package/src/components/index.native.js +1 -0
- package/src/components/inner-blocks/README.md +2 -0
- package/src/components/inner-blocks/default-block-appender.js +2 -7
- package/src/components/inner-blocks/use-nested-settings-update.js +16 -14
- package/src/components/inserter/index.js +77 -5
- package/src/components/inserter/index.native.js +2 -2
- package/src/components/inserter/library.js +17 -12
- package/src/components/inserter/menu.js +31 -13
- package/src/components/inserter/tabs.native.js +5 -4
- package/src/components/inserter/test/block-types-tab.native.js +9 -10
- package/src/components/inserter/test/index.native.js +3 -7
- package/src/components/inserter/test/reusable-blocks-tab.native.js +8 -10
- package/src/components/inspector-controls/block-support-slot-container.js +3 -1
- package/src/components/inspector-controls/block-support-tools-panel.js +39 -58
- package/src/components/inspector-controls/fill.native.js +4 -3
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls/slot.js +2 -7
- package/src/components/letter-spacing-control/index.js +6 -6
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/link-preview.js +1 -1
- package/src/components/link-control/search-item.js +11 -2
- package/src/components/link-control/search-results.js +1 -0
- package/src/components/link-control/style.scss +2 -1
- package/src/components/link-control/test/index.js +4 -0
- package/src/components/link-control/use-search-handler.js +25 -4
- package/src/components/list-view/block-select-button.js +20 -1
- package/src/components/list-view/block.js +10 -0
- package/src/components/media-placeholder/index.js +2 -0
- package/src/components/media-replace-flow/index.js +35 -5
- package/src/components/media-upload/test/index.native.js +28 -47
- package/src/components/media-upload-progress/index.native.js +1 -0
- package/src/components/media-upload-progress/test/index.native.js +60 -47
- package/src/components/panel-color-settings/index.js +8 -4
- package/src/components/provider/block-refs-provider.js +4 -1
- package/src/components/rich-text/file-paste-handler.js +3 -1
- package/src/components/rich-text/prevent-event-discovery.js +23 -0
- package/src/components/rich-text/use-input-rules.js +2 -1
- package/src/components/selection-scroll-into-view/index.js +1 -0
- package/src/components/url-input/README.md +5 -0
- package/src/components/use-display-block-controls/index.native.js +38 -0
- package/src/components/use-on-block-drop/index.js +7 -3
- package/src/components/writing-flow/test/use-multi-selection.js +36 -0
- package/src/components/writing-flow/use-multi-selection.js +12 -9
- package/src/hooks/border-color.js +69 -9
- package/src/hooks/border-radius.js +32 -0
- package/src/hooks/border-style.js +26 -0
- package/src/hooks/border-width.js +56 -32
- package/src/hooks/border.js +115 -20
- package/src/hooks/border.scss +3 -17
- package/src/hooks/color-panel.js +3 -0
- package/src/hooks/color-panel.native.js +63 -0
- package/src/hooks/color.js +8 -7
- package/src/hooks/dimensions.scss +5 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.native.js +23 -0
- package/src/hooks/letter-spacing.js +1 -1
- package/src/hooks/typography.js +1 -1
- package/src/store/actions.js +1 -2
- package/src/store/defaults.js +2 -0
- package/src/store/defaults.native.js +2 -6
- package/src/store/selectors.js +10 -5
- package/src/style.scss +4 -3
- package/src/utils/get-paste-event-data.js +1 -1
- package/src/utils/parse-css-unit-to-px.js +1 -1
- package/src/utils/test/parse-css-unit-to-px.js +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/use-canvas-click-redirect/index.js +0 -66
- package/build/components/use-canvas-click-redirect/index.js.map +0 -1
- package/build-module/components/use-canvas-click-redirect/index.js +0 -54
- package/build-module/components/use-canvas-click-redirect/index.js.map +0 -1
- package/src/components/use-canvas-click-redirect/index.js +0 -57
|
@@ -5,13 +5,18 @@
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.block-editor-panel-color-gradient-settings {
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
.block-editor-panel-color-gradient-settings__panel-title {
|
|
9
|
+
display: flex;
|
|
10
|
+
gap: $grid-unit-10;
|
|
11
11
|
|
|
12
|
-
&__panel-title {
|
|
13
12
|
.component-color-indicator {
|
|
14
|
-
|
|
13
|
+
width: $grid-unit-15;
|
|
14
|
+
height: $grid-unit-15;
|
|
15
|
+
align-self: center;
|
|
16
|
+
|
|
17
|
+
&:first-child {
|
|
18
|
+
margin-left: $grid-unit-15;
|
|
19
|
+
}
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
22
|
|
|
@@ -37,4 +42,53 @@
|
|
|
37
42
|
.block-editor-block-inspector & .components-base-control {
|
|
38
43
|
margin-bottom: inherit;
|
|
39
44
|
}
|
|
45
|
+
|
|
46
|
+
.block-editor-panel-color-gradient-settings__dropdown {
|
|
47
|
+
display: block;
|
|
48
|
+
}
|
|
40
49
|
}
|
|
50
|
+
|
|
51
|
+
.block-editor-panel-color-gradient-settings__dropdown {
|
|
52
|
+
width: 100%;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.block-editor-panel-color-gradient-settings__dropdown-content .components-popover__content {
|
|
56
|
+
& > div {
|
|
57
|
+
width: $sidebar-width;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@include break-medium() {
|
|
62
|
+
.block-editor-panel-color-gradient-settings__dropdown-content {
|
|
63
|
+
.components-popover__content {
|
|
64
|
+
margin-right: #{ math.div($sidebar-width, 2) + $grid-unit-20 } !important;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&.is-from-top .components-popover__content {
|
|
68
|
+
margin-top: #{ -($grid-unit-60 + $grid-unit-15) } !important;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&.is-from-bottom .components-popover__content {
|
|
72
|
+
margin-bottom: #{ -($grid-unit-60 + $grid-unit-15) } !important;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.block-editor-panel-color-gradient-settings__dropdown:last-child > div {
|
|
78
|
+
border-bottom-width: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.block-editor-panel-color-gradient-settings__item {
|
|
82
|
+
padding-top: $grid-unit-15 !important;
|
|
83
|
+
padding-bottom: $grid-unit-15 !important;
|
|
84
|
+
.block-editor-panel-color-gradient-settings__color-indicator {
|
|
85
|
+
// Show a diagonal line (crossed out) for empty swatches.
|
|
86
|
+
background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&.is-open {
|
|
90
|
+
background: $gray-100;
|
|
91
|
+
color: var(--wp-admin-theme-color);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# ContrastChecker
|
|
2
2
|
|
|
3
|
-
ContrastChecker component determines if contrast for text styles is sufficient (WCAG 2.0 AA) when used with a given background color.
|
|
3
|
+
ContrastChecker component determines if contrast for text styles is sufficient (WCAG 2.0 AA) when used with a given background color.
|
|
4
|
+
|
|
5
|
+
ContrastChecker also accounts for font sizes.
|
|
4
6
|
|
|
5
7
|
A notice will be rendered if the color combination of text and background colors are low.
|
|
6
8
|
|
|
@@ -20,22 +20,31 @@ function ContrastCheckerMessage( {
|
|
|
20
20
|
colordTextColor,
|
|
21
21
|
backgroundColor,
|
|
22
22
|
textColor,
|
|
23
|
+
shouldShowTransparencyWarning,
|
|
23
24
|
} ) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
let msg = '';
|
|
26
|
+
if ( shouldShowTransparencyWarning ) {
|
|
27
|
+
msg = __( 'Transparent text may be hard for people to read.' );
|
|
28
|
+
} else {
|
|
29
|
+
msg =
|
|
30
|
+
colordBackgroundColor.brightness() < colordTextColor.brightness()
|
|
31
|
+
? __(
|
|
32
|
+
'This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.'
|
|
33
|
+
)
|
|
34
|
+
: __(
|
|
35
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.'
|
|
36
|
+
);
|
|
37
|
+
}
|
|
32
38
|
|
|
33
39
|
// Note: The `Notice` component can speak messages via its `spokenMessage`
|
|
34
40
|
// prop, but the contrast checker requires granular control over when the
|
|
35
41
|
// announcements are made. Notably, the message will be re-announced if a
|
|
36
42
|
// new color combination is selected and the contrast is still insufficient.
|
|
37
43
|
useEffect( () => {
|
|
38
|
-
|
|
44
|
+
const speakMsg = shouldShowTransparencyWarning
|
|
45
|
+
? __( 'Transparent text may be hard for people to read.' )
|
|
46
|
+
: __( 'This color combination may be hard for people to read.' );
|
|
47
|
+
speak( speakMsg );
|
|
39
48
|
}, [ backgroundColor, textColor ] );
|
|
40
49
|
|
|
41
50
|
return (
|
|
@@ -58,6 +67,7 @@ function ContrastChecker( {
|
|
|
58
67
|
fontSize, // font size value in pixels
|
|
59
68
|
isLargeText,
|
|
60
69
|
textColor,
|
|
70
|
+
enableAlphaChecker = false,
|
|
61
71
|
} ) {
|
|
62
72
|
if (
|
|
63
73
|
! ( backgroundColor || fallbackBackgroundColor ) ||
|
|
@@ -69,28 +79,46 @@ function ContrastChecker( {
|
|
|
69
79
|
backgroundColor || fallbackBackgroundColor
|
|
70
80
|
);
|
|
71
81
|
const colordTextColor = colord( textColor || fallbackTextColor );
|
|
82
|
+
const textColorHasTransparency = colordTextColor.alpha() < 1;
|
|
83
|
+
const backgroundColorHasTransparency = colordBackgroundColor.alpha() < 1;
|
|
72
84
|
const hasTransparency =
|
|
73
|
-
|
|
85
|
+
textColorHasTransparency || backgroundColorHasTransparency;
|
|
86
|
+
const isReadable = colordTextColor.isReadable( colordBackgroundColor, {
|
|
87
|
+
level: 'AA',
|
|
88
|
+
size:
|
|
89
|
+
isLargeText || ( isLargeText !== false && fontSize >= 24 )
|
|
90
|
+
? 'large'
|
|
91
|
+
: 'small',
|
|
92
|
+
} );
|
|
74
93
|
|
|
75
|
-
if
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
level: 'AA',
|
|
79
|
-
size:
|
|
80
|
-
isLargeText || ( isLargeText !== false && fontSize >= 24 )
|
|
81
|
-
? 'large'
|
|
82
|
-
: 'small',
|
|
83
|
-
} )
|
|
84
|
-
) {
|
|
94
|
+
// Don't show the message if the text is readable AND there's no transparency.
|
|
95
|
+
// This is the default.
|
|
96
|
+
if ( isReadable && ! hasTransparency ) {
|
|
85
97
|
return null;
|
|
86
98
|
}
|
|
87
99
|
|
|
100
|
+
if ( hasTransparency ) {
|
|
101
|
+
if (
|
|
102
|
+
// If there's transparency, don't show the message if the alpha checker is disabled.
|
|
103
|
+
! enableAlphaChecker ||
|
|
104
|
+
// If the alpha checker is enabled, we only show the warning if the text has transparency.
|
|
105
|
+
( isReadable && ! textColorHasTransparency )
|
|
106
|
+
) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
88
111
|
return (
|
|
89
112
|
<ContrastCheckerMessage
|
|
90
113
|
backgroundColor={ backgroundColor }
|
|
91
114
|
textColor={ textColor }
|
|
92
115
|
colordBackgroundColor={ colordBackgroundColor }
|
|
93
116
|
colordTextColor={ colordTextColor }
|
|
117
|
+
// Flag to warn about transparency only if the text is otherwise readable according to colord
|
|
118
|
+
// to ensure the readability warnings take precedence.
|
|
119
|
+
shouldShowTransparencyWarning={
|
|
120
|
+
isReadable && textColorHasTransparency
|
|
121
|
+
}
|
|
94
122
|
/>
|
|
95
123
|
);
|
|
96
124
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Text, View } from 'react-native';
|
|
5
|
+
import { colord, extend } from 'colord';
|
|
6
|
+
import namesPlugin from 'colord/plugins/names';
|
|
7
|
+
import a11yPlugin from 'colord/plugins/a11y';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* WordPress dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { speak } from '@wordpress/a11y';
|
|
13
|
+
import { __ } from '@wordpress/i18n';
|
|
14
|
+
import { useEffect } from '@wordpress/element';
|
|
15
|
+
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
16
|
+
import { Icon, warning } from '@wordpress/icons';
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
import styles from './style.scss';
|
|
21
|
+
|
|
22
|
+
extend( [ namesPlugin, a11yPlugin ] );
|
|
23
|
+
|
|
24
|
+
function ContrastCheckerMessage( {
|
|
25
|
+
colordBackgroundColor,
|
|
26
|
+
colordTextColor,
|
|
27
|
+
backgroundColor,
|
|
28
|
+
textColor,
|
|
29
|
+
msgStyle,
|
|
30
|
+
} ) {
|
|
31
|
+
const msg =
|
|
32
|
+
colordBackgroundColor.brightness() < colordTextColor.brightness()
|
|
33
|
+
? __(
|
|
34
|
+
'This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.'
|
|
35
|
+
)
|
|
36
|
+
: __(
|
|
37
|
+
'This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.'
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Note: The `Notice` component can speak messages via its `spokenMessage`
|
|
41
|
+
// prop, but the contrast checker requires granular control over when the
|
|
42
|
+
// announcements are made. Notably, the message will be re-announced if a
|
|
43
|
+
// new color combination is selected and the contrast is still insufficient.
|
|
44
|
+
useEffect( () => {
|
|
45
|
+
speak( __( 'This color combination may be hard for people to read.' ) );
|
|
46
|
+
}, [ backgroundColor, textColor ] );
|
|
47
|
+
|
|
48
|
+
const iconStyle = usePreferredColorSchemeStyle(
|
|
49
|
+
styles[ 'block-editor-contrast-checker__icon' ],
|
|
50
|
+
styles[ 'block-editor-contrast-checker__icon-dark' ]
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<View style={ styles[ 'block-editor-contrast-checker' ] }>
|
|
55
|
+
<Icon style={ iconStyle } icon={ warning } />
|
|
56
|
+
<Text style={ msgStyle }>{ msg }</Text>
|
|
57
|
+
</View>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function ContrastChecker( {
|
|
62
|
+
backgroundColor,
|
|
63
|
+
fallbackBackgroundColor,
|
|
64
|
+
fallbackTextColor,
|
|
65
|
+
fontSize, // font size value in pixels
|
|
66
|
+
isLargeText,
|
|
67
|
+
textColor,
|
|
68
|
+
} ) {
|
|
69
|
+
const msgStyle = usePreferredColorSchemeStyle(
|
|
70
|
+
styles[ 'block-editor-contrast-checker__notice' ],
|
|
71
|
+
styles[ 'block-editor-contrast-checker__notice-dark' ]
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (
|
|
75
|
+
! ( backgroundColor || fallbackBackgroundColor ) ||
|
|
76
|
+
! ( textColor || fallbackTextColor )
|
|
77
|
+
) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const colordBackgroundColor = colord(
|
|
82
|
+
backgroundColor || fallbackBackgroundColor
|
|
83
|
+
);
|
|
84
|
+
const colordTextColor = colord( textColor || fallbackTextColor );
|
|
85
|
+
|
|
86
|
+
const hasTransparency =
|
|
87
|
+
colordBackgroundColor.alpha() !== 1 || colordTextColor.alpha() !== 1;
|
|
88
|
+
|
|
89
|
+
if (
|
|
90
|
+
hasTransparency ||
|
|
91
|
+
colordTextColor.isReadable( colordBackgroundColor, {
|
|
92
|
+
level: 'AA',
|
|
93
|
+
size:
|
|
94
|
+
isLargeText || ( isLargeText !== false && fontSize >= 24 )
|
|
95
|
+
? 'large'
|
|
96
|
+
: 'small',
|
|
97
|
+
} )
|
|
98
|
+
) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<ContrastCheckerMessage
|
|
104
|
+
backgroundColor={ backgroundColor }
|
|
105
|
+
textColor={ textColor }
|
|
106
|
+
colordBackgroundColor={ colordBackgroundColor }
|
|
107
|
+
colordTextColor={ colordTextColor }
|
|
108
|
+
msgStyle={ msgStyle }
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default ContrastChecker;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.block-editor-contrast-checker {
|
|
2
|
+
flex-direction: row;
|
|
3
|
+
align-items: center;
|
|
4
|
+
padding: 8px 0;
|
|
5
|
+
justify-content: space-between;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.block-editor-contrast-checker__notice {
|
|
9
|
+
font-size: 11px;
|
|
10
|
+
font-weight: 500;
|
|
11
|
+
color: $yellow-50;
|
|
12
|
+
flex: 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.block-editor-contrast-checker__notice-dark {
|
|
16
|
+
color: $yellow-30;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.block-editor-contrast-checker__icon {
|
|
20
|
+
color: $yellow-50;
|
|
21
|
+
margin-right: 5px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.block-editor-contrast-checker__icon-dark {
|
|
25
|
+
color: $yellow-30;
|
|
26
|
+
}
|
|
@@ -50,6 +50,20 @@ describe( 'ContrastChecker', () => {
|
|
|
50
50
|
expect( wrapper.html() ).toBeNull();
|
|
51
51
|
} );
|
|
52
52
|
|
|
53
|
+
test( 'should render null when the colors meet AA WCAG guidelines and alpha checker enabled.', () => {
|
|
54
|
+
const wrapper = mount(
|
|
55
|
+
<ContrastChecker
|
|
56
|
+
backgroundColor={ backgroundColor }
|
|
57
|
+
textColor={ textColor }
|
|
58
|
+
isLargeText={ isLargeText }
|
|
59
|
+
enableAlphaChecker={ true }
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
64
|
+
expect( wrapper.html() ).toBeNull();
|
|
65
|
+
} );
|
|
66
|
+
|
|
53
67
|
test( 'should render component when the colors do not meet AA WCAG guidelines.', () => {
|
|
54
68
|
const wrapper = mount(
|
|
55
69
|
<ContrastChecker
|
|
@@ -258,4 +272,55 @@ describe( 'ContrastChecker', () => {
|
|
|
258
272
|
|
|
259
273
|
expect( speak ).toHaveBeenCalledTimes( 2 );
|
|
260
274
|
} );
|
|
275
|
+
|
|
276
|
+
// enableAlphaChecker tests
|
|
277
|
+
test( 'should render component when the colors meet AA WCAG guidelines but the text color only has alpha transparency with alpha checker enabled.', () => {
|
|
278
|
+
const wrapper = mount(
|
|
279
|
+
<ContrastChecker
|
|
280
|
+
backgroundColor={ backgroundColor }
|
|
281
|
+
textColor={ 'rgba(0,0,0,0.9)' }
|
|
282
|
+
isLargeText={ isLargeText }
|
|
283
|
+
enableAlphaChecker={ true }
|
|
284
|
+
/>
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
288
|
+
'Transparent text may be hard for people to read.'
|
|
289
|
+
);
|
|
290
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
291
|
+
'Transparent text may be hard for people to read.'
|
|
292
|
+
);
|
|
293
|
+
} );
|
|
294
|
+
|
|
295
|
+
test( 'should render null when the colors meet AA WCAG guidelines but the background color only has alpha transparency with alpha checker enabled.', () => {
|
|
296
|
+
const wrapper = mount(
|
|
297
|
+
<ContrastChecker
|
|
298
|
+
backgroundColor={ 'rgba(255,255,255,0.7)' }
|
|
299
|
+
textColor={ textColor }
|
|
300
|
+
isLargeText={ isLargeText }
|
|
301
|
+
enableAlphaChecker={ true }
|
|
302
|
+
/>
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
expect( speak ).not.toHaveBeenCalled();
|
|
306
|
+
expect( wrapper.html() ).toBeNull();
|
|
307
|
+
} );
|
|
308
|
+
|
|
309
|
+
test( 'should render component when the colors meet AA WCAG guidelines but all colors have alpha transparency with alpha checker enabled.', () => {
|
|
310
|
+
const wrapper = mount(
|
|
311
|
+
<ContrastChecker
|
|
312
|
+
backgroundColor={ 'rgba(255,255,255,0.7)' }
|
|
313
|
+
textColor={ 'rgba(0,0,0,0.7)' }
|
|
314
|
+
isLargeText={ isLargeText }
|
|
315
|
+
enableAlphaChecker={ true }
|
|
316
|
+
/>
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
expect( speak ).toHaveBeenCalledWith(
|
|
320
|
+
'Transparent text may be hard for people to read.'
|
|
321
|
+
);
|
|
322
|
+
expect( wrapper.find( Notice ).children().text() ).toBe(
|
|
323
|
+
'Transparent text may be hard for people to read.'
|
|
324
|
+
);
|
|
325
|
+
} );
|
|
261
326
|
} );
|
|
@@ -8,9 +8,9 @@ import classnames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { compose } from '@wordpress/compose';
|
|
11
|
-
import { getDefaultBlockName } from '@wordpress/blocks';
|
|
12
11
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
13
12
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
13
|
+
import { ENTER, SPACE } from '@wordpress/keycodes';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -26,13 +26,12 @@ export const ZWNBSP = '\ufeff';
|
|
|
26
26
|
|
|
27
27
|
export function DefaultBlockAppender( {
|
|
28
28
|
isLocked,
|
|
29
|
-
isVisible,
|
|
30
29
|
onAppend,
|
|
31
30
|
showPrompt,
|
|
32
31
|
placeholder,
|
|
33
32
|
rootClientId,
|
|
34
33
|
} ) {
|
|
35
|
-
if ( isLocked
|
|
34
|
+
if ( isLocked ) {
|
|
36
35
|
return null;
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -48,20 +47,23 @@ export function DefaultBlockAppender( {
|
|
|
48
47
|
>
|
|
49
48
|
<p
|
|
50
49
|
tabIndex="0"
|
|
51
|
-
// Only necessary for `useCanvasClickRedirect` to consider it
|
|
52
|
-
// as a target. Ideally it should consider any tabbable target,
|
|
53
|
-
// but the inserter is rendered in place while it should be
|
|
54
|
-
// rendered in a popover, just like it does for an empty
|
|
55
|
-
// paragraph block.
|
|
56
|
-
contentEditable
|
|
57
|
-
suppressContentEditableWarning
|
|
58
50
|
// We want this element to be styled as a paragraph by themes.
|
|
59
51
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
60
52
|
role="button"
|
|
61
|
-
aria-label={ __( 'Add block' ) }
|
|
53
|
+
aria-label={ __( 'Add default block' ) }
|
|
62
54
|
// A wrapping container for this one already has the wp-block className.
|
|
63
55
|
className="block-editor-default-block-appender__content"
|
|
64
|
-
|
|
56
|
+
onKeyDown={ ( event ) => {
|
|
57
|
+
if ( ENTER === event.keyCode || SPACE === event.keyCode ) {
|
|
58
|
+
onAppend();
|
|
59
|
+
}
|
|
60
|
+
} }
|
|
61
|
+
onClick={ () => onAppend() }
|
|
62
|
+
onFocus={ () => {
|
|
63
|
+
if ( showPrompt ) {
|
|
64
|
+
onAppend();
|
|
65
|
+
}
|
|
66
|
+
} }
|
|
65
67
|
>
|
|
66
68
|
{ showPrompt ? value : ZWNBSP }
|
|
67
69
|
</p>
|
|
@@ -77,23 +79,14 @@ export function DefaultBlockAppender( {
|
|
|
77
79
|
|
|
78
80
|
export default compose(
|
|
79
81
|
withSelect( ( select, ownProps ) => {
|
|
80
|
-
const {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
isBlockValid,
|
|
84
|
-
getSettings,
|
|
85
|
-
getTemplateLock,
|
|
86
|
-
} = select( blockEditorStore );
|
|
82
|
+
const { getBlockCount, getSettings, getTemplateLock } = select(
|
|
83
|
+
blockEditorStore
|
|
84
|
+
);
|
|
87
85
|
|
|
88
86
|
const isEmpty = ! getBlockCount( ownProps.rootClientId );
|
|
89
|
-
const isLastBlockDefault =
|
|
90
|
-
getBlockName( ownProps.lastBlockClientId ) ===
|
|
91
|
-
getDefaultBlockName();
|
|
92
|
-
const isLastBlockValid = isBlockValid( ownProps.lastBlockClientId );
|
|
93
87
|
const { bodyPlaceholder } = getSettings();
|
|
94
88
|
|
|
95
89
|
return {
|
|
96
|
-
isVisible: isEmpty || ! isLastBlockDefault || ! isLastBlockValid,
|
|
97
90
|
showPrompt: isEmpty,
|
|
98
91
|
isLocked: !! getTemplateLock( ownProps.rootClientId ),
|
|
99
92
|
placeholder: bodyPlaceholder,
|
|
@@ -6,24 +6,12 @@ exports[`DefaultBlockAppender should append a default block when input focused 1
|
|
|
6
6
|
data-root-client-id=""
|
|
7
7
|
>
|
|
8
8
|
<p
|
|
9
|
-
aria-label="Add block"
|
|
9
|
+
aria-label="Add default block"
|
|
10
10
|
className="block-editor-default-block-appender__content"
|
|
11
|
-
|
|
12
|
-
onFocus={
|
|
13
|
-
|
|
14
|
-
"calls": Array [
|
|
15
|
-
Array [],
|
|
16
|
-
],
|
|
17
|
-
"results": Array [
|
|
18
|
-
Object {
|
|
19
|
-
"type": "return",
|
|
20
|
-
"value": undefined,
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
}
|
|
24
|
-
}
|
|
11
|
+
onClick={[Function]}
|
|
12
|
+
onFocus={[Function]}
|
|
13
|
+
onKeyDown={[Function]}
|
|
25
14
|
role="button"
|
|
26
|
-
suppressContentEditableWarning={true}
|
|
27
15
|
tabIndex="0"
|
|
28
16
|
>
|
|
29
17
|
Type / to choose a block
|
|
@@ -42,12 +30,12 @@ exports[`DefaultBlockAppender should match snapshot 1`] = `
|
|
|
42
30
|
data-root-client-id=""
|
|
43
31
|
>
|
|
44
32
|
<p
|
|
45
|
-
aria-label="Add block"
|
|
33
|
+
aria-label="Add default block"
|
|
46
34
|
className="block-editor-default-block-appender__content"
|
|
47
|
-
|
|
48
|
-
onFocus={[
|
|
35
|
+
onClick={[Function]}
|
|
36
|
+
onFocus={[Function]}
|
|
37
|
+
onKeyDown={[Function]}
|
|
49
38
|
role="button"
|
|
50
|
-
suppressContentEditableWarning={true}
|
|
51
39
|
tabIndex="0"
|
|
52
40
|
>
|
|
53
41
|
Type / to choose a block
|
|
@@ -66,12 +54,12 @@ exports[`DefaultBlockAppender should optionally show without prompt 1`] = `
|
|
|
66
54
|
data-root-client-id=""
|
|
67
55
|
>
|
|
68
56
|
<p
|
|
69
|
-
aria-label="Add block"
|
|
57
|
+
aria-label="Add default block"
|
|
70
58
|
className="block-editor-default-block-appender__content"
|
|
71
|
-
|
|
72
|
-
onFocus={[
|
|
59
|
+
onClick={[Function]}
|
|
60
|
+
onFocus={[Function]}
|
|
61
|
+
onKeyDown={[Function]}
|
|
73
62
|
role="button"
|
|
74
|
-
suppressContentEditableWarning={true}
|
|
75
63
|
tabIndex="0"
|
|
76
64
|
>
|
|
77
65
|
|
|
@@ -14,16 +14,10 @@ describe( 'DefaultBlockAppender', () => {
|
|
|
14
14
|
expect( onAppend ).toHaveBeenCalledWith();
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
it( 'should render nothing if not visible', () => {
|
|
18
|
-
const wrapper = shallow( <DefaultBlockAppender /> );
|
|
19
|
-
|
|
20
|
-
expect( wrapper.type() ).toBe( null );
|
|
21
|
-
} );
|
|
22
|
-
|
|
23
17
|
it( 'should match snapshot', () => {
|
|
24
18
|
const onAppend = jest.fn();
|
|
25
19
|
const wrapper = shallow(
|
|
26
|
-
<DefaultBlockAppender
|
|
20
|
+
<DefaultBlockAppender onAppend={ onAppend } showPrompt />
|
|
27
21
|
);
|
|
28
22
|
|
|
29
23
|
expect( wrapper ).toMatchSnapshot();
|
|
@@ -32,10 +26,10 @@ describe( 'DefaultBlockAppender', () => {
|
|
|
32
26
|
it( 'should append a default block when input focused', () => {
|
|
33
27
|
const onAppend = jest.fn();
|
|
34
28
|
const wrapper = shallow(
|
|
35
|
-
<DefaultBlockAppender
|
|
29
|
+
<DefaultBlockAppender onAppend={ onAppend } showPrompt />
|
|
36
30
|
);
|
|
37
31
|
|
|
38
|
-
wrapper.find( 'p' ).simulate( '
|
|
32
|
+
wrapper.find( 'p' ).simulate( 'click' );
|
|
39
33
|
|
|
40
34
|
expect( wrapper ).toMatchSnapshot();
|
|
41
35
|
|
|
@@ -45,11 +39,7 @@ describe( 'DefaultBlockAppender', () => {
|
|
|
45
39
|
it( 'should optionally show without prompt', () => {
|
|
46
40
|
const onAppend = jest.fn();
|
|
47
41
|
const wrapper = shallow(
|
|
48
|
-
<DefaultBlockAppender
|
|
49
|
-
isVisible
|
|
50
|
-
onAppend={ onAppend }
|
|
51
|
-
showPrompt={ false }
|
|
52
|
-
/>
|
|
42
|
+
<DefaultBlockAppender onAppend={ onAppend } showPrompt={ false } />
|
|
53
43
|
);
|
|
54
44
|
const input = wrapper.find( 'p' );
|
|
55
45
|
|
|
@@ -11,6 +11,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import { store as blockEditorStore } from '../../store';
|
|
14
|
+
import { getDefaultStyle } from '../block-styles/utils';
|
|
14
15
|
|
|
15
16
|
export default function DefaultStylePicker( { blockName } ) {
|
|
16
17
|
const {
|
|
@@ -38,6 +39,9 @@ export default function DefaultStylePicker( { blockName } ) {
|
|
|
38
39
|
],
|
|
39
40
|
[ styles ]
|
|
40
41
|
);
|
|
42
|
+
const defaultStyleName = useMemo( () => getDefaultStyle( styles )?.name, [
|
|
43
|
+
styles,
|
|
44
|
+
] );
|
|
41
45
|
const selectOnChange = useCallback(
|
|
42
46
|
( blockStyle ) => {
|
|
43
47
|
onUpdatePreferredStyleVariations( blockName, blockStyle );
|
|
@@ -45,14 +49,22 @@ export default function DefaultStylePicker( { blockName } ) {
|
|
|
45
49
|
[ blockName, onUpdatePreferredStyleVariations ]
|
|
46
50
|
);
|
|
47
51
|
|
|
52
|
+
// Until the functionality is migrated to global styles,
|
|
53
|
+
// only show the default style picker if a non-default style has already been selected.
|
|
54
|
+
if ( ! preferredStyle || preferredStyle === defaultStyleName ) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
return (
|
|
49
59
|
onUpdatePreferredStyleVariations && (
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
<div className="default-style-picker__default-switcher">
|
|
61
|
+
<SelectControl
|
|
62
|
+
options={ selectOptions }
|
|
63
|
+
value={ preferredStyle || '' }
|
|
64
|
+
label={ __( 'Default Style' ) }
|
|
65
|
+
onChange={ selectOnChange }
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
56
68
|
)
|
|
57
69
|
);
|
|
58
70
|
}
|
|
@@ -160,12 +160,15 @@ async function loadScript( head, { id, src } ) {
|
|
|
160
160
|
} );
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
function Iframe(
|
|
163
|
+
function Iframe(
|
|
164
|
+
{ contentRef, children, head, tabIndex = 0, assets, ...props },
|
|
165
|
+
ref
|
|
166
|
+
) {
|
|
164
167
|
const [ , forceRender ] = useReducer( () => ( {} ) );
|
|
165
168
|
const [ iframeDocument, setIframeDocument ] = useState();
|
|
166
169
|
const [ bodyClasses, setBodyClasses ] = useState( [] );
|
|
167
|
-
const styles = useParsedAssets(
|
|
168
|
-
const scripts = useParsedAssets(
|
|
170
|
+
const styles = useParsedAssets( assets?.styles );
|
|
171
|
+
const scripts = useParsedAssets( assets?.scripts );
|
|
169
172
|
const clearerRef = useBlockSelectionClearer();
|
|
170
173
|
const [ before, writingFlowRef, after ] = useWritingFlow();
|
|
171
174
|
const setRef = useRefEffect( ( node ) => {
|
|
@@ -188,6 +191,7 @@ function Iframe( { contentRef, children, head, tabIndex = 0, ...props }, ref ) {
|
|
|
188
191
|
Array.from( ownerDocument.body.classList ).filter(
|
|
189
192
|
( name ) =>
|
|
190
193
|
name.startsWith( 'admin-color-' ) ||
|
|
194
|
+
name.startsWith( 'post-type-' ) ||
|
|
191
195
|
name === 'wp-embed-responsive'
|
|
192
196
|
)
|
|
193
197
|
);
|