@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,270 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.BlockPatternsCategoryDialog = BlockPatternsCategoryDialog;
|
|
8
|
-
exports.BlockPatternsCategoryPanel = BlockPatternsCategoryPanel;
|
|
9
|
-
exports.default = exports.allPatternsCategory = void 0;
|
|
10
|
-
exports.isPatternFiltered = isPatternFiltered;
|
|
11
|
-
exports.myPatternsCategory = void 0;
|
|
12
|
-
exports.usePatternsCategories = usePatternsCategories;
|
|
13
|
-
var _react = require("react");
|
|
14
|
-
var _element = require("@wordpress/element");
|
|
15
|
-
var _i18n = require("@wordpress/i18n");
|
|
16
|
-
var _compose = require("@wordpress/compose");
|
|
17
|
-
var _components = require("@wordpress/components");
|
|
18
|
-
var _icons = require("@wordpress/icons");
|
|
19
|
-
var _dom = require("@wordpress/dom");
|
|
20
|
-
var _a11y = require("@wordpress/a11y");
|
|
21
|
-
var _usePatternsState = _interopRequireDefault(require("./hooks/use-patterns-state"));
|
|
22
|
-
var _blockPatternsList = _interopRequireDefault(require("../block-patterns-list"));
|
|
23
|
-
var _explorer = _interopRequireDefault(require("./block-patterns-explorer/explorer"));
|
|
24
|
-
var _mobileTabNavigation = _interopRequireDefault(require("./mobile-tab-navigation"));
|
|
25
|
-
var _usePatternsPaging = _interopRequireDefault(require("./hooks/use-patterns-paging"));
|
|
26
|
-
var _blockPatternsFilter = require("./block-patterns-filter");
|
|
27
|
-
/**
|
|
28
|
-
* WordPress dependencies
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Internal dependencies
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
const noop = () => {};
|
|
36
|
-
const allPatternsCategory = {
|
|
37
|
-
name: 'allPatterns',
|
|
38
|
-
label: (0, _i18n.__)('All patterns')
|
|
39
|
-
};
|
|
40
|
-
exports.allPatternsCategory = allPatternsCategory;
|
|
41
|
-
const myPatternsCategory = {
|
|
42
|
-
name: 'myPatterns',
|
|
43
|
-
label: (0, _i18n.__)('My patterns')
|
|
44
|
-
};
|
|
45
|
-
exports.myPatternsCategory = myPatternsCategory;
|
|
46
|
-
function isPatternFiltered(pattern, sourceFilter, syncFilter) {
|
|
47
|
-
const isUserPattern = pattern.name.startsWith('core/block');
|
|
48
|
-
const isDirectoryPattern = pattern.source === 'core' || pattern.source?.startsWith('pattern-directory');
|
|
49
|
-
|
|
50
|
-
// If theme source selected, filter out user created patterns and those from
|
|
51
|
-
// the core patterns directory.
|
|
52
|
-
if (sourceFilter === _blockPatternsFilter.PATTERN_TYPES.theme && (isUserPattern || isDirectoryPattern)) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// If the directory source is selected, filter out user created patterns
|
|
57
|
-
// and those bundled with the theme.
|
|
58
|
-
if (sourceFilter === _blockPatternsFilter.PATTERN_TYPES.directory && (isUserPattern || !isDirectoryPattern)) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// If user source selected, filter out theme patterns. Any pattern without
|
|
63
|
-
// an id wasn't created by a user.
|
|
64
|
-
if (sourceFilter === _blockPatternsFilter.PATTERN_TYPES.user && !pattern.id) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Filter by sync status.
|
|
69
|
-
if (syncFilter === _blockPatternsFilter.SYNC_TYPES.full && pattern.syncStatus !== '') {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
if (syncFilter === _blockPatternsFilter.SYNC_TYPES.unsynced && pattern.syncStatus !== 'unsynced' && isUserPattern) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
function usePatternsCategories(rootClientId, sourceFilter = 'all') {
|
|
78
|
-
const [patterns, allCategories] = (0, _usePatternsState.default)(undefined, rootClientId);
|
|
79
|
-
const filteredPatterns = (0, _element.useMemo)(() => sourceFilter === 'all' ? patterns : patterns.filter(pattern => !isPatternFiltered(pattern, sourceFilter)), [sourceFilter, patterns]);
|
|
80
|
-
const hasRegisteredCategory = (0, _element.useCallback)(pattern => {
|
|
81
|
-
if (!pattern.categories || !pattern.categories.length) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
return pattern.categories.some(cat => allCategories.some(category => category.name === cat));
|
|
85
|
-
}, [allCategories]);
|
|
86
|
-
|
|
87
|
-
// Remove any empty categories.
|
|
88
|
-
const populatedCategories = (0, _element.useMemo)(() => {
|
|
89
|
-
const categories = allCategories.filter(category => filteredPatterns.some(pattern => pattern.categories?.includes(category.name))).sort((a, b) => a.label.localeCompare(b.label));
|
|
90
|
-
if (filteredPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
|
|
91
|
-
categories.push({
|
|
92
|
-
name: 'uncategorized',
|
|
93
|
-
label: (0, _i18n._x)('Uncategorized')
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
if (filteredPatterns.some(pattern => pattern.id)) {
|
|
97
|
-
categories.unshift(myPatternsCategory);
|
|
98
|
-
}
|
|
99
|
-
if (filteredPatterns.length > 0) {
|
|
100
|
-
categories.unshift({
|
|
101
|
-
name: allPatternsCategory.name,
|
|
102
|
-
label: allPatternsCategory.label
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
(0, _a11y.speak)((0, _i18n.sprintf)( /* translators: %d: number of categories . */
|
|
106
|
-
(0, _i18n._n)('%d category button displayed.', '%d category buttons displayed.', categories.length), categories.length));
|
|
107
|
-
return categories;
|
|
108
|
-
}, [allCategories, filteredPatterns, hasRegisteredCategory]);
|
|
109
|
-
return populatedCategories;
|
|
110
|
-
}
|
|
111
|
-
function BlockPatternsCategoryDialog({
|
|
112
|
-
rootClientId,
|
|
113
|
-
onInsert,
|
|
114
|
-
onHover,
|
|
115
|
-
category,
|
|
116
|
-
showTitlesAsTooltip,
|
|
117
|
-
patternFilter
|
|
118
|
-
}) {
|
|
119
|
-
const container = (0, _element.useRef)();
|
|
120
|
-
(0, _element.useEffect)(() => {
|
|
121
|
-
const timeout = setTimeout(() => {
|
|
122
|
-
const [firstTabbable] = _dom.focus.tabbable.find(container.current);
|
|
123
|
-
firstTabbable?.focus();
|
|
124
|
-
});
|
|
125
|
-
return () => clearTimeout(timeout);
|
|
126
|
-
}, [category]);
|
|
127
|
-
return (0, _react.createElement)("div", {
|
|
128
|
-
ref: container,
|
|
129
|
-
className: "block-editor-inserter__patterns-category-dialog"
|
|
130
|
-
}, (0, _react.createElement)(BlockPatternsCategoryPanel, {
|
|
131
|
-
key: category.name,
|
|
132
|
-
rootClientId: rootClientId,
|
|
133
|
-
onInsert: onInsert,
|
|
134
|
-
onHover: onHover,
|
|
135
|
-
category: category,
|
|
136
|
-
showTitlesAsTooltip: showTitlesAsTooltip,
|
|
137
|
-
patternFilter: patternFilter
|
|
138
|
-
}));
|
|
139
|
-
}
|
|
140
|
-
function BlockPatternsCategoryPanel({
|
|
141
|
-
rootClientId,
|
|
142
|
-
onInsert,
|
|
143
|
-
onHover = noop,
|
|
144
|
-
category,
|
|
145
|
-
showTitlesAsTooltip
|
|
146
|
-
}) {
|
|
147
|
-
const [allPatterns,, onClickPattern] = (0, _usePatternsState.default)(onInsert, rootClientId);
|
|
148
|
-
const [patternSyncFilter, setPatternSyncFilter] = (0, _element.useState)('all');
|
|
149
|
-
const [patternSourceFilter, setPatternSourceFilter] = (0, _element.useState)('all');
|
|
150
|
-
const availableCategories = usePatternsCategories(rootClientId, patternSourceFilter);
|
|
151
|
-
const scrollContainerRef = (0, _element.useRef)();
|
|
152
|
-
const currentCategoryPatterns = (0, _element.useMemo)(() => allPatterns.filter(pattern => {
|
|
153
|
-
var _pattern$categories$f;
|
|
154
|
-
if (isPatternFiltered(pattern, patternSourceFilter, patternSyncFilter)) {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
if (category.name === allPatternsCategory.name) {
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
if (category.name === myPatternsCategory.name && pattern.id) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
if (category.name !== 'uncategorized') {
|
|
164
|
-
return pattern.categories?.includes(category.name);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// The uncategorized category should show all the patterns without any category
|
|
168
|
-
// or with no available category.
|
|
169
|
-
const availablePatternCategories = (_pattern$categories$f = pattern.categories?.filter(cat => availableCategories.find(availableCategory => availableCategory.name === cat))) !== null && _pattern$categories$f !== void 0 ? _pattern$categories$f : [];
|
|
170
|
-
return availablePatternCategories.length === 0;
|
|
171
|
-
}), [allPatterns, availableCategories, category.name, patternSourceFilter, patternSyncFilter]);
|
|
172
|
-
const pagingProps = (0, _usePatternsPaging.default)(currentCategoryPatterns, category, scrollContainerRef);
|
|
173
|
-
const {
|
|
174
|
-
changePage
|
|
175
|
-
} = pagingProps;
|
|
176
|
-
|
|
177
|
-
// Hide block pattern preview on unmount.
|
|
178
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
179
|
-
(0, _element.useEffect)(() => () => onHover(null), []);
|
|
180
|
-
const onSetPatternSyncFilter = (0, _element.useCallback)(value => {
|
|
181
|
-
setPatternSyncFilter(value);
|
|
182
|
-
changePage(1);
|
|
183
|
-
}, [setPatternSyncFilter, changePage]);
|
|
184
|
-
const onSetPatternSourceFilter = (0, _element.useCallback)(value => {
|
|
185
|
-
setPatternSourceFilter(value);
|
|
186
|
-
changePage(1);
|
|
187
|
-
}, [setPatternSourceFilter, changePage]);
|
|
188
|
-
return (0, _react.createElement)("div", {
|
|
189
|
-
className: "block-editor-inserter__patterns-category-panel"
|
|
190
|
-
}, (0, _react.createElement)(_components.__experimentalVStack, {
|
|
191
|
-
spacing: 2,
|
|
192
|
-
className: "block-editor-inserter__patterns-category-panel-header"
|
|
193
|
-
}, (0, _react.createElement)(_components.__experimentalHStack, null, (0, _react.createElement)(_components.FlexBlock, null, (0, _react.createElement)(_components.__experimentalHeading, {
|
|
194
|
-
level: 4,
|
|
195
|
-
as: "div"
|
|
196
|
-
}, category.label)), (0, _react.createElement)(_blockPatternsFilter.BlockPatternsSyncFilter, {
|
|
197
|
-
patternSyncFilter: patternSyncFilter,
|
|
198
|
-
patternSourceFilter: patternSourceFilter,
|
|
199
|
-
setPatternSyncFilter: onSetPatternSyncFilter,
|
|
200
|
-
setPatternSourceFilter: onSetPatternSourceFilter,
|
|
201
|
-
scrollContainerRef: scrollContainerRef,
|
|
202
|
-
category: category
|
|
203
|
-
})), !currentCategoryPatterns.length && (0, _react.createElement)(_components.__experimentalText, {
|
|
204
|
-
variant: "muted",
|
|
205
|
-
className: "block-editor-inserter__patterns-category-no-results"
|
|
206
|
-
}, (0, _i18n.__)('No results found'))), currentCategoryPatterns.length > 0 && (0, _react.createElement)(_blockPatternsList.default, {
|
|
207
|
-
ref: scrollContainerRef,
|
|
208
|
-
shownPatterns: pagingProps.categoryPatternsAsyncList,
|
|
209
|
-
blockPatterns: pagingProps.categoryPatterns,
|
|
210
|
-
onClickPattern: onClickPattern,
|
|
211
|
-
onHover: onHover,
|
|
212
|
-
label: category.label,
|
|
213
|
-
orientation: "vertical",
|
|
214
|
-
category: category.name,
|
|
215
|
-
isDraggable: true,
|
|
216
|
-
showTitlesAsTooltip: showTitlesAsTooltip,
|
|
217
|
-
patternFilter: patternSourceFilter,
|
|
218
|
-
pagingProps: pagingProps
|
|
219
|
-
}));
|
|
220
|
-
}
|
|
221
|
-
function BlockPatternsTabs({
|
|
222
|
-
onSelectCategory,
|
|
223
|
-
selectedCategory,
|
|
224
|
-
onInsert,
|
|
225
|
-
rootClientId
|
|
226
|
-
}) {
|
|
227
|
-
const [showPatternsExplorer, setShowPatternsExplorer] = (0, _element.useState)(false);
|
|
228
|
-
const categories = usePatternsCategories(rootClientId);
|
|
229
|
-
const initialCategory = selectedCategory || categories[0];
|
|
230
|
-
const isMobile = (0, _compose.useViewportMatch)('medium', '<');
|
|
231
|
-
return (0, _react.createElement)(_react.Fragment, null, !isMobile && (0, _react.createElement)("div", {
|
|
232
|
-
className: "block-editor-inserter__block-patterns-tabs-container"
|
|
233
|
-
}, (0, _react.createElement)("nav", {
|
|
234
|
-
"aria-label": (0, _i18n.__)('Block pattern categories'),
|
|
235
|
-
className: "block-editor-inserter__block-patterns-tabs"
|
|
236
|
-
}, (0, _react.createElement)(_components.__experimentalItemGroup, {
|
|
237
|
-
role: "list"
|
|
238
|
-
}, categories.map(category => (0, _react.createElement)(_components.__experimentalItem, {
|
|
239
|
-
role: "listitem",
|
|
240
|
-
key: category.name,
|
|
241
|
-
onClick: () => onSelectCategory(category),
|
|
242
|
-
className: category === selectedCategory ? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category' : 'block-editor-inserter__patterns-category',
|
|
243
|
-
"aria-label": category.label,
|
|
244
|
-
"aria-current": category === selectedCategory ? 'true' : undefined
|
|
245
|
-
}, (0, _react.createElement)(_components.__experimentalHStack, null, (0, _react.createElement)(_components.FlexBlock, null, category.label), (0, _react.createElement)(_icons.Icon, {
|
|
246
|
-
icon: (0, _i18n.isRTL)() ? _icons.chevronLeft : _icons.chevronRight
|
|
247
|
-
})))), (0, _react.createElement)("div", {
|
|
248
|
-
role: "listitem"
|
|
249
|
-
}, (0, _react.createElement)(_components.Button, {
|
|
250
|
-
className: "block-editor-inserter__patterns-explore-button",
|
|
251
|
-
onClick: () => setShowPatternsExplorer(true),
|
|
252
|
-
variant: "secondary"
|
|
253
|
-
}, (0, _i18n.__)('Explore all patterns')))))), isMobile && (0, _react.createElement)(_mobileTabNavigation.default, {
|
|
254
|
-
categories: categories
|
|
255
|
-
}, category => (0, _react.createElement)(BlockPatternsCategoryPanel, {
|
|
256
|
-
key: category.name,
|
|
257
|
-
onInsert: onInsert,
|
|
258
|
-
rootClientId: rootClientId,
|
|
259
|
-
category: category,
|
|
260
|
-
showTitlesAsTooltip: false
|
|
261
|
-
})), showPatternsExplorer && (0, _react.createElement)(_explorer.default, {
|
|
262
|
-
initialCategory: initialCategory,
|
|
263
|
-
patternCategories: categories,
|
|
264
|
-
onModalClose: () => setShowPatternsExplorer(false),
|
|
265
|
-
rootClientId: rootClientId
|
|
266
|
-
}));
|
|
267
|
-
}
|
|
268
|
-
var _default = BlockPatternsTabs;
|
|
269
|
-
exports.default = _default;
|
|
270
|
-
//# sourceMappingURL=block-patterns-tab.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_compose","_components","_icons","_dom","_a11y","_usePatternsState","_interopRequireDefault","_blockPatternsList","_explorer","_mobileTabNavigation","_usePatternsPaging","_blockPatternsFilter","noop","allPatternsCategory","name","label","__","exports","myPatternsCategory","isPatternFiltered","pattern","sourceFilter","syncFilter","isUserPattern","startsWith","isDirectoryPattern","source","PATTERN_TYPES","theme","directory","user","id","SYNC_TYPES","full","syncStatus","unsynced","usePatternsCategories","rootClientId","patterns","allCategories","usePatternsState","undefined","filteredPatterns","useMemo","filter","hasRegisteredCategory","useCallback","categories","length","some","cat","category","populatedCategories","includes","sort","a","b","localeCompare","find","push","_x","unshift","speak","sprintf","_n","BlockPatternsCategoryDialog","onInsert","onHover","showTitlesAsTooltip","patternFilter","container","useRef","useEffect","timeout","setTimeout","firstTabbable","focus","tabbable","current","clearTimeout","_react","createElement","ref","className","BlockPatternsCategoryPanel","key","allPatterns","onClickPattern","patternSyncFilter","setPatternSyncFilter","useState","patternSourceFilter","setPatternSourceFilter","availableCategories","scrollContainerRef","currentCategoryPatterns","_pattern$categories$f","availablePatternCategories","availableCategory","pagingProps","usePatternsPaging","changePage","onSetPatternSyncFilter","value","onSetPatternSourceFilter","__experimentalVStack","spacing","__experimentalHStack","FlexBlock","__experimentalHeading","level","as","BlockPatternsSyncFilter","__experimentalText","variant","default","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","orientation","isDraggable","BlockPatternsTabs","onSelectCategory","selectedCategory","showPatternsExplorer","setShowPatternsExplorer","initialCategory","isMobile","useViewportMatch","Fragment","__experimentalItemGroup","role","map","__experimentalItem","onClick","Icon","icon","isRTL","chevronLeft","chevronRight","Button","patternCategories","onModalClose","_default"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { _x, __, _n, isRTL, sprintf } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n\tFlexBlock,\n\tButton,\n} from '@wordpress/components';\nimport { Icon, chevronRight, chevronLeft } from '@wordpress/icons';\nimport { focus } from '@wordpress/dom';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from './hooks/use-patterns-state';\nimport BlockPatternList from '../block-patterns-list';\nimport PatternsExplorerModal from './block-patterns-explorer/explorer';\nimport MobileTabNavigation from './mobile-tab-navigation';\nimport usePatternsPaging from './hooks/use-patterns-paging';\nimport {\n\tBlockPatternsSyncFilter,\n\tSYNC_TYPES,\n\tPATTERN_TYPES,\n} from './block-patterns-filter';\n\nconst noop = () => {};\n\nexport const allPatternsCategory = {\n\tname: 'allPatterns',\n\tlabel: __( 'All patterns' ),\n};\n\nexport const myPatternsCategory = {\n\tname: 'myPatterns',\n\tlabel: __( 'My patterns' ),\n};\n\nexport function isPatternFiltered( pattern, sourceFilter, syncFilter ) {\n\tconst isUserPattern = pattern.name.startsWith( 'core/block' );\n\tconst isDirectoryPattern =\n\t\tpattern.source === 'core' ||\n\t\tpattern.source?.startsWith( 'pattern-directory' );\n\n\t// If theme source selected, filter out user created patterns and those from\n\t// the core patterns directory.\n\tif (\n\t\tsourceFilter === PATTERN_TYPES.theme &&\n\t\t( isUserPattern || isDirectoryPattern )\n\t) {\n\t\treturn true;\n\t}\n\n\t// If the directory source is selected, filter out user created patterns\n\t// and those bundled with the theme.\n\tif (\n\t\tsourceFilter === PATTERN_TYPES.directory &&\n\t\t( isUserPattern || ! isDirectoryPattern )\n\t) {\n\t\treturn true;\n\t}\n\n\t// If user source selected, filter out theme patterns. Any pattern without\n\t// an id wasn't created by a user.\n\tif ( sourceFilter === PATTERN_TYPES.user && ! pattern.id ) {\n\t\treturn true;\n\t}\n\n\t// Filter by sync status.\n\tif ( syncFilter === SYNC_TYPES.full && pattern.syncStatus !== '' ) {\n\t\treturn true;\n\t}\n\n\tif (\n\t\tsyncFilter === SYNC_TYPES.unsynced &&\n\t\tpattern.syncStatus !== 'unsynced' &&\n\t\tisUserPattern\n\t) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nexport function usePatternsCategories( rootClientId, sourceFilter = 'all' ) {\n\tconst [ patterns, allCategories ] = usePatternsState(\n\t\tundefined,\n\t\trootClientId\n\t);\n\n\tconst filteredPatterns = useMemo(\n\t\t() =>\n\t\t\tsourceFilter === 'all'\n\t\t\t\t? patterns\n\t\t\t\t: patterns.filter(\n\t\t\t\t\t\t( pattern ) =>\n\t\t\t\t\t\t\t! isPatternFiltered( pattern, sourceFilter )\n\t\t\t\t ),\n\t\t[ sourceFilter, patterns ]\n\t);\n\n\tconst hasRegisteredCategory = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn pattern.categories.some( ( cat ) =>\n\t\t\t\tallCategories.some( ( category ) => category.name === cat )\n\t\t\t);\n\t\t},\n\t\t[ allCategories ]\n\t);\n\n\t// Remove any empty categories.\n\tconst populatedCategories = useMemo( () => {\n\t\tconst categories = allCategories\n\t\t\t.filter( ( category ) =>\n\t\t\t\tfilteredPatterns.some( ( pattern ) =>\n\t\t\t\t\tpattern.categories?.includes( category.name )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.sort( ( a, b ) => a.label.localeCompare( b.label ) );\n\n\t\tif (\n\t\t\tfilteredPatterns.some(\n\t\t\t\t( pattern ) => ! hasRegisteredCategory( pattern )\n\t\t\t) &&\n\t\t\t! categories.find(\n\t\t\t\t( category ) => category.name === 'uncategorized'\n\t\t\t)\n\t\t) {\n\t\t\tcategories.push( {\n\t\t\t\tname: 'uncategorized',\n\t\t\t\tlabel: _x( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\t\tif ( filteredPatterns.some( ( pattern ) => pattern.id ) ) {\n\t\t\tcategories.unshift( myPatternsCategory );\n\t\t}\n\t\tif ( filteredPatterns.length > 0 ) {\n\t\t\tcategories.unshift( {\n\t\t\t\tname: allPatternsCategory.name,\n\t\t\t\tlabel: allPatternsCategory.label,\n\t\t\t} );\n\t\t}\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of categories . */\n\t\t\t\t_n(\n\t\t\t\t\t'%d category button displayed.',\n\t\t\t\t\t'%d category buttons displayed.',\n\t\t\t\t\tcategories.length\n\t\t\t\t),\n\t\t\t\tcategories.length\n\t\t\t)\n\t\t);\n\t\treturn categories;\n\t}, [ allCategories, filteredPatterns, hasRegisteredCategory ] );\n\n\treturn populatedCategories;\n}\n\nexport function BlockPatternsCategoryDialog( {\n\trootClientId,\n\tonInsert,\n\tonHover,\n\tcategory,\n\tshowTitlesAsTooltip,\n\tpatternFilter,\n} ) {\n\tconst container = useRef();\n\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tconst [ firstTabbable ] = focus.tabbable.find( container.current );\n\t\t\tfirstTabbable?.focus();\n\t\t} );\n\t\treturn () => clearTimeout( timeout );\n\t}, [ category ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ container }\n\t\t\tclassName=\"block-editor-inserter__patterns-category-dialog\"\n\t\t>\n\t\t\t<BlockPatternsCategoryPanel\n\t\t\t\tkey={ category.name }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tcategory={ category }\n\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\tpatternFilter={ patternFilter }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport function BlockPatternsCategoryPanel( {\n\trootClientId,\n\tonInsert,\n\tonHover = noop,\n\tcategory,\n\tshowTitlesAsTooltip,\n} ) {\n\tconst [ allPatterns, , onClickPattern ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\tconst [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst availableCategories = usePatternsCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\tconst scrollContainerRef = useRef();\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) => {\n\t\t\t\tif (\n\t\t\t\t\tisPatternFiltered(\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tpatternSourceFilter,\n\t\t\t\t\t\tpatternSyncFilter\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ( category.name === allPatternsCategory.name ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif ( category.name === myPatternsCategory.name && pattern.id ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif ( category.name !== 'uncategorized' ) {\n\t\t\t\t\treturn pattern.categories?.includes( category.name );\n\t\t\t\t}\n\n\t\t\t\t// The uncategorized category should show all the patterns without any category\n\t\t\t\t// or with no available category.\n\t\t\t\tconst availablePatternCategories =\n\t\t\t\t\tpattern.categories?.filter( ( cat ) =>\n\t\t\t\t\t\tavailableCategories.find(\n\t\t\t\t\t\t\t( availableCategory ) =>\n\t\t\t\t\t\t\t\tavailableCategory.name === cat\n\t\t\t\t\t\t)\n\t\t\t\t\t) ?? [];\n\n\t\t\t\treturn availablePatternCategories.length === 0;\n\t\t\t} ),\n\t\t[\n\t\t\tallPatterns,\n\t\t\tavailableCategories,\n\t\t\tcategory.name,\n\t\t\tpatternSourceFilter,\n\t\t\tpatternSyncFilter,\n\t\t]\n\t);\n\n\tconst pagingProps = usePatternsPaging(\n\t\tcurrentCategoryPatterns,\n\t\tcategory,\n\t\tscrollContainerRef\n\t);\n\tconst { changePage } = pagingProps;\n\n\t// Hide block pattern preview on unmount.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tuseEffect( () => () => onHover( null ), [] );\n\n\tconst onSetPatternSyncFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSyncFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSyncFilter, changePage ]\n\t);\n\tconst onSetPatternSourceFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSourceFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSourceFilter, changePage ]\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-inserter__patterns-category-panel\">\n\t\t\t<VStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"block-editor-inserter__patterns-category-panel-header\"\n\t\t\t>\n\t\t\t\t<HStack>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<Heading level={ 4 } as=\"div\">\n\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<BlockPatternsSyncFilter\n\t\t\t\t\t\tpatternSyncFilter={ patternSyncFilter }\n\t\t\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\t\t\tsetPatternSyncFilter={ onSetPatternSyncFilter }\n\t\t\t\t\t\tsetPatternSourceFilter={ onSetPatternSourceFilter }\n\t\t\t\t\t\tscrollContainerRef={ scrollContainerRef }\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t{ ! currentCategoryPatterns.length && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-category-no-results\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'No results found' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</VStack>\n\n\t\t\t{ currentCategoryPatterns.length > 0 && (\n\t\t\t\t<BlockPatternList\n\t\t\t\t\tref={ scrollContainerRef }\n\t\t\t\t\tshownPatterns={ pagingProps.categoryPatternsAsyncList }\n\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\tlabel={ category.label }\n\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\tcategory={ category.name }\n\t\t\t\t\tisDraggable\n\t\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\t\tpatternFilter={ patternSourceFilter }\n\t\t\t\t\tpagingProps={ pagingProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nfunction BlockPatternsTabs( {\n\tonSelectCategory,\n\tselectedCategory,\n\tonInsert,\n\trootClientId,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\n\tconst categories = usePatternsCategories( rootClientId );\n\n\tconst initialCategory = selectedCategory || categories[ 0 ];\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn (\n\t\t<>\n\t\t\t{ ! isMobile && (\n\t\t\t\t<div className=\"block-editor-inserter__block-patterns-tabs-container\">\n\t\t\t\t\t<nav\n\t\t\t\t\t\taria-label={ __( 'Block pattern categories' ) }\n\t\t\t\t\t\tclassName=\"block-editor-inserter__block-patterns-tabs\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ItemGroup role=\"list\">\n\t\t\t\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t\t\t\t<Item\n\t\t\t\t\t\t\t\t\trole=\"listitem\"\n\t\t\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tonSelectCategory( category )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category'\n\t\t\t\t\t\t\t\t\t\t\t: 'block-editor-inserter__patterns-category'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-label={ category.label }\n\t\t\t\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronRight\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t<div role=\"listitem\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explore-button\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowPatternsExplorer( true )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Explore all patterns' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t</nav>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isMobile && (\n\t\t\t\t<MobileTabNavigation categories={ categories }>\n\t\t\t\t\t{ ( category ) => (\n\t\t\t\t\t\t<BlockPatternsCategoryPanel\n\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\tshowTitlesAsTooltip={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</MobileTabNavigation>\n\t\t\t) }\n\t\t\t{ showPatternsExplorer && (\n\t\t\t\t<PatternsExplorerModal\n\t\t\t\t\tinitialCategory={ initialCategory }\n\t\t\t\t\tpatternCategories={ categories }\n\t\t\t\t\tonModalClose={ () => setShowPatternsExplorer( false ) }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default BlockPatternsTabs;\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA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AK,CAC9B;IACDZ,OAAO,EAAC;EAAW,GAEjB,IAAAlG,QAAE,EAAE,sBAAuB,CACtB,CACJ,CACK,CACP,CACD,CACL,EACCgH,QAAQ,IACT,IAAAhD,MAAA,CAAAC,aAAA,EAACxE,oBAAA,CAAA0G,OAAmB;IAACpE,UAAU,EAAGA;EAAY,GACzCI,QAAQ,IACX,IAAA6B,MAAA,CAAAC,aAAA,EAACG,0BAA0B;IAC1BC,GAAG,EAAGlC,QAAQ,CAACrC,IAAM;IACrBoD,QAAQ,EAAGA,QAAU;IACrB7B,YAAY,EAAGA,YAAc;IAC7Bc,QAAQ,EAAGA,QAAU;IACrBiB,mBAAmB,EAAG;EAAO,CAC7B,CAEkB,CACrB,EACCyD,oBAAoB,IACrB,IAAA7C,MAAA,CAAAC,aAAA,EAACzE,SAAA,CAAA2G,OAAqB;IACrBY,eAAe,EAAGA,eAAiB;IACnCe,iBAAiB,EAAG/F,UAAY;IAChCgG,YAAY,EAAGA,CAAA,KAAMjB,uBAAuB,CAAE,KAAM,CAAG;IACvDzF,YAAY,EAAGA;EAAc,CAC7B,CAED,CAAC;AAEL;AAAC,IAAA2G,QAAA,GAEctB,iBAAiB;AAAAzG,OAAA,CAAAkG,OAAA,GAAA6B,QAAA"}
|
package/build/store/utils.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mapRichTextSettings = mapRichTextSettings;
|
|
7
|
-
/**
|
|
8
|
-
* Helper function that maps attribute definition properties to the
|
|
9
|
-
* ones used by RichText utils like `create, toHTMLString, etc..`.
|
|
10
|
-
*
|
|
11
|
-
* @param {Object} attributeDefinition A block's attribute definition object.
|
|
12
|
-
* @return {Object} The mapped object.
|
|
13
|
-
*/
|
|
14
|
-
function mapRichTextSettings(attributeDefinition) {
|
|
15
|
-
const {
|
|
16
|
-
__unstablePreserveWhiteSpace: preserveWhiteSpace
|
|
17
|
-
} = attributeDefinition;
|
|
18
|
-
return {
|
|
19
|
-
preserveWhiteSpace
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=utils.js.map
|
package/build/store/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["mapRichTextSettings","attributeDefinition","__unstablePreserveWhiteSpace","preserveWhiteSpace"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * Helper function that maps attribute definition properties to the\n * ones used by RichText utils like `create, toHTMLString, etc..`.\n *\n * @param {Object} attributeDefinition A block's attribute definition object.\n * @return {Object} The mapped object.\n */\nexport function mapRichTextSettings( attributeDefinition ) {\n\tconst { __unstablePreserveWhiteSpace: preserveWhiteSpace } =\n\t\tattributeDefinition;\n\treturn { preserveWhiteSpace };\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAmBA,CAAEC,mBAAmB,EAAG;EAC1D,MAAM;IAAEC,4BAA4B,EAAEC;EAAmB,CAAC,GACzDF,mBAAmB;EACpB,OAAO;IAAEE;EAAmB,CAAC;AAC9B"}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import classnames from 'classnames';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { useRef, useEffect } from '@wordpress/element';
|
|
11
|
-
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
12
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
|
-
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import BlockSelectionButton from './block-selection-button';
|
|
19
|
-
import BlockContextualToolbar from './block-contextual-toolbar';
|
|
20
|
-
import { store as blockEditorStore } from '../../store';
|
|
21
|
-
import BlockPopover from '../block-popover';
|
|
22
|
-
import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
|
|
23
|
-
import Inserter from '../inserter';
|
|
24
|
-
import { useShouldContextualToolbarShow } from '../../utils/use-should-contextual-toolbar-show';
|
|
25
|
-
function selector(select) {
|
|
26
|
-
const {
|
|
27
|
-
__unstableGetEditorMode,
|
|
28
|
-
hasMultiSelection,
|
|
29
|
-
isTyping,
|
|
30
|
-
getLastMultiSelectedBlockClientId
|
|
31
|
-
} = select(blockEditorStore);
|
|
32
|
-
return {
|
|
33
|
-
editorMode: __unstableGetEditorMode(),
|
|
34
|
-
hasMultiSelection: hasMultiSelection(),
|
|
35
|
-
isTyping: isTyping(),
|
|
36
|
-
lastClientId: hasMultiSelection() ? getLastMultiSelectedBlockClientId() : null
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function SelectedBlockPopover({
|
|
40
|
-
clientId,
|
|
41
|
-
rootClientId,
|
|
42
|
-
isEmptyDefaultBlock,
|
|
43
|
-
capturingClientId,
|
|
44
|
-
__unstablePopoverSlot,
|
|
45
|
-
__unstableContentRef
|
|
46
|
-
}) {
|
|
47
|
-
const {
|
|
48
|
-
editorMode,
|
|
49
|
-
hasMultiSelection,
|
|
50
|
-
isTyping,
|
|
51
|
-
lastClientId
|
|
52
|
-
} = useSelect(selector, []);
|
|
53
|
-
const isInsertionPointVisible = useSelect(select => {
|
|
54
|
-
const {
|
|
55
|
-
isBlockInsertionPointVisible,
|
|
56
|
-
getBlockInsertionPoint,
|
|
57
|
-
getBlockOrder
|
|
58
|
-
} = select(blockEditorStore);
|
|
59
|
-
if (!isBlockInsertionPointVisible()) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
const insertionPoint = getBlockInsertionPoint();
|
|
63
|
-
const order = getBlockOrder(insertionPoint.rootClientId);
|
|
64
|
-
return order[insertionPoint.index] === clientId;
|
|
65
|
-
}, [clientId]);
|
|
66
|
-
const isToolbarForced = useRef(false);
|
|
67
|
-
const {
|
|
68
|
-
shouldShowContextualToolbar,
|
|
69
|
-
canFocusHiddenToolbar
|
|
70
|
-
} = useShouldContextualToolbarShow();
|
|
71
|
-
const {
|
|
72
|
-
stopTyping
|
|
73
|
-
} = useDispatch(blockEditorStore);
|
|
74
|
-
const showEmptyBlockSideInserter = !isTyping && editorMode === 'edit' && isEmptyDefaultBlock;
|
|
75
|
-
const shouldShowBreadcrumb = !hasMultiSelection && (editorMode === 'navigation' || editorMode === 'zoom-out');
|
|
76
|
-
useShortcut('core/block-editor/focus-toolbar', () => {
|
|
77
|
-
isToolbarForced.current = true;
|
|
78
|
-
stopTyping(true);
|
|
79
|
-
}, {
|
|
80
|
-
isDisabled: !canFocusHiddenToolbar
|
|
81
|
-
});
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
isToolbarForced.current = false;
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// Stores the active toolbar item index so the block toolbar can return focus
|
|
87
|
-
// to it when re-mounting.
|
|
88
|
-
const initialToolbarItemIndexRef = useRef();
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
// Resets the index whenever the active block changes so this is not
|
|
91
|
-
// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
92
|
-
initialToolbarItemIndexRef.current = undefined;
|
|
93
|
-
}, [clientId]);
|
|
94
|
-
const popoverProps = useBlockToolbarPopoverProps({
|
|
95
|
-
contentElement: __unstableContentRef?.current,
|
|
96
|
-
clientId
|
|
97
|
-
});
|
|
98
|
-
if (showEmptyBlockSideInserter) {
|
|
99
|
-
return createElement(BlockPopover, {
|
|
100
|
-
clientId: capturingClientId || clientId,
|
|
101
|
-
__unstableCoverTarget: true,
|
|
102
|
-
bottomClientId: lastClientId,
|
|
103
|
-
className: classnames('block-editor-block-list__block-side-inserter-popover', {
|
|
104
|
-
'is-insertion-point-visible': isInsertionPointVisible
|
|
105
|
-
}),
|
|
106
|
-
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
107
|
-
__unstableContentRef: __unstableContentRef,
|
|
108
|
-
resize: false,
|
|
109
|
-
shift: false,
|
|
110
|
-
...popoverProps
|
|
111
|
-
}, createElement("div", {
|
|
112
|
-
className: "block-editor-block-list__empty-block-inserter"
|
|
113
|
-
}, createElement(Inserter, {
|
|
114
|
-
position: "bottom right",
|
|
115
|
-
rootClientId: rootClientId,
|
|
116
|
-
clientId: clientId,
|
|
117
|
-
__experimentalIsQuick: true
|
|
118
|
-
})));
|
|
119
|
-
}
|
|
120
|
-
if (shouldShowBreadcrumb || shouldShowContextualToolbar) {
|
|
121
|
-
return createElement(BlockPopover, {
|
|
122
|
-
clientId: capturingClientId || clientId,
|
|
123
|
-
bottomClientId: lastClientId,
|
|
124
|
-
className: classnames('block-editor-block-list__block-popover', {
|
|
125
|
-
'is-insertion-point-visible': isInsertionPointVisible
|
|
126
|
-
}),
|
|
127
|
-
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
128
|
-
__unstableContentRef: __unstableContentRef,
|
|
129
|
-
resize: false,
|
|
130
|
-
...popoverProps
|
|
131
|
-
}, shouldShowContextualToolbar && createElement(BlockContextualToolbar
|
|
132
|
-
// If the toolbar is being shown because of being forced
|
|
133
|
-
// it should focus the toolbar right after the mount.
|
|
134
|
-
, {
|
|
135
|
-
focusOnMount: isToolbarForced.current,
|
|
136
|
-
__experimentalInitialIndex: initialToolbarItemIndexRef.current,
|
|
137
|
-
__experimentalOnIndexChange: index => {
|
|
138
|
-
initialToolbarItemIndexRef.current = index;
|
|
139
|
-
}
|
|
140
|
-
// Resets the index whenever the active block changes so
|
|
141
|
-
// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
142
|
-
,
|
|
143
|
-
key: clientId
|
|
144
|
-
}), shouldShowBreadcrumb && createElement(BlockSelectionButton, {
|
|
145
|
-
clientId: clientId,
|
|
146
|
-
rootClientId: rootClientId
|
|
147
|
-
}));
|
|
148
|
-
}
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
function wrapperSelector(select) {
|
|
152
|
-
const {
|
|
153
|
-
getSelectedBlockClientId,
|
|
154
|
-
getFirstMultiSelectedBlockClientId,
|
|
155
|
-
getBlockRootClientId,
|
|
156
|
-
getBlock,
|
|
157
|
-
getBlockParents,
|
|
158
|
-
__experimentalGetBlockListSettingsForBlocks
|
|
159
|
-
} = select(blockEditorStore);
|
|
160
|
-
const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
|
|
161
|
-
if (!clientId) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const {
|
|
165
|
-
name,
|
|
166
|
-
attributes = {}
|
|
167
|
-
} = getBlock(clientId) || {};
|
|
168
|
-
const blockParentsClientIds = getBlockParents(clientId);
|
|
169
|
-
|
|
170
|
-
// Get Block List Settings for all ancestors of the current Block clientId.
|
|
171
|
-
const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(blockParentsClientIds);
|
|
172
|
-
|
|
173
|
-
// Get the clientId of the topmost parent with the capture toolbars setting.
|
|
174
|
-
const capturingClientId = blockParentsClientIds.find(parentClientId => parentBlockListSettings[parentClientId]?.__experimentalCaptureToolbars);
|
|
175
|
-
return {
|
|
176
|
-
clientId,
|
|
177
|
-
rootClientId: getBlockRootClientId(clientId),
|
|
178
|
-
name,
|
|
179
|
-
isEmptyDefaultBlock: name && isUnmodifiedDefaultBlock({
|
|
180
|
-
name,
|
|
181
|
-
attributes
|
|
182
|
-
}),
|
|
183
|
-
capturingClientId
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
export default function WrappedBlockPopover({
|
|
187
|
-
__unstablePopoverSlot,
|
|
188
|
-
__unstableContentRef
|
|
189
|
-
}) {
|
|
190
|
-
const selected = useSelect(wrapperSelector, []);
|
|
191
|
-
if (!selected) {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
const {
|
|
195
|
-
clientId,
|
|
196
|
-
rootClientId,
|
|
197
|
-
name,
|
|
198
|
-
isEmptyDefaultBlock,
|
|
199
|
-
capturingClientId
|
|
200
|
-
} = selected;
|
|
201
|
-
if (!name) {
|
|
202
|
-
return null;
|
|
203
|
-
}
|
|
204
|
-
return createElement(SelectedBlockPopover, {
|
|
205
|
-
clientId: clientId,
|
|
206
|
-
rootClientId: rootClientId,
|
|
207
|
-
isEmptyDefaultBlock: isEmptyDefaultBlock,
|
|
208
|
-
capturingClientId: capturingClientId,
|
|
209
|
-
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
210
|
-
__unstableContentRef: __unstableContentRef
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=selected-block-popover.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useRef","useEffect","isUnmodifiedDefaultBlock","useDispatch","useSelect","useShortcut","BlockSelectionButton","BlockContextualToolbar","store","blockEditorStore","BlockPopover","useBlockToolbarPopoverProps","Inserter","useShouldContextualToolbarShow","selector","select","__unstableGetEditorMode","hasMultiSelection","isTyping","getLastMultiSelectedBlockClientId","editorMode","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isToolbarForced","shouldShowContextualToolbar","canFocusHiddenToolbar","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","current","isDisabled","initialToolbarItemIndexRef","undefined","popoverProps","contentElement","createElement","__unstableCoverTarget","bottomClientId","className","resize","shift","position","__experimentalIsQuick","focusOnMount","__experimentalInitialIndex","__experimentalOnIndexChange","key","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","find","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\nimport Inserter from '../inserter';\nimport { useShouldContextualToolbarShow } from '../../utils/use-should-contextual-toolbar-show';\n\nfunction selector( select ) {\n\tconst {\n\t\t__unstableGetEditorMode,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\teditorMode: __unstableGetEditorMode(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\tisTyping: isTyping(),\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { editorMode, hasMultiSelection, isTyping, lastClientId } = useSelect(\n\t\tselector,\n\t\t[]\n\t);\n\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isToolbarForced = useRef( false );\n\tconst { shouldShowContextualToolbar, canFocusHiddenToolbar } =\n\t\tuseShouldContextualToolbarShow();\n\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && editorMode === 'edit' && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb =\n\t\t! hasMultiSelection &&\n\t\t( editorMode === 'navigation' || editorMode === 'zoom-out' );\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tuseEffect( () => {\n\t\t// Resets the index whenever the active block changes so this is not\n\t\t// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\tinitialToolbarItemIndexRef.current = undefined;\n\t}, [ clientId ] );\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\tif ( showEmptyBlockSideInserter ) {\n\t\treturn (\n\t\t\t<BlockPopover\n\t\t\t\tclientId={ capturingClientId || clientId }\n\t\t\t\t__unstableCoverTarget\n\t\t\t\tbottomClientId={ lastClientId }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-block-list__block-side-inserter-popover',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\tresize={ false }\n\t\t\t\tshift={ false }\n\t\t\t\t{ ...popoverProps }\n\t\t\t>\n\t\t\t\t<div className=\"block-editor-block-list__empty-block-inserter\">\n\t\t\t\t\t<Inserter\n\t\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</BlockPopover>\n\t\t);\n\t}\n\n\tif ( shouldShowBreadcrumb || shouldShowContextualToolbar ) {\n\t\treturn (\n\t\t\t<BlockPopover\n\t\t\t\tclientId={ capturingClientId || clientId }\n\t\t\t\tbottomClientId={ lastClientId }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-block-list__block-popover',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\tresize={ false }\n\t\t\t\t{ ...popoverProps }\n\t\t\t>\n\t\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t\t}\n\t\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t\t} }\n\t\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t\t<BlockSelectionButton\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockPopover>\n\t\t);\n\t}\n\n\treturn null;\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = blockParentsClientIds.find(\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,MAAM,EAAEC,SAAS,QAAQ,oBAAoB;AACtD,SAASC,wBAAwB,QAAQ,mBAAmB;AAC5D,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,WAAW,QAAQ,+BAA+B;;AAE3D;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,OAAOC,sBAAsB,MAAM,4BAA4B;AAC/D,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,OAAOC,QAAQ,MAAM,aAAa;AAClC,SAASC,8BAA8B,QAAQ,gDAAgD;AAE/F,SAASC,QAAQA,CAAEC,MAAM,EAAG;EAC3B,MAAM;IACLC,uBAAuB;IACvBC,iBAAiB;IACjBC,QAAQ;IACRC;EACD,CAAC,GAAGJ,MAAM,CAAEN,gBAAiB,CAAC;EAE9B,OAAO;IACNW,UAAU,EAAEJ,uBAAuB,CAAC,CAAC;IACrCC,iBAAiB,EAAEA,iBAAiB,CAAC,CAAC;IACtCC,QAAQ,EAAEA,QAAQ,CAAC,CAAC;IACpBG,YAAY,EAAEJ,iBAAiB,CAAC,CAAC,GAC9BE,iCAAiC,CAAC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AAQ;IACRC,YAAY,EAAEuC,oBAAoB,CAAExC,QAAS,CAAC;IAC9C4C,IAAI;IACJ1C,mBAAmB,EAClB0C,IAAI,IAAIjE,wBAAwB,CAAE;MAAEiE,IAAI;MAAEC;IAAW,CAAE,CAAC;IACzD1C;EACD,CAAC;AACF;AAEA,eAAe,SAASgD,mBAAmBA,CAAE;EAC5C/C,qBAAqB;EACrBC;AACD,CAAC,EAAG;EACH,MAAM+C,QAAQ,GAAGvE,SAAS,CAAEwD,eAAe,EAAE,EAAG,CAAC;EAEjD,IAAK,CAAEe,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,MAAM;IACLpD,QAAQ;IACRC,YAAY;IACZ2C,IAAI;IACJ1C,mBAAmB;IACnBC;EACD,CAAC,GAAGiD,QAAQ;EAEZ,IAAK,CAAER,IAAI,EAAG;IACb,OAAO,IAAI;EACZ;EAEA,OACCnB,aAAA,CAAC1B,oBAAoB;IACpBC,QAAQ,EAAGA,QAAU;IACrBC,YAAY,EAAGA,YAAc;IAC7BC,mBAAmB,EAAGA,mBAAqB;IAC3CC,iBAAiB,EAAGA,iBAAmB;IACvCC,qBAAqB,EAAGA,qBAAuB;IAC/CC,oBAAoB,EAAGA;EAAsB,CAC7C,CAAC;AAEJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Modal","useState","__","PatternExplorerSidebar","PatternList","usePatternsCategories","PatternsExplorer","initialCategory","rootClientId","searchValue","setSearchValue","patternSourceFilter","setPatternSourceFilter","selectedCategory","setSelectedCategory","name","patternCategories","createElement","className","onClickCategory","PatternsExplorerModal","onModalClose","restProps","title","onRequestClose","isFullScreen"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/explorer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternExplorerSidebar from './sidebar';\nimport PatternList from './patterns-list';\nimport { usePatternsCategories } from '../block-patterns-tab';\n\nfunction PatternsExplorer( { initialCategory, rootClientId } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst [ selectedCategory, setSelectedCategory ] = useState(\n\t\tinitialCategory?.name\n\t);\n\n\tconst patternCategories = usePatternsCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-explorer\">\n\t\t\t<PatternExplorerSidebar\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tonClickCategory={ setSelectedCategory }\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tsetSearchValue={ setSearchValue }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\tsetPatternSourceFilter={ setPatternSourceFilter }\n\t\t\t/>\n\t\t\t<PatternList\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerModal( { onModalClose, ...restProps } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Patterns' ) }\n\t\t\tonRequestClose={ onModalClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<PatternsExplorer { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nexport default PatternsExplorerModal;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,sBAAsB,MAAM,WAAW;AAC9C,OAAOC,WAAW,MAAM,iBAAiB;AACzC,SAASC,qBAAqB,QAAQ,u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f","useDebounce","__experimentalHeading","Heading","speak","BlockPatternsList","useInsertionPoint","usePatternsState","InserterListbox","searchItems","BlockPatternsPaging","usePatternsPaging","allPatternsCategory","myPatternsCategory","PatternsListHeader","filterValue","filteredBlockPatternsLength","createElement","level","lineHeight","className","PatternList","searchValue","selectedCategory","patternCategories","container","debouncedSpeak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","patterns","onClickPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","id","hasKnownCategory","categories","some","category","includes","length","count","resultsFoundMessage","pagingProps","previousSearchValue","setPreviousSearchValue","changePage","hasItems","ref","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","isDraggable"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/patterns-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport { allPatternsCategory, myPatternsCategory } from '../block-patterns-tab';\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight={ '48px' }\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d pattern found',\n\t\t\t\t\t'%d patterns found',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( { searchValue, selectedCategory, patternCategories } ) {\n\tconst container = useRef();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst filteredPatterns = patterns.filter( ( pattern ) => {\n\t\t\tif ( selectedCategory === allPatternsCategory.name ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === myPatternsCategory.name && pattern.id ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === 'uncategorized' ) {\n\t\t\t\tconst hasKnownCategory = pattern.categories.some(\n\t\t\t\t\t( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t);\n\n\t\t\t\treturn ! pattern.categories?.length || ! hasKnownCategory;\n\t\t\t}\n\n\t\t\treturn pattern.categories?.includes( selectedCategory );\n\t\t} );\n\n\t\tif ( ! searchValue ) {\n\t\t\treturn filteredPatterns;\n\t\t}\n\n\t\treturn searchItems( filteredPatterns, searchValue );\n\t}, [\n\t\tsearchValue,\n\t\tpatterns,\n\t\tselectedCategory,\n\t\tregisteredPatternCategories,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! searchValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ searchValue, debouncedSpeak, filteredBlockPatterns.length ] );\n\n\tconst pagingProps = usePatternsPaging(\n\t\tfilteredBlockPatterns,\n\t\tselectedCategory,\n\t\tcontainer\n\t);\n\n\t// Reset page when search value changes.\n\tconst [ previousSearchValue, setPreviousSearchValue ] =\n\t\tuseState( searchValue );\n\tif ( searchValue !== previousSearchValue ) {\n\t\tsetPreviousSearchValue( searchValue );\n\t\tpagingProps.changePage( 1 );\n\t}\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-patterns-explorer__list\"\n\t\t\tref={ container }\n\t\t>\n\t\t\t<PatternsListHeader\n\t\t\t\tfilterValue={ searchValue }\n\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t/>\n\n\t\t\t<InserterListbox>\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tshownPatterns={\n\t\t\t\t\t\t\t\tpagingProps.categoryPatternsAsyncList\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockPatternsPaging { ...pagingProps } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</InserterListbox>\n\t\t</div>\n\t);\n}\n\nexport default PatternList;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AACzE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAA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,EAAE,CAAE1B,WAAW,EAAEI,cAAc,EAAEU,qBAAqB,CAACU,MAAM,CAAG,CAAC;EAElE,MAAMG,WAAW,GAAGtC,iBAAiB,CACpCyB,qBAAqB,EACrBb,gBAAgB,EAChBE,SACD,CAAC;;EAED;EACA,MAAM,CAAEyB,mBAAmB,EAAEC,sBAAsB,CAAE,GACpDrD,QAAQ,CAAEwB,WAAY,CAAC;EACxB,IAAKA,WAAW,KAAK4B,mBAAmB,EAAG;IAC1CC,sBAAsB,CAAE7B,WAAY,CAAC;IACrC2B,WAAW,CAACG,UAAU,CAAE,CAAE,CAAC;EAC5B;EAEA,MAAMC,QAAQ,GAAG,CAAC,CAAEjB,qBAAqB,EAAEU,MAAM;EACjD,OACC7B,aAAA;IACCG,SAAS,EAAC,4CAA4C;IACtDkC,GAAG,EAAG7B;EAAW,GAEjBR,aAAA,CAACH,kBAAkB;IAClBC,WAAW,EAAGO,WAAa;IAC3BN,2BAA2B,EAAGoB,qBAAqB,CAACU;EAAQ,CAC5D,CAAC,EAEF7B,aAAA,CAACT,eAAe,QACb6C,QAAQ,IACTpC,aAAA,CAAAsC,QAAA,QACCtC,aAAA,CAACZ,iBAAiB;IACjBmD,aAAa,EACZP,WAAW,CAACQ,yBACZ;IACDC,aAAa,EAAGT,WAAW,CAACU,gBAAkB;IAC9C5B,cAAc,EAAGA,cAAgB;IACjC6B,WAAW,EAAG;EAAO,CACrB,CAAC,EACF3C,aAAA,CAACP,mBAAmB;IAAA,GAAMuC;EAAW,CAAI,CACxC,CAEa,CACb,CAAC;AAER;AAEA,eAAe5B,WAAW"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Button","SearchControl","__","PatternCategoriesList","selectedCategory","patternCategories","onClickCategory","baseClassName","createElement","className","map","name","label","key","isPressed","onClick","PatternsExplorerSearch","searchValue","setSearchValue","__nextHasNoMarginBottom","onChange","value","placeholder","PatternExplorerSidebar"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, SearchControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nfunction PatternCategoriesList( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ `${ baseClassName }__categories-list` }>\n\t\t\t{ patternCategories.map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tclassName={ `${ baseClassName }__categories-list__item` }\n\t\t\t\t\t\tisPressed={ selectedCategory === name }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonClickCategory( name );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerSearch( { searchValue, setSearchValue } ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__search';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tonChange={ setSearchValue }\n\t\t\t\tvalue={ searchValue }\n\t\t\t\tlabel={ __( 'Search for patterns' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternExplorerSidebar( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\tsearchValue,\n\tsetSearchValue,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<PatternsExplorerSearch\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tsetSearchValue={ setSearchValue }\n\t\t\t/>\n\t\t\t{ ! searchValue && (\n\t\t\t\t<PatternCategoriesList\n\t\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default PatternExplorerSidebar;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,aAAa,QAAQ,uBAAuB;AAC7D,SAASC,EAAE,QAAQ,iBAAiB;AAEpC,SAASC,qBAAqBA,CAAE;EAC/BC,gBAAgB;EAChBC,iBAAiB;EACjBC;AACD,CAAC,EAAG;EACH,MAAMC,aAAa,GAAG,+CAA+C;EACrE,OACCC,aAAA;IAAKC,SAAS,EAAI,GAAGF,aAAe;EAAoB,GACrDF,iBAAiB,CAACK,GAAG,CAAE,CAAE;IAAEC,IAAI;IAAEC;EAAM,CAAC,KAAM;IAC/C,OACCJ,aAAA,CAACR,MAAM;MACNa,GAAG,EAAGF,IAAM;MACZC,KAAK,EAAGA,KAAO;MACfH,SAAS,EAAI,GAAGF,aAAe,yBAA0B;MACzDO,SAAS,EAAGV,gBAAgB,KAAKO,IAAM;MACvCI,OAAO,EAAGA,CAAA,KAAM;QACfT,eAAe,CAAEK,IAAK,CAAC;MACxB;IAAG,GAEDC,KACK,CAAC;EAEX,CAAE,CACE,CAAC;AAER;AAEA,SAASI,sBAAsBA,CAAE;EAAEC,WAAW;EAAEC;AAAe,CAAC,EAAG;EAClE,MAAMX,aAAa,GAAG,8CAA8C;EACpE,OACCC,aAAA;IAAKC,SAAS,EAAGF;EAAe,GAC/BC,aAAA,CAACP,aAAa;IACbkB,uBAAuB;IACvBC,QAAQ,EAAGF,cAAgB;IAC3BG,KAAK,EAAGJ,WAAa;IACrBL,KAAK,EAAGV,EAAE,CAAE,qBAAsB,CAAG;IACrCoB,WAAW,EAAGpB,EAAE,CAAE,QAAS;EAAG,CAC9B,CACG,CAAC;AAER;AAEA,SAASqB,sBAAsBA,CAAE;EAChCnB,gBAAgB;EAChB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