@wordpress/block-editor 8.0.13 → 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 +30 -6
- 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/font-appearance-control/index.js +11 -11
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/iframe/index.js +6 -9
- 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 +31 -6
- 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/font-appearance-control/index.js +12 -12
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +6 -9
- 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 +33 -3
- 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/font-appearance-control/index.js +12 -12
- package/src/components/iframe/index.js +10 -10
- 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
|
@@ -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
|
}
|
|
@@ -3,54 +3,54 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { CustomSelectControl } from '@wordpress/components';
|
|
5
5
|
import { useMemo } from '@wordpress/element';
|
|
6
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
7
7
|
|
|
8
8
|
const FONT_STYLES = [
|
|
9
9
|
{
|
|
10
|
-
name:
|
|
10
|
+
name: _x( 'Regular', 'font style' ),
|
|
11
11
|
value: 'normal',
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
|
-
name:
|
|
14
|
+
name: _x( 'Italic', 'font style' ),
|
|
15
15
|
value: 'italic',
|
|
16
16
|
},
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
const FONT_WEIGHTS = [
|
|
20
20
|
{
|
|
21
|
-
name:
|
|
21
|
+
name: _x( 'Thin', 'font weight' ),
|
|
22
22
|
value: '100',
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
name:
|
|
25
|
+
name: _x( 'Extra Light', 'font weight' ),
|
|
26
26
|
value: '200',
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
|
-
name:
|
|
29
|
+
name: _x( 'Light', 'font weight' ),
|
|
30
30
|
value: '300',
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
name:
|
|
33
|
+
name: _x( 'Regular', 'font weight' ),
|
|
34
34
|
value: '400',
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
name:
|
|
37
|
+
name: _x( 'Medium', 'font weight' ),
|
|
38
38
|
value: '500',
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
name:
|
|
41
|
+
name: _x( 'Semi Bold', 'font weight' ),
|
|
42
42
|
value: '600',
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
|
-
name:
|
|
45
|
+
name: _x( 'Bold', 'font weight' ),
|
|
46
46
|
value: '700',
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
-
name:
|
|
49
|
+
name: _x( 'Extra Bold', 'font weight' ),
|
|
50
50
|
value: '800',
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
|
-
name:
|
|
53
|
+
name: _x( 'Black', 'font weight' ),
|
|
54
54
|
value: '900',
|
|
55
55
|
},
|
|
56
56
|
];
|
|
@@ -75,13 +75,9 @@ function styleSheetsCompat( doc ) {
|
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
if ( isMatch && ! doc.getElementById( ownerNode.id ) ) {
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
For blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).
|
|
82
|
-
For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`,
|
|
83
|
-
ownerNode.outerHTML
|
|
84
|
-
);
|
|
78
|
+
// Display warning once we have a way to add style dependencies to the editor.
|
|
79
|
+
// See: https://github.com/WordPress/gutenberg/pull/37466.
|
|
80
|
+
|
|
85
81
|
doc.head.appendChild( ownerNode.cloneNode( true ) );
|
|
86
82
|
|
|
87
83
|
// Add inline styles belonging to the stylesheet.
|
|
@@ -164,12 +160,15 @@ async function loadScript( head, { id, src } ) {
|
|
|
164
160
|
} );
|
|
165
161
|
}
|
|
166
162
|
|
|
167
|
-
function Iframe(
|
|
163
|
+
function Iframe(
|
|
164
|
+
{ contentRef, children, head, tabIndex = 0, assets, ...props },
|
|
165
|
+
ref
|
|
166
|
+
) {
|
|
168
167
|
const [ , forceRender ] = useReducer( () => ( {} ) );
|
|
169
168
|
const [ iframeDocument, setIframeDocument ] = useState();
|
|
170
169
|
const [ bodyClasses, setBodyClasses ] = useState( [] );
|
|
171
|
-
const styles = useParsedAssets(
|
|
172
|
-
const scripts = useParsedAssets(
|
|
170
|
+
const styles = useParsedAssets( assets?.styles );
|
|
171
|
+
const scripts = useParsedAssets( assets?.scripts );
|
|
173
172
|
const clearerRef = useBlockSelectionClearer();
|
|
174
173
|
const [ before, writingFlowRef, after ] = useWritingFlow();
|
|
175
174
|
const setRef = useRefEffect( ( node ) => {
|
|
@@ -192,6 +191,7 @@ function Iframe( { contentRef, children, head, tabIndex = 0, ...props }, ref ) {
|
|
|
192
191
|
Array.from( ownerDocument.body.classList ).filter(
|
|
193
192
|
( name ) =>
|
|
194
193
|
name.startsWith( 'admin-color-' ) ||
|
|
194
|
+
name.startsWith( 'post-type-' ) ||
|
|
195
195
|
name === 'wp-embed-responsive'
|
|
196
196
|
)
|
|
197
197
|
);
|
package/src/components/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export { default as BlockColorsStyleSelector } from './color-style-selector';
|
|
|
24
24
|
export { default as BlockEdit, useBlockEditContext } from './block-edit';
|
|
25
25
|
export { default as BlockIcon } from './block-icon';
|
|
26
26
|
export { default as BlockNavigationDropdown } from './block-navigation/dropdown';
|
|
27
|
+
export { default as BlockStyles } from './block-styles';
|
|
27
28
|
export { default as __experimentalBlockVariationPicker } from './block-variation-picker';
|
|
28
29
|
export { default as __experimentalBlockPatternSetup } from './block-pattern-setup';
|
|
29
30
|
export { default as __experimentalBlockVariationTransforms } from './block-variation-transforms';
|
|
@@ -48,6 +49,7 @@ export { default as __experimentalLetterSpacingControl } from './letter-spacing-
|
|
|
48
49
|
export { default as __experimentalTextDecorationControl } from './text-decoration-control';
|
|
49
50
|
export { default as __experimentalTextTransformControl } from './text-transform-control';
|
|
50
51
|
export { default as __experimentalColorGradientControl } from './colors-gradients/control';
|
|
52
|
+
export { default as __experimentalColorGradientSettingsDropdown } from './colors-gradients/dropdown';
|
|
51
53
|
export { default as __experimentalPanelColorGradientSettings } from './colors-gradients/panel-color-gradient-settings';
|
|
52
54
|
export {
|
|
53
55
|
default as __experimentalImageEditor,
|
|
@@ -140,7 +142,6 @@ export {
|
|
|
140
142
|
} from './typewriter';
|
|
141
143
|
export { default as Warning } from './warning';
|
|
142
144
|
export { default as WritingFlow } from './writing-flow';
|
|
143
|
-
export { useCanvasClickRedirect as __unstableUseCanvasClickRedirect } from './use-canvas-click-redirect';
|
|
144
145
|
export { default as useBlockDisplayInformation } from './use-block-display-information';
|
|
145
146
|
export { default as __unstableIframe } from './iframe';
|
|
146
147
|
export { default as __experimentalUseNoRecursiveRenders } from './use-no-recursive-renders';
|
|
@@ -54,6 +54,7 @@ export { default as __experimentalPanelColorGradientSettings } from './colors-gr
|
|
|
54
54
|
export { default as useSetting } from './use-setting';
|
|
55
55
|
export { default as __experimentalUseNoRecursiveRenders } from './use-no-recursive-renders';
|
|
56
56
|
export { default as Warning } from './warning';
|
|
57
|
+
export { default as ContrastChecker } from './contrast-checker';
|
|
57
58
|
|
|
58
59
|
export {
|
|
59
60
|
BottomSheetSettings,
|
|
@@ -41,6 +41,8 @@ _Note:_ A block can render at most a single `InnerBlocks` and `InnerBlocks.Conte
|
|
|
41
41
|
|
|
42
42
|
_Note:_ Because the save step will automatically apply props to the element returned by `save`, it is important to include the wrapping `div` in the above simple example even though we are applying no props of our own. In a real-world example, you may have your own attributes to apply to the saved markup, or sibling content adjacent to the rendered nested blocks.
|
|
43
43
|
|
|
44
|
+
_Note:_ Inner blocks, by default, are not visible inside a WordPress excerpt. If you wish your block to appear then it needs to be returned from the `excerpt_allowed_wrapper_blocks` filter. More details can be found on the [filter reference page](https://developer.wordpress.org/reference/hooks/excerpt_allowed_wrapper_blocks/) page, as well as the [excerpt_remove_blocks](https://developer.wordpress.org/reference/functions/excerpt_remove_blocks/) page.
|
|
45
|
+
|
|
44
46
|
## Props
|
|
45
47
|
|
|
46
48
|
### `allowedBlocks`
|
|
@@ -16,13 +16,8 @@ import BaseDefaultBlockAppender from '../default-block-appender';
|
|
|
16
16
|
import withClientId from './with-client-id';
|
|
17
17
|
import { store as blockEditorStore } from '../../store';
|
|
18
18
|
|
|
19
|
-
export const DefaultBlockAppender = ( { clientId
|
|
20
|
-
return
|
|
21
|
-
<BaseDefaultBlockAppender
|
|
22
|
-
rootClientId={ clientId }
|
|
23
|
-
lastBlockClientId={ lastBlockClientId }
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
19
|
+
export const DefaultBlockAppender = ( { clientId } ) => {
|
|
20
|
+
return <BaseDefaultBlockAppender rootClientId={ clientId } />;
|
|
26
21
|
};
|
|
27
22
|
|
|
28
23
|
export default compose( [
|
|
@@ -11,6 +11,8 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
|
11
11
|
import { store as blockEditorStore } from '../../store';
|
|
12
12
|
import { getLayoutType } from '../../layouts';
|
|
13
13
|
|
|
14
|
+
/** @typedef {import('../../selectors').WPDirectInsertBlock } WPDirectInsertBlock */
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* This hook is a side effect which updates the block-editor store when changes
|
|
16
18
|
* happen to inner block settings. The given props are transformed into a
|
|
@@ -18,20 +20,20 @@ import { getLayoutType } from '../../layouts';
|
|
|
18
20
|
* the block-editor store, then the store is updated with the new settings which
|
|
19
21
|
* came from props.
|
|
20
22
|
*
|
|
21
|
-
* @param {string}
|
|
22
|
-
* @param {string[]}
|
|
23
|
-
*
|
|
24
|
-
* @param {?
|
|
25
|
-
* @param {?Function|boolean}
|
|
26
|
-
*
|
|
27
|
-
* @param {string}
|
|
28
|
-
*
|
|
29
|
-
* @param {boolean}
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @param {string}
|
|
33
|
-
*
|
|
34
|
-
* @param {Object}
|
|
23
|
+
* @param {string} clientId The client ID of the block to update.
|
|
24
|
+
* @param {string[]} allowedBlocks An array of block names which are permitted
|
|
25
|
+
* in inner blocks.
|
|
26
|
+
* @param {?WPDirectInsertBlock} __experimentalDefaultBlock The default block to insert: [ blockName, { blockAttributes } ].
|
|
27
|
+
* @param {?Function|boolean} __experimentalDirectInsert If a default block should be inserted directly by the
|
|
28
|
+
* appender.
|
|
29
|
+
* @param {string} [templateLock] The template lock specified for the inner
|
|
30
|
+
* blocks component. (e.g. "all")
|
|
31
|
+
* @param {boolean} captureToolbars Whether or children toolbars should be shown
|
|
32
|
+
* in the inner blocks component rather than on
|
|
33
|
+
* the child block.
|
|
34
|
+
* @param {string} orientation The direction in which the block
|
|
35
|
+
* should face.
|
|
36
|
+
* @param {Object} layout The layout object for the block container.
|
|
35
37
|
*/
|
|
36
38
|
export default function useNestedSettingsUpdate(
|
|
37
39
|
clientId,
|
|
@@ -176,7 +176,7 @@ class Inserter extends Component {
|
|
|
176
176
|
onSelectOrClose,
|
|
177
177
|
} = this.props;
|
|
178
178
|
|
|
179
|
-
if ( hasSingleBlockType || directInsertBlock
|
|
179
|
+
if ( hasSingleBlockType || directInsertBlock ) {
|
|
180
180
|
return this.renderToggle( { onToggle: insertOnlyAllowedBlock } );
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -251,10 +251,68 @@ export default compose( [
|
|
|
251
251
|
onSelectOrClose,
|
|
252
252
|
} = ownProps;
|
|
253
253
|
|
|
254
|
-
if ( ! hasSingleBlockType && ! directInsertBlock
|
|
254
|
+
if ( ! hasSingleBlockType && ! directInsertBlock ) {
|
|
255
255
|
return;
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
function getAdjacentBlockAttributes( attributesToCopy ) {
|
|
259
|
+
const { getBlock, getPreviousBlockClientId } = select(
|
|
260
|
+
blockEditorStore
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
if (
|
|
264
|
+
! attributesToCopy ||
|
|
265
|
+
( ! clientId && ! rootClientId )
|
|
266
|
+
) {
|
|
267
|
+
return {};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const result = {};
|
|
271
|
+
let adjacentAttributes = {};
|
|
272
|
+
|
|
273
|
+
// If there is no clientId, then attempt to get attributes
|
|
274
|
+
// from the last block within innerBlocks of the root block.
|
|
275
|
+
if ( ! clientId ) {
|
|
276
|
+
const parentBlock = getBlock( rootClientId );
|
|
277
|
+
|
|
278
|
+
if ( parentBlock?.innerBlocks?.length ) {
|
|
279
|
+
const lastInnerBlock =
|
|
280
|
+
parentBlock.innerBlocks[
|
|
281
|
+
parentBlock.innerBlocks.length - 1
|
|
282
|
+
];
|
|
283
|
+
|
|
284
|
+
if (
|
|
285
|
+
directInsertBlock &&
|
|
286
|
+
directInsertBlock?.name === lastInnerBlock.name
|
|
287
|
+
) {
|
|
288
|
+
adjacentAttributes = lastInnerBlock.attributes;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
292
|
+
// Otherwise, attempt to get attributes from the
|
|
293
|
+
// previous block relative to the current clientId.
|
|
294
|
+
const currentBlock = getBlock( clientId );
|
|
295
|
+
const previousBlock = getBlock(
|
|
296
|
+
getPreviousBlockClientId( clientId )
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
if ( currentBlock?.name === previousBlock?.name ) {
|
|
300
|
+
adjacentAttributes =
|
|
301
|
+
previousBlock?.attributes || {};
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Copy over only those attributes flagged to be copied.
|
|
306
|
+
attributesToCopy.forEach( ( attribute ) => {
|
|
307
|
+
if ( adjacentAttributes.hasOwnProperty( attribute ) ) {
|
|
308
|
+
result[ attribute ] =
|
|
309
|
+
adjacentAttributes[ attribute ];
|
|
310
|
+
}
|
|
311
|
+
} );
|
|
312
|
+
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
315
|
+
|
|
258
316
|
function getInsertionIndex() {
|
|
259
317
|
const {
|
|
260
318
|
getBlockIndex,
|
|
@@ -284,9 +342,23 @@ export default compose( [
|
|
|
284
342
|
|
|
285
343
|
const { insertBlock } = dispatch( blockEditorStore );
|
|
286
344
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
345
|
+
let blockToInsert;
|
|
346
|
+
|
|
347
|
+
// Attempt to augment the directInsertBlock with attributes from an adjacent block.
|
|
348
|
+
// This ensures styling from nearby blocks is preserved in the newly inserted block.
|
|
349
|
+
// See: https://github.com/WordPress/gutenberg/issues/37904
|
|
350
|
+
if ( directInsertBlock ) {
|
|
351
|
+
const newAttributes = getAdjacentBlockAttributes(
|
|
352
|
+
directInsertBlock.attributesToCopy
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
blockToInsert = createBlock( directInsertBlock.name, {
|
|
356
|
+
...( directInsertBlock.attributes || {} ),
|
|
357
|
+
...newAttributes,
|
|
358
|
+
} );
|
|
359
|
+
} else {
|
|
360
|
+
blockToInsert = createBlock( allowedBlockType.name );
|
|
361
|
+
}
|
|
290
362
|
|
|
291
363
|
insertBlock( blockToInsert, getInsertionIndex(), rootClientId );
|
|
292
364
|
|
|
@@ -7,7 +7,7 @@ import { delay } from 'lodash';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { __, _x } from '@wordpress/i18n';
|
|
11
11
|
import { Dropdown, ToolbarButton, Picker } from '@wordpress/components';
|
|
12
12
|
import { Component } from '@wordpress/element';
|
|
13
13
|
import { withDispatch, withSelect } from '@wordpress/data';
|
|
@@ -34,7 +34,7 @@ const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
|
|
|
34
34
|
|
|
35
35
|
const defaultRenderToggle = ( { onToggle, disabled, style, onLongPress } ) => (
|
|
36
36
|
<ToolbarButton
|
|
37
|
-
title={
|
|
37
|
+
title={ _x( 'Add block', 'Generic label for block inserter button' ) }
|
|
38
38
|
icon={
|
|
39
39
|
<Icon
|
|
40
40
|
icon={ plusCircleFilled }
|
|
@@ -7,6 +7,7 @@ import { noop } from 'lodash';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect } from '@wordpress/data';
|
|
10
|
+
import { forwardRef } from '@wordpress/element';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
@@ -14,17 +15,20 @@ import { useSelect } from '@wordpress/data';
|
|
|
14
15
|
import InserterMenu from './menu';
|
|
15
16
|
import { store as blockEditorStore } from '../../store';
|
|
16
17
|
|
|
17
|
-
function InserterLibrary(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
function InserterLibrary(
|
|
19
|
+
{
|
|
20
|
+
rootClientId,
|
|
21
|
+
clientId,
|
|
22
|
+
isAppender,
|
|
23
|
+
showInserterHelpPanel,
|
|
24
|
+
showMostUsedBlocks = false,
|
|
25
|
+
__experimentalInsertionIndex,
|
|
26
|
+
__experimentalFilterValue,
|
|
27
|
+
onSelect = noop,
|
|
28
|
+
shouldFocusBlock = false,
|
|
29
|
+
},
|
|
30
|
+
ref
|
|
31
|
+
) {
|
|
28
32
|
const destinationRootClientId = useSelect(
|
|
29
33
|
( select ) => {
|
|
30
34
|
const { getBlockRootClientId } = select( blockEditorStore );
|
|
@@ -47,8 +51,9 @@ function InserterLibrary( {
|
|
|
47
51
|
__experimentalInsertionIndex={ __experimentalInsertionIndex }
|
|
48
52
|
__experimentalFilterValue={ __experimentalFilterValue }
|
|
49
53
|
shouldFocusBlock={ shouldFocusBlock }
|
|
54
|
+
ref={ ref }
|
|
50
55
|
/>
|
|
51
56
|
);
|
|
52
57
|
}
|
|
53
58
|
|
|
54
|
-
export default InserterLibrary;
|
|
59
|
+
export default forwardRef( InserterLibrary );
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
forwardRef,
|
|
6
|
+
useState,
|
|
7
|
+
useCallback,
|
|
8
|
+
useMemo,
|
|
9
|
+
useImperativeHandle,
|
|
10
|
+
useRef,
|
|
11
|
+
} from '@wordpress/element';
|
|
5
12
|
import { VisuallyHidden, SearchControl } from '@wordpress/components';
|
|
6
13
|
import { __ } from '@wordpress/i18n';
|
|
7
14
|
import { useSelect } from '@wordpress/data';
|
|
@@ -19,17 +26,20 @@ import useInsertionPoint from './hooks/use-insertion-point';
|
|
|
19
26
|
import InserterTabs from './tabs';
|
|
20
27
|
import { store as blockEditorStore } from '../../store';
|
|
21
28
|
|
|
22
|
-
function InserterMenu(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
function InserterMenu(
|
|
30
|
+
{
|
|
31
|
+
rootClientId,
|
|
32
|
+
clientId,
|
|
33
|
+
isAppender,
|
|
34
|
+
__experimentalInsertionIndex,
|
|
35
|
+
onSelect,
|
|
36
|
+
showInserterHelpPanel,
|
|
37
|
+
showMostUsedBlocks,
|
|
38
|
+
__experimentalFilterValue = '',
|
|
39
|
+
shouldFocusBlock = true,
|
|
40
|
+
},
|
|
41
|
+
ref
|
|
42
|
+
) {
|
|
33
43
|
const [ filterValue, setFilterValue ] = useState(
|
|
34
44
|
__experimentalFilterValue
|
|
35
45
|
);
|
|
@@ -168,6 +178,13 @@ function InserterMenu( {
|
|
|
168
178
|
[ blocksTab, patternsTab, reusableBlocksTab ]
|
|
169
179
|
);
|
|
170
180
|
|
|
181
|
+
const searchRef = useRef();
|
|
182
|
+
useImperativeHandle( ref, () => ( {
|
|
183
|
+
focusSearch: () => {
|
|
184
|
+
searchRef.current.focus();
|
|
185
|
+
},
|
|
186
|
+
} ) );
|
|
187
|
+
|
|
171
188
|
return (
|
|
172
189
|
<div className="block-editor-inserter__menu">
|
|
173
190
|
<div className="block-editor-inserter__main-area">
|
|
@@ -182,6 +199,7 @@ function InserterMenu( {
|
|
|
182
199
|
value={ filterValue }
|
|
183
200
|
label={ __( 'Search for blocks and patterns' ) }
|
|
184
201
|
placeholder={ __( 'Search' ) }
|
|
202
|
+
ref={ searchRef }
|
|
185
203
|
/>
|
|
186
204
|
{ !! filterValue && (
|
|
187
205
|
<InserterSearchResults
|
|
@@ -219,4 +237,4 @@ function InserterMenu( {
|
|
|
219
237
|
);
|
|
220
238
|
}
|
|
221
239
|
|
|
222
|
-
export default InserterMenu;
|
|
240
|
+
export default forwardRef( InserterMenu );
|
|
@@ -63,7 +63,7 @@ function InserterTabs( {
|
|
|
63
63
|
}, [ tabIndex ] );
|
|
64
64
|
|
|
65
65
|
const { tabs, tabKeys } = useMemo( () => {
|
|
66
|
-
const filteredTabs = InserterTabs.
|
|
66
|
+
const filteredTabs = InserterTabs.getTabs().filter(
|
|
67
67
|
( { name } ) => showReusableBlocks || name !== 'reusable'
|
|
68
68
|
);
|
|
69
69
|
return {
|
|
@@ -114,8 +114,9 @@ function InserterTabs( {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
function TabsControl( { onChangeTab, showReusableBlocks } ) {
|
|
117
|
+
const tabs = InserterTabs.getTabs();
|
|
117
118
|
const segments = useMemo( () => {
|
|
118
|
-
const filteredTabs =
|
|
119
|
+
const filteredTabs = tabs.filter(
|
|
119
120
|
( { name } ) => showReusableBlocks || name !== 'reusable'
|
|
120
121
|
);
|
|
121
122
|
return filteredTabs.map( ( { title } ) => title );
|
|
@@ -123,7 +124,7 @@ function TabsControl( { onChangeTab, showReusableBlocks } ) {
|
|
|
123
124
|
|
|
124
125
|
const segmentHandler = useCallback(
|
|
125
126
|
( selectedTab ) => {
|
|
126
|
-
const tabTitles =
|
|
127
|
+
const tabTitles = tabs.map( ( { title } ) => title );
|
|
127
128
|
onChangeTab( tabTitles.indexOf( selectedTab ) );
|
|
128
129
|
},
|
|
129
130
|
[ onChangeTab ]
|
|
@@ -139,7 +140,7 @@ function TabsControl( { onChangeTab, showReusableBlocks } ) {
|
|
|
139
140
|
|
|
140
141
|
InserterTabs.Control = TabsControl;
|
|
141
142
|
|
|
142
|
-
InserterTabs.
|
|
143
|
+
InserterTabs.getTabs = () => [
|
|
143
144
|
{ name: 'blocks', title: __( 'Blocks' ), component: BlockTypesTab },
|
|
144
145
|
{ name: 'reusable', title: __( 'Reusable' ), component: ReusableBlocksTab },
|
|
145
146
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { render } from 'test/helpers';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -13,9 +13,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
13
13
|
*/
|
|
14
14
|
import items from './fixtures';
|
|
15
15
|
import BlockTypesTab from '../block-types-tab';
|
|
16
|
-
import BlockTypesList from '../../block-types-list';
|
|
17
16
|
|
|
18
|
-
jest.mock( '../../block-types-list' );
|
|
19
17
|
jest.mock( '../hooks/use-clipboard-block' );
|
|
20
18
|
jest.mock( '@wordpress/data/src/components/use-select' );
|
|
21
19
|
|
|
@@ -35,11 +33,11 @@ describe( 'BlockTypesTab component', () => {
|
|
|
35
33
|
} );
|
|
36
34
|
|
|
37
35
|
it( 'renders without crashing', () => {
|
|
38
|
-
const component =
|
|
36
|
+
const component = render(
|
|
39
37
|
<BlockTypesTab
|
|
40
38
|
rootClientId={ 0 }
|
|
41
39
|
onSelect={ jest.fn() }
|
|
42
|
-
listProps={ {} }
|
|
40
|
+
listProps={ { contentContainerStyle: {} } }
|
|
43
41
|
/>
|
|
44
42
|
);
|
|
45
43
|
expect( component ).toBeTruthy();
|
|
@@ -52,15 +50,16 @@ describe( 'BlockTypesTab component', () => {
|
|
|
52
50
|
( { id, category } ) =>
|
|
53
51
|
category !== 'reusable' && id !== 'core-embed/a-paragraph-embed'
|
|
54
52
|
);
|
|
55
|
-
const component =
|
|
53
|
+
const component = render(
|
|
56
54
|
<BlockTypesTab
|
|
57
55
|
rootClientId={ 0 }
|
|
58
56
|
onSelect={ jest.fn() }
|
|
59
|
-
listProps={ {} }
|
|
57
|
+
listProps={ { contentContainerStyle: {} } }
|
|
60
58
|
/>
|
|
61
59
|
);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
|
|
61
|
+
blockItems.forEach( ( item ) => {
|
|
62
|
+
expect( component.getByText( item.title ) ).toBeTruthy();
|
|
63
|
+
} );
|
|
65
64
|
} );
|
|
66
65
|
} );
|