@wordpress/block-editor 12.24.0 → 12.25.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/README.md +1 -1
- package/build/components/alignment-control/ui.js +3 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +0 -9
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/index.js +4 -3
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -9
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +6 -6
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-refs.js +17 -46
- package/build/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +10 -14
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-mover/index.native.js +3 -1
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +0 -25
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +3 -1
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/use-transformed-patterns.js +6 -2
- package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build/components/block-switcher/utils.js +15 -5
- package/build/components/block-switcher/utils.js.map +1 -1
- package/build/components/block-toolbar/use-has-block-toolbar.js +14 -9
- package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
- package/build/components/block-tools/index.js +3 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +2 -5
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +5 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-variation-picker/index.js +3 -2
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +3 -1
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/floating-toolbar/index.native.js +9 -5
- package/build/components/floating-toolbar/index.native.js.map +1 -1
- package/build/components/global-styles/background-panel.js +1 -1
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +3 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +16 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +3 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +23 -23
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +149 -132
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +45 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/inner-blocks/index.js +16 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +12 -31
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +4 -0
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +56 -0
- package/build/components/inserter/category-tabs/index.js.map +1 -0
- package/build/components/inserter/media-tab/index.js +2 -2
- package/build/components/inserter/media-tab/index.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +0 -25
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +13 -3
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/media-tab/media-tab.js +15 -29
- package/build/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build/components/inserter/menu.js +59 -69
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/tabs.js +6 -6
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/line-height-control/index.js +6 -2
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +9 -3
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/block-select-button.js +5 -170
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +166 -14
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/index.js +1 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/list-view/utils.js +3 -1
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/media-placeholder/index.js +3 -3
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +3 -1
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/provider/block-refs-provider.js +3 -4
- package/build/components/provider/block-refs-provider.js.map +1 -1
- package/build/components/provider/use-block-sync.js +3 -12
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/event-listeners/before-input-rules.js +93 -0
- package/build/components/rich-text/event-listeners/before-input-rules.js.map +1 -0
- package/build/components/rich-text/event-listeners/delete.js +58 -0
- package/build/components/rich-text/event-listeners/delete.js.map +1 -0
- package/build/components/rich-text/event-listeners/enter.js +98 -0
- package/build/components/rich-text/event-listeners/enter.js.map +1 -0
- package/build/components/rich-text/event-listeners/firefox-compat.js +36 -0
- package/build/components/rich-text/event-listeners/firefox-compat.js.map +1 -0
- package/build/components/rich-text/event-listeners/index.js +44 -0
- package/build/components/rich-text/event-listeners/index.js.map +1 -0
- package/build/components/rich-text/event-listeners/input-events.js +22 -0
- package/build/components/rich-text/event-listeners/input-events.js.map +1 -0
- package/build/components/rich-text/event-listeners/input-rules.js +135 -0
- package/build/components/rich-text/event-listeners/input-rules.js.map +1 -0
- package/build/components/rich-text/event-listeners/insert-replacement-text.js +33 -0
- package/build/components/rich-text/event-listeners/insert-replacement-text.js.map +1 -0
- package/build/components/rich-text/event-listeners/paste-handler.js +146 -0
- package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -0
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.js +27 -0
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.js.map +1 -0
- package/build/components/rich-text/event-listeners/shortcuts.js +22 -0
- package/build/components/rich-text/event-listeners/shortcuts.js.map +1 -0
- package/build/components/rich-text/event-listeners/undo-automatic-change.js +51 -0
- package/build/components/rich-text/event-listeners/undo-automatic-change.js.map +1 -0
- package/build/components/rich-text/index.js +11 -31
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +13 -3
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/multiline.js +6 -2
- package/build/components/rich-text/multiline.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +12 -0
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +8 -4
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/segmented-text-control/index.js +62 -0
- package/build/components/segmented-text-control/index.js.map +1 -0
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +16 -2
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/text-alignment-control/index.js +76 -0
- package/build/components/text-alignment-control/index.js.map +1 -0
- package/build/components/text-decoration-control/index.js +21 -25
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +18 -22
- package/build/components/text-transform-control/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +9 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +3 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js +3 -1
- package/build/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +3 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/components/writing-mode-control/index.js +16 -20
- package/build/components/writing-mode-control/index.js.map +1 -1
- package/build/hooks/duotone.js +3 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/utils.js +11 -6
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +4 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +32 -8
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js +27 -6
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +11 -8
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +21 -7
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +17 -0
- package/build/utils/object.js.map +1 -1
- package/build/utils/order-inserter-block-items.js +6 -2
- package/build/utils/order-inserter-block-items.js.map +1 -1
- package/build/utils/pasting.js +6 -2
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +3 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +0 -9
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/index.js +4 -3
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -9
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +6 -6
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-refs.js +19 -48
- package/build-module/components/block-list/use-block-props/use-block-refs.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +10 -14
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +3 -1
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -26
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/use-transformed-patterns.js +6 -2
- package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
- package/build-module/components/block-switcher/utils.js +15 -5
- package/build-module/components/block-switcher/utils.js.map +1 -1
- package/build-module/components/block-toolbar/use-has-block-toolbar.js +14 -9
- package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +2 -5
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +5 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +3 -2
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +3 -1
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/floating-toolbar/index.native.js +9 -5
- package/build-module/components/floating-toolbar/index.native.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +1 -1
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +17 -1
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +3 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +24 -24
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +149 -132
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +44 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +16 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +13 -32
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +4 -0
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +49 -0
- package/build-module/components/inserter/category-tabs/index.js.map +1 -0
- package/build-module/components/inserter/media-tab/index.js +1 -1
- package/build-module/components/inserter/media-tab/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +0 -24
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +13 -3
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-tab.js +17 -31
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build-module/components/inserter/menu.js +61 -71
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/tabs.js +6 -6
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/line-height-control/index.js +6 -2
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +9 -3
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +7 -172
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +167 -15
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/index.js +1 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/list-view/utils.js +3 -1
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +3 -3
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +3 -1
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/provider/block-refs-provider.js +3 -4
- package/build-module/components/provider/block-refs-provider.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +4 -13
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/before-input-rules.js +86 -0
- package/build-module/components/rich-text/event-listeners/before-input-rules.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/delete.js +51 -0
- package/build-module/components/rich-text/event-listeners/delete.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/enter.js +92 -0
- package/build-module/components/rich-text/event-listeners/enter.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/firefox-compat.js +29 -0
- package/build-module/components/rich-text/event-listeners/firefox-compat.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/index.js +36 -0
- package/build-module/components/rich-text/event-listeners/index.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/input-events.js +15 -0
- package/build-module/components/rich-text/event-listeners/input-events.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/input-rules.js +127 -0
- package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.js +27 -0
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/paste-handler.js +142 -0
- package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.js +21 -0
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/shortcuts.js +15 -0
- package/build-module/components/rich-text/event-listeners/shortcuts.js.map +1 -0
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.js +45 -0
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.js.map +1 -0
- package/build-module/components/rich-text/index.js +12 -32
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +13 -3
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/multiline.js +6 -2
- package/build-module/components/rich-text/multiline.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +12 -0
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +8 -4
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/segmented-text-control/index.js +55 -0
- package/build-module/components/segmented-text-control/index.js.map +1 -0
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +16 -2
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/text-alignment-control/index.js +68 -0
- package/build-module/components/text-alignment-control/index.js.map +1 -0
- package/build-module/components/text-decoration-control/index.js +21 -25
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +18 -22
- package/build-module/components/text-transform-control/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +9 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +3 -1
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js +3 -1
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +3 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/components/writing-mode-control/index.js +16 -20
- package/build-module/components/writing-mode-control/index.js.map +1 -1
- package/build-module/hooks/duotone.js +3 -1
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/utils.js +11 -6
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +4 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +32 -8
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js +27 -5
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +11 -8
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +21 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +16 -0
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/order-inserter-block-items.js +6 -2
- package/build-module/utils/order-inserter-block-items.js.map +1 -1
- package/build-module/utils/pasting.js +6 -2
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/content-rtl.css +41 -68
- package/build-style/content.css +41 -68
- package/build-style/style-rtl.css +100 -199
- package/build-style/style.css +100 -199
- package/package.json +31 -31
- package/src/components/alignment-control/ui.js +3 -1
- package/src/components/block-bindings-toolbar-indicator/style.scss +1 -4
- package/src/components/block-canvas/style.scss +1 -3
- package/src/components/block-draggable/test/helpers.native.js +8 -8
- package/src/components/block-inspector/index.js +1 -2
- package/src/components/block-list/block.js +2 -13
- package/src/components/block-list/content.scss +9 -1
- package/src/components/block-list/index.js +4 -4
- package/src/components/block-list/index.native.js +1 -6
- package/src/components/block-list/use-block-props/index.js +12 -4
- package/src/components/block-list/use-block-props/use-block-refs.js +17 -57
- package/src/components/block-list/use-block-props/use-is-hovered.js +11 -16
- package/src/components/block-mover/index.native.js +3 -1
- package/src/components/block-patterns-list/style.scss +1 -3
- package/src/components/block-preview/style.scss +13 -15
- package/src/components/block-settings-menu/block-settings-dropdown.js +1 -51
- package/src/components/block-switcher/pattern-transformations-menu.js +3 -1
- package/src/components/block-switcher/use-transformed-patterns.js +6 -2
- package/src/components/block-switcher/utils.js +14 -5
- package/src/components/block-toolbar/style.scss +8 -11
- package/src/components/block-toolbar/use-has-block-toolbar.js +21 -16
- package/src/components/block-tools/index.js +3 -1
- package/src/components/block-tools/use-show-block-tools.js +36 -48
- package/src/components/block-tools/zoom-out-mode-inserters.js +5 -1
- package/src/components/block-variation-picker/content.scss +22 -72
- package/src/components/block-variation-picker/index.js +3 -2
- package/src/components/block-variation-transforms/index.js +3 -1
- package/src/components/floating-toolbar/index.native.js +5 -2
- package/src/components/global-styles/background-panel.js +1 -3
- package/src/components/global-styles/color-panel.js +3 -1
- package/src/components/global-styles/dimensions-panel.js +18 -1
- package/src/components/global-styles/hooks.js +2 -0
- package/src/components/global-styles/test/utils.js +21 -0
- package/src/components/global-styles/typography-panel.js +27 -23
- package/src/components/global-styles/use-global-styles-output.js +211 -187
- package/src/components/global-styles/utils.js +55 -0
- package/src/components/inner-blocks/index.js +14 -1
- package/src/components/inserter/block-patterns-tab/index.js +15 -65
- package/src/components/inserter/block-types-tab.js +5 -0
- package/src/components/inserter/category-tabs/index.js +74 -0
- package/src/components/inserter/media-tab/index.js +1 -1
- package/src/components/inserter/media-tab/media-panel.js +0 -22
- package/src/components/inserter/media-tab/media-preview.js +15 -7
- package/src/components/inserter/media-tab/media-tab.js +44 -83
- package/src/components/inserter/menu.js +139 -117
- package/src/components/inserter/style.scss +90 -170
- package/src/components/inserter/tabs.js +5 -13
- package/src/components/line-height-control/index.js +6 -2
- package/src/components/link-control/search-item.js +9 -3
- package/src/components/list-view/block-select-button.js +73 -266
- package/src/components/list-view/block.js +218 -28
- package/src/components/list-view/index.js +1 -1
- package/src/components/list-view/style.scss +20 -28
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/list-view/utils.js +3 -1
- package/src/components/media-placeholder/content.scss +0 -11
- package/src/components/media-placeholder/index.js +3 -3
- package/src/components/navigable-toolbar/index.js +3 -1
- package/src/components/provider/block-refs-provider.js +3 -8
- package/src/components/provider/test/use-block-sync.js +7 -0
- package/src/components/provider/use-block-sync.js +3 -20
- package/src/components/rich-text/event-listeners/before-input-rules.js +92 -0
- package/src/components/rich-text/event-listeners/delete.js +53 -0
- package/src/components/rich-text/event-listeners/enter.js +104 -0
- package/src/components/rich-text/event-listeners/firefox-compat.js +31 -0
- package/src/components/rich-text/event-listeners/index.js +56 -0
- package/src/components/rich-text/event-listeners/input-events.js +13 -0
- package/src/components/rich-text/event-listeners/input-rules.js +146 -0
- package/src/components/rich-text/event-listeners/insert-replacement-text.js +28 -0
- package/src/components/rich-text/event-listeners/paste-handler.js +169 -0
- package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +24 -0
- package/src/components/rich-text/event-listeners/shortcuts.js +13 -0
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +45 -0
- package/src/components/rich-text/index.js +7 -34
- package/src/components/rich-text/index.native.js +11 -0
- package/src/components/rich-text/multiline.js +6 -2
- package/src/components/rich-text/native/index.native.js +11 -0
- package/src/components/rich-text/use-format-types.js +6 -2
- package/src/components/segmented-text-control/index.js +63 -0
- package/src/components/{writing-mode-control → segmented-text-control}/style.scss +2 -5
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +16 -1
- package/src/components/text-alignment-control/index.js +91 -0
- package/src/components/text-alignment-control/stories/index.story.js +39 -0
- package/src/components/text-decoration-control/index.js +20 -33
- package/src/components/text-transform-control/index.js +17 -30
- package/src/components/use-block-display-information/index.js +9 -3
- package/src/components/use-on-block-drop/index.js +3 -1
- package/src/components/writing-flow/use-drag-selection.js +3 -1
- package/src/components/writing-flow/use-tab-nav.js +3 -1
- package/src/components/writing-mode-control/index.js +15 -28
- package/src/hooks/duotone.js +3 -1
- package/src/hooks/utils.js +16 -2
- package/src/private-apis.js +4 -2
- package/src/store/actions.js +36 -12
- package/src/store/private-selectors.js +28 -4
- package/src/store/reducer.js +13 -23
- package/src/store/selectors.js +20 -7
- package/src/style.scss +1 -2
- package/src/utils/object.js +16 -0
- package/src/utils/order-inserter-block-items.js +6 -2
- package/src/utils/pasting.js +6 -2
- package/build/components/block-list/use-block-props/use-block-moving-mode-class-names.js +0 -54
- package/build/components/block-list/use-block-props/use-block-moving-mode-class-names.js.map +0 -1
- package/build/components/rich-text/use-before-input-rules.js +0 -98
- package/build/components/rich-text/use-before-input-rules.js.map +0 -1
- package/build/components/rich-text/use-delete.js +0 -64
- package/build/components/rich-text/use-delete.js.map +0 -1
- package/build/components/rich-text/use-enter.js +0 -109
- package/build/components/rich-text/use-enter.js.map +0 -1
- package/build/components/rich-text/use-firefox-compat.js +0 -44
- package/build/components/rich-text/use-firefox-compat.js.map +0 -1
- package/build/components/rich-text/use-input-events.js +0 -25
- package/build/components/rich-text/use-input-events.js.map +0 -1
- package/build/components/rich-text/use-input-rules.js +0 -139
- package/build/components/rich-text/use-input-rules.js.map +0 -1
- package/build/components/rich-text/use-insert-replacement-text.js +0 -38
- package/build/components/rich-text/use-insert-replacement-text.js.map +0 -1
- package/build/components/rich-text/use-paste-handler.js +0 -158
- package/build/components/rich-text/use-paste-handler.js.map +0 -1
- package/build/components/rich-text/use-remove-browser-shortcuts.js +0 -32
- package/build/components/rich-text/use-remove-browser-shortcuts.js.map +0 -1
- package/build/components/rich-text/use-shortcuts.js +0 -25
- package/build/components/rich-text/use-shortcuts.js.map +0 -1
- package/build/components/rich-text/use-undo-automatic-change.js +0 -53
- package/build/components/rich-text/use-undo-automatic-change.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js +0 -47
- package/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js.map +0 -1
- package/build-module/components/rich-text/use-before-input-rules.js +0 -92
- package/build-module/components/rich-text/use-before-input-rules.js.map +0 -1
- package/build-module/components/rich-text/use-delete.js +0 -57
- package/build-module/components/rich-text/use-delete.js.map +0 -1
- package/build-module/components/rich-text/use-enter.js +0 -102
- package/build-module/components/rich-text/use-enter.js.map +0 -1
- package/build-module/components/rich-text/use-firefox-compat.js +0 -37
- package/build-module/components/rich-text/use-firefox-compat.js.map +0 -1
- package/build-module/components/rich-text/use-input-events.js +0 -18
- package/build-module/components/rich-text/use-input-events.js.map +0 -1
- package/build-module/components/rich-text/use-input-rules.js +0 -132
- package/build-module/components/rich-text/use-input-rules.js.map +0 -1
- package/build-module/components/rich-text/use-insert-replacement-text.js +0 -32
- package/build-module/components/rich-text/use-insert-replacement-text.js.map +0 -1
- package/build-module/components/rich-text/use-paste-handler.js +0 -152
- package/build-module/components/rich-text/use-paste-handler.js.map +0 -1
- package/build-module/components/rich-text/use-remove-browser-shortcuts.js +0 -26
- package/build-module/components/rich-text/use-remove-browser-shortcuts.js.map +0 -1
- package/build-module/components/rich-text/use-shortcuts.js +0 -18
- package/build-module/components/rich-text/use-shortcuts.js.map +0 -1
- package/build-module/components/rich-text/use-undo-automatic-change.js +0 -46
- package/build-module/components/rich-text/use-undo-automatic-change.js.map +0 -1
- package/src/components/block-list/use-block-props/use-block-moving-mode-class-names.js +0 -55
- package/src/components/rich-text/use-before-input-rules.js +0 -99
- package/src/components/rich-text/use-delete.js +0 -59
- package/src/components/rich-text/use-enter.js +0 -110
- package/src/components/rich-text/use-firefox-compat.js +0 -39
- package/src/components/rich-text/use-input-events.js +0 -19
- package/src/components/rich-text/use-input-rules.js +0 -150
- package/src/components/rich-text/use-insert-replacement-text.js +0 -31
- package/src/components/rich-text/use-paste-handler.js +0 -180
- package/src/components/rich-text/use-remove-browser-shortcuts.js +0 -29
- package/src/components/rich-text/use-shortcuts.js +0 -19
- package/src/components/rich-text/use-undo-automatic-change.js +0 -46
- package/src/components/text-decoration-control/style.scss +0 -18
- package/src/components/text-transform-control/style.scss +0 -18
|
@@ -179,7 +179,9 @@ function useInnerBlocksProps(props = {}, options = {}) {
|
|
|
179
179
|
getBlockRootClientId,
|
|
180
180
|
getBlockEditingMode,
|
|
181
181
|
getBlockSettings,
|
|
182
|
-
isDragging
|
|
182
|
+
isDragging,
|
|
183
|
+
getSettings,
|
|
184
|
+
getBlockOrder
|
|
183
185
|
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
184
186
|
const {
|
|
185
187
|
hasBlockSupport,
|
|
@@ -190,6 +192,18 @@ function useInnerBlocksProps(props = {}, options = {}) {
|
|
|
190
192
|
const blockEditingMode = getBlockEditingMode(clientId);
|
|
191
193
|
const parentClientId = getBlockRootClientId(clientId);
|
|
192
194
|
const [defaultLayout] = getBlockSettings(clientId, 'layout');
|
|
195
|
+
|
|
196
|
+
// In zoom out mode, we want to disable the drop zone for the sections.
|
|
197
|
+
// The inner blocks belonging to the section drop zone is
|
|
198
|
+
// already disabled by the blocks themselves being disabled.
|
|
199
|
+
let _isDropZoneDisabled = blockEditingMode === 'disabled';
|
|
200
|
+
if (__unstableGetEditorMode() === 'zoom-out') {
|
|
201
|
+
const {
|
|
202
|
+
sectionRootClientId
|
|
203
|
+
} = (0, _lockUnlock.unlock)(getSettings());
|
|
204
|
+
const sectionsClientIds = getBlockOrder(sectionRootClientId);
|
|
205
|
+
_isDropZoneDisabled = sectionsClientIds?.includes(clientId);
|
|
206
|
+
}
|
|
193
207
|
return {
|
|
194
208
|
__experimentalCaptureToolbars: hasBlockSupport(blockName, '__experimentalExposeControlsToChildren', false),
|
|
195
209
|
hasOverlay: blockName !== 'core/template' && !isBlockSelected(clientId) && !hasSelectedInnerBlock(clientId, true) && enableClickThrough && !isDragging(),
|
|
@@ -197,7 +211,7 @@ function useInnerBlocksProps(props = {}, options = {}) {
|
|
|
197
211
|
blockType: getBlockType(blockName),
|
|
198
212
|
parentLock: getTemplateLock(parentClientId),
|
|
199
213
|
parentClientId,
|
|
200
|
-
isDropZoneDisabled:
|
|
214
|
+
isDropZoneDisabled: _isDropZoneDisabled,
|
|
201
215
|
defaultLayout
|
|
202
216
|
};
|
|
203
217
|
}, [clientId]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_compose","_element","_data","_blocks","_buttonBlockAppender","_defaultBlockAppender","_useNestedSettingsUpdate","_useInnerBlockTemplateSync","_useBlockContext","_blockList","_blockContext","_context","_useBlockSync","_store","_useBlockDropZone","_lockUnlock","EMPTY_OBJECT","BlockContext","children","clientId","context","useBlockContext","_react","createElement","BlockContextProvider","value","BlockListItemsMemo","memo","BlockListItems","UncontrolledInnerBlocks","props","allowedBlocks","prioritizedInserterBlocks","defaultBlock","directInsert","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","layout","name","blockType","parentLock","defaultLayout","useNestedSettingsUpdate","useInnerBlockTemplateSync","defaultLayoutBlockSupport","getBlockSupport","allowSizingOnChildren","usedLayout","memoedLayout","useMemo","items","rootClientId","Object","keys","providesContext","length","ControlledInnerBlocks","useBlockSync","ForwardedInnerBlocks","forwardRef","ref","innerBlocksProps","useInnerBlocksProps","className","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","dropZoneElement","__unstableLayoutClassNames","layoutClassNames","useBlockEditContext","selected","useSelect","select","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","getTemplateLock","getBlockRootClientId","getBlockEditingMode","getBlockSettings","isDragging","unlock","blockEditorStore","hasBlockSupport","getBlockType","blocksStore","blockName","enableClickThrough","blockEditingMode","parentClientId","hasOverlay","isDropZoneDisabled","blockDropZoneRef","useBlockDropZone","isDisabled","useMergeRefs","InnerBlocks","onChange","classnames","save","getInnerBlocksProps","DefaultBlockAppender","ButtonBlockAppender","Content","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport useBlockContext from './use-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_OBJECT = {};\n\nfunction BlockContext( { children, clientId } ) {\n\tconst context = useBlockContext( clientId );\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t{ children }\n\t\t</BlockContextProvider>\n\t);\n}\n\nconst BlockListItemsMemo = memo( BlockListItems );\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\tlayout,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tdefaultLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tparentLock,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tlayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst defaultLayoutBlockSupport =\n\t\tgetBlockSupport( name, 'layout' ) ||\n\t\tgetBlockSupport( name, '__experimentalLayout' ) ||\n\t\tEMPTY_OBJECT;\n\n\tconst { allowSizingOnChildren = false } = defaultLayoutBlockSupport;\n\tconst usedLayout = layout || defaultLayoutBlockSupport;\n\n\tconst memoedLayout = useMemo(\n\t\t() => ( {\n\t\t\t// Default layout will know about any content/wide size defined by the theme.\n\t\t\t...defaultLayout,\n\t\t\t...usedLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ defaultLayout, usedLayout, allowSizingOnChildren ]\n\t);\n\n\t// For controlled inner blocks, we don't want a change in blocks to\n\t// re-render the blocks list.\n\tconst items = (\n\t\t<BlockListItemsMemo\n\t\t\trootClientId={ clientId }\n\t\t\trenderAppender={ renderAppender }\n\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\tlayout={ memoedLayout }\n\t\t\twrapperRef={ wrapperRef }\n\t\t\tplaceholder={ placeholder }\n\t\t/>\n\t);\n\n\tif ( Object.keys( blockType.providesContext ).length === 0 ) {\n\t\treturn items;\n\t}\n\n\treturn <BlockContext clientId={ clientId }>{ items }</BlockContext>;\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst {\n\t\t__unstableDisableLayoutClassNames,\n\t\t__unstableDisableDropZone,\n\t\tdropZoneElement,\n\t} = options;\n\tconst {\n\t\tclientId,\n\t\tlayout = null,\n\t\t__unstableLayoutClassNames: layoutClassNames = '',\n\t} = useBlockEditContext();\n\tconst selected = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockSettings,\n\t\t\t\tisDragging,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\tconst { hasBlockSupport, getBlockType } = select( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation';\n\t\t\tconst blockEditingMode = getBlockEditingMode( clientId );\n\t\t\tconst parentClientId = getBlockRootClientId( clientId );\n\t\t\tconst [ defaultLayout ] = getBlockSettings( clientId, 'layout' );\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough &&\n\t\t\t\t\t! isDragging(),\n\t\t\t\tname: blockName,\n\t\t\t\tblockType: getBlockType( blockName ),\n\t\t\t\tparentLock: getTemplateLock( parentClientId ),\n\t\t\t\tparentClientId,\n\t\t\t\tisDropZoneDisabled: blockEditingMode === 'disabled',\n\t\t\t\tdefaultLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst {\n\t\t__experimentalCaptureToolbars,\n\t\thasOverlay,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tparentClientId,\n\t\tisDropZoneDisabled,\n\t\tdefaultLayout,\n\t} = selected;\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\tdropZoneElement,\n\t\trootClientId: clientId,\n\t\tparentClientId,\n\t\tisDisabled: isDropZoneDisabled,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ? null : blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\tlayout,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tdefaultLayout,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t__unstableDisableLayoutClassNames ? '' : layoutClassNames,\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AASA,IAAAK,oBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,qBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,wBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,0BAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,gBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AACA,IAAAY,QAAA,GAAAZ,OAAA;AACA,IAAAa,aAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,iBAAA,GAAAhB,sBAAA,CAAAC,OAAA;AACA,IAAAgB,WAAA,GAAAhB,OAAA;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAcA,MAAMiB,YAAY,GAAG,CAAC,CAAC;AAEvB,SAASC,YAAYA,CAAE;EAAEC,QAAQ;EAAEC;AAAS,CAAC,EAAG;EAC/C,MAAMC,OAAO,GAAG,IAAAC,wBAAe,EAAEF,QAAS,CAAC;EAC3C,OACC,IAAAG,MAAA,CAAAC,aAAA,EAACb,aAAA,CAAAc,oBAAoB;IAACC,KAAK,EAAGL;EAAS,GACpCF,QACmB,CAAC;AAEzB;AAEA,MAAM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AM8C;IAAO,CAAI;EAElC,CAAC;AACF;AAEAF,mBAAmB,CAACuC,IAAI,GAAGC,qCAAmB;;AAE9C;AACA5C,oBAAoB,CAAC6C,oBAAoB,GAAGA,6BAAoB;AAChE7C,oBAAoB,CAAC8C,mBAAmB,GAAGA,4BAAmB;AAE9D9C,oBAAoB,CAAC+C,OAAO,GAAG,MAAM3C,mBAAmB,CAACuC,IAAI,CAAC,CAAC,CAAC7F,QAAQ;;AAExE;AACA;AACA;AAFA,IAAAkG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGelD,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_compose","_element","_data","_blocks","_buttonBlockAppender","_defaultBlockAppender","_useNestedSettingsUpdate","_useInnerBlockTemplateSync","_useBlockContext","_blockList","_blockContext","_context","_useBlockSync","_store","_useBlockDropZone","_lockUnlock","EMPTY_OBJECT","BlockContext","children","clientId","context","useBlockContext","_react","createElement","BlockContextProvider","value","BlockListItemsMemo","memo","BlockListItems","UncontrolledInnerBlocks","props","allowedBlocks","prioritizedInserterBlocks","defaultBlock","directInsert","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","layout","name","blockType","parentLock","defaultLayout","useNestedSettingsUpdate","useInnerBlockTemplateSync","defaultLayoutBlockSupport","getBlockSupport","allowSizingOnChildren","usedLayout","memoedLayout","useMemo","items","rootClientId","Object","keys","providesContext","length","ControlledInnerBlocks","useBlockSync","ForwardedInnerBlocks","forwardRef","ref","innerBlocksProps","useInnerBlocksProps","className","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","dropZoneElement","__unstableLayoutClassNames","layoutClassNames","useBlockEditContext","selected","useSelect","select","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","getTemplateLock","getBlockRootClientId","getBlockEditingMode","getBlockSettings","isDragging","getSettings","getBlockOrder","unlock","blockEditorStore","hasBlockSupport","getBlockType","blocksStore","blockName","enableClickThrough","blockEditingMode","parentClientId","_isDropZoneDisabled","sectionRootClientId","sectionsClientIds","includes","hasOverlay","isDropZoneDisabled","blockDropZoneRef","useBlockDropZone","isDisabled","useMergeRefs","InnerBlocks","onChange","classnames","save","getInnerBlocksProps","DefaultBlockAppender","ButtonBlockAppender","Content","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport useBlockContext from './use-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_OBJECT = {};\n\nfunction BlockContext( { children, clientId } ) {\n\tconst context = useBlockContext( clientId );\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t{ children }\n\t\t</BlockContextProvider>\n\t);\n}\n\nconst BlockListItemsMemo = memo( BlockListItems );\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\tlayout,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tdefaultLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tparentLock,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tlayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst defaultLayoutBlockSupport =\n\t\tgetBlockSupport( name, 'layout' ) ||\n\t\tgetBlockSupport( name, '__experimentalLayout' ) ||\n\t\tEMPTY_OBJECT;\n\n\tconst { allowSizingOnChildren = false } = defaultLayoutBlockSupport;\n\tconst usedLayout = layout || defaultLayoutBlockSupport;\n\n\tconst memoedLayout = useMemo(\n\t\t() => ( {\n\t\t\t// Default layout will know about any content/wide size defined by the theme.\n\t\t\t...defaultLayout,\n\t\t\t...usedLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ defaultLayout, usedLayout, allowSizingOnChildren ]\n\t);\n\n\t// For controlled inner blocks, we don't want a change in blocks to\n\t// re-render the blocks list.\n\tconst items = (\n\t\t<BlockListItemsMemo\n\t\t\trootClientId={ clientId }\n\t\t\trenderAppender={ renderAppender }\n\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\tlayout={ memoedLayout }\n\t\t\twrapperRef={ wrapperRef }\n\t\t\tplaceholder={ placeholder }\n\t\t/>\n\t);\n\n\tif ( Object.keys( blockType.providesContext ).length === 0 ) {\n\t\treturn items;\n\t}\n\n\treturn <BlockContext clientId={ clientId }>{ items }</BlockContext>;\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst {\n\t\t__unstableDisableLayoutClassNames,\n\t\t__unstableDisableDropZone,\n\t\tdropZoneElement,\n\t} = options;\n\tconst {\n\t\tclientId,\n\t\tlayout = null,\n\t\t__unstableLayoutClassNames: layoutClassNames = '',\n\t} = useBlockEditContext();\n\tconst selected = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockSettings,\n\t\t\t\tisDragging,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\tconst { hasBlockSupport, getBlockType } = select( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation';\n\t\t\tconst blockEditingMode = getBlockEditingMode( clientId );\n\t\t\tconst parentClientId = getBlockRootClientId( clientId );\n\t\t\tconst [ defaultLayout ] = getBlockSettings( clientId, 'layout' );\n\n\t\t\t// In zoom out mode, we want to disable the drop zone for the sections.\n\t\t\t// The inner blocks belonging to the section drop zone is\n\t\t\t// already disabled by the blocks themselves being disabled.\n\t\t\tlet _isDropZoneDisabled = blockEditingMode === 'disabled';\n\t\t\tif ( __unstableGetEditorMode() === 'zoom-out' ) {\n\t\t\t\tconst { sectionRootClientId } = unlock( getSettings() );\n\t\t\t\tconst sectionsClientIds = getBlockOrder( sectionRootClientId );\n\t\t\t\t_isDropZoneDisabled = sectionsClientIds?.includes( clientId );\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough &&\n\t\t\t\t\t! isDragging(),\n\t\t\t\tname: blockName,\n\t\t\t\tblockType: getBlockType( blockName ),\n\t\t\t\tparentLock: getTemplateLock( parentClientId ),\n\t\t\t\tparentClientId,\n\t\t\t\tisDropZoneDisabled: _isDropZoneDisabled,\n\t\t\t\tdefaultLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst {\n\t\t__experimentalCaptureToolbars,\n\t\thasOverlay,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tparentClientId,\n\t\tisDropZoneDisabled,\n\t\tdefaultLayout,\n\t} = selected;\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\tdropZoneElement,\n\t\trootClientId: clientId,\n\t\tparentClientId,\n\t\tisDisabled: isDropZoneDisabled,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ? null : blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\tlayout,\n\t\tname,\n\t\tblockType,\n\t\tparentLock,\n\t\tdefaultLayout,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t__unstableDisableLayoutClassNames ? '' : layoutClassNames,\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AASA,IAAAK,oBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,qBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,wBAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,0BAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,gBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,UAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AACA,IAAAY,QAAA,GAAAZ,OAAA;AACA,IAAAa,aAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,iBAAA,GAAAhB,sBAAA,CAAAC,OAAA;AACA,IAAAgB,WAAA,GAAAhB,OAAA;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAcA,MAAMiB,YAAY,GAAG,CAAC,CAAC;AAEvB,SAASC,YAAYA,CAAE;EAAEC,QAAQ;EAAEC;AAAS,CAAC,EAAG;EAC/C,MAAMC,OAAO,GAAG,IAAAC,wBAAe,EAAEF,QAAS,CAAC;EAC3C,OACC,IAAAG,MAAA,CAAAC,aAAA,EAACb,aAAA,CAAAc,oBAAoB;IAACC,KAAK,EAAGL;EAAS,GACpCF,Q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ACRwC,GAAG;IACHG,SAAS,EAAE,IAAA2C,mBAAU,EACpBtF,KAAK,CAAC2C,SAAS,EACf,iCAAiC,EACjCE,iCAAiC,GAAG,EAAE,GAAGI,gBAAgB,EACzD;MACC,aAAa,EAAE6B;IAChB,CACD,CAAC;IACD1F,QAAQ,EAAEC,QAAQ,GACjB,IAAAG,MAAA,CAAAC,aAAA,EAAC2F,WAAW;MAAA,GAAM3C,gBAAgB;MAAGpD,QAAQ,EAAGA;IAAU,CAAE,CAAC,GAE7D,IAAAG,MAAA,CAAAC,aAAA,EAACd,UAAA,CAAAmB,cAAc;MAAA,GAAM8C;IAAO,CAAI;EAElC,CAAC;AACF;AAEAF,mBAAmB,CAAC6C,IAAI,GAAGC,qCAAmB;;AAE9C;AACAlD,oBAAoB,CAACmD,oBAAoB,GAAGA,6BAAoB;AAChEnD,oBAAoB,CAACoD,mBAAmB,GAAGA,4BAAmB;AAE9DpD,oBAAoB,CAACqD,OAAO,GAAG,MAAMjD,mBAAmB,CAAC6C,IAAI,CAAC,CAAC,CAACnG,QAAQ;;AAExE;AACA;AACA;AAFA,IAAAwG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAGexD,oBAAoB","ignoreList":[]}
|
|
@@ -7,15 +7,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _element = require("@wordpress/element");
|
|
10
|
-
var _i18n = require("@wordpress/i18n");
|
|
11
10
|
var _compose = require("@wordpress/compose");
|
|
12
11
|
var _components = require("@wordpress/components");
|
|
13
|
-
var
|
|
12
|
+
var _i18n = require("@wordpress/i18n");
|
|
14
13
|
var _blockPatternsExplorer = _interopRequireDefault(require("../block-patterns-explorer"));
|
|
15
14
|
var _mobileTabNavigation = _interopRequireDefault(require("../mobile-tab-navigation"));
|
|
16
15
|
var _patternCategoryPreviews = require("./pattern-category-previews");
|
|
17
16
|
var _usePatternCategories = require("./use-pattern-categories");
|
|
18
|
-
var
|
|
17
|
+
var _categoryTabs = _interopRequireDefault(require("../category-tabs"));
|
|
18
|
+
var _noResults = _interopRequireDefault(require("../no-results"));
|
|
19
19
|
/**
|
|
20
20
|
* WordPress dependencies
|
|
21
21
|
*/
|
|
@@ -24,9 +24,6 @@ var _lockUnlock = require("../../../lock-unlock");
|
|
|
24
24
|
* Internal dependencies
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
const {
|
|
28
|
-
Tabs
|
|
29
|
-
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
30
27
|
function BlockPatternsTab({
|
|
31
28
|
onSelectCategory,
|
|
32
29
|
selectedCategory,
|
|
@@ -37,39 +34,23 @@ function BlockPatternsTab({
|
|
|
37
34
|
const [showPatternsExplorer, setShowPatternsExplorer] = (0, _element.useState)(false);
|
|
38
35
|
const categories = (0, _usePatternCategories.usePatternCategories)(rootClientId);
|
|
39
36
|
const isMobile = (0, _compose.useViewportMatch)('medium', '<');
|
|
37
|
+
if (!categories.length) {
|
|
38
|
+
return (0, _react.createElement)(_noResults.default, null);
|
|
39
|
+
}
|
|
40
40
|
return (0, _react.createElement)(_react.Fragment, null, !isMobile && (0, _react.createElement)("div", {
|
|
41
41
|
className: "block-editor-inserter__block-patterns-tabs-container"
|
|
42
|
-
}, (0, _react.createElement)(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Pass the full category object
|
|
48
|
-
onSelectCategory(categories.find(category => category.name === categoryId));
|
|
49
|
-
}
|
|
50
|
-
}, (0, _react.createElement)(Tabs.TabList, {
|
|
51
|
-
className: "block-editor-inserter__block-patterns-tablist"
|
|
52
|
-
}, categories.map(category => (0, _react.createElement)(Tabs.Tab, {
|
|
53
|
-
key: category.name,
|
|
54
|
-
tabId: category.name,
|
|
55
|
-
className: "block-editor-inserter__patterns-tab",
|
|
56
|
-
"aria-label": category.label,
|
|
57
|
-
"aria-current": category === selectedCategory ? 'true' : undefined
|
|
58
|
-
}, (0, _react.createElement)(_components.__experimentalHStack, null, (0, _react.createElement)(_components.FlexBlock, null, category.label), (0, _react.createElement)(_icons.Icon, {
|
|
59
|
-
icon: (0, _i18n.isRTL)() ? _icons.chevronLeft : _icons.chevronRight
|
|
60
|
-
}))))), categories.map(category => (0, _react.createElement)(Tabs.TabPanel, {
|
|
61
|
-
key: category.name,
|
|
62
|
-
tabId: category.name,
|
|
63
|
-
focusable: false,
|
|
64
|
-
className: "block-editor-inserter__patterns-category-panel"
|
|
65
|
-
}, children))), (0, _react.createElement)(_components.Button, {
|
|
42
|
+
}, (0, _react.createElement)(_categoryTabs.default, {
|
|
43
|
+
categories: categories,
|
|
44
|
+
selectedCategory: selectedCategory,
|
|
45
|
+
onSelectCategory: onSelectCategory
|
|
46
|
+
}, children), (0, _react.createElement)(_components.Button, {
|
|
66
47
|
className: "block-editor-inserter__patterns-explore-button",
|
|
67
48
|
onClick: () => setShowPatternsExplorer(true),
|
|
68
49
|
variant: "secondary"
|
|
69
50
|
}, (0, _i18n.__)('Explore all patterns'))), isMobile && (0, _react.createElement)(_mobileTabNavigation.default, {
|
|
70
51
|
categories: categories
|
|
71
52
|
}, category => (0, _react.createElement)("div", {
|
|
72
|
-
className: "block-editor-
|
|
53
|
+
className: "block-editor-inserter__category-panel"
|
|
73
54
|
}, (0, _react.createElement)(_patternCategoryPreviews.PatternCategoryPreviews, {
|
|
74
55
|
key: category.name,
|
|
75
56
|
onInsert: onInsert,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_components","_i18n","_blockPatternsExplorer","_interopRequireDefault","_mobileTabNavigation","_patternCategoryPreviews","_usePatternCategories","_categoryTabs","_noResults","BlockPatternsTab","onSelectCategory","selectedCategory","onInsert","rootClientId","children","showPatternsExplorer","setShowPatternsExplorer","useState","categories","usePatternCategories","isMobile","useViewportMatch","length","_react","createElement","default","Fragment","className","Button","onClick","variant","__","category","PatternCategoryPreviews","key","name","showTitlesAsTooltip","initialCategory","patternCategories","onModalClose","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternsExplorerModal from '../block-patterns-explorer';\nimport MobileTabNavigation from '../mobile-tab-navigation';\nimport { PatternCategoryPreviews } from './pattern-category-previews';\nimport { usePatternCategories } from './use-pattern-categories';\nimport CategoryTabs from '../category-tabs';\nimport InserterNoResults from '../no-results';\n\nfunction BlockPatternsTab( {\n\tonSelectCategory,\n\tselectedCategory,\n\tonInsert,\n\trootClientId,\n\tchildren,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\n\tconst categories = usePatternCategories( rootClientId );\n\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\tif ( ! categories.length ) {\n\t\treturn <InserterNoResults />;\n\t}\n\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<CategoryTabs\n\t\t\t\t\t\tcategories={ categories }\n\t\t\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\t\t\tonSelectCategory={ onSelectCategory }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</CategoryTabs>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explore-button\"\n\t\t\t\t\t\tonClick={ () => setShowPatternsExplorer( true ) }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Explore all patterns' ) }\n\t\t\t\t\t</Button>\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<div className=\"block-editor-inserter__category-panel\">\n\t\t\t\t\t\t\t<PatternCategoryPreviews\n\t\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\t\tshowTitlesAsTooltip={ false }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\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={ selectedCategory || categories[ 0 ] }\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 BlockPatternsTab;\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,sBAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAD,sBAAA,CAAAL,OAAA;AACA,IAAAO,wBAAA,GAAAP,OAAA;AACA,IAAAQ,qBAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAJ,sBAAA,CAAAL,OAAA;AACA,IAAAU,UAAA,GAAAL,sBAAA,CAAAL,OAAA;AAhBA;AACA;AACA;;AAMA;AACA;AACA;;AAQA,SAASW,gBAAgBA,CAAE;EAC1BC,gBAAgB;EAChBC,gBAAgB;EAChBC,QAAQ;EACRC,YAAY;EACZC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,oBAAoB,EAAEC,uBAAuB,CAAE,GAA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ACG,CAEc,CACrB,EACCrB,oBAAoB,IACrB,IAAAQ,MAAA,CAAAC,aAAA,EAACtB,sBAAA,CAAAuB,OAAqB;IACrBY,eAAe,EAAG1B,gBAAgB,IAAIO,UAAU,CAAE,CAAC,CAAI;IACvDoB,iBAAiB,EAAGpB,UAAY;IAChCqB,YAAY,EAAGA,CAAA,KAAMvB,uBAAuB,CAAE,KAAM,CAAG;IACvDH,YAAY,EAAGA;EAAc,CAC7B,CAED,CAAC;AAEL;AAAC,IAAA2B,QAAA,GAAAC,OAAA,CAAAhB,OAAA,GAEchB,gBAAgB","ignoreList":[]}
|
|
@@ -15,6 +15,7 @@ var _panel = _interopRequireDefault(require("./panel"));
|
|
|
15
15
|
var _useBlockTypesState = _interopRequireDefault(require("./hooks/use-block-types-state"));
|
|
16
16
|
var _inserterListbox = _interopRequireDefault(require("../inserter-listbox"));
|
|
17
17
|
var _sorting = require("../../utils/sorting");
|
|
18
|
+
var _noResults = _interopRequireDefault(require("./no-results"));
|
|
18
19
|
/**
|
|
19
20
|
* WordPress dependencies
|
|
20
21
|
*/
|
|
@@ -89,6 +90,9 @@ function BlockTypesTab({
|
|
|
89
90
|
return Object.entries(collections);
|
|
90
91
|
}, [collections]);
|
|
91
92
|
const currentlyRenderedCollections = (0, _compose.useAsyncList)(didRenderAllCategories ? collectionEntries : EMPTY_ARRAY);
|
|
93
|
+
if (!items.length) {
|
|
94
|
+
return (0, _react.createElement)(_noResults.default, null);
|
|
95
|
+
}
|
|
92
96
|
return (0, _react.createElement)(_inserterListbox.default, null, (0, _react.createElement)("div", null, showMostUsedBlocks && !!suggestedItems.length && (0, _react.createElement)(_panel.default, {
|
|
93
97
|
title: (0, _i18n._x)('Most used', 'blocks')
|
|
94
98
|
}, (0, _react.createElement)(_blockTypesList.default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_element","_compose","_blockTypesList","_interopRequireDefault","_panel","_useBlockTypesState","_inserterListbox","_sorting","getBlockNamespace","item","name","split","MAX_SUGGESTED_ITEMS","EMPTY_ARRAY","BlockTypesTab","rootClientId","onInsert","onHover","showMostUsedBlocks","items","categories","collections","onSelectItem","useBlockTypesState","suggestedItems","useMemo","orderBy","slice","uncategorizedItems","filter","category","itemsPerCategory","pipe","itemList","reduce","acc","push","itemsPerCollection","result","Object","keys","forEach","namespace","length","useEffect","currentlyRenderedCategories","useAsyncList","didRenderAllCategories","collectionEntries","entries","currentlyRenderedCollections","_react","createElement","default","title","_x","onSelect","label","map","categoryItems","slug","key","icon","className","__","collection","collectionItems","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-types-tab.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { pipe, useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport InserterPanel from './panel';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport InserterListbox from '../inserter-listbox';\nimport { orderBy } from '../../utils/sorting';\n\nconst getBlockNamespace = ( item ) => item.name.split( '/' )[ 0 ];\n\nconst MAX_SUGGESTED_ITEMS = 6;\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation and rerendering the component.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nexport function BlockTypesTab( {\n\trootClientId,\n\tonInsert,\n\tonHover,\n\tshowMostUsedBlocks,\n} ) {\n\tconst [ items, categories, collections, onSelectItem ] = useBlockTypesState(\n\t\trootClientId,\n\t\tonInsert\n\t);\n\n\tconst suggestedItems = useMemo( () => {\n\t\treturn orderBy( items, 'frecency', 'desc' ).slice(\n\t\t\t0,\n\t\t\tMAX_SUGGESTED_ITEMS\n\t\t);\n\t}, [ items ] );\n\n\tconst uncategorizedItems = useMemo( () => {\n\t\treturn items.filter( ( item ) => ! item.category );\n\t}, [ items ] );\n\n\tconst itemsPerCategory = useMemo( () => {\n\t\treturn pipe(\n\t\t\t( itemList ) =>\n\t\t\t\titemList.filter(\n\t\t\t\t\t( item ) => item.category && item.category !== 'reusable'\n\t\t\t\t),\n\t\t\t( itemList ) =>\n\t\t\t\titemList.reduce( ( acc, item ) => {\n\t\t\t\t\tconst { category } = item;\n\t\t\t\t\tif ( ! acc[ category ] ) {\n\t\t\t\t\t\tacc[ category ] = [];\n\t\t\t\t\t}\n\t\t\t\t\tacc[ category ].push( item );\n\t\t\t\t\treturn acc;\n\t\t\t\t}, {} )\n\t\t)( items );\n\t}, [ items ] );\n\n\tconst itemsPerCollection = useMemo( () => {\n\t\t// Create a new Object to avoid mutating collection.\n\t\tconst result = { ...collections };\n\t\tObject.keys( collections ).forEach( ( namespace ) => {\n\t\t\tresult[ namespace ] = items.filter(\n\t\t\t\t( item ) => getBlockNamespace( item ) === namespace\n\t\t\t);\n\t\t\tif ( result[ namespace ].length === 0 ) {\n\t\t\t\tdelete result[ namespace ];\n\t\t\t}\n\t\t} );\n\n\t\treturn result;\n\t}, [ items, collections ] );\n\n\t// Hide block preview on unmount.\n\tuseEffect( () => () => onHover( null ), [] );\n\n\t/**\n\t * The inserter contains a big number of blocks and opening it is a costful operation.\n\t * The rendering is the most costful part of it, in order to improve the responsiveness\n\t * of the \"opening\" action, these lazy lists allow us to render the inserter category per category,\n\t * once all the categories are rendered, we start rendering the collections and the uncategorized block types.\n\t */\n\tconst currentlyRenderedCategories = useAsyncList( categories );\n\tconst didRenderAllCategories =\n\t\tcategories.length === currentlyRenderedCategories.length;\n\n\t// Async List requires an array.\n\tconst collectionEntries = useMemo( () => {\n\t\treturn Object.entries( collections );\n\t}, [ collections ] );\n\tconst currentlyRenderedCollections = useAsyncList(\n\t\tdidRenderAllCategories ? collectionEntries : EMPTY_ARRAY\n\t);\n\n\treturn (\n\t\t<InserterListbox>\n\t\t\t<div>\n\t\t\t\t{ showMostUsedBlocks && !! suggestedItems.length && (\n\t\t\t\t\t<InserterPanel title={ _x( 'Most used', 'blocks' ) }>\n\t\t\t\t\t\t<BlockTypesList\n\t\t\t\t\t\t\titems={ suggestedItems }\n\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\t\tlabel={ _x( 'Most used', 'blocks' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</InserterPanel>\n\t\t\t\t) }\n\n\t\t\t\t{ currentlyRenderedCategories.map( ( category ) => {\n\t\t\t\t\tconst categoryItems = itemsPerCategory[ category.slug ];\n\t\t\t\t\tif ( ! categoryItems || ! categoryItems.length ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<InserterPanel\n\t\t\t\t\t\t\tkey={ category.slug }\n\t\t\t\t\t\t\ttitle={ category.title }\n\t\t\t\t\t\t\ticon={ category.icon }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockTypesList\n\t\t\t\t\t\t\t\titems={ categoryItems }\n\t\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\t\t\tlabel={ category.title }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</InserterPanel>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\n\t\t\t\t{ didRenderAllCategories && uncategorizedItems.length > 0 && (\n\t\t\t\t\t<InserterPanel\n\t\t\t\t\t\tclassName=\"block-editor-inserter__uncategorized-blocks-panel\"\n\t\t\t\t\t\ttitle={ __( 'Uncategorized' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockTypesList\n\t\t\t\t\t\t\titems={ uncategorizedItems }\n\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\t\tlabel={ __( 'Uncategorized' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</InserterPanel>\n\t\t\t\t) }\n\n\t\t\t\t{ currentlyRenderedCollections.map(\n\t\t\t\t\t( [ namespace, collection ] ) => {\n\t\t\t\t\t\tconst collectionItems = itemsPerCollection[ namespace ];\n\t\t\t\t\t\tif ( ! collectionItems || ! collectionItems.length ) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<InserterPanel\n\t\t\t\t\t\t\t\tkey={ namespace }\n\t\t\t\t\t\t\t\ttitle={ collection.title }\n\t\t\t\t\t\t\t\ticon={ collection.icon }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<BlockTypesList\n\t\t\t\t\t\t\t\t\titems={ collectionItems }\n\t\t\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\t\t\t\tlabel={ collection.title }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</InserterPanel>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</InserterListbox>\n\t);\n}\n\nexport default BlockTypesTab;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,eAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,mBAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,gBAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAdA;AACA;AACA;;AAKA;AACA;AACA;;AAOA,MAAMS,iBAAiB,GAAKC,IAAI,IAAMA,IAAI,CAACC,IAAI,CAACC,KAAK,CAAE,GAAI,CAAC,CAAE,CAAC,CAAE;AAEjE,MAAMC,mBAAmB,GAAG,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,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S,kBAAoB;IAC5B4B,QAAQ,EAAGlC,YAAc;IACzBL,OAAO,EAAGA,OAAS;IACnBwC,KAAK,EAAG,IAAAO,QAAE,EAAE,eAAgB;EAAG,CAC/B,CACa,CACf,EAECd,4BAA4B,CAACQ,GAAG,CACjC,CAAE,CAAEhB,SAAS,EAAEuB,UAAU,CAAE,KAAM;IAChC,MAAMC,eAAe,GAAG7B,kBAAkB,CAAEK,SAAS,CAAE;IACvD,IAAK,CAAEwB,eAAe,IAAI,CAAEA,eAAe,CAACvB,MAAM,EAAG;MACpD,OAAO,IAAI;IACZ;IAEA,OACC,IAAAQ,MAAA,CAAAC,aAAA,EAAChD,MAAA,CAAAiD,OAAa;MACbQ,GAAG,EAAGnB,SAAW;MACjBY,KAAK,EAAGW,UAAU,CAACX,KAAO;MAC1BQ,IAAI,EAAGG,UAAU,CAACH;IAAM,GAExB,IAAAX,MAAA,CAAAC,aAAA,EAAClD,eAAA,CAAAmD,OAAc;MACdlC,KAAK,EAAG+C,eAAiB;MACzBV,QAAQ,EAAGlC,YAAc;MACzBL,OAAO,EAAGA,OAAS;MACnBwC,KAAK,EAAGQ,UAAU,CAACX;IAAO,CAC1B,CACa,CAAC;EAElB,CACD,CACI,CACW,CAAC;AAEpB;AAAC,IAAAa,QAAA,GAAAC,OAAA,CAAAf,OAAA,GAEcvC,aAAa","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_element","_compose","_blockTypesList","_interopRequireDefault","_panel","_useBlockTypesState","_inserterListbox","_sorting","_noResults","getBlockNamespace","item","name","split","MAX_SUGGESTED_ITEMS","EMPTY_ARRAY","BlockTypesTab","rootClientId","onInsert","onHover","showMostUsedBlocks","items","categories","collections","onSelectItem","useBlockTypesState","suggestedItems","useMemo","orderBy","slice","uncategorizedItems","filter","category","itemsPerCategory","pipe","itemList","reduce","acc","push","itemsPerCollection","result","Object","keys","forEach","namespace","length","useEffect","currentlyRenderedCategories","useAsyncList","didRenderAllCategories","collectionEntries","entries","currentlyRenderedCollections","_react","createElement","default","title","_x","onSelect","label","map","categoryItems","slug","key","icon","className","__","collection","collectionItems","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-types-tab.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { useMemo, useEffect } from '@wordpress/element';\nimport { pipe, useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport InserterPanel from './panel';\nimport useBlockTypesState from './hooks/use-block-types-state';\nimport InserterListbox from '../inserter-listbox';\nimport { orderBy } from '../../utils/sorting';\nimport InserterNoResults from './no-results';\n\nconst getBlockNamespace = ( item ) => item.name.split( '/' )[ 0 ];\n\nconst MAX_SUGGESTED_ITEMS = 6;\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation and rerendering the component.\n *\n * @type {Array}\n */\nconst EMPTY_ARRAY = [];\n\nexport function BlockTypesTab( {\n\trootClientId,\n\tonInsert,\n\tonHover,\n\tshowMostUsedBlocks,\n} ) {\n\tconst [ items, categories, collections, onSelectItem ] = useBlockTypesState(\n\t\trootClientId,\n\t\tonInsert\n\t);\n\n\tconst suggestedItems = useMemo( () => {\n\t\treturn orderBy( items, 'frecency', 'desc' ).slice(\n\t\t\t0,\n\t\t\tMAX_SUGGESTED_ITEMS\n\t\t);\n\t}, [ items ] );\n\n\tconst uncategorizedItems = useMemo( () => {\n\t\treturn items.filter( ( item ) => ! item.category );\n\t}, [ items ] );\n\n\tconst itemsPerCategory = useMemo( () => {\n\t\treturn pipe(\n\t\t\t( itemList ) =>\n\t\t\t\titemList.filter(\n\t\t\t\t\t( item ) => item.category && item.category !== 'reusable'\n\t\t\t\t),\n\t\t\t( itemList ) =>\n\t\t\t\titemList.reduce( ( acc, item ) => {\n\t\t\t\t\tconst { category } = item;\n\t\t\t\t\tif ( ! acc[ category ] ) {\n\t\t\t\t\t\tacc[ category ] = [];\n\t\t\t\t\t}\n\t\t\t\t\tacc[ category ].push( item );\n\t\t\t\t\treturn acc;\n\t\t\t\t}, {} )\n\t\t)( items );\n\t}, [ items ] );\n\n\tconst itemsPerCollection = useMemo( () => {\n\t\t// Create a new Object to avoid mutating collection.\n\t\tconst result = { ...collections };\n\t\tObject.keys( collections ).forEach( ( namespace ) => {\n\t\t\tresult[ namespace ] = items.filter(\n\t\t\t\t( item ) => getBlockNamespace( item ) === namespace\n\t\t\t);\n\t\t\tif ( result[ namespace ].length === 0 ) {\n\t\t\t\tdelete result[ namespace ];\n\t\t\t}\n\t\t} );\n\n\t\treturn result;\n\t}, [ items, collections ] );\n\n\t// Hide block preview on unmount.\n\tuseEffect( () => () => onHover( null ), [] );\n\n\t/**\n\t * The inserter contains a big number of blocks and opening it is a costful operation.\n\t * The rendering is the most costful part of it, in order to improve the responsiveness\n\t * of the \"opening\" action, these lazy lists allow us to render the inserter category per category,\n\t * once all the categories are rendered, we start rendering the collections and the uncategorized block types.\n\t */\n\tconst currentlyRenderedCategories = useAsyncList( categories );\n\tconst didRenderAllCategories =\n\t\tcategories.length === currentlyRenderedCategories.length;\n\n\t// Async List requires an array.\n\tconst collectionEntries = useMemo( () => {\n\t\treturn Object.entries( collections );\n\t}, [ collections ] );\n\tconst currentlyRenderedCollections = useAsyncList(\n\t\tdidRenderAllCategories ? collectionEntries : EMPTY_ARRAY\n\t);\n\n\tif ( ! items.length ) {\n\t\treturn <InserterNoResults />;\n\t}\n\n\treturn (\n\t\t<InserterListbox>\n\t\t\t<div>\n\t\t\t\t{ showMostUsedBlocks && !! suggestedItems.length && (\n\t\t\t\t\t<InserterPanel title={ _x( 'Most used', 'blocks' ) }>\n\t\t\t\t\t\t<BlockTypesList\n\t\t\t\t\t\t\titems={ suggestedItems }\n\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\t\tlabel={ _x( 'Most used', 'blocks' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</InserterPanel>\n\t\t\t\t) }\n\n\t\t\t\t{ currentlyRenderedCategories.map( ( category ) => {\n\t\t\t\t\tconst categoryItems = itemsPerCategory[ category.slug ];\n\t\t\t\t\tif ( ! categoryItems || ! categoryItems.length ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<InserterPanel\n\t\t\t\t\t\t\tkey={ category.slug }\n\t\t\t\t\t\t\ttitle={ category.title }\n\t\t\t\t\t\t\ticon={ category.icon }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockTypesList\n\t\t\t\t\t\t\t\titems={ categoryItems }\n\t\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\t\t\tlabel={ category.title }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</InserterPanel>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\n\t\t\t\t{ didRenderAllCategories && uncategorizedItems.length > 0 && (\n\t\t\t\t\t<InserterPanel\n\t\t\t\t\t\tclassName=\"block-editor-inserter__uncategorized-blocks-panel\"\n\t\t\t\t\t\ttitle={ __( 'Uncategorized' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockTypesList\n\t\t\t\t\t\t\titems={ uncategorizedItems }\n\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\t\tlabel={ __( 'Uncategorized' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</InserterPanel>\n\t\t\t\t) }\n\n\t\t\t\t{ currentlyRenderedCollections.map(\n\t\t\t\t\t( [ namespace, collection ] ) => {\n\t\t\t\t\t\tconst collectionItems = itemsPerCollection[ namespace ];\n\t\t\t\t\t\tif ( ! collectionItems || ! collectionItems.length ) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<InserterPanel\n\t\t\t\t\t\t\t\tkey={ namespace }\n\t\t\t\t\t\t\t\ttitle={ collection.title }\n\t\t\t\t\t\t\t\ticon={ collection.icon }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<BlockTypesList\n\t\t\t\t\t\t\t\t\titems={ collectionItems }\n\t\t\t\t\t\t\t\t\tonSelect={ onSelectItem }\n\t\t\t\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\t\t\t\tlabel={ collection.title }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</InserterPanel>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</InserterListbox>\n\t);\n}\n\nexport default BlockTypesTab;\n"],"mappings":";;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,eAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,mBAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,gBAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAL,sBAAA,CAAAJ,OAAA;AAfA;AACA;AACA;;AAKA;AACA;AACA;;AAQA,MAAMU,iBAAiB,GAAKC,IAAI,IAAMA,IAAI,CAACC,IAAI,CAACC,KAAK,CAAE,GAAI,CAAC,CAAE,CAAC,CAAE;AAEjE,MAAMC,mBAAmB,GAAG,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAG,EAAE;AAEf,SAASC,aAAaA,CAAE;EAC9BC,YAAY;EACZC,QAAQ;EACRC,OAAO;EACPC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,KAAK,EAAEC,UAAU,EAAEC,WAAW,EAAE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AAGlC,YAAc;IACzBL,OAAO,EAAGA,OAAS;IACnBwC,KAAK,EAAG,IAAAO,QAAE,EAAE,eAAgB;EAAG,CAC/B,CACa,CACf,EAECd,4BAA4B,CAACQ,GAAG,CACjC,CAAE,CAAEhB,SAAS,EAAEuB,UAAU,CAAE,KAAM;IAChC,MAAMC,eAAe,GAAG7B,kBAAkB,CAAEK,SAAS,CAAE;IACvD,IAAK,CAAEwB,eAAe,IAAI,CAAEA,eAAe,CAACvB,MAAM,EAAG;MACpD,OAAO,IAAI;IACZ;IAEA,OACC,IAAAQ,MAAA,CAAAC,aAAA,EAACjD,MAAA,CAAAkD,OAAa;MACbQ,GAAG,EAAGnB,SAAW;MACjBY,KAAK,EAAGW,UAAU,CAACX,KAAO;MAC1BQ,IAAI,EAAGG,UAAU,CAACH;IAAM,GAExB,IAAAX,MAAA,CAAAC,aAAA,EAACnD,eAAA,CAAAoD,OAAc;MACdlC,KAAK,EAAG+C,eAAiB;MACzBV,QAAQ,EAAGlC,YAAc;MACzBL,OAAO,EAAGA,OAAS;MACnBwC,KAAK,EAAGQ,UAAU,CAACX;IAAO,CAC1B,CACa,CAAC;EAElB,CACD,CACI,CACW,CAAC;AAEpB;AAAC,IAAAa,QAAA,GAAAC,OAAA,CAAAf,OAAA,GAEcvC,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _i18n = require("@wordpress/i18n");
|
|
9
|
+
var _components = require("@wordpress/components");
|
|
10
|
+
var _icons = require("@wordpress/icons");
|
|
11
|
+
var _lockUnlock = require("../../../lock-unlock");
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
Tabs
|
|
22
|
+
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
23
|
+
function CategoryTabs({
|
|
24
|
+
categories,
|
|
25
|
+
selectedCategory,
|
|
26
|
+
onSelectCategory,
|
|
27
|
+
children
|
|
28
|
+
}) {
|
|
29
|
+
return (0, _react.createElement)(Tabs, {
|
|
30
|
+
className: "block-editor-inserter__category-tabs",
|
|
31
|
+
selectOnMove: false,
|
|
32
|
+
selectedTabId: selectedCategory ? selectedCategory.name : null,
|
|
33
|
+
orientation: 'vertical',
|
|
34
|
+
onSelect: categoryId => {
|
|
35
|
+
// Pass the full category object
|
|
36
|
+
onSelectCategory(categories.find(category => category.name === categoryId));
|
|
37
|
+
}
|
|
38
|
+
}, (0, _react.createElement)(Tabs.TabList, {
|
|
39
|
+
className: "block-editor-inserter__category-tablist"
|
|
40
|
+
}, categories.map(category => (0, _react.createElement)(Tabs.Tab, {
|
|
41
|
+
key: category.name,
|
|
42
|
+
tabId: category.name,
|
|
43
|
+
className: "block-editor-inserter__category-tab",
|
|
44
|
+
"aria-label": category.label,
|
|
45
|
+
"aria-current": category === selectedCategory ? 'true' : undefined
|
|
46
|
+
}, (0, _react.createElement)(_components.__experimentalHStack, null, (0, _react.createElement)(_components.FlexBlock, null, category.label), (0, _react.createElement)(_icons.Icon, {
|
|
47
|
+
icon: (0, _i18n.isRTL)() ? _icons.chevronLeft : _icons.chevronRight
|
|
48
|
+
}))))), categories.map(category => (0, _react.createElement)(Tabs.TabPanel, {
|
|
49
|
+
key: category.name,
|
|
50
|
+
tabId: category.name,
|
|
51
|
+
focusable: false,
|
|
52
|
+
className: "block-editor-inserter__category-panel"
|
|
53
|
+
}, children)));
|
|
54
|
+
}
|
|
55
|
+
var _default = exports.default = CategoryTabs;
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_icons","_lockUnlock","Tabs","unlock","componentsPrivateApis","CategoryTabs","categories","selectedCategory","onSelectCategory","children","_react","createElement","className","selectOnMove","selectedTabId","name","orientation","onSelect","categoryId","find","category","TabList","map","Tab","key","tabId","label","undefined","__experimentalHStack","FlexBlock","Icon","icon","isRTL","chevronLeft","chevronRight","TabPanel","focusable","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/inserter/category-tabs/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isRTL } from '@wordpress/i18n';\nimport {\n\t__experimentalHStack as HStack,\n\tFlexBlock,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { Icon, chevronRight, chevronLeft } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nfunction CategoryTabs( {\n\tcategories,\n\tselectedCategory,\n\tonSelectCategory,\n\tchildren,\n} ) {\n\treturn (\n\t\t<Tabs\n\t\t\tclassName=\"block-editor-inserter__category-tabs\"\n\t\t\tselectOnMove={ false }\n\t\t\tselectedTabId={ selectedCategory ? selectedCategory.name : null }\n\t\t\torientation={ 'vertical' }\n\t\t\tonSelect={ ( categoryId ) => {\n\t\t\t\t// Pass the full category object\n\t\t\t\tonSelectCategory(\n\t\t\t\t\tcategories.find(\n\t\t\t\t\t\t( category ) => category.name === categoryId\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} }\n\t\t>\n\t\t\t<Tabs.TabList className=\"block-editor-inserter__category-tablist\">\n\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\ttabId={ category.name }\n\t\t\t\t\t\tclassName=\"block-editor-inserter__category-tab\"\n\t\t\t\t\t\taria-label={ category.label }\n\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\tcategory === selectedCategory ? 'true' : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t<FlexBlock>{ category.label }</FlexBlock>\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ isRTL() ? chevronLeft : chevronRight }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t) ) }\n\t\t\t</Tabs.TabList>\n\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\tkey={ category.name }\n\t\t\t\t\ttabId={ category.name }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t\tclassName=\"block-editor-inserter__category-panel\"\n\t\t\t\t>\n\t\t\t\t\t{ children }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t) ) }\n\t\t</Tabs>\n\t);\n}\n\nexport default CategoryTabs;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AAdA;AACA;AACA;;AASA;AACA;AACA;;AAGA,MAAM;EAAEI;AAAK,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAEhD,SAASC,YAAYA,CAAE;EACtBC,UAAU;EACVC,gBAAgB;EAChBC,gBAAgB;EAChBC;AACD,CAAC,EAAG;EACH,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACT,IAAI;IACJU,SAAS,EAAC,sCAAsC;IAChDC,YAAY,EAAG,KAAO;IACtBC,aAAa,EAAGP,gBAAgB,GAAGA,gBAAgB,CAACQ,IAAI,GAAG,IAAM;IACjEC,WAAW,EAAG,UAAY;IAC1BC,QAAQ,EAAKC,UAAU,IAAM;MAC5B;MACAV,gBAAgB,CACfF,UAAU,CAACa,IAAI,CACZC,QAAQ,IAAMA,QAAQ,CAACL,IAAI,KAAKG,UACnC,CACD,CAAC;IACF;EAAG,GAEH,IAAAR,MAAA,CAAAC,aAAA,EAACT,IAAI,CAACmB,OAAO;IAACT,SAAS,EAAC;EAAyC,GAC9DN,UAAU,CAACgB,GAAG,CAAIF,QAAQ,IAC3B,IAAAV,MAAA,CAAAC,aAAA,EAACT,IAAI,CAACqB,GAAG;IACRC,GAAG,EAAGJ,QAAQ,CAACL,IAAM;IACrBU,KAAK,EAAGL,QAAQ,CAACL,IAAM;IACvBH,SAAS,EAAC,qCAAqC;IAC/C,cAAaQ,QAAQ,CAACM,KAAO;IAC7B,gBACCN,QAAQ,KAAKb,gBAAgB,GAAG,MAAM,GAAGoB;EACzC,GAED,IAAAjB,MAAA,CAAAC,aAAA,EAACZ,WAAA,CAAA6B,oBAAM,QACN,IAAAlB,MAAA,CAAAC,aAAA,EAACZ,WAAA,CAAA8B,SAAS,QAAGT,QAAQ,CAACM,KAAkB,CAAC,EACzC,IAAAhB,MAAA,CAAAC,aAAA,EAACX,MAAA,CAAA8B,IAAI;IACJC,IAAI,EAAG,IAAAC,WAAK,EAAC,CAAC,GAAGC,kBAAW,GAAGC;EAAc,CAC7C,CACM,CACC,CACT,CACW,CAAC,EACb5B,UAAU,CAACgB,GAAG,CAAIF,QAAQ,IAC3B,IAAAV,MAAA,CAAAC,aAAA,EAACT,IAAI,CAACiC,QAAQ;IACbX,GAAG,EAAGJ,QAAQ,CAACL,IAAM;IACrBU,KAAK,EAAGL,QAAQ,CAACL,IAAM;IACvBqB,SAAS,EAAG,KAAO;IACnBxB,SAAS,EAAC;EAAuC,GAE/CH,QACY,CACd,CACG,CAAC;AAET;AAAC,IAAA4B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEclC,YAAY","ignoreList":[]}
|
|
@@ -4,10 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
Object.defineProperty(exports, "
|
|
7
|
+
Object.defineProperty(exports, "MediaCategoryPanel", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
10
|
-
return _mediaPanel.
|
|
10
|
+
return _mediaPanel.MediaCategoryPanel;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "MediaTab", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_mediaTab","_interopRequireDefault","require","_mediaPanel","_hooks"],"sources":["@wordpress/block-editor/src/components/inserter/media-tab/index.js"],"sourcesContent":["export { default as MediaTab } from './media-tab';\nexport {
|
|
1
|
+
{"version":3,"names":["_mediaTab","_interopRequireDefault","require","_mediaPanel","_hooks"],"sources":["@wordpress/block-editor/src/components/inserter/media-tab/index.js"],"sourcesContent":["export { default as MediaTab } from './media-tab';\nexport { MediaCategoryPanel } from './media-panel';\nexport { useMediaCategories } from './hooks';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA","ignoreList":[]}
|
|
@@ -4,12 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.MediaCategoryDialog = MediaCategoryDialog;
|
|
8
7
|
exports.MediaCategoryPanel = MediaCategoryPanel;
|
|
9
8
|
var _react = require("react");
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
9
|
var _components = require("@wordpress/components");
|
|
12
|
-
var _dom = require("@wordpress/dom");
|
|
13
10
|
var _i18n = require("@wordpress/i18n");
|
|
14
11
|
var _compose = require("@wordpress/compose");
|
|
15
12
|
var _mediaList = _interopRequireDefault(require("./media-list"));
|
|
@@ -24,28 +21,6 @@ var _noResults = _interopRequireDefault(require("../no-results"));
|
|
|
24
21
|
*/
|
|
25
22
|
|
|
26
23
|
const INITIAL_MEDIA_ITEMS_PER_PAGE = 10;
|
|
27
|
-
function MediaCategoryDialog({
|
|
28
|
-
rootClientId,
|
|
29
|
-
onInsert,
|
|
30
|
-
category
|
|
31
|
-
}) {
|
|
32
|
-
const container = (0, _element.useRef)();
|
|
33
|
-
(0, _element.useEffect)(() => {
|
|
34
|
-
const timeout = setTimeout(() => {
|
|
35
|
-
const [firstTabbable] = _dom.focus.tabbable.find(container.current);
|
|
36
|
-
firstTabbable?.focus();
|
|
37
|
-
});
|
|
38
|
-
return () => clearTimeout(timeout);
|
|
39
|
-
}, [category]);
|
|
40
|
-
return (0, _react.createElement)("div", {
|
|
41
|
-
ref: container,
|
|
42
|
-
className: "block-editor-inserter__media-dialog"
|
|
43
|
-
}, (0, _react.createElement)(MediaCategoryPanel, {
|
|
44
|
-
rootClientId: rootClientId,
|
|
45
|
-
onInsert: onInsert,
|
|
46
|
-
category: category
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
24
|
function MediaCategoryPanel({
|
|
50
25
|
rootClientId,
|
|
51
26
|
onInsert,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_compose","_mediaList","_interopRequireDefault","_hooks","_noResults","INITIAL_MEDIA_ITEMS_PER_PAGE","MediaCategoryPanel","rootClientId","onInsert","category","search","setSearch","debouncedSearch","useDebouncedInput","mediaList","isLoading","useMediaResults","per_page","baseCssClass","searchLabel","labels","search_items","__","_react","createElement","className","SearchControl","onChange","value","label","placeholder","Spinner","length","default","onClick"],"sources":["@wordpress/block-editor/src/components/inserter/media-tab/media-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Spinner, SearchControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useDebouncedInput } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport MediaList from './media-list';\nimport { useMediaResults } from './hooks';\nimport InserterNoResults from '../no-results';\n\nconst INITIAL_MEDIA_ITEMS_PER_PAGE = 10;\n\nexport function MediaCategoryPanel( { rootClientId, onInsert, category } ) {\n\tconst [ search, setSearch, debouncedSearch ] = useDebouncedInput();\n\tconst { mediaList, isLoading } = useMediaResults( category, {\n\t\tper_page: !! debouncedSearch ? 20 : INITIAL_MEDIA_ITEMS_PER_PAGE,\n\t\tsearch: debouncedSearch,\n\t} );\n\tconst baseCssClass = 'block-editor-inserter__media-panel';\n\tconst searchLabel = category.labels.search_items || __( 'Search' );\n\treturn (\n\t\t<div className={ baseCssClass }>\n\t\t\t<SearchControl\n\t\t\t\tclassName={ `${ baseCssClass }-search` }\n\t\t\t\tonChange={ setSearch }\n\t\t\t\tvalue={ search }\n\t\t\t\tlabel={ searchLabel }\n\t\t\t\tplaceholder={ searchLabel }\n\t\t\t/>\n\t\t\t{ isLoading && (\n\t\t\t\t<div className={ `${ baseCssClass }-spinner` }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ ! isLoading && ! mediaList?.length && <InserterNoResults /> }\n\t\t\t{ ! isLoading && !! mediaList?.length && (\n\t\t\t\t<MediaList\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tonClick={ onInsert }\n\t\t\t\t\tmediaList={ mediaList }\n\t\t\t\t\tcategory={ category }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,UAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAF,sBAAA,CAAAJ,OAAA;AAZA;AACA;AACA;;AAKA;AACA;AACA;;AAKA,MAAMO,4BAA4B,GAAG,EAAE;AAEhC,SAASC,kBAAkBA,CAAE;EAAEC,YAAY;EAAEC,Q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AAQ,EAAGA;EAAU,CACrB,CAEE,CAAC;AAER","ignoreList":[]}
|
|
@@ -94,18 +94,28 @@ function MediaPreview({
|
|
|
94
94
|
createErrorNotice,
|
|
95
95
|
createSuccessNotice
|
|
96
96
|
} = (0, _data.useDispatch)(_notices.store);
|
|
97
|
-
const
|
|
97
|
+
const {
|
|
98
|
+
getSettings
|
|
99
|
+
} = (0, _data.useSelect)(_store.store);
|
|
98
100
|
const onMediaInsert = (0, _element.useCallback)(previewBlock => {
|
|
99
101
|
// Prevent multiple uploads when we're in the process of inserting.
|
|
100
102
|
if (isInserting) {
|
|
101
103
|
return;
|
|
102
104
|
}
|
|
105
|
+
const settings = getSettings();
|
|
103
106
|
const clonedBlock = (0, _blocks.cloneBlock)(previewBlock);
|
|
104
107
|
const {
|
|
105
108
|
id,
|
|
106
109
|
url,
|
|
107
110
|
caption
|
|
108
111
|
} = clonedBlock.attributes;
|
|
112
|
+
|
|
113
|
+
// User has no permission to upload media.
|
|
114
|
+
if (!id && !settings.mediaUpload) {
|
|
115
|
+
setShowExternalUploadModal(true);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
109
119
|
// Media item already exists in library, so just insert it.
|
|
110
120
|
if (!!id) {
|
|
111
121
|
onClick(clonedBlock);
|
|
@@ -118,7 +128,7 @@ function MediaPreview({
|
|
|
118
128
|
// If this happens, we insert the image block using the external
|
|
119
129
|
// URL and let the user know about the possible implications.
|
|
120
130
|
window.fetch(url).then(response => response.blob()).then(blob => {
|
|
121
|
-
mediaUpload({
|
|
131
|
+
settings.mediaUpload({
|
|
122
132
|
filesList: [blob],
|
|
123
133
|
additionalData: {
|
|
124
134
|
caption
|
|
@@ -152,7 +162,7 @@ function MediaPreview({
|
|
|
152
162
|
setShowExternalUploadModal(true);
|
|
153
163
|
setIsInserting(false);
|
|
154
164
|
});
|
|
155
|
-
}, [isInserting, onClick,
|
|
165
|
+
}, [isInserting, getSettings, onClick, createSuccessNotice, createErrorNotice]);
|
|
156
166
|
const title = typeof media.title === 'string' ? media.title : media.title?.rendered || (0, _i18n.__)('no title');
|
|
157
167
|
let truncatedTitle;
|
|
158
168
|
if (title.length > MAXIMUM_TITLE_LENGTH) {
|