@wordpress/block-editor 12.9.1-next.5a1d1283.0 → 12.10.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 +6 -0
- package/README.md +33 -3
- package/build/components/block-canvas/index.js +107 -0
- package/build/components/block-canvas/index.js.map +1 -0
- package/build/components/block-inspector/index.js +4 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +19 -4
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +66 -0
- package/build/components/block-patterns-paging/index.js.map +1 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js +28 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +4 -7
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -0
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js +3 -7
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +18 -7
- package/build/components/block-tools/block-contextual-toolbar.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/border-radius-control/input-controls.js +1 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +2 -4
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/default-block-appender/index.native.js +20 -1
- package/build/components/default-block-appender/index.native.js.map +1 -1
- package/build/components/duotone/utils.js +68 -0
- package/build/components/duotone/utils.js.map +1 -1
- package/build/components/editor-styles/index.js +28 -9
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -101
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +61 -0
- package/build/components/global-styles/image-settings-panel.js.map +1 -0
- package/build/components/global-styles/index.js +11 -17
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +19 -15
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +67 -33
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +2 -5
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/use-transform-image.js +9 -9
- package/build/components/image-editor/use-transform-image.js.map +1 -1
- package/build/components/index.js +8 -12
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +6 -5
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +13 -7
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +12 -6
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +57 -23
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +24 -9
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-source-filter.js +54 -0
- package/build/components/inserter/block-patterns-source-filter.js.map +1 -0
- package/build/components/inserter/block-patterns-sync-filter.js +46 -0
- package/build/components/inserter/block-patterns-sync-filter.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +91 -45
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.js +57 -0
- package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -0
- package/build/components/inserter/hooks/use-patterns-state.js +21 -10
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/menu.js +13 -11
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/search-results.js +4 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -12
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +12 -1
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build/components/inspector-controls/fill.js +24 -13
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/groups.js +5 -3
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +13 -0
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/link-control/index.js +12 -2
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -3
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +13 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +29 -24
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-placeholder/index.js +2 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +11 -11
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js +2 -3
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/constants.js +30 -0
- package/build/components/media-upload/constants.js.map +1 -0
- package/build/components/media-upload/index.native.js +63 -53
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +1 -1
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/index.js +34 -35
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +14 -32
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/multiline.js +95 -0
- package/build/components/rich-text/multiline.js.map +1 -0
- package/build/components/rich-text/split-value.js +10 -16
- package/build/components/rich-text/split-value.js.map +1 -1
- package/build/components/rich-text/use-enter.js +31 -40
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +18 -33
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/use-block-commands/index.js +30 -18
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +5 -2
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/background.js +258 -0
- package/build/hooks/background.js.map +1 -0
- package/build/hooks/block-hooks.js +188 -0
- package/build/hooks/block-hooks.js.map +1 -0
- package/build/hooks/block-rename-ui.js +160 -0
- package/build/hooks/block-rename-ui.js.map +1 -0
- package/build/hooks/duotone.js +29 -42
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +2 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +31 -14
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +4 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +10 -3
- package/build/hooks/style.js.map +1 -1
- package/build/private-apis.js +2 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +33 -10
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +42 -8
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +23 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +43 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +84 -23
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +0 -4
- package/build/store/utils.js.map +1 -1
- package/build-module/components/block-canvas/index.js +97 -0
- package/build-module/components/block-canvas/index.js.map +1 -0
- package/build-module/components/block-inspector/index.js +4 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +20 -5
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +59 -0
- package/build-module/components/block-patterns-paging/index.js.map +1 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +28 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +4 -7
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -0
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js +3 -7
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +18 -7
- package/build-module/components/block-tools/block-contextual-toolbar.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/border-radius-control/input-controls.js +1 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +2 -4
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/default-block-appender/index.native.js +20 -1
- package/build-module/components/default-block-appender/index.native.js.map +1 -1
- package/build-module/components/duotone/utils.js +65 -0
- package/build-module/components/duotone/utils.js.map +1 -1
- package/build-module/components/editor-styles/index.js +28 -9
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +3 -100
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +53 -0
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -0
- package/build-module/components/global-styles/index.js +2 -2
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +18 -16
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +66 -33
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -5
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/use-transform-image.js +9 -9
- package/build-module/components/image-editor/use-transform-image.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/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +14 -8
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +12 -6
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +59 -25
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +23 -9
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-source-filter.js +44 -0
- package/build-module/components/inserter/block-patterns-source-filter.js.map +1 -0
- package/build-module/components/inserter/block-patterns-sync-filter.js +38 -0
- package/build-module/components/inserter/block-patterns-sync-filter.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +87 -46
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.js +50 -0
- package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -0
- package/build-module/components/inserter/hooks/use-patterns-state.js +22 -10
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/menu.js +13 -11
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/search-results.js +4 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -12
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +13 -2
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +25 -14
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +5 -3
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +15 -1
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/link-control/index.js +12 -2
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +1 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +13 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +30 -25
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +2 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +7 -7
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +2 -3
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/constants.js +14 -0
- package/build-module/components/media-upload/constants.js.map +1 -0
- package/build-module/components/media-upload/index.native.js +53 -34
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +1 -1
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +35 -37
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +15 -33
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/multiline.js +87 -0
- package/build-module/components/rich-text/multiline.js.map +1 -0
- package/build-module/components/rich-text/split-value.js +10 -16
- package/build-module/components/rich-text/split-value.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +33 -42
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +19 -34
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +2 -2
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +28 -16
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +5 -2
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/background.js +244 -0
- package/build-module/hooks/background.js.map +1 -0
- package/build-module/hooks/block-hooks.js +181 -0
- package/build-module/hooks/block-hooks.js.map +1 -0
- package/build-module/hooks/block-rename-ui.js +153 -0
- package/build-module/hooks/block-rename-ui.js.map +1 -0
- package/build-module/hooks/duotone.js +26 -39
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -2
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +33 -16
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +4 -2
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +10 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +33 -10
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +39 -8
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +21 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +41 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +78 -22
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +0 -4
- package/build-module/store/utils.js.map +1 -1
- package/build-style/content-rtl.css +0 -1
- package/build-style/content.css +0 -1
- package/build-style/style-rtl.css +170 -127
- package/build-style/style.css +170 -127
- package/package.json +32 -32
- package/src/components/block-canvas/index.js +108 -0
- package/src/components/block-inspector/index.js +5 -1
- package/src/components/block-list/content.scss +0 -1
- package/src/components/block-patterns-list/index.js +32 -7
- package/src/components/block-patterns-list/style.scss +26 -9
- package/src/components/block-patterns-paging/index.js +92 -0
- package/src/components/block-patterns-paging/style.scss +42 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +44 -0
- package/src/components/block-settings-menu-controls/index.js +4 -9
- package/src/components/block-styles/index.js +1 -0
- package/src/components/block-styles/style.scss +3 -3
- package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -6
- package/src/components/block-tools/block-contextual-toolbar.js +16 -5
- package/src/components/block-tools/block-selection-button.js +9 -1
- package/src/components/block-tools/style.scss +0 -98
- package/src/components/border-radius-control/input-controls.js +1 -1
- package/src/components/border-radius-control/linked-button.js +8 -11
- package/src/components/color-palette/test/__snapshots__/control.js.snap +34 -21
- package/src/components/colors/with-colors.js +3 -2
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -35
- package/src/components/default-block-appender/index.native.js +26 -3
- package/src/components/duotone/utils.js +65 -0
- package/src/components/editor-styles/index.js +32 -23
- package/src/components/global-styles/hooks.js +4 -112
- package/src/components/global-styles/image-settings-panel.js +71 -0
- package/src/components/global-styles/index.js +4 -3
- package/src/components/global-styles/use-global-styles-output.js +25 -16
- package/src/components/global-styles/utils.js +1 -2
- package/src/components/iframe/index.js +72 -33
- package/src/components/image-editor/use-save-image.js +2 -9
- package/src/components/image-editor/use-transform-image.js +9 -9
- package/src/components/index.js +1 -1
- package/src/components/index.native.js +2 -2
- package/src/components/inner-blocks/use-nested-settings-update.js +15 -10
- package/src/components/inserter/block-patterns-explorer/explorer.js +17 -5
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +109 -40
- package/src/components/inserter/block-patterns-explorer/sidebar.js +23 -8
- package/src/components/inserter/block-patterns-source-filter.js +40 -0
- package/src/components/inserter/block-patterns-sync-filter.js +35 -0
- package/src/components/inserter/block-patterns-tab.js +168 -57
- package/src/components/inserter/hooks/use-patterns-paging.js +65 -0
- package/src/components/inserter/hooks/use-patterns-state.js +27 -16
- package/src/components/inserter/menu.js +15 -17
- package/src/components/inserter/search-results.js +6 -4
- package/src/components/inserter/style.scss +23 -2
- package/src/components/inserter/tabs.js +2 -12
- package/src/components/inserter/test/index.native.js +8 -12
- package/src/components/inspector-controls/block-support-slot-container.js +19 -3
- package/src/components/inspector-controls/fill.js +28 -14
- package/src/components/inspector-controls/groups.js +6 -2
- package/src/components/inspector-controls/slot.js +28 -3
- package/src/components/inspector-controls-tabs/styles-tab.js +4 -0
- package/src/components/link-control/index.js +13 -0
- package/src/components/link-control/style.scss +23 -2
- package/src/components/link-control/test/index.js +88 -6
- package/src/components/list-view/block-select-button.js +1 -3
- package/src/components/list-view/block.js +19 -1
- package/src/components/list-view/style.scss +1 -2
- package/src/components/list-view/use-block-selection.js +38 -32
- package/src/components/media-placeholder/README.md +2 -2
- package/src/components/media-placeholder/index.js +2 -2
- package/src/components/media-placeholder/index.native.js +11 -12
- package/src/components/media-replace-flow/index.js +2 -2
- package/src/components/media-replace-flow/test/index.js +5 -23
- package/src/components/media-upload/README.md +3 -2
- package/src/components/media-upload/constants.js +15 -0
- package/src/components/media-upload/index.native.js +66 -40
- package/src/components/media-upload/style.native.scss +4 -0
- package/src/components/media-upload/test/index.native.js +2 -2
- package/src/components/preview-options/README.md +7 -0
- package/src/components/preview-options/index.js +1 -1
- package/src/components/rich-text/index.js +48 -44
- package/src/components/rich-text/index.native.js +14 -42
- package/src/components/rich-text/multiline.js +121 -0
- package/src/components/rich-text/split-value.js +10 -35
- package/src/components/rich-text/use-enter.js +32 -42
- package/src/components/rich-text/use-paste-handler.js +16 -40
- package/src/components/spacing-sizes-control/style.scss +5 -7
- package/src/components/spacing-sizes-control/utils.js +1 -2
- package/src/components/use-block-commands/index.js +28 -20
- package/src/components/use-block-display-information/index.js +3 -0
- package/src/hooks/background.js +288 -0
- package/src/hooks/background.scss +57 -0
- package/src/hooks/block-hooks.js +257 -0
- package/src/hooks/block-hooks.scss +16 -0
- package/src/hooks/block-rename-ui.js +230 -0
- package/src/hooks/block-rename-ui.scss +3 -0
- package/src/hooks/duotone.js +42 -43
- package/src/hooks/index.js +2 -2
- package/src/hooks/layout.js +31 -33
- package/src/hooks/position.js +4 -3
- package/src/hooks/style.js +11 -2
- package/src/hooks/test/align.native.js +4 -3
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +52 -10
- package/src/store/private-actions.js +37 -6
- package/src/store/private-selectors.js +21 -0
- package/src/store/reducer.js +38 -0
- package/src/store/selectors.js +107 -26
- package/src/store/test/actions.js +19 -8
- package/src/store/test/private-actions.js +17 -0
- package/src/store/test/reducer.js +25 -0
- package/src/store/test/selectors.js +130 -123
- package/src/store/utils.js +3 -10
- package/src/style.scss +4 -0
- package/build/components/duotone/components.js +0 -135
- package/build/components/duotone/components.js.map +0 -1
- package/build/components/duotone/index.js +0 -38
- package/build/components/duotone/index.js.map +0 -1
- package/build/components/global-styles/behaviors-panel.js +0 -64
- package/build/components/global-styles/behaviors-panel.js.map +0 -1
- package/build/components/inserter/reusable-blocks-tab.js +0 -85
- package/build/components/inserter/reusable-blocks-tab.js.map +0 -1
- package/build/hooks/auto-inserting-blocks.js +0 -174
- package/build/hooks/auto-inserting-blocks.js.map +0 -1
- package/build/hooks/behaviors.js +0 -173
- package/build/hooks/behaviors.js.map +0 -1
- package/build-module/components/duotone/components.js +0 -126
- package/build-module/components/duotone/components.js.map +0 -1
- package/build-module/components/duotone/index.js +0 -3
- package/build-module/components/duotone/index.js.map +0 -1
- package/build-module/components/global-styles/behaviors-panel.js +0 -57
- package/build-module/components/global-styles/behaviors-panel.js.map +0 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +0 -76
- package/build-module/components/inserter/reusable-blocks-tab.js.map +0 -1
- package/build-module/hooks/auto-inserting-blocks.js +0 -167
- package/build-module/hooks/auto-inserting-blocks.js.map +0 -1
- package/build-module/hooks/behaviors.js +0 -166
- package/build-module/hooks/behaviors.js.map +0 -1
- package/src/components/duotone/components.js +0 -133
- package/src/components/duotone/index.js +0 -7
- package/src/components/global-styles/behaviors-panel.js +0 -71
- package/src/components/inserter/reusable-blocks-tab.js +0 -84
- package/src/components/inserter/test/reusable-blocks-tab.js +0 -73
- package/src/hooks/auto-inserting-blocks.js +0 -232
- package/src/hooks/behaviors.js +0 -206
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
useRef,
|
|
9
9
|
useEffect,
|
|
10
10
|
} from '@wordpress/element';
|
|
11
|
-
import { _x, __, isRTL } from '@wordpress/i18n';
|
|
12
|
-
import {
|
|
11
|
+
import { _x, __, _n, isRTL, sprintf } from '@wordpress/i18n';
|
|
12
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
13
13
|
import {
|
|
14
14
|
__experimentalItemGroup as ItemGroup,
|
|
15
15
|
__experimentalItem as Item,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from '@wordpress/components';
|
|
20
20
|
import { Icon, chevronRight, chevronLeft } from '@wordpress/icons';
|
|
21
21
|
import { focus } from '@wordpress/dom';
|
|
22
|
+
import { speak } from '@wordpress/a11y';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Internal dependencies
|
|
@@ -27,29 +28,68 @@ import usePatternsState from './hooks/use-patterns-state';
|
|
|
27
28
|
import BlockPatternList from '../block-patterns-list';
|
|
28
29
|
import PatternsExplorerModal from './block-patterns-explorer/explorer';
|
|
29
30
|
import MobileTabNavigation from './mobile-tab-navigation';
|
|
31
|
+
import BlockPatternsPaging from '../block-patterns-paging';
|
|
32
|
+
import usePatternsPaging from './hooks/use-patterns-paging';
|
|
33
|
+
import {
|
|
34
|
+
PATTERN_TYPES,
|
|
35
|
+
default as BlockPatternsSourceFilter,
|
|
36
|
+
} from './block-patterns-source-filter';
|
|
37
|
+
import {
|
|
38
|
+
BlockPatternsSyncFilter,
|
|
39
|
+
SYNC_TYPES,
|
|
40
|
+
} from './block-patterns-sync-filter';
|
|
30
41
|
|
|
31
42
|
const noop = () => {};
|
|
32
43
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
export const allPatternsCategory = {
|
|
45
|
+
name: 'allPatterns',
|
|
46
|
+
label: __( 'All categories' ),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export function isPatternFiltered( pattern, sourceFilter, syncFilter ) {
|
|
50
|
+
if (
|
|
51
|
+
sourceFilter === PATTERN_TYPES.theme &&
|
|
52
|
+
pattern.name.startsWith( 'core/block' )
|
|
53
|
+
) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if ( sourceFilter === PATTERN_TYPES.user && ! pattern.id ) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
if (
|
|
60
|
+
sourceFilter === PATTERN_TYPES.user &&
|
|
61
|
+
syncFilter === SYNC_TYPES.full &&
|
|
62
|
+
pattern.syncStatus !== ''
|
|
63
|
+
) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
if (
|
|
67
|
+
sourceFilter === PATTERN_TYPES.user &&
|
|
68
|
+
syncFilter === SYNC_TYPES.unsynced &&
|
|
69
|
+
pattern.syncStatus !== 'unsynced'
|
|
70
|
+
) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
46
75
|
|
|
47
|
-
function usePatternsCategories( rootClientId ) {
|
|
48
|
-
const [
|
|
76
|
+
export function usePatternsCategories( rootClientId, sourceFilter = 'all' ) {
|
|
77
|
+
const [ patterns, allCategories ] = usePatternsState(
|
|
49
78
|
undefined,
|
|
50
79
|
rootClientId
|
|
51
80
|
);
|
|
52
81
|
|
|
82
|
+
const filteredPatterns = useMemo(
|
|
83
|
+
() =>
|
|
84
|
+
sourceFilter === 'all'
|
|
85
|
+
? patterns
|
|
86
|
+
: patterns.filter(
|
|
87
|
+
( pattern ) =>
|
|
88
|
+
! isPatternFiltered( pattern, sourceFilter )
|
|
89
|
+
),
|
|
90
|
+
[ sourceFilter, patterns ]
|
|
91
|
+
);
|
|
92
|
+
|
|
53
93
|
const hasRegisteredCategory = useCallback(
|
|
54
94
|
( pattern ) => {
|
|
55
95
|
if ( ! pattern.categories || ! pattern.categories.length ) {
|
|
@@ -67,22 +107,14 @@ function usePatternsCategories( rootClientId ) {
|
|
|
67
107
|
const populatedCategories = useMemo( () => {
|
|
68
108
|
const categories = allCategories
|
|
69
109
|
.filter( ( category ) =>
|
|
70
|
-
|
|
110
|
+
filteredPatterns.some( ( pattern ) =>
|
|
71
111
|
pattern.categories?.includes( category.name )
|
|
72
112
|
)
|
|
73
113
|
)
|
|
74
|
-
.sort( (
|
|
75
|
-
// Sort categories according to `patternCategoriesOrder`.
|
|
76
|
-
let aIndex = patternCategoriesOrder.indexOf( aName );
|
|
77
|
-
let bIndex = patternCategoriesOrder.indexOf( bName );
|
|
78
|
-
// All other categories should come after that.
|
|
79
|
-
if ( aIndex < 0 ) aIndex = patternCategoriesOrder.length;
|
|
80
|
-
if ( bIndex < 0 ) bIndex = patternCategoriesOrder.length;
|
|
81
|
-
return aIndex - bIndex;
|
|
82
|
-
} );
|
|
114
|
+
.sort( ( a, b ) => a.label.localeCompare( b.label ) );
|
|
83
115
|
|
|
84
116
|
if (
|
|
85
|
-
|
|
117
|
+
filteredPatterns.some(
|
|
86
118
|
( pattern ) => ! hasRegisteredCategory( pattern )
|
|
87
119
|
) &&
|
|
88
120
|
! categories.find(
|
|
@@ -94,9 +126,25 @@ function usePatternsCategories( rootClientId ) {
|
|
|
94
126
|
label: _x( 'Uncategorized' ),
|
|
95
127
|
} );
|
|
96
128
|
}
|
|
97
|
-
|
|
129
|
+
if ( filteredPatterns.length > 0 ) {
|
|
130
|
+
categories.unshift( {
|
|
131
|
+
name: allPatternsCategory.name,
|
|
132
|
+
label: allPatternsCategory.label,
|
|
133
|
+
} );
|
|
134
|
+
}
|
|
135
|
+
speak(
|
|
136
|
+
sprintf(
|
|
137
|
+
/* translators: %d: number of categories . */
|
|
138
|
+
_n(
|
|
139
|
+
'%d category button displayed.',
|
|
140
|
+
'%d category buttons displayed.',
|
|
141
|
+
categories.length
|
|
142
|
+
),
|
|
143
|
+
categories.length
|
|
144
|
+
)
|
|
145
|
+
);
|
|
98
146
|
return categories;
|
|
99
|
-
}, [ allCategories,
|
|
147
|
+
}, [ allCategories, filteredPatterns, hasRegisteredCategory ] );
|
|
100
148
|
|
|
101
149
|
return populatedCategories;
|
|
102
150
|
}
|
|
@@ -107,6 +155,7 @@ export function BlockPatternsCategoryDialog( {
|
|
|
107
155
|
onHover,
|
|
108
156
|
category,
|
|
109
157
|
showTitlesAsTooltip,
|
|
158
|
+
patternFilter,
|
|
110
159
|
} ) {
|
|
111
160
|
const container = useRef();
|
|
112
161
|
|
|
@@ -129,6 +178,7 @@ export function BlockPatternsCategoryDialog( {
|
|
|
129
178
|
onHover={ onHover }
|
|
130
179
|
category={ category }
|
|
131
180
|
showTitlesAsTooltip={ showTitlesAsTooltip }
|
|
181
|
+
patternFilter={ patternFilter }
|
|
132
182
|
/>
|
|
133
183
|
</div>
|
|
134
184
|
);
|
|
@@ -140,16 +190,35 @@ export function BlockPatternsCategoryPanel( {
|
|
|
140
190
|
onHover = noop,
|
|
141
191
|
category,
|
|
142
192
|
showTitlesAsTooltip,
|
|
193
|
+
patternFilter,
|
|
143
194
|
} ) {
|
|
144
|
-
const [ allPatterns, ,
|
|
195
|
+
const [ allPatterns, , onClickPattern ] = usePatternsState(
|
|
145
196
|
onInsert,
|
|
146
197
|
rootClientId
|
|
147
198
|
);
|
|
199
|
+
const [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );
|
|
148
200
|
|
|
149
|
-
const availableCategories = usePatternsCategories(
|
|
201
|
+
const availableCategories = usePatternsCategories(
|
|
202
|
+
rootClientId,
|
|
203
|
+
patternFilter
|
|
204
|
+
);
|
|
205
|
+
const container = useRef();
|
|
150
206
|
const currentCategoryPatterns = useMemo(
|
|
151
207
|
() =>
|
|
152
208
|
allPatterns.filter( ( pattern ) => {
|
|
209
|
+
if (
|
|
210
|
+
isPatternFiltered(
|
|
211
|
+
pattern,
|
|
212
|
+
patternFilter,
|
|
213
|
+
patternSyncFilter
|
|
214
|
+
)
|
|
215
|
+
) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if ( category.name === allPatternsCategory.name ) {
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
153
222
|
if ( category.name !== 'uncategorized' ) {
|
|
154
223
|
return pattern.categories?.includes( category.name );
|
|
155
224
|
}
|
|
@@ -166,35 +235,60 @@ export function BlockPatternsCategoryPanel( {
|
|
|
166
235
|
|
|
167
236
|
return availablePatternCategories.length === 0;
|
|
168
237
|
} ),
|
|
169
|
-
[
|
|
238
|
+
[
|
|
239
|
+
allPatterns,
|
|
240
|
+
availableCategories,
|
|
241
|
+
category.name,
|
|
242
|
+
patternFilter,
|
|
243
|
+
patternSyncFilter,
|
|
244
|
+
]
|
|
170
245
|
);
|
|
171
246
|
|
|
172
|
-
const
|
|
247
|
+
const pagingProps = usePatternsPaging(
|
|
248
|
+
currentCategoryPatterns,
|
|
249
|
+
category,
|
|
250
|
+
container
|
|
251
|
+
);
|
|
173
252
|
|
|
174
253
|
// Hide block pattern preview on unmount.
|
|
254
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
175
255
|
useEffect( () => () => onHover( null ), [] );
|
|
176
256
|
|
|
177
|
-
if ( ! currentCategoryPatterns.length ) {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
257
|
return (
|
|
182
|
-
<div
|
|
258
|
+
<div
|
|
259
|
+
className="block-editor-inserter__patterns-category-panel"
|
|
260
|
+
ref={ container }
|
|
261
|
+
>
|
|
183
262
|
<div className="block-editor-inserter__patterns-category-panel-title">
|
|
184
263
|
{ category.label }
|
|
185
264
|
</div>
|
|
186
265
|
<p>{ category.description }</p>
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
266
|
+
{ patternFilter === PATTERN_TYPES.user && (
|
|
267
|
+
<BlockPatternsSyncFilter
|
|
268
|
+
patternSyncFilter={ patternSyncFilter }
|
|
269
|
+
setPatternSyncFilter={ setPatternSyncFilter }
|
|
270
|
+
/>
|
|
271
|
+
) }
|
|
272
|
+
{ ! currentCategoryPatterns.length && (
|
|
273
|
+
<div>{ __( 'No results found' ) }</div>
|
|
274
|
+
) }
|
|
275
|
+
{ currentCategoryPatterns.length > 0 && (
|
|
276
|
+
<BlockPatternList
|
|
277
|
+
shownPatterns={ pagingProps.categoryPatternsAsyncList }
|
|
278
|
+
blockPatterns={ pagingProps.categoryPatterns }
|
|
279
|
+
onClickPattern={ onClickPattern }
|
|
280
|
+
onHover={ onHover }
|
|
281
|
+
label={ category.label }
|
|
282
|
+
orientation="vertical"
|
|
283
|
+
category={ category.name }
|
|
284
|
+
isDraggable
|
|
285
|
+
showTitlesAsTooltip={ showTitlesAsTooltip }
|
|
286
|
+
patternFilter={ patternFilter }
|
|
287
|
+
/>
|
|
288
|
+
) }
|
|
289
|
+
{ pagingProps.numPages > 1 && (
|
|
290
|
+
<BlockPatternsPaging { ...pagingProps } />
|
|
291
|
+
) }
|
|
198
292
|
</div>
|
|
199
293
|
);
|
|
200
294
|
}
|
|
@@ -206,24 +300,40 @@ function BlockPatternsTabs( {
|
|
|
206
300
|
rootClientId,
|
|
207
301
|
} ) {
|
|
208
302
|
const [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );
|
|
209
|
-
const
|
|
303
|
+
const [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );
|
|
304
|
+
|
|
305
|
+
const categories = usePatternsCategories(
|
|
306
|
+
rootClientId,
|
|
307
|
+
patternSourceFilter
|
|
308
|
+
);
|
|
309
|
+
|
|
210
310
|
const initialCategory = selectedCategory || categories[ 0 ];
|
|
211
311
|
const isMobile = useViewportMatch( 'medium', '<' );
|
|
212
312
|
return (
|
|
213
313
|
<>
|
|
214
314
|
{ ! isMobile && (
|
|
215
315
|
<div className="block-editor-inserter__block-patterns-tabs-container">
|
|
216
|
-
<nav
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
316
|
+
<nav
|
|
317
|
+
aria-label={ __( 'Block pattern categories' ) }
|
|
318
|
+
className="block-editor-inserter__block-patterns-tabs"
|
|
319
|
+
>
|
|
320
|
+
<BlockPatternsSourceFilter
|
|
321
|
+
value={ patternSourceFilter }
|
|
322
|
+
onChange={ ( value ) => {
|
|
323
|
+
setPatternSourceFilter( value );
|
|
324
|
+
onSelectCategory( allPatternsCategory, value );
|
|
325
|
+
} }
|
|
326
|
+
/>
|
|
327
|
+
<ItemGroup role="list">
|
|
221
328
|
{ categories.map( ( category ) => (
|
|
222
329
|
<Item
|
|
223
330
|
role="listitem"
|
|
224
331
|
key={ category.name }
|
|
225
332
|
onClick={ () =>
|
|
226
|
-
onSelectCategory(
|
|
333
|
+
onSelectCategory(
|
|
334
|
+
category,
|
|
335
|
+
patternSourceFilter
|
|
336
|
+
)
|
|
227
337
|
}
|
|
228
338
|
className={
|
|
229
339
|
category === selectedCategory
|
|
@@ -283,6 +393,7 @@ function BlockPatternsTabs( {
|
|
|
283
393
|
initialCategory={ initialCategory }
|
|
284
394
|
patternCategories={ categories }
|
|
285
395
|
onModalClose={ () => setShowPatternsExplorer( false ) }
|
|
396
|
+
rootClientId={ rootClientId }
|
|
286
397
|
/>
|
|
287
398
|
) }
|
|
288
399
|
</>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
5
|
+
import { useAsyncList, usePrevious } from '@wordpress/compose';
|
|
6
|
+
import { getScrollContainer } from '@wordpress/dom';
|
|
7
|
+
|
|
8
|
+
const PAGE_SIZE = 20;
|
|
9
|
+
const INITIAL_INSERTER_RESULTS = 5;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Supplies values needed to page the patterns list client side.
|
|
13
|
+
*
|
|
14
|
+
* @param {Array} currentCategoryPatterns An array of the current patterns to display.
|
|
15
|
+
* @param {string} currentCategory The currently selected category.
|
|
16
|
+
* @param {Object} scrollContainerRef Ref of container to to find scroll container for when moving between pages.
|
|
17
|
+
* @param {string} currentFilter The currently search filter.
|
|
18
|
+
*
|
|
19
|
+
* @return {Object} Returns the relevant paging values. (totalItems, categoryPatternsList, numPages, changePage, currentPage)
|
|
20
|
+
*/
|
|
21
|
+
export default function usePatternsPaging(
|
|
22
|
+
currentCategoryPatterns,
|
|
23
|
+
currentCategory,
|
|
24
|
+
scrollContainerRef,
|
|
25
|
+
currentFilter = ''
|
|
26
|
+
) {
|
|
27
|
+
const [ currentPage, setCurrentPage ] = useState( 1 );
|
|
28
|
+
const previousCategory = usePrevious( currentCategory );
|
|
29
|
+
const previousFilter = usePrevious( currentFilter );
|
|
30
|
+
if (
|
|
31
|
+
( previousCategory !== currentCategory ||
|
|
32
|
+
previousFilter !== currentFilter ) &&
|
|
33
|
+
currentPage !== 1
|
|
34
|
+
) {
|
|
35
|
+
setCurrentPage( 1 );
|
|
36
|
+
}
|
|
37
|
+
const totalItems = currentCategoryPatterns.length;
|
|
38
|
+
const pageIndex = currentPage - 1;
|
|
39
|
+
const categoryPatterns = useMemo( () => {
|
|
40
|
+
return currentCategoryPatterns.slice(
|
|
41
|
+
pageIndex * PAGE_SIZE,
|
|
42
|
+
pageIndex * PAGE_SIZE + PAGE_SIZE
|
|
43
|
+
);
|
|
44
|
+
}, [ pageIndex, currentCategoryPatterns ] );
|
|
45
|
+
const categoryPatternsAsyncList = useAsyncList( categoryPatterns, {
|
|
46
|
+
step: INITIAL_INSERTER_RESULTS,
|
|
47
|
+
} );
|
|
48
|
+
const numPages = Math.ceil( currentCategoryPatterns.length / PAGE_SIZE );
|
|
49
|
+
const changePage = ( page ) => {
|
|
50
|
+
const scrollContainer = getScrollContainer(
|
|
51
|
+
scrollContainerRef?.current
|
|
52
|
+
);
|
|
53
|
+
scrollContainer?.scrollTo( 0, 0 );
|
|
54
|
+
|
|
55
|
+
setCurrentPage( page );
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
totalItems,
|
|
59
|
+
categoryPatterns,
|
|
60
|
+
categoryPatternsAsyncList,
|
|
61
|
+
numPages,
|
|
62
|
+
changePage,
|
|
63
|
+
currentPage,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useCallback, useMemo } from '@wordpress/element';
|
|
5
|
-
import { cloneBlock } from '@wordpress/blocks';
|
|
5
|
+
import { cloneBlock, createBlock } from '@wordpress/blocks';
|
|
6
6
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
7
|
import { __, sprintf } from '@wordpress/i18n';
|
|
8
8
|
import { store as noticesStore } from '@wordpress/notices';
|
|
@@ -12,12 +12,6 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
12
12
|
*/
|
|
13
13
|
import { store as blockEditorStore } from '../../../store';
|
|
14
14
|
|
|
15
|
-
const CUSTOM_CATEGORY = {
|
|
16
|
-
name: 'custom',
|
|
17
|
-
label: __( 'My patterns' ),
|
|
18
|
-
description: __( 'Custom patterns added by site users.' ),
|
|
19
|
-
};
|
|
20
|
-
|
|
21
15
|
/**
|
|
22
16
|
* Retrieves the block patterns inserter state.
|
|
23
17
|
*
|
|
@@ -27,30 +21,47 @@ const CUSTOM_CATEGORY = {
|
|
|
27
21
|
* @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)
|
|
28
22
|
*/
|
|
29
23
|
const usePatternsState = ( onInsert, rootClientId ) => {
|
|
30
|
-
const { patternCategories, patterns } = useSelect(
|
|
24
|
+
const { patternCategories, patterns, userPatternCategories } = useSelect(
|
|
31
25
|
( select ) => {
|
|
32
26
|
const { __experimentalGetAllowedPatterns, getSettings } =
|
|
33
27
|
select( blockEditorStore );
|
|
34
|
-
|
|
28
|
+
const {
|
|
29
|
+
__experimentalUserPatternCategories,
|
|
30
|
+
__experimentalBlockPatternCategories,
|
|
31
|
+
} = getSettings();
|
|
35
32
|
return {
|
|
36
33
|
patterns: __experimentalGetAllowedPatterns( rootClientId ),
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
userPatternCategories: __experimentalUserPatternCategories,
|
|
35
|
+
patternCategories: __experimentalBlockPatternCategories,
|
|
39
36
|
};
|
|
40
37
|
},
|
|
41
38
|
[ rootClientId ]
|
|
42
39
|
);
|
|
43
40
|
|
|
44
|
-
const allCategories = useMemo(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
const allCategories = useMemo( () => {
|
|
42
|
+
const categories = [ ...patternCategories ];
|
|
43
|
+
userPatternCategories?.forEach( ( userCategory ) => {
|
|
44
|
+
if (
|
|
45
|
+
! categories.find(
|
|
46
|
+
( existingCategory ) =>
|
|
47
|
+
existingCategory.name === userCategory.name
|
|
48
|
+
)
|
|
49
|
+
) {
|
|
50
|
+
categories.push( userCategory );
|
|
51
|
+
}
|
|
52
|
+
} );
|
|
53
|
+
return categories;
|
|
54
|
+
}, [ patternCategories, userPatternCategories ] );
|
|
48
55
|
|
|
49
56
|
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
50
57
|
const onClickPattern = useCallback(
|
|
51
58
|
( pattern, blocks ) => {
|
|
59
|
+
const patternBlocks =
|
|
60
|
+
pattern.id && pattern.syncStatus !== 'unsynced'
|
|
61
|
+
? [ createBlock( 'core/block', { ref: pattern.id } ) ]
|
|
62
|
+
: blocks;
|
|
52
63
|
onInsert(
|
|
53
|
-
(
|
|
64
|
+
( patternBlocks ?? [] ).map( ( block ) => cloneBlock( block ) ),
|
|
54
65
|
pattern.name
|
|
55
66
|
);
|
|
56
67
|
createSuccessNotice(
|
|
@@ -27,7 +27,6 @@ import BlockTypesTab from './block-types-tab';
|
|
|
27
27
|
import BlockPatternsTabs, {
|
|
28
28
|
BlockPatternsCategoryDialog,
|
|
29
29
|
} from './block-patterns-tab';
|
|
30
|
-
import ReusableBlocksTab from './reusable-blocks-tab';
|
|
31
30
|
import { MediaTab, MediaCategoryDialog, useMediaCategories } from './media-tab';
|
|
32
31
|
import InserterSearchResults from './search-results';
|
|
33
32
|
import useDebouncedInput from './hooks/use-debounced-input';
|
|
@@ -55,6 +54,7 @@ function InserterMenu(
|
|
|
55
54
|
const [ hoveredItem, setHoveredItem ] = useState( null );
|
|
56
55
|
const [ selectedPatternCategory, setSelectedPatternCategory ] =
|
|
57
56
|
useState( null );
|
|
57
|
+
const [ patternFilter, setPatternFilter ] = useState( 'all' );
|
|
58
58
|
const [ selectedMediaCategory, setSelectedMediaCategory ] =
|
|
59
59
|
useState( null );
|
|
60
60
|
const [ selectedTab, setSelectedTab ] = useState( null );
|
|
@@ -121,8 +121,9 @@ function InserterMenu(
|
|
|
121
121
|
);
|
|
122
122
|
|
|
123
123
|
const onClickPatternCategory = useCallback(
|
|
124
|
-
( patternCategory ) => {
|
|
124
|
+
( patternCategory, filter ) => {
|
|
125
125
|
setSelectedPatternCategory( patternCategory );
|
|
126
|
+
setPatternFilter( filter );
|
|
126
127
|
},
|
|
127
128
|
[ setSelectedPatternCategory ]
|
|
128
129
|
);
|
|
@@ -174,17 +175,6 @@ function InserterMenu(
|
|
|
174
175
|
]
|
|
175
176
|
);
|
|
176
177
|
|
|
177
|
-
const reusableBlocksTab = useMemo(
|
|
178
|
-
() => (
|
|
179
|
-
<ReusableBlocksTab
|
|
180
|
-
rootClientId={ destinationRootClientId }
|
|
181
|
-
onInsert={ onInsert }
|
|
182
|
-
onHover={ onHover }
|
|
183
|
-
/>
|
|
184
|
-
),
|
|
185
|
-
[ destinationRootClientId, onInsert, onHover ]
|
|
186
|
-
);
|
|
187
|
-
|
|
188
178
|
const mediaTab = useMemo(
|
|
189
179
|
() => (
|
|
190
180
|
<MediaTab
|
|
@@ -208,13 +198,11 @@ function InserterMenu(
|
|
|
208
198
|
return blocksTab;
|
|
209
199
|
} else if ( tab.name === 'patterns' ) {
|
|
210
200
|
return patternsTab;
|
|
211
|
-
} else if ( tab.name === 'reusable' ) {
|
|
212
|
-
return reusableBlocksTab;
|
|
213
201
|
} else if ( tab.name === 'media' ) {
|
|
214
202
|
return mediaTab;
|
|
215
203
|
}
|
|
216
204
|
},
|
|
217
|
-
[ blocksTab, patternsTab,
|
|
205
|
+
[ blocksTab, patternsTab, mediaTab ]
|
|
218
206
|
);
|
|
219
207
|
|
|
220
208
|
const searchRef = useRef();
|
|
@@ -235,6 +223,15 @@ function InserterMenu(
|
|
|
235
223
|
selectedTab === 'media' &&
|
|
236
224
|
! delayedFilterValue &&
|
|
237
225
|
selectedMediaCategory;
|
|
226
|
+
|
|
227
|
+
const handleSetSelectedTab = ( value ) => {
|
|
228
|
+
// If no longer on patterns tab remove the category setting.
|
|
229
|
+
if ( value !== 'patterns' ) {
|
|
230
|
+
setSelectedPatternCategory( null );
|
|
231
|
+
}
|
|
232
|
+
setSelectedTab( value );
|
|
233
|
+
};
|
|
234
|
+
|
|
238
235
|
return (
|
|
239
236
|
<div className="block-editor-inserter__menu">
|
|
240
237
|
<div
|
|
@@ -278,7 +275,7 @@ function InserterMenu(
|
|
|
278
275
|
showReusableBlocks={ hasReusableBlocks }
|
|
279
276
|
showMedia={ showMedia }
|
|
280
277
|
prioritizePatterns={ prioritizePatterns }
|
|
281
|
-
onSelect={
|
|
278
|
+
onSelect={ handleSetSelectedTab }
|
|
282
279
|
>
|
|
283
280
|
{ getCurrentTab }
|
|
284
281
|
</InserterTabs>
|
|
@@ -305,6 +302,7 @@ function InserterMenu(
|
|
|
305
302
|
onInsert={ onInsertPattern }
|
|
306
303
|
onHover={ onHoverPattern }
|
|
307
304
|
category={ selectedPatternCategory }
|
|
305
|
+
patternFilter={ patternFilter }
|
|
308
306
|
showTitlesAsTooltip
|
|
309
307
|
/>
|
|
310
308
|
) }
|
|
@@ -81,7 +81,7 @@ function InserterSearchResults( {
|
|
|
81
81
|
blockTypeCollections,
|
|
82
82
|
onSelectBlockType,
|
|
83
83
|
] = useBlockTypesState( destinationRootClientId, onInsertBlocks );
|
|
84
|
-
const [ patterns, ,
|
|
84
|
+
const [ patterns, , onClickPattern ] = usePatternsState(
|
|
85
85
|
onInsertBlocks,
|
|
86
86
|
destinationRootClientId
|
|
87
87
|
);
|
|
@@ -105,8 +105,10 @@ function InserterSearchResults( {
|
|
|
105
105
|
if ( maxBlockTypesToShow === 0 ) {
|
|
106
106
|
return [];
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
const nonPatternBlockTypes = blockTypes.filter(
|
|
109
|
+
( blockType ) => blockType.name !== 'core/block'
|
|
110
|
+
);
|
|
111
|
+
let orderedItems = orderBy( nonPatternBlockTypes, 'frecency', 'desc' );
|
|
110
112
|
|
|
111
113
|
if ( ! filterValue && prioritizedBlocks.length ) {
|
|
112
114
|
orderedItems = orderInserterBlockItems(
|
|
@@ -189,7 +191,7 @@ function InserterSearchResults( {
|
|
|
189
191
|
<BlockPatternsList
|
|
190
192
|
shownPatterns={ currentShownPatterns }
|
|
191
193
|
blockPatterns={ filteredBlockPatterns }
|
|
192
|
-
onClickPattern={
|
|
194
|
+
onClickPattern={ onClickPattern }
|
|
193
195
|
onHover={ onHoverPattern }
|
|
194
196
|
isDraggable={ isDraggable }
|
|
195
197
|
/>
|
|
@@ -271,11 +271,15 @@ $block-inserter-tabs-height: 44px;
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
.block-editor-inserter__block-patterns-tabs-container
|
|
274
|
+
.block-editor-inserter__block-patterns-tabs-container,
|
|
275
|
+
.block-editor-block-patterns-explorer__sidebar {
|
|
275
276
|
height: 100%;
|
|
276
277
|
nav {
|
|
277
278
|
height: 100%;
|
|
278
279
|
}
|
|
280
|
+
.block-editor-block-patterns__source-filter select.components-select-control__input {
|
|
281
|
+
height: 40px;
|
|
282
|
+
}
|
|
279
283
|
}
|
|
280
284
|
|
|
281
285
|
.block-editor-inserter__block-patterns-tabs {
|
|
@@ -312,10 +316,14 @@ $block-inserter-tabs-height: 44px;
|
|
|
312
316
|
.block-editor-block-patterns-list {
|
|
313
317
|
margin-top: $grid-unit-30;
|
|
314
318
|
}
|
|
319
|
+
}
|
|
315
320
|
|
|
321
|
+
.block-editor-block-patterns-list__list-item {
|
|
316
322
|
.block-editor-block-preview__container {
|
|
317
323
|
box-shadow: 0 15px 25px rgb(0 0 0 / 7%);
|
|
318
|
-
|
|
324
|
+
}
|
|
325
|
+
&:hover {
|
|
326
|
+
.block-editor-block-preview__container {
|
|
319
327
|
box-shadow: 0 0 0 2px $gray-900, 0 15px 25px rgb(0 0 0 / 7%);
|
|
320
328
|
}
|
|
321
329
|
}
|
|
@@ -453,6 +461,11 @@ $block-inserter-tabs-height: 44px;
|
|
|
453
461
|
&__list {
|
|
454
462
|
margin-left: $sidebar-width;
|
|
455
463
|
padding: $grid-unit-30 0 $grid-unit-40;
|
|
464
|
+
.block-editor-patterns__sync-status-filter {
|
|
465
|
+
.components-input-control__container {
|
|
466
|
+
width: 380px;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
456
469
|
}
|
|
457
470
|
|
|
458
471
|
.block-editor-block-patterns-list {
|
|
@@ -739,3 +752,11 @@ $block-inserter-tabs-height: 44px;
|
|
|
739
752
|
.components-menu-group .reusable-blocks-menu-items__rename-hint {
|
|
740
753
|
margin: 0;
|
|
741
754
|
}
|
|
755
|
+
|
|
756
|
+
.block-editor-patterns__sync-status-filter {
|
|
757
|
+
.components-input-control__container {
|
|
758
|
+
select.components-select-control__input {
|
|
759
|
+
height: 40px;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|