@wordpress/block-editor 12.13.0 → 12.14.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/build/components/block-heading-level-dropdown/index.js +1 -1
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-list/index.js +2 -9
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +16 -3
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +6 -4
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-styles/index.js +0 -8
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +18 -14
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +11 -81
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/empty-block-inserter.js +56 -0
- package/build/components/block-tools/empty-block-inserter.js.map +1 -0
- package/build/components/block-tools/index.js +48 -9
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/selected-block-tools.js +113 -0
- package/build/components/block-tools/selected-block-tools.js.map +1 -0
- package/build/components/block-tools/use-selected-block-tool-props.js +56 -0
- package/build/components/block-tools/use-selected-block-tool-props.js.map +1 -0
- package/build/components/editable-text/index.js +1 -2
- package/build/components/editable-text/index.js.map +1 -1
- package/build/components/iframe/index.js +4 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/{explorer.js → index.js} +7 -7
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -4
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/index.js +75 -0
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +108 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
- package/build/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +18 -34
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +55 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/utils.js +70 -0
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +9 -5
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +15 -12
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.js +3 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/link-control/index.js +6 -5
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +39 -0
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +16 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/index.js +3 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +69 -18
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +1 -14
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/index.js +0 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/format-edit.js +45 -0
- package/build/components/rich-text/native/format-edit.js.map +1 -0
- package/build/components/rich-text/native/get-format-colors.native.js +41 -0
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -0
- package/build/components/rich-text/native/index.js +9 -0
- package/build/components/rich-text/native/index.js.map +1 -0
- package/build/components/rich-text/native/index.native.js +1158 -0
- package/build/components/rich-text/native/index.native.js.map +1 -0
- package/build/components/rich-text/native/toolbar-button-with-options.native.js +58 -0
- package/build/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
- package/build/components/rich-text/native/use-format-types.js +111 -0
- package/build/components/rich-text/native/use-format-types.js.map +1 -0
- package/build/components/rich-text/use-paste-handler.js +2 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +7 -3
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +10 -10
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +2 -2
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +7 -6
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +16 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +7 -8
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-rename-ui.js +7 -5
- package/build/hooks/block-rename-ui.js.map +1 -1
- package/build/hooks/content-lock-ui.js +5 -5
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +8 -7
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-fields.js +4 -4
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/duotone.js +9 -20
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +90 -86
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +10 -9
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +10 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +30 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +3 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +30 -37
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +18 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -13
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-list/index.js +3 -10
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +16 -3
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +7 -5
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +0 -8
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +17 -13
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +11 -80
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/empty-block-inserter.js +48 -0
- package/build-module/components/block-tools/empty-block-inserter.js.map +1 -0
- package/build-module/components/block-tools/index.js +48 -9
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-tools.js +105 -0
- package/build-module/components/block-tools/selected-block-tools.js.map +1 -0
- package/build-module/components/block-tools/use-selected-block-tool-props.js +50 -0
- package/build-module/components/block-tools/use-selected-block-tool-props.js.map +1 -0
- package/build-module/components/editable-text/index.js +1 -2
- package/build-module/components/editable-text/index.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/{explorer.js → index.js} +5 -5
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/index.js +66 -0
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +42 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +100 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
- package/build-module/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +7 -20
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +47 -0
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js +58 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +9 -5
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +15 -12
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.js +4 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/link-control/index.js +7 -6
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +39 -0
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/index.js +3 -2
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +69 -17
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +1 -14
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/format-edit.js +38 -0
- package/build-module/components/rich-text/native/format-edit.js.map +1 -0
- package/build-module/components/rich-text/native/get-format-colors.native.js +34 -0
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -0
- package/build-module/components/rich-text/native/index.js +2 -0
- package/build-module/components/rich-text/native/index.js.map +1 -0
- package/build-module/components/rich-text/native/index.native.js +1148 -0
- package/build-module/components/rich-text/native/index.native.js.map +1 -0
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +51 -0
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
- package/build-module/components/rich-text/native/use-format-types.js +104 -0
- package/build-module/components/rich-text/native/use-format-types.js.map +1 -0
- package/build-module/components/rich-text/use-paste-handler.js +2 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +2 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +7 -3
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +8 -8
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +2 -2
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +5 -4
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +17 -5
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +5 -6
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-rename-ui.js +5 -3
- package/build-module/hooks/block-rename-ui.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +3 -3
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +6 -5
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-fields.js +4 -4
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/duotone.js +10 -21
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +90 -86
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +11 -10
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +10 -13
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +30 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +4 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +29 -37
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +17 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +15 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +16 -15
- package/build-style/style.css +16 -15
- package/package.json +31 -31
- package/src/components/block-heading-level-dropdown/index.js +1 -1
- package/src/components/block-list/index.js +4 -18
- package/src/components/block-list-appender/index.js +20 -4
- package/src/components/block-quick-navigation/index.js +11 -5
- package/src/components/block-styles/index.js +0 -10
- package/src/components/block-switcher/pattern-transformations-menu.js +20 -14
- package/src/components/block-toolbar/style.scss +8 -0
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-contextual-toolbar.js +11 -134
- package/src/components/block-tools/empty-block-inserter.js +56 -0
- package/src/components/block-tools/index.js +72 -16
- package/src/components/block-tools/selected-block-tools.js +127 -0
- package/src/components/block-tools/style.scss +0 -10
- package/src/components/block-tools/use-selected-block-tool-props.js +66 -0
- package/src/components/editable-text/index.js +1 -8
- package/src/components/iframe/index.js +4 -3
- package/src/components/inserter/block-patterns-explorer/{explorer.js → index.js} +4 -4
- package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -1
- package/src/components/inserter/block-patterns-tab/index.js +118 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +175 -0
- package/src/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +15 -21
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +96 -0
- package/src/components/inserter/block-patterns-tab/utils.js +76 -0
- package/src/components/inserter/media-tab/media-list.js +7 -7
- package/src/components/inserter/media-tab/media-preview.js +27 -22
- package/src/components/inserter/menu.js +4 -5
- package/src/components/link-control/README.md +2 -2
- package/src/components/link-control/index.js +15 -6
- package/src/components/link-control/style.scss +8 -5
- package/src/components/list-view/block-select-button.js +44 -1
- package/src/components/list-view/block.js +11 -11
- package/src/components/list-view/index.js +2 -0
- package/src/components/media-replace-flow/style.scss +2 -2
- package/src/components/navigable-toolbar/index.js +71 -25
- package/src/components/plain-text/README.md +3 -3
- package/src/components/provider/use-block-sync.js +2 -21
- package/src/components/rich-text/README.md +9 -8
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +3 -1
- package/src/components/rich-text/native/format-edit.js +44 -0
- package/src/components/rich-text/native/get-format-colors.native.js +54 -0
- package/src/components/rich-text/native/index.js +1 -0
- package/src/components/rich-text/native/index.native.js +1363 -0
- package/src/components/rich-text/native/style.native.scss +28 -0
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +79 -0
- package/src/components/rich-text/native/test/index.native.js +278 -0
- package/src/components/rich-text/native/test/performance/rich-text.native.js +44 -0
- package/src/components/rich-text/native/toolbar-button-with-options.native.js +61 -0
- package/src/components/rich-text/native/use-format-types.js +146 -0
- package/src/components/rich-text/use-paste-handler.js +1 -6
- package/src/components/url-popover/image-url-input-ui.js +1 -0
- package/src/components/writing-flow/use-tab-nav.js +8 -3
- package/src/hooks/align.js +8 -8
- package/src/hooks/align.native.js +2 -2
- package/src/hooks/anchor.js +21 -23
- package/src/hooks/background.js +28 -6
- package/src/hooks/block-hooks.js +20 -16
- package/src/hooks/block-rename-ui.js +6 -4
- package/src/hooks/content-lock-ui.js +3 -3
- package/src/hooks/custom-class-name.js +7 -6
- package/src/hooks/custom-fields.js +5 -5
- package/src/hooks/duotone.js +23 -33
- package/src/hooks/layout.js +114 -105
- package/src/hooks/position.js +8 -21
- package/src/hooks/style.js +17 -31
- package/src/hooks/test/align.js +4 -4
- package/src/hooks/utils.js +33 -1
- package/src/private-apis.js +4 -1
- package/src/store/actions.js +26 -72
- package/src/store/reducer.js +19 -0
- package/src/store/selectors.js +13 -19
- package/build/components/block-tools/selected-block-popover.js +0 -221
- package/build/components/block-tools/selected-block-popover.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
- package/build/components/inserter/block-patterns-filter.js.map +0 -1
- package/build/components/inserter/block-patterns-tab.js +0 -270
- package/build/components/inserter/block-patterns-tab.js.map +0 -1
- package/build/store/utils.js +0 -22
- package/build/store/utils.js.map +0 -1
- package/build-module/components/block-tools/selected-block-popover.js +0 -213
- package/build-module/components/block-tools/selected-block-popover.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
- package/build-module/components/inserter/block-patterns-filter.js.map +0 -1
- package/build-module/components/inserter/block-patterns-tab.js +0 -254
- package/build-module/components/inserter/block-patterns-tab.js.map +0 -1
- package/build-module/store/utils.js +0 -16
- package/build-module/store/utils.js.map +0 -1
- package/src/components/block-tools/selected-block-popover.js +0 -265
- package/src/components/inserter/block-patterns-tab.js +0 -448
- package/src/store/utils.js +0 -12
- /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
|
@@ -1,448 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
useMemo,
|
|
6
|
-
useState,
|
|
7
|
-
useCallback,
|
|
8
|
-
useRef,
|
|
9
|
-
useEffect,
|
|
10
|
-
} from '@wordpress/element';
|
|
11
|
-
import { _x, __, _n, isRTL, sprintf } from '@wordpress/i18n';
|
|
12
|
-
import { useViewportMatch } from '@wordpress/compose';
|
|
13
|
-
import {
|
|
14
|
-
__experimentalItemGroup as ItemGroup,
|
|
15
|
-
__experimentalItem as Item,
|
|
16
|
-
__experimentalHStack as HStack,
|
|
17
|
-
__experimentalVStack as VStack,
|
|
18
|
-
__experimentalHeading as Heading,
|
|
19
|
-
__experimentalText as Text,
|
|
20
|
-
FlexBlock,
|
|
21
|
-
Button,
|
|
22
|
-
} from '@wordpress/components';
|
|
23
|
-
import { Icon, chevronRight, chevronLeft } from '@wordpress/icons';
|
|
24
|
-
import { focus } from '@wordpress/dom';
|
|
25
|
-
import { speak } from '@wordpress/a11y';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Internal dependencies
|
|
29
|
-
*/
|
|
30
|
-
import usePatternsState from './hooks/use-patterns-state';
|
|
31
|
-
import BlockPatternList from '../block-patterns-list';
|
|
32
|
-
import PatternsExplorerModal from './block-patterns-explorer/explorer';
|
|
33
|
-
import MobileTabNavigation from './mobile-tab-navigation';
|
|
34
|
-
import usePatternsPaging from './hooks/use-patterns-paging';
|
|
35
|
-
import {
|
|
36
|
-
BlockPatternsSyncFilter,
|
|
37
|
-
SYNC_TYPES,
|
|
38
|
-
PATTERN_TYPES,
|
|
39
|
-
} from './block-patterns-filter';
|
|
40
|
-
|
|
41
|
-
const noop = () => {};
|
|
42
|
-
|
|
43
|
-
export const allPatternsCategory = {
|
|
44
|
-
name: 'allPatterns',
|
|
45
|
-
label: __( 'All patterns' ),
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const myPatternsCategory = {
|
|
49
|
-
name: 'myPatterns',
|
|
50
|
-
label: __( 'My patterns' ),
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export function isPatternFiltered( pattern, sourceFilter, syncFilter ) {
|
|
54
|
-
const isUserPattern = pattern.name.startsWith( 'core/block' );
|
|
55
|
-
const isDirectoryPattern =
|
|
56
|
-
pattern.source === 'core' ||
|
|
57
|
-
pattern.source?.startsWith( 'pattern-directory' );
|
|
58
|
-
|
|
59
|
-
// If theme source selected, filter out user created patterns and those from
|
|
60
|
-
// the core patterns directory.
|
|
61
|
-
if (
|
|
62
|
-
sourceFilter === PATTERN_TYPES.theme &&
|
|
63
|
-
( isUserPattern || isDirectoryPattern )
|
|
64
|
-
) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// If the directory source is selected, filter out user created patterns
|
|
69
|
-
// and those bundled with the theme.
|
|
70
|
-
if (
|
|
71
|
-
sourceFilter === PATTERN_TYPES.directory &&
|
|
72
|
-
( isUserPattern || ! isDirectoryPattern )
|
|
73
|
-
) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// If user source selected, filter out theme patterns. Any pattern without
|
|
78
|
-
// an id wasn't created by a user.
|
|
79
|
-
if ( sourceFilter === PATTERN_TYPES.user && ! pattern.id ) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Filter by sync status.
|
|
84
|
-
if ( syncFilter === SYNC_TYPES.full && pattern.syncStatus !== '' ) {
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
syncFilter === SYNC_TYPES.unsynced &&
|
|
90
|
-
pattern.syncStatus !== 'unsynced' &&
|
|
91
|
-
isUserPattern
|
|
92
|
-
) {
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function usePatternsCategories( rootClientId, sourceFilter = 'all' ) {
|
|
100
|
-
const [ patterns, allCategories ] = usePatternsState(
|
|
101
|
-
undefined,
|
|
102
|
-
rootClientId
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const filteredPatterns = useMemo(
|
|
106
|
-
() =>
|
|
107
|
-
sourceFilter === 'all'
|
|
108
|
-
? patterns
|
|
109
|
-
: patterns.filter(
|
|
110
|
-
( pattern ) =>
|
|
111
|
-
! isPatternFiltered( pattern, sourceFilter )
|
|
112
|
-
),
|
|
113
|
-
[ sourceFilter, patterns ]
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
const hasRegisteredCategory = useCallback(
|
|
117
|
-
( pattern ) => {
|
|
118
|
-
if ( ! pattern.categories || ! pattern.categories.length ) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return pattern.categories.some( ( cat ) =>
|
|
123
|
-
allCategories.some( ( category ) => category.name === cat )
|
|
124
|
-
);
|
|
125
|
-
},
|
|
126
|
-
[ allCategories ]
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
// Remove any empty categories.
|
|
130
|
-
const populatedCategories = useMemo( () => {
|
|
131
|
-
const categories = allCategories
|
|
132
|
-
.filter( ( category ) =>
|
|
133
|
-
filteredPatterns.some( ( pattern ) =>
|
|
134
|
-
pattern.categories?.includes( category.name )
|
|
135
|
-
)
|
|
136
|
-
)
|
|
137
|
-
.sort( ( a, b ) => a.label.localeCompare( b.label ) );
|
|
138
|
-
|
|
139
|
-
if (
|
|
140
|
-
filteredPatterns.some(
|
|
141
|
-
( pattern ) => ! hasRegisteredCategory( pattern )
|
|
142
|
-
) &&
|
|
143
|
-
! categories.find(
|
|
144
|
-
( category ) => category.name === 'uncategorized'
|
|
145
|
-
)
|
|
146
|
-
) {
|
|
147
|
-
categories.push( {
|
|
148
|
-
name: 'uncategorized',
|
|
149
|
-
label: _x( 'Uncategorized' ),
|
|
150
|
-
} );
|
|
151
|
-
}
|
|
152
|
-
if ( filteredPatterns.some( ( pattern ) => pattern.id ) ) {
|
|
153
|
-
categories.unshift( myPatternsCategory );
|
|
154
|
-
}
|
|
155
|
-
if ( filteredPatterns.length > 0 ) {
|
|
156
|
-
categories.unshift( {
|
|
157
|
-
name: allPatternsCategory.name,
|
|
158
|
-
label: allPatternsCategory.label,
|
|
159
|
-
} );
|
|
160
|
-
}
|
|
161
|
-
speak(
|
|
162
|
-
sprintf(
|
|
163
|
-
/* translators: %d: number of categories . */
|
|
164
|
-
_n(
|
|
165
|
-
'%d category button displayed.',
|
|
166
|
-
'%d category buttons displayed.',
|
|
167
|
-
categories.length
|
|
168
|
-
),
|
|
169
|
-
categories.length
|
|
170
|
-
)
|
|
171
|
-
);
|
|
172
|
-
return categories;
|
|
173
|
-
}, [ allCategories, filteredPatterns, hasRegisteredCategory ] );
|
|
174
|
-
|
|
175
|
-
return populatedCategories;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export function BlockPatternsCategoryDialog( {
|
|
179
|
-
rootClientId,
|
|
180
|
-
onInsert,
|
|
181
|
-
onHover,
|
|
182
|
-
category,
|
|
183
|
-
showTitlesAsTooltip,
|
|
184
|
-
patternFilter,
|
|
185
|
-
} ) {
|
|
186
|
-
const container = useRef();
|
|
187
|
-
|
|
188
|
-
useEffect( () => {
|
|
189
|
-
const timeout = setTimeout( () => {
|
|
190
|
-
const [ firstTabbable ] = focus.tabbable.find( container.current );
|
|
191
|
-
firstTabbable?.focus();
|
|
192
|
-
} );
|
|
193
|
-
return () => clearTimeout( timeout );
|
|
194
|
-
}, [ category ] );
|
|
195
|
-
|
|
196
|
-
return (
|
|
197
|
-
<div
|
|
198
|
-
ref={ container }
|
|
199
|
-
className="block-editor-inserter__patterns-category-dialog"
|
|
200
|
-
>
|
|
201
|
-
<BlockPatternsCategoryPanel
|
|
202
|
-
key={ category.name }
|
|
203
|
-
rootClientId={ rootClientId }
|
|
204
|
-
onInsert={ onInsert }
|
|
205
|
-
onHover={ onHover }
|
|
206
|
-
category={ category }
|
|
207
|
-
showTitlesAsTooltip={ showTitlesAsTooltip }
|
|
208
|
-
patternFilter={ patternFilter }
|
|
209
|
-
/>
|
|
210
|
-
</div>
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export function BlockPatternsCategoryPanel( {
|
|
215
|
-
rootClientId,
|
|
216
|
-
onInsert,
|
|
217
|
-
onHover = noop,
|
|
218
|
-
category,
|
|
219
|
-
showTitlesAsTooltip,
|
|
220
|
-
} ) {
|
|
221
|
-
const [ allPatterns, , onClickPattern ] = usePatternsState(
|
|
222
|
-
onInsert,
|
|
223
|
-
rootClientId
|
|
224
|
-
);
|
|
225
|
-
const [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );
|
|
226
|
-
const [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );
|
|
227
|
-
|
|
228
|
-
const availableCategories = usePatternsCategories(
|
|
229
|
-
rootClientId,
|
|
230
|
-
patternSourceFilter
|
|
231
|
-
);
|
|
232
|
-
const scrollContainerRef = useRef();
|
|
233
|
-
const currentCategoryPatterns = useMemo(
|
|
234
|
-
() =>
|
|
235
|
-
allPatterns.filter( ( pattern ) => {
|
|
236
|
-
if (
|
|
237
|
-
isPatternFiltered(
|
|
238
|
-
pattern,
|
|
239
|
-
patternSourceFilter,
|
|
240
|
-
patternSyncFilter
|
|
241
|
-
)
|
|
242
|
-
) {
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if ( category.name === allPatternsCategory.name ) {
|
|
247
|
-
return true;
|
|
248
|
-
}
|
|
249
|
-
if ( category.name === myPatternsCategory.name && pattern.id ) {
|
|
250
|
-
return true;
|
|
251
|
-
}
|
|
252
|
-
if ( category.name !== 'uncategorized' ) {
|
|
253
|
-
return pattern.categories?.includes( category.name );
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// The uncategorized category should show all the patterns without any category
|
|
257
|
-
// or with no available category.
|
|
258
|
-
const availablePatternCategories =
|
|
259
|
-
pattern.categories?.filter( ( cat ) =>
|
|
260
|
-
availableCategories.find(
|
|
261
|
-
( availableCategory ) =>
|
|
262
|
-
availableCategory.name === cat
|
|
263
|
-
)
|
|
264
|
-
) ?? [];
|
|
265
|
-
|
|
266
|
-
return availablePatternCategories.length === 0;
|
|
267
|
-
} ),
|
|
268
|
-
[
|
|
269
|
-
allPatterns,
|
|
270
|
-
availableCategories,
|
|
271
|
-
category.name,
|
|
272
|
-
patternSourceFilter,
|
|
273
|
-
patternSyncFilter,
|
|
274
|
-
]
|
|
275
|
-
);
|
|
276
|
-
|
|
277
|
-
const pagingProps = usePatternsPaging(
|
|
278
|
-
currentCategoryPatterns,
|
|
279
|
-
category,
|
|
280
|
-
scrollContainerRef
|
|
281
|
-
);
|
|
282
|
-
const { changePage } = pagingProps;
|
|
283
|
-
|
|
284
|
-
// Hide block pattern preview on unmount.
|
|
285
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
286
|
-
useEffect( () => () => onHover( null ), [] );
|
|
287
|
-
|
|
288
|
-
const onSetPatternSyncFilter = useCallback(
|
|
289
|
-
( value ) => {
|
|
290
|
-
setPatternSyncFilter( value );
|
|
291
|
-
changePage( 1 );
|
|
292
|
-
},
|
|
293
|
-
[ setPatternSyncFilter, changePage ]
|
|
294
|
-
);
|
|
295
|
-
const onSetPatternSourceFilter = useCallback(
|
|
296
|
-
( value ) => {
|
|
297
|
-
setPatternSourceFilter( value );
|
|
298
|
-
changePage( 1 );
|
|
299
|
-
},
|
|
300
|
-
[ setPatternSourceFilter, changePage ]
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
return (
|
|
304
|
-
<div className="block-editor-inserter__patterns-category-panel">
|
|
305
|
-
<VStack
|
|
306
|
-
spacing={ 2 }
|
|
307
|
-
className="block-editor-inserter__patterns-category-panel-header"
|
|
308
|
-
>
|
|
309
|
-
<HStack>
|
|
310
|
-
<FlexBlock>
|
|
311
|
-
<Heading level={ 4 } as="div">
|
|
312
|
-
{ category.label }
|
|
313
|
-
</Heading>
|
|
314
|
-
</FlexBlock>
|
|
315
|
-
<BlockPatternsSyncFilter
|
|
316
|
-
patternSyncFilter={ patternSyncFilter }
|
|
317
|
-
patternSourceFilter={ patternSourceFilter }
|
|
318
|
-
setPatternSyncFilter={ onSetPatternSyncFilter }
|
|
319
|
-
setPatternSourceFilter={ onSetPatternSourceFilter }
|
|
320
|
-
scrollContainerRef={ scrollContainerRef }
|
|
321
|
-
category={ category }
|
|
322
|
-
/>
|
|
323
|
-
</HStack>
|
|
324
|
-
{ ! currentCategoryPatterns.length && (
|
|
325
|
-
<Text
|
|
326
|
-
variant="muted"
|
|
327
|
-
className="block-editor-inserter__patterns-category-no-results"
|
|
328
|
-
>
|
|
329
|
-
{ __( 'No results found' ) }
|
|
330
|
-
</Text>
|
|
331
|
-
) }
|
|
332
|
-
</VStack>
|
|
333
|
-
|
|
334
|
-
{ currentCategoryPatterns.length > 0 && (
|
|
335
|
-
<BlockPatternList
|
|
336
|
-
ref={ scrollContainerRef }
|
|
337
|
-
shownPatterns={ pagingProps.categoryPatternsAsyncList }
|
|
338
|
-
blockPatterns={ pagingProps.categoryPatterns }
|
|
339
|
-
onClickPattern={ onClickPattern }
|
|
340
|
-
onHover={ onHover }
|
|
341
|
-
label={ category.label }
|
|
342
|
-
orientation="vertical"
|
|
343
|
-
category={ category.name }
|
|
344
|
-
isDraggable
|
|
345
|
-
showTitlesAsTooltip={ showTitlesAsTooltip }
|
|
346
|
-
patternFilter={ patternSourceFilter }
|
|
347
|
-
pagingProps={ pagingProps }
|
|
348
|
-
/>
|
|
349
|
-
) }
|
|
350
|
-
</div>
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
function BlockPatternsTabs( {
|
|
355
|
-
onSelectCategory,
|
|
356
|
-
selectedCategory,
|
|
357
|
-
onInsert,
|
|
358
|
-
rootClientId,
|
|
359
|
-
} ) {
|
|
360
|
-
const [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );
|
|
361
|
-
|
|
362
|
-
const categories = usePatternsCategories( rootClientId );
|
|
363
|
-
|
|
364
|
-
const initialCategory = selectedCategory || categories[ 0 ];
|
|
365
|
-
const isMobile = useViewportMatch( 'medium', '<' );
|
|
366
|
-
return (
|
|
367
|
-
<>
|
|
368
|
-
{ ! isMobile && (
|
|
369
|
-
<div className="block-editor-inserter__block-patterns-tabs-container">
|
|
370
|
-
<nav
|
|
371
|
-
aria-label={ __( 'Block pattern categories' ) }
|
|
372
|
-
className="block-editor-inserter__block-patterns-tabs"
|
|
373
|
-
>
|
|
374
|
-
<ItemGroup role="list">
|
|
375
|
-
{ categories.map( ( category ) => (
|
|
376
|
-
<Item
|
|
377
|
-
role="listitem"
|
|
378
|
-
key={ category.name }
|
|
379
|
-
onClick={ () =>
|
|
380
|
-
onSelectCategory( category )
|
|
381
|
-
}
|
|
382
|
-
className={
|
|
383
|
-
category === selectedCategory
|
|
384
|
-
? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category'
|
|
385
|
-
: 'block-editor-inserter__patterns-category'
|
|
386
|
-
}
|
|
387
|
-
aria-label={ category.label }
|
|
388
|
-
aria-current={
|
|
389
|
-
category === selectedCategory
|
|
390
|
-
? 'true'
|
|
391
|
-
: undefined
|
|
392
|
-
}
|
|
393
|
-
>
|
|
394
|
-
<HStack>
|
|
395
|
-
<FlexBlock>
|
|
396
|
-
{ category.label }
|
|
397
|
-
</FlexBlock>
|
|
398
|
-
<Icon
|
|
399
|
-
icon={
|
|
400
|
-
isRTL()
|
|
401
|
-
? chevronLeft
|
|
402
|
-
: chevronRight
|
|
403
|
-
}
|
|
404
|
-
/>
|
|
405
|
-
</HStack>
|
|
406
|
-
</Item>
|
|
407
|
-
) ) }
|
|
408
|
-
<div role="listitem">
|
|
409
|
-
<Button
|
|
410
|
-
className="block-editor-inserter__patterns-explore-button"
|
|
411
|
-
onClick={ () =>
|
|
412
|
-
setShowPatternsExplorer( true )
|
|
413
|
-
}
|
|
414
|
-
variant="secondary"
|
|
415
|
-
>
|
|
416
|
-
{ __( 'Explore all patterns' ) }
|
|
417
|
-
</Button>
|
|
418
|
-
</div>
|
|
419
|
-
</ItemGroup>
|
|
420
|
-
</nav>
|
|
421
|
-
</div>
|
|
422
|
-
) }
|
|
423
|
-
{ isMobile && (
|
|
424
|
-
<MobileTabNavigation categories={ categories }>
|
|
425
|
-
{ ( category ) => (
|
|
426
|
-
<BlockPatternsCategoryPanel
|
|
427
|
-
key={ category.name }
|
|
428
|
-
onInsert={ onInsert }
|
|
429
|
-
rootClientId={ rootClientId }
|
|
430
|
-
category={ category }
|
|
431
|
-
showTitlesAsTooltip={ false }
|
|
432
|
-
/>
|
|
433
|
-
) }
|
|
434
|
-
</MobileTabNavigation>
|
|
435
|
-
) }
|
|
436
|
-
{ showPatternsExplorer && (
|
|
437
|
-
<PatternsExplorerModal
|
|
438
|
-
initialCategory={ initialCategory }
|
|
439
|
-
patternCategories={ categories }
|
|
440
|
-
onModalClose={ () => setShowPatternsExplorer( false ) }
|
|
441
|
-
rootClientId={ rootClientId }
|
|
442
|
-
/>
|
|
443
|
-
) }
|
|
444
|
-
</>
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
export default BlockPatternsTabs;
|
package/src/store/utils.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper function that maps attribute definition properties to the
|
|
3
|
-
* ones used by RichText utils like `create, toHTMLString, etc..`.
|
|
4
|
-
*
|
|
5
|
-
* @param {Object} attributeDefinition A block's attribute definition object.
|
|
6
|
-
* @return {Object} The mapped object.
|
|
7
|
-
*/
|
|
8
|
-
export function mapRichTextSettings( attributeDefinition ) {
|
|
9
|
-
const { __unstablePreserveWhiteSpace: preserveWhiteSpace } =
|
|
10
|
-
attributeDefinition;
|
|
11
|
-
return { preserveWhiteSpace };
|
|
12
|
-
}
|
/package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js}
RENAMED
|
File without changes
|