@wordpress/block-editor 8.0.12-next.33ec3857e2.0 → 8.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/build/components/block-caption/index.native.js +3 -14
- package/build/components/block-caption/index.native.js.map +1 -1
- package/build/components/block-inspector/index.js +33 -12
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +1 -1
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -3
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +1 -3
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js +11 -3
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mover/button.js +2 -2
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +2 -2
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +2 -2
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-preview/auto.js +2 -10
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings/container.native.js +1 -2
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +134 -110
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/utils.js +0 -39
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +23 -3
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-tools/back-compat.js +1 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +3 -3
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +9 -0
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +1 -11
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/button-block-appender/index.js +1 -2
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +10 -51
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/default-block-appender/index.js +19 -16
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/default-style-picker/index.js +3 -18
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +11 -11
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/gradients/use-gradient.js +4 -4
- package/build/components/gradients/use-gradient.js.map +1 -1
- package/build/components/iframe/index.js +6 -7
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +9 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/default-block-appender.js +4 -2
- package/build/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -2
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +2 -2
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +3 -3
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +1 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/tabs.native.js +4 -7
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +1 -2
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +50 -22
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +5 -3
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +0 -2
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +3 -1
- 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/list-view/block-select-button.js +3 -23
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-placeholder/index.js +0 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +0 -2
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +37 -10
- package/build/components/provider/use-block-sync.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/use-input-rules.js +1 -3
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/selection-scroll-into-view/index.js +1 -2
- package/build/components/selection-scroll-into-view/index.js.map +1 -1
- package/build/components/use-canvas-click-redirect/index.js +66 -0
- package/build/components/use-canvas-click-redirect/index.js.map +1 -0
- package/build/components/use-on-block-drop/index.js +4 -8
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-setting/index.js +7 -0
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +1 -3
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/hooks/border-color.js +5 -63
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/border-radius.js +0 -47
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border-style.js +0 -41
- package/build/hooks/border-style.js.map +1 -1
- package/build/hooks/border-width.js +31 -70
- package/build/hooks/border-width.js.map +1 -1
- package/build/hooks/border.js +11 -81
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +6 -5
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/layout.js +2 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/letter-spacing.js +1 -1
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/style.js +2 -1
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/layouts/flex.js +9 -29
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +10 -6
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +5 -4
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +1 -5
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +24 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +2 -2
- 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 +3 -13
- package/build-module/components/block-caption/index.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +33 -12
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +1 -1
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -3
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -3
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +10 -3
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +2 -2
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +2 -2
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +2 -2
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-preview/auto.js +2 -10
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +1 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +133 -112
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/utils.js +0 -34
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +21 -3
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -2
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -3
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +9 -0
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +1 -11
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +1 -2
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +13 -54
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +18 -15
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +3 -17
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +12 -12
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +4 -3
- package/build-module/components/gradients/use-gradient.js.map +1 -1
- package/build-module/components/iframe/index.js +6 -7
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/default-block-appender.js +4 -2
- package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -2
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -2
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +4 -4
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +1 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +4 -7
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +1 -2
- 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 +50 -22
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +5 -3
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +0 -2
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +3 -1
- 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/list-view/block-select-button.js +3 -22
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +0 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +0 -2
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +41 -14
- package/build-module/components/provider/use-block-sync.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/use-input-rules.js +1 -2
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/selection-scroll-into-view/index.js +1 -2
- package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
- package/build-module/components/use-canvas-click-redirect/index.js +54 -0
- package/build-module/components/use-canvas-click-redirect/index.js.map +1 -0
- package/build-module/components/use-on-block-drop/index.js +4 -8
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +7 -0
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +4 -3
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/hooks/border-color.js +7 -61
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/border-radius.js +0 -42
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border-style.js +0 -36
- package/build-module/hooks/border-style.js.map +1 -1
- package/build-module/hooks/border-width.js +32 -66
- package/build-module/hooks/border-width.js.map +1 -1
- package/build-module/hooks/border.js +12 -80
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +6 -5
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/layout.js +2 -1
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +1 -1
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/style.js +2 -1
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/layouts/flex.js +9 -29
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +10 -6
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +5 -4
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +1 -5
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +24 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +2 -2
- 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 +180 -212
- package/build-style/style.css +180 -212
- package/package.json +27 -27
- package/src/components/block-caption/index.native.js +4 -22
- package/src/components/block-inspector/index.js +32 -13
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/block.native.js +2 -2
- package/src/components/block-list/use-block-props/index.js +1 -3
- package/src/components/block-list/use-in-between-inserter.js +1 -1
- package/src/components/block-list-appender/index.js +21 -5
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +2 -5
- package/src/components/block-mover/button.js +2 -6
- package/src/components/block-mover/index.js +2 -5
- package/src/components/block-mover/index.native.js +2 -5
- package/src/components/block-preview/auto.js +2 -7
- package/src/components/block-settings/container.native.js +0 -1
- package/src/components/block-styles/index.js +145 -125
- package/src/components/block-styles/style.scss +51 -59
- package/src/components/block-styles/test/{utils.js → index.js} +1 -60
- package/src/components/block-styles/utils.js +0 -39
- package/src/components/block-switcher/block-styles-menu.js +38 -3
- package/src/components/block-tools/back-compat.js +0 -1
- package/src/components/block-tools/block-selection-button.js +3 -9
- package/src/components/block-tools/index.js +11 -0
- package/src/components/block-tools/insertion-point.js +1 -10
- package/src/components/border-style-control/style.scss +1 -0
- package/src/components/button-block-appender/index.js +0 -1
- package/src/components/colors-gradients/panel-color-gradient-settings.js +19 -75
- package/src/components/colors-gradients/style.scss +5 -42
- package/src/components/default-block-appender/index.js +24 -17
- package/src/components/default-block-appender/style.scss +0 -4
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +24 -12
- package/src/components/default-block-appender/test/index.js +14 -4
- package/src/components/default-style-picker/index.js +6 -18
- package/src/components/font-appearance-control/index.js +12 -12
- package/src/components/gradients/use-gradient.js +7 -7
- package/src/components/iframe/index.js +6 -13
- package/src/components/index.js +1 -1
- package/src/components/inner-blocks/README.md +0 -2
- package/src/components/inner-blocks/default-block-appender.js +7 -2
- package/src/components/inserter/hooks/use-insertion-point.js +2 -9
- package/src/components/inserter/index.js +2 -2
- package/src/components/inserter/index.native.js +4 -7
- package/src/components/inserter/quick-inserter.js +1 -1
- package/src/components/inserter/tabs.native.js +4 -5
- package/src/components/inspector-controls/block-support-slot-container.js +1 -3
- package/src/components/inspector-controls/block-support-tools-panel.js +57 -21
- package/src/components/inspector-controls/fill.native.js +3 -4
- package/src/components/inspector-controls/groups.js +0 -2
- package/src/components/inspector-controls/slot.js +7 -2
- package/src/components/letter-spacing-control/index.js +6 -6
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/test/index.js +0 -2
- package/src/components/list-view/block-select-button.js +1 -20
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/media-placeholder/index.js +0 -2
- package/src/components/media-replace-flow/index.js +0 -2
- package/src/components/provider/use-block-sync.js +45 -11
- package/src/components/rich-text/file-paste-handler.js +1 -3
- package/src/components/rich-text/use-input-rules.js +1 -2
- package/src/components/selection-scroll-into-view/index.js +0 -1
- package/src/components/url-input/README.md +0 -5
- package/src/components/use-canvas-click-redirect/index.js +57 -0
- package/src/components/use-on-block-drop/index.js +4 -11
- package/src/components/use-setting/index.js +9 -0
- package/src/components/writing-flow/use-multi-selection.js +9 -12
- package/src/hooks/border-color.js +3 -55
- package/src/hooks/border-radius.js +0 -32
- package/src/hooks/border-style.js +0 -26
- package/src/hooks/border-width.js +32 -56
- package/src/hooks/border.js +20 -115
- package/src/hooks/border.scss +17 -3
- package/src/hooks/color.js +13 -14
- package/src/hooks/layout.js +1 -0
- package/src/hooks/letter-spacing.js +1 -1
- package/src/hooks/style.js +2 -1
- package/src/hooks/test/style.js +0 -2
- package/src/hooks/typography.js +1 -1
- package/src/layouts/flex.js +8 -31
- package/src/layouts/flow.js +8 -6
- package/src/store/actions.js +5 -5
- package/src/store/defaults.js +0 -2
- package/src/store/reducer.js +23 -1
- package/src/store/selectors.js +2 -2
- package/src/store/test/reducer.js +35 -0
- package/src/store/test/selectors.js +1 -1
- package/src/style.scss +3 -4
- 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 +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-styles/menu-items.js +0 -63
- package/build/components/block-styles/menu-items.js.map +0 -1
- package/build/components/block-styles/preview-panel.js +0 -45
- package/build/components/block-styles/preview-panel.js.map +0 -1
- package/build/components/block-styles/use-styles-for-block.js +0 -119
- package/build/components/block-styles/use-styles-for-block.js.map +0 -1
- package/build/components/rich-text/prevent-event-discovery.js +0 -33
- package/build/components/rich-text/prevent-event-discovery.js.map +0 -1
- package/build/components/use-display-block-controls/index.native.js +0 -45
- package/build/components/use-display-block-controls/index.native.js.map +0 -1
- package/build-module/components/block-styles/menu-items.js +0 -50
- package/build-module/components/block-styles/menu-items.js.map +0 -1
- package/build-module/components/block-styles/preview-panel.js +0 -35
- package/build-module/components/block-styles/preview-panel.js.map +0 -1
- package/build-module/components/block-styles/use-styles-for-block.js +0 -107
- package/build-module/components/block-styles/use-styles-for-block.js.map +0 -1
- package/build-module/components/rich-text/prevent-event-discovery.js +0 -25
- package/build-module/components/rich-text/prevent-event-discovery.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.native.js +0 -34
- package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
- package/src/components/block-styles/menu-items.js +0 -49
- package/src/components/block-styles/preview-panel.js +0 -36
- package/src/components/block-styles/use-styles-for-block.js +0 -99
- package/src/components/rich-text/prevent-event-discovery.js +0 -23
- package/src/components/use-display-block-controls/index.native.js +0 -38
- package/src/components/writing-flow/test/use-multi-selection.js +0 -36
- package/src/hooks/dimensions.scss +0 -5
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
getActiveStyle,
|
|
6
|
-
getDefaultStyle,
|
|
7
|
-
getRenderedStyles,
|
|
8
|
-
replaceActiveStyle,
|
|
9
|
-
} from '../utils';
|
|
4
|
+
import { getActiveStyle, replaceActiveStyle } from '../utils';
|
|
10
5
|
|
|
11
6
|
describe( 'getActiveStyle', () => {
|
|
12
7
|
it( 'Should return the undefined if no active style', () => {
|
|
@@ -79,57 +74,3 @@ describe( 'replaceActiveStyle', () => {
|
|
|
79
74
|
);
|
|
80
75
|
} );
|
|
81
76
|
} );
|
|
82
|
-
|
|
83
|
-
describe( 'getRenderedStyles', () => {
|
|
84
|
-
it( 'Should return an empty array if styles is falsy', () => {
|
|
85
|
-
expect( getRenderedStyles( null ) ).toEqual( [] );
|
|
86
|
-
} );
|
|
87
|
-
|
|
88
|
-
it( 'Should return an empty array if styles array is empty', () => {
|
|
89
|
-
expect( getRenderedStyles( [] ) ).toEqual( [] );
|
|
90
|
-
} );
|
|
91
|
-
|
|
92
|
-
it( 'Should return styles collection if there is a default', () => {
|
|
93
|
-
const styles = [
|
|
94
|
-
{ name: 'hazlenut' },
|
|
95
|
-
{ name: 'cashew', isDefault: true },
|
|
96
|
-
];
|
|
97
|
-
|
|
98
|
-
expect( getRenderedStyles( styles ) ).toEqual( styles );
|
|
99
|
-
} );
|
|
100
|
-
|
|
101
|
-
it( 'Should add a default item to the styles collection if there is no default', () => {
|
|
102
|
-
const styles = [ { name: 'pistachio' }, { name: 'peanut' } ];
|
|
103
|
-
const defaultStyle = {
|
|
104
|
-
name: 'default',
|
|
105
|
-
label: 'Default',
|
|
106
|
-
isDefault: true,
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
expect( getRenderedStyles( styles ) ).toEqual( [
|
|
110
|
-
defaultStyle,
|
|
111
|
-
...styles,
|
|
112
|
-
] );
|
|
113
|
-
} );
|
|
114
|
-
} );
|
|
115
|
-
|
|
116
|
-
describe( 'getDefaultStyle', () => {
|
|
117
|
-
it( 'Should return default style object', () => {
|
|
118
|
-
const styles = [
|
|
119
|
-
{ name: 'trout' },
|
|
120
|
-
{ name: 'bream', isDefault: true },
|
|
121
|
-
];
|
|
122
|
-
|
|
123
|
-
expect( getDefaultStyle( styles ) ).toEqual( styles[ 1 ] );
|
|
124
|
-
} );
|
|
125
|
-
|
|
126
|
-
it( 'Should return `undefined` if there is no default', () => {
|
|
127
|
-
const styles = [ { name: 'snapper' }, { name: 'perch' } ];
|
|
128
|
-
|
|
129
|
-
expect( getDefaultStyle( styles ) ).toBeUndefined();
|
|
130
|
-
} );
|
|
131
|
-
|
|
132
|
-
it( 'Should return `undefined` if `styles` argument is no passed', () => {
|
|
133
|
-
expect( getDefaultStyle() ).toBeUndefined();
|
|
134
|
-
} );
|
|
135
|
-
} );
|
|
@@ -6,7 +6,6 @@ import { find } from 'lodash';
|
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
8
8
|
import TokenList from '@wordpress/token-list';
|
|
9
|
-
import { _x } from '@wordpress/i18n';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Returns the active style from the given className.
|
|
@@ -52,41 +51,3 @@ export function replaceActiveStyle( className, activeStyle, newStyle ) {
|
|
|
52
51
|
|
|
53
52
|
return list.value;
|
|
54
53
|
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Returns a collection of styles that can be represented on the frontend.
|
|
58
|
-
* The function checks a style collection for a default style. If none is found, it adds one to
|
|
59
|
-
* act as a fallback for when there is no active style applied to a block. The default item also serves
|
|
60
|
-
* as a switch on the frontend to deactivate non-default styles.
|
|
61
|
-
*
|
|
62
|
-
* @param {Array} styles Block style variations.
|
|
63
|
-
*
|
|
64
|
-
* @return {Array<Object?>} The style collection.
|
|
65
|
-
*/
|
|
66
|
-
export function getRenderedStyles( styles ) {
|
|
67
|
-
if ( ! styles || styles.length === 0 ) {
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return getDefaultStyle( styles )
|
|
72
|
-
? styles
|
|
73
|
-
: [
|
|
74
|
-
{
|
|
75
|
-
name: 'default',
|
|
76
|
-
label: _x( 'Default', 'block style' ),
|
|
77
|
-
isDefault: true,
|
|
78
|
-
},
|
|
79
|
-
...styles,
|
|
80
|
-
];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Returns a style object from a collection of styles where that style object is the default block style.
|
|
85
|
-
*
|
|
86
|
-
* @param {Array} styles Block style variations.
|
|
87
|
-
*
|
|
88
|
-
* @return {Object?} The default style object, if found.
|
|
89
|
-
*/
|
|
90
|
-
export function getDefaultStyle( styles ) {
|
|
91
|
-
return find( styles, 'isDefault' );
|
|
92
|
-
}
|
|
@@ -3,21 +3,56 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { MenuGroup } from '@wordpress/components';
|
|
6
|
+
import { useState } from '@wordpress/element';
|
|
7
|
+
import { useSelect } from '@wordpress/data';
|
|
8
|
+
import {
|
|
9
|
+
cloneBlock,
|
|
10
|
+
getBlockFromExample,
|
|
11
|
+
store as blocksStore,
|
|
12
|
+
} from '@wordpress/blocks';
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
15
|
* Internal dependencies
|
|
9
16
|
*/
|
|
10
|
-
import
|
|
17
|
+
import BlockStyles from '../block-styles';
|
|
18
|
+
import PreviewBlockPopover from './preview-block-popover';
|
|
11
19
|
|
|
12
20
|
export default function BlockStylesMenu( { hoveredBlock, onSwitch } ) {
|
|
13
|
-
const { clientId } = hoveredBlock;
|
|
21
|
+
const { name, clientId } = hoveredBlock;
|
|
22
|
+
const [ hoveredClassName, setHoveredClassName ] = useState();
|
|
23
|
+
const blockType = useSelect(
|
|
24
|
+
( select ) => select( blocksStore ).getBlockType( name ),
|
|
25
|
+
[ name ]
|
|
26
|
+
);
|
|
14
27
|
|
|
15
28
|
return (
|
|
16
29
|
<MenuGroup
|
|
17
30
|
label={ __( 'Styles' ) }
|
|
18
31
|
className="block-editor-block-switcher__styles__menugroup"
|
|
19
32
|
>
|
|
20
|
-
|
|
33
|
+
{ hoveredClassName && (
|
|
34
|
+
<PreviewBlockPopover
|
|
35
|
+
blocks={
|
|
36
|
+
blockType && blockType.example
|
|
37
|
+
? getBlockFromExample( blockType.name, {
|
|
38
|
+
attributes: {
|
|
39
|
+
...blockType.example.attributes,
|
|
40
|
+
className: hoveredClassName,
|
|
41
|
+
},
|
|
42
|
+
innerBlocks: blockType.example.innerBlocks,
|
|
43
|
+
} )
|
|
44
|
+
: cloneBlock( hoveredBlock, {
|
|
45
|
+
className: hoveredClassName,
|
|
46
|
+
} )
|
|
47
|
+
}
|
|
48
|
+
/>
|
|
49
|
+
) }
|
|
50
|
+
<BlockStyles
|
|
51
|
+
clientId={ clientId }
|
|
52
|
+
onSwitch={ onSwitch }
|
|
53
|
+
onHoverClassName={ setHoveredClassName }
|
|
54
|
+
itemRole="menuitem"
|
|
55
|
+
/>
|
|
21
56
|
</MenuGroup>
|
|
22
57
|
);
|
|
23
58
|
}
|
|
@@ -59,7 +59,7 @@ function BlockSelectionButton( { clientId, rootClientId, blockElement } ) {
|
|
|
59
59
|
hasBlockMovingClientId,
|
|
60
60
|
getBlockListSettings,
|
|
61
61
|
} = select( blockEditorStore );
|
|
62
|
-
const index = getBlockIndex( clientId
|
|
62
|
+
const index = getBlockIndex( clientId );
|
|
63
63
|
const { name, attributes } = getBlock( clientId );
|
|
64
64
|
const blockMovingMode = hasBlockMovingClientId();
|
|
65
65
|
return {
|
|
@@ -169,14 +169,8 @@ function BlockSelectionButton( { clientId, rootClientId, blockElement } ) {
|
|
|
169
169
|
if ( ( isEnter || isSpace ) && startingBlockClientId ) {
|
|
170
170
|
const sourceRoot = getBlockRootClientId( startingBlockClientId );
|
|
171
171
|
const destRoot = getBlockRootClientId( selectedBlockClientId );
|
|
172
|
-
const sourceBlockIndex = getBlockIndex(
|
|
173
|
-
|
|
174
|
-
sourceRoot
|
|
175
|
-
);
|
|
176
|
-
let destinationBlockIndex = getBlockIndex(
|
|
177
|
-
selectedBlockClientId,
|
|
178
|
-
destRoot
|
|
179
|
-
);
|
|
172
|
+
const sourceBlockIndex = getBlockIndex( startingBlockClientId );
|
|
173
|
+
let destinationBlockIndex = getBlockIndex( selectedBlockClientId );
|
|
180
174
|
if (
|
|
181
175
|
sourceBlockIndex < destinationBlockIndex &&
|
|
182
176
|
sourceRoot === destRoot
|
|
@@ -95,6 +95,17 @@ export default function BlockTools( {
|
|
|
95
95
|
} else if (
|
|
96
96
|
isMatch( 'core/block-editor/delete-multi-selection', event )
|
|
97
97
|
) {
|
|
98
|
+
/**
|
|
99
|
+
* Check if the target element is a text area, input or
|
|
100
|
+
* event.defaultPrevented and return early. In all these
|
|
101
|
+
* cases backspace could be handled elsewhere.
|
|
102
|
+
*/
|
|
103
|
+
if (
|
|
104
|
+
[ 'INPUT', 'TEXTAREA' ].includes( event.target.nodeName ) ||
|
|
105
|
+
event.defaultPrevented
|
|
106
|
+
) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
98
109
|
const clientIds = getSelectedBlockClientIds();
|
|
99
110
|
if ( clientIds.length > 1 ) {
|
|
100
111
|
event.preventDefault();
|
|
@@ -32,7 +32,7 @@ function InsertionPointPopover( {
|
|
|
32
32
|
__unstablePopoverSlot,
|
|
33
33
|
__unstableContentRef,
|
|
34
34
|
} ) {
|
|
35
|
-
const { selectBlock
|
|
35
|
+
const { selectBlock } = useDispatch( blockEditorStore );
|
|
36
36
|
const openRef = useContext( InsertionPointOpenRef );
|
|
37
37
|
const ref = useRef();
|
|
38
38
|
const {
|
|
@@ -195,14 +195,6 @@ function InsertionPointPopover( {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
function maybeHideInserterPoint( event ) {
|
|
199
|
-
// Only hide the inserter if it's triggered on the wrapper,
|
|
200
|
-
// and the inserter is not open.
|
|
201
|
-
if ( event.target === ref.current && ! openRef.current ) {
|
|
202
|
-
hideInsertionPoint();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
198
|
// Only show the in-between inserter between blocks, so when there's a
|
|
207
199
|
// previous and a next element.
|
|
208
200
|
const showInsertionPointInserter =
|
|
@@ -317,7 +309,6 @@ function InsertionPointPopover( {
|
|
|
317
309
|
className={ classnames( className, {
|
|
318
310
|
'is-with-inserter': showInsertionPointInserter,
|
|
319
311
|
} ) }
|
|
320
|
-
onHoverEnd={ maybeHideInserterPoint }
|
|
321
312
|
style={ style }
|
|
322
313
|
>
|
|
323
314
|
<motion.div
|
|
@@ -90,7 +90,6 @@ function ButtonBlockAppender(
|
|
|
90
90
|
export const ButtonBlockerAppender = forwardRef( ( props, ref ) => {
|
|
91
91
|
deprecated( `wp.blockEditor.ButtonBlockerAppender`, {
|
|
92
92
|
alternative: 'wp.blockEditor.ButtonBlockAppender',
|
|
93
|
-
since: '5.9',
|
|
94
93
|
} );
|
|
95
94
|
|
|
96
95
|
return ButtonBlockAppender( props, ref );
|
|
@@ -7,17 +7,8 @@ import { every, isEmpty } from 'lodash';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
__experimentalItem as Item,
|
|
13
|
-
__experimentalHStack as HStack,
|
|
14
|
-
__experimentalSpacer as Spacer,
|
|
15
|
-
FlexItem,
|
|
16
|
-
ColorIndicator,
|
|
17
|
-
PanelBody,
|
|
18
|
-
Dropdown,
|
|
19
|
-
} from '@wordpress/components';
|
|
20
|
-
import { sprintf, __, isRTL } from '@wordpress/i18n';
|
|
10
|
+
import { PanelBody, ColorIndicator } from '@wordpress/components';
|
|
11
|
+
import { sprintf, __ } from '@wordpress/i18n';
|
|
21
12
|
|
|
22
13
|
/**
|
|
23
14
|
* Internal dependencies
|
|
@@ -136,13 +127,6 @@ export const PanelColorGradientSettingsInner = ( {
|
|
|
136
127
|
</span>
|
|
137
128
|
);
|
|
138
129
|
|
|
139
|
-
let dropdownPosition;
|
|
140
|
-
let popoverProps;
|
|
141
|
-
if ( __experimentalIsRenderedInSidebar ) {
|
|
142
|
-
dropdownPosition = isRTL() ? 'bottom right' : 'bottom left';
|
|
143
|
-
popoverProps = { __unstableForcePosition: true };
|
|
144
|
-
}
|
|
145
|
-
|
|
146
130
|
return (
|
|
147
131
|
<PanelBody
|
|
148
132
|
className={ classnames(
|
|
@@ -152,63 +136,23 @@ export const PanelColorGradientSettingsInner = ( {
|
|
|
152
136
|
title={ showTitle ? titleElement : undefined }
|
|
153
137
|
{ ...props }
|
|
154
138
|
>
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
'block-editor-panel-color-gradient-settings__item',
|
|
173
|
-
{ 'is-open': isOpen }
|
|
174
|
-
) }
|
|
175
|
-
>
|
|
176
|
-
<HStack justify="flex-start">
|
|
177
|
-
<ColorIndicator
|
|
178
|
-
className="block-editor-panel-color-gradient-settings__color-indicator"
|
|
179
|
-
colorValue={
|
|
180
|
-
setting.gradientValue ??
|
|
181
|
-
setting.colorValue
|
|
182
|
-
}
|
|
183
|
-
/>
|
|
184
|
-
<FlexItem>{ setting.label }</FlexItem>
|
|
185
|
-
</HStack>
|
|
186
|
-
</Item>
|
|
187
|
-
);
|
|
188
|
-
} }
|
|
189
|
-
renderContent={ () => (
|
|
190
|
-
<ColorGradientControl
|
|
191
|
-
showTitle={ false }
|
|
192
|
-
{ ...{
|
|
193
|
-
colors,
|
|
194
|
-
gradients,
|
|
195
|
-
disableCustomColors,
|
|
196
|
-
disableCustomGradients,
|
|
197
|
-
__experimentalHasMultipleOrigins,
|
|
198
|
-
__experimentalIsRenderedInSidebar,
|
|
199
|
-
enableAlpha,
|
|
200
|
-
...setting,
|
|
201
|
-
} }
|
|
202
|
-
/>
|
|
203
|
-
) }
|
|
204
|
-
/>
|
|
205
|
-
) ) }
|
|
206
|
-
</ItemGroup>
|
|
207
|
-
{ !! children && (
|
|
208
|
-
<>
|
|
209
|
-
<Spacer marginY={ 4 } /> { children }
|
|
210
|
-
</>
|
|
211
|
-
) }
|
|
139
|
+
{ settings.map( ( setting, index ) => (
|
|
140
|
+
<ColorGradientControl
|
|
141
|
+
showTitle={ showTitle }
|
|
142
|
+
key={ index }
|
|
143
|
+
{ ...{
|
|
144
|
+
colors,
|
|
145
|
+
gradients,
|
|
146
|
+
disableCustomColors,
|
|
147
|
+
disableCustomGradients,
|
|
148
|
+
__experimentalHasMultipleOrigins,
|
|
149
|
+
__experimentalIsRenderedInSidebar,
|
|
150
|
+
enableAlpha,
|
|
151
|
+
...setting,
|
|
152
|
+
} }
|
|
153
|
+
/>
|
|
154
|
+
) ) }
|
|
155
|
+
{ children }
|
|
212
156
|
</PanelBody>
|
|
213
157
|
);
|
|
214
158
|
};
|
|
@@ -5,14 +5,13 @@
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.block-editor-panel-color-gradient-settings {
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
.component-color-indicator {
|
|
9
|
+
vertical-align: text-bottom;
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
+
&__panel-title {
|
|
12
13
|
.component-color-indicator {
|
|
13
|
-
|
|
14
|
-
height: $grid-unit-15;
|
|
15
|
-
align-self: center;
|
|
14
|
+
display: inline-block;
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -38,40 +37,4 @@
|
|
|
38
37
|
.block-editor-block-inspector & .components-base-control {
|
|
39
38
|
margin-bottom: inherit;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
.block-editor-panel-color-gradient-settings__dropdown {
|
|
43
|
-
display: block;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.block-editor-panel-color-gradient-settings__dropdown-content .components-popover__content {
|
|
48
|
-
& > div {
|
|
49
|
-
width: $sidebar-width;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@include break-medium() {
|
|
54
|
-
.block-editor-panel-color-gradient-settings__dropdown-content .components-popover__content {
|
|
55
|
-
margin-right: #{ math.div($sidebar-width, 2) + $grid-unit-20 } !important;
|
|
56
|
-
margin-top: #{ -($grid-unit-60 + $grid-unit-15) } !important;
|
|
57
|
-
}
|
|
58
40
|
}
|
|
59
|
-
|
|
60
|
-
.block-editor-panel-color-gradient-settings__dropdown:last-child > div {
|
|
61
|
-
border-bottom-width: 0;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.block-editor-panel-color-gradient-settings__item {
|
|
65
|
-
padding-top: $grid-unit-15 !important;
|
|
66
|
-
padding-bottom: $grid-unit-15 !important;
|
|
67
|
-
.block-editor-panel-color-gradient-settings__color-indicator {
|
|
68
|
-
// Show a diagonal line (crossed out) for empty swatches.
|
|
69
|
-
background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
&.is-open {
|
|
73
|
-
background: $gray-100;
|
|
74
|
-
color: var(--wp-admin-theme-color);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
@@ -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';
|
|
11
12
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
12
13
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
13
|
-
import { ENTER, SPACE } from '@wordpress/keycodes';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -26,12 +26,13 @@ export const ZWNBSP = '\ufeff';
|
|
|
26
26
|
|
|
27
27
|
export function DefaultBlockAppender( {
|
|
28
28
|
isLocked,
|
|
29
|
+
isVisible,
|
|
29
30
|
onAppend,
|
|
30
31
|
showPrompt,
|
|
31
32
|
placeholder,
|
|
32
33
|
rootClientId,
|
|
33
34
|
} ) {
|
|
34
|
-
if ( isLocked ) {
|
|
35
|
+
if ( isLocked || ! isVisible ) {
|
|
35
36
|
return null;
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -47,23 +48,20 @@ export function DefaultBlockAppender( {
|
|
|
47
48
|
>
|
|
48
49
|
<p
|
|
49
50
|
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
|
|
50
58
|
// We want this element to be styled as a paragraph by themes.
|
|
51
59
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
52
60
|
role="button"
|
|
53
|
-
aria-label={ __( 'Add
|
|
61
|
+
aria-label={ __( 'Add block' ) }
|
|
54
62
|
// A wrapping container for this one already has the wp-block className.
|
|
55
63
|
className="block-editor-default-block-appender__content"
|
|
56
|
-
|
|
57
|
-
if ( ENTER === event.keyCode || SPACE === event.keyCode ) {
|
|
58
|
-
onAppend();
|
|
59
|
-
}
|
|
60
|
-
} }
|
|
61
|
-
onClick={ () => onAppend() }
|
|
62
|
-
onFocus={ () => {
|
|
63
|
-
if ( showPrompt ) {
|
|
64
|
-
onAppend();
|
|
65
|
-
}
|
|
66
|
-
} }
|
|
64
|
+
onFocus={ onAppend }
|
|
67
65
|
>
|
|
68
66
|
{ showPrompt ? value : ZWNBSP }
|
|
69
67
|
</p>
|
|
@@ -79,14 +77,23 @@ export function DefaultBlockAppender( {
|
|
|
79
77
|
|
|
80
78
|
export default compose(
|
|
81
79
|
withSelect( ( select, ownProps ) => {
|
|
82
|
-
const {
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
const {
|
|
81
|
+
getBlockCount,
|
|
82
|
+
getBlockName,
|
|
83
|
+
isBlockValid,
|
|
84
|
+
getSettings,
|
|
85
|
+
getTemplateLock,
|
|
86
|
+
} = select( blockEditorStore );
|
|
85
87
|
|
|
86
88
|
const isEmpty = ! getBlockCount( ownProps.rootClientId );
|
|
89
|
+
const isLastBlockDefault =
|
|
90
|
+
getBlockName( ownProps.lastBlockClientId ) ===
|
|
91
|
+
getDefaultBlockName();
|
|
92
|
+
const isLastBlockValid = isBlockValid( ownProps.lastBlockClientId );
|
|
87
93
|
const { bodyPlaceholder } = getSettings();
|
|
88
94
|
|
|
89
95
|
return {
|
|
96
|
+
isVisible: isEmpty || ! isLastBlockDefault || ! isLastBlockValid,
|
|
90
97
|
showPrompt: isEmpty,
|
|
91
98
|
isLocked: !! getTemplateLock( ownProps.rootClientId ),
|
|
92
99
|
placeholder: bodyPlaceholder,
|
|
@@ -6,12 +6,24 @@ 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
|
|
9
|
+
aria-label="Add block"
|
|
10
10
|
className="block-editor-default-block-appender__content"
|
|
11
|
-
|
|
12
|
-
onFocus={
|
|
13
|
-
|
|
11
|
+
contentEditable={true}
|
|
12
|
+
onFocus={
|
|
13
|
+
[MockFunction] {
|
|
14
|
+
"calls": Array [
|
|
15
|
+
Array [],
|
|
16
|
+
],
|
|
17
|
+
"results": Array [
|
|
18
|
+
Object {
|
|
19
|
+
"type": "return",
|
|
20
|
+
"value": undefined,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
}
|
|
24
|
+
}
|
|
14
25
|
role="button"
|
|
26
|
+
suppressContentEditableWarning={true}
|
|
15
27
|
tabIndex="0"
|
|
16
28
|
>
|
|
17
29
|
Type / to choose a block
|
|
@@ -30,12 +42,12 @@ exports[`DefaultBlockAppender should match snapshot 1`] = `
|
|
|
30
42
|
data-root-client-id=""
|
|
31
43
|
>
|
|
32
44
|
<p
|
|
33
|
-
aria-label="Add
|
|
45
|
+
aria-label="Add block"
|
|
34
46
|
className="block-editor-default-block-appender__content"
|
|
35
|
-
|
|
36
|
-
onFocus={[
|
|
37
|
-
onKeyDown={[Function]}
|
|
47
|
+
contentEditable={true}
|
|
48
|
+
onFocus={[MockFunction]}
|
|
38
49
|
role="button"
|
|
50
|
+
suppressContentEditableWarning={true}
|
|
39
51
|
tabIndex="0"
|
|
40
52
|
>
|
|
41
53
|
Type / to choose a block
|
|
@@ -54,12 +66,12 @@ exports[`DefaultBlockAppender should optionally show without prompt 1`] = `
|
|
|
54
66
|
data-root-client-id=""
|
|
55
67
|
>
|
|
56
68
|
<p
|
|
57
|
-
aria-label="Add
|
|
69
|
+
aria-label="Add block"
|
|
58
70
|
className="block-editor-default-block-appender__content"
|
|
59
|
-
|
|
60
|
-
onFocus={[
|
|
61
|
-
onKeyDown={[Function]}
|
|
71
|
+
contentEditable={true}
|
|
72
|
+
onFocus={[MockFunction]}
|
|
62
73
|
role="button"
|
|
74
|
+
suppressContentEditableWarning={true}
|
|
63
75
|
tabIndex="0"
|
|
64
76
|
>
|
|
65
77
|
|
|
@@ -14,10 +14,16 @@ 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
|
+
|
|
17
23
|
it( 'should match snapshot', () => {
|
|
18
24
|
const onAppend = jest.fn();
|
|
19
25
|
const wrapper = shallow(
|
|
20
|
-
<DefaultBlockAppender onAppend={ onAppend } showPrompt />
|
|
26
|
+
<DefaultBlockAppender isVisible onAppend={ onAppend } showPrompt />
|
|
21
27
|
);
|
|
22
28
|
|
|
23
29
|
expect( wrapper ).toMatchSnapshot();
|
|
@@ -26,10 +32,10 @@ describe( 'DefaultBlockAppender', () => {
|
|
|
26
32
|
it( 'should append a default block when input focused', () => {
|
|
27
33
|
const onAppend = jest.fn();
|
|
28
34
|
const wrapper = shallow(
|
|
29
|
-
<DefaultBlockAppender onAppend={ onAppend } showPrompt />
|
|
35
|
+
<DefaultBlockAppender isVisible onAppend={ onAppend } showPrompt />
|
|
30
36
|
);
|
|
31
37
|
|
|
32
|
-
wrapper.find( 'p' ).simulate( '
|
|
38
|
+
wrapper.find( 'p' ).simulate( 'focus' );
|
|
33
39
|
|
|
34
40
|
expect( wrapper ).toMatchSnapshot();
|
|
35
41
|
|
|
@@ -39,7 +45,11 @@ describe( 'DefaultBlockAppender', () => {
|
|
|
39
45
|
it( 'should optionally show without prompt', () => {
|
|
40
46
|
const onAppend = jest.fn();
|
|
41
47
|
const wrapper = shallow(
|
|
42
|
-
<DefaultBlockAppender
|
|
48
|
+
<DefaultBlockAppender
|
|
49
|
+
isVisible
|
|
50
|
+
onAppend={ onAppend }
|
|
51
|
+
showPrompt={ false }
|
|
52
|
+
/>
|
|
43
53
|
);
|
|
44
54
|
const input = wrapper.find( 'p' );
|
|
45
55
|
|