@wordpress/block-editor 10.5.0 → 11.0.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 +10 -0
- package/build/autocompleters/block.js +2 -6
- package/build/autocompleters/block.js.map +1 -1
- package/build/autocompleters/link.js +2 -0
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/block-card/index.js +51 -3
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +46 -39
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +4 -3
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-edit/edit.native.js +4 -7
- package/build/components/block-edit/edit.native.js.map +1 -1
- package/build/components/block-inspector/index.js +35 -33
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-context.native.js +5 -8
- package/build/components/block-list/block-list-context.native.js.map +1 -1
- package/build/components/block-list/block.js +55 -24
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +61 -28
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +3 -2
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +33 -11
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +9 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +5 -9
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +8 -49
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-variation-picker/index.js +1 -2
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/height-control/index.js +115 -0
- package/build/components/height-control/index.js.map +1 -0
- package/build/components/iframe/index.js +11 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +2 -0
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/zoom-dropdown.js +1 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +20 -6
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +25 -46
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +3 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +27 -0
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build/components/inserter/index.js +8 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +3 -4
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +103 -0
- package/build/components/inserter/media-tab/hooks.js.map +1 -0
- package/build/components/inserter/media-tab/index.js +32 -0
- package/build/components/inserter/media-tab/index.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +100 -0
- package/build/components/inserter/media-tab/media-list.js.map +1 -0
- package/build/components/inserter/media-tab/media-panel.js +96 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build/components/inserter/media-tab/media-tab.js +120 -0
- package/build/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build/components/inserter/media-tab/utils.js +54 -0
- package/build/components/inserter/media-tab/utils.js.map +1 -0
- package/build/components/inserter/menu.js +35 -12
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +70 -0
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build/components/inserter/quick-inserter.js +1 -0
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +3 -1
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +16 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/index.js +71 -0
- package/build/components/inspector-controls-tabs/index.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build/components/inspector-controls-tabs/utils.js +37 -0
- package/build/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build/components/link-control/index.js +1 -0
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +0 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +3 -3
- package/build/components/link-control/use-internal-input-value.js.map +1 -1
- package/build/components/list-view/block.js +5 -2
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +13 -12
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-upload/index.native.js +2 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +104 -0
- package/build/components/off-canvas-editor/appender.js.map +1 -0
- package/build/components/off-canvas-editor/block-edit-button.js +50 -0
- package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +36 -4
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +3 -5
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +20 -11
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf.js +1 -1
- package/build/components/off-canvas-editor/leaf.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +185 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build/components/off-canvas-editor/update-attributes.js +108 -0
- package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +8 -4
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +3 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-insert-replacement-text.js +43 -0
- package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build/components/rich-text/utils.js +1 -19
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/ungroup-button/index.native.js +4 -2
- package/build/components/ungroup-button/index.native.js.map +1 -1
- package/build/components/url-input/index.js +46 -43
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +8 -4
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +9 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/child-layout.js +209 -0
- package/build/hooks/child-layout.js.map +1 -0
- package/build/hooks/content-lock-ui.js +1 -1
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +25 -7
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +57 -1
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/min-height.js +4 -10
- package/build/hooks/min-height.js.map +1 -1
- package/build/store/reducer.js +393 -270
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +57 -47
- package/build/store/selectors.js.map +1 -1
- package/build/utils/sorting.js +63 -0
- package/build/utils/sorting.js.map +1 -0
- package/build-module/autocompleters/block.js +2 -6
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/autocompleters/link.js +2 -0
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/block-card/index.js +45 -3
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +40 -31
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +4 -2
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-edit/edit.native.js +4 -6
- package/build-module/components/block-edit/edit.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +32 -30
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-context.native.js +5 -8
- package/build-module/components/block-list/block-list-context.native.js.map +1 -1
- package/build-module/components/block-list/block.js +55 -25
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +61 -28
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +3 -2
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +35 -13
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +9 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +5 -8
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +6 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +8 -49
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -2
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/height-control/index.js +103 -0
- package/build-module/components/height-control/index.js.map +1 -0
- package/build-module/components/iframe/index.js +11 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/zoom-dropdown.js +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +22 -8
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +27 -49
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -2
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build-module/components/inserter/index.js +8 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +3 -5
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +89 -0
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
- package/build-module/components/inserter/media-tab/index.js +4 -0
- package/build-module/components/inserter/media-tab/index.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +86 -0
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js +77 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-tab.js +100 -0
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build-module/components/inserter/media-tab/utils.js +45 -0
- package/build-module/components/inserter/media-tab/utils.js.map +1 -0
- package/build-module/components/inserter/menu.js +33 -12
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build-module/components/inserter/quick-inserter.js +1 -0
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +3 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +15 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +5 -2
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/index.js +56 -0
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/utils.js +26 -0
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build-module/components/link-control/index.js +1 -0
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +0 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +3 -3
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
- package/build-module/components/list-view/block.js +5 -2
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +12 -11
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +2 -4
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +89 -0
- package/build-module/components/off-canvas-editor/appender.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +36 -6
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +3 -4
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +20 -12
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf.js +1 -1
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +165 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
- package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +6 -2
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -2
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
- package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build-module/components/rich-text/utils.js +1 -16
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/ungroup-button/index.native.js +3 -2
- package/build-module/components/ungroup-button/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +46 -43
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +9 -5
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +8 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/child-layout.js +189 -0
- package/build-module/hooks/child-layout.js.map +1 -0
- package/build-module/hooks/content-lock-ui.js +1 -1
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +25 -8
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +55 -0
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/min-height.js +3 -9
- package/build-module/hooks/min-height.js.map +1 -1
- package/build-module/store/reducer.js +391 -271
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +54 -47
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/sorting.js +56 -0
- package/build-module/utils/sorting.js.map +1 -0
- package/build-style/content-rtl.css +701 -0
- package/build-style/content.css +701 -0
- package/build-style/default-editor-styles-rtl.css +14 -0
- package/build-style/default-editor-styles.css +14 -0
- package/build-style/style-rtl.css +286 -662
- package/build-style/style.css +286 -662
- package/package.json +32 -30
- package/src/autocompleters/block.js +2 -6
- package/src/autocompleters/link.js +2 -0
- package/src/components/alignment-control/test/index.js +4 -1
- package/src/components/block-alignment-control/test/index.js +4 -1
- package/src/components/block-card/index.js +46 -2
- package/src/components/block-card/style.scss +4 -0
- package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
- package/src/components/block-draggable/content.scss +20 -0
- package/src/components/block-draggable/index.native.js +54 -40
- package/src/components/block-draggable/style.scss +0 -21
- package/src/components/block-draggable/test/helpers.native.js +7 -9
- package/src/components/block-draggable/test/index.native.js +35 -45
- package/src/components/block-edit/edit.js +5 -2
- package/src/components/block-edit/edit.native.js +5 -6
- package/src/components/block-inspector/index.js +96 -81
- package/src/components/block-inspector/style.scss +9 -1
- package/src/components/block-list/block-list-context.native.js +5 -8
- package/src/components/block-list/block.js +74 -23
- package/src/components/block-list/block.native.js +78 -23
- package/src/components/block-list/{style.scss → content.scss} +1 -15
- package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
- package/src/components/block-pattern-setup/index.js +2 -1
- package/src/components/block-patterns-list/index.js +47 -24
- package/src/components/block-preview/README.md +15 -10
- package/src/components/block-preview/auto.js +7 -1
- package/src/components/block-preview/content.scss +4 -0
- package/src/components/block-preview/index.js +7 -12
- package/src/components/block-preview/style.scss +0 -7
- package/src/components/block-preview/test/index.js +18 -35
- package/src/components/block-selection-clearer/test/index.js +12 -12
- package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
- package/src/components/block-switcher/test/index.js +4 -0
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/insertion-point.js +3 -47
- package/src/components/block-tools/style.scss +12 -5
- package/src/components/block-variation-picker/index.js +1 -4
- package/src/components/block-vertical-alignment-control/test/index.js +4 -1
- package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/height-control/index.js +123 -0
- package/src/components/height-control/stories/index.js +21 -0
- package/src/components/height-control/style.scss +5 -0
- package/src/components/iframe/index.js +25 -18
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
- package/src/components/inner-blocks/index.js +23 -6
- package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
- package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/src/components/inserter/block-patterns-tab.js +28 -71
- package/src/components/inserter/block-types-tab.js +3 -2
- package/src/components/inserter/hooks/use-debounced-input.js +17 -0
- package/src/components/inserter/index.js +10 -2
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +88 -0
- package/src/components/inserter/media-tab/index.js +3 -0
- package/src/components/inserter/media-tab/media-list.js +93 -0
- package/src/components/inserter/media-tab/media-panel.js +83 -0
- package/src/components/inserter/media-tab/media-tab.js +135 -0
- package/src/components/inserter/media-tab/utils.js +37 -0
- package/src/components/inserter/menu.js +55 -13
- package/src/components/inserter/mobile-tab-navigation.js +85 -0
- package/src/components/inserter/quick-inserter.js +1 -0
- package/src/components/inserter/search-results.js +3 -2
- package/src/components/inserter/stories/index.js +1 -1
- package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
- package/src/components/inserter/style.scss +176 -11
- package/src/components/inserter/tabs.js +12 -1
- package/src/components/inserter-list-item/index.js +11 -1
- package/src/components/inserter-list-item/style.scss +26 -0
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/index.js +62 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
- package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
- package/src/components/inspector-controls-tabs/utils.js +28 -0
- package/src/components/line-height-control/test/index.js +5 -5
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/index.js +1 -0
- package/src/components/link-control/search-input.js +0 -1
- package/src/components/link-control/test/index.js +188 -401
- package/src/components/link-control/use-internal-input-value.js +3 -3
- package/src/components/list-view/block.js +3 -0
- package/src/components/list-view/branch.js +10 -8
- package/src/components/list-view/style.scss +20 -9
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +37 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/appender.js +93 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block.js +88 -22
- package/src/components/off-canvas-editor/branch.js +3 -5
- package/src/components/off-canvas-editor/index.js +59 -33
- package/src/components/off-canvas-editor/leaf.js +5 -1
- package/src/components/off-canvas-editor/link-ui.js +166 -0
- package/src/components/off-canvas-editor/style.scss +17 -388
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/plain-text/{style.scss → content.scss} +0 -0
- package/src/components/recursion-provider/test/index.js +27 -29
- package/src/components/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +2 -2
- package/src/components/rich-text/index.native.js +0 -2
- package/src/components/rich-text/style.scss +0 -43
- package/src/components/rich-text/use-insert-replacement-text.js +31 -0
- package/src/components/rich-text/use-undo-automatic-change.js +7 -1
- package/src/components/rich-text/utils.js +2 -21
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +21 -9
- package/src/components/use-block-display-information/index.js +14 -5
- package/src/components/use-setting/index.js +13 -1
- package/src/components/use-setting/test/index.js +99 -0
- package/src/content.scss +10 -0
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/content-lock-ui.js +1 -1
- package/src/hooks/dimensions.js +45 -7
- package/src/hooks/layout.js +60 -0
- package/src/hooks/min-height.js +2 -19
- package/src/store/reducer.js +459 -423
- package/src/store/selectors.js +56 -57
- package/src/store/test/performance.js +71 -0
- package/src/store/test/reducer.js +623 -491
- package/src/store/test/selectors.js +1820 -1306
- package/src/style.scss +4 -7
- package/src/utils/sorting.js +54 -0
- package/src/utils/test/sorting.js +49 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-preview/live.js +0 -30
- package/build/components/block-preview/live.js.map +0 -1
- package/build-module/components/block-preview/live.js +0 -20
- package/build-module/components/block-preview/live.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","select","block","blockEditorStore","getBlock","blockType","name","providesContext","attributes","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","__unstableLayoutClassNames","layoutClassNames","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","blocksStore","hasBlockSupport","blockDropZoneRef","rootClientId","InnerBlocks","value","onChange","className","children","save","getInnerBlocksProps","DefaultBlockAppender","ButtonBlockAppender","Content"],"mappings":";;;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AASA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,uBAAT,CAAkCC,KAAlC,EAA0C;AACzC,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,0BAHK;AAILC,IAAAA,0BAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,YANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,8BARK;AASLC,IAAAA,6BAA6B,EAAEC,eAT1B;AAULC,IAAAA,6BAVK;AAWLC,IAAAA,cAXK;AAYLC,IAAAA,WAZK;AAaLC,IAAAA,WAbK;AAcLC,IAAAA;AAdK,MAeFf,KAfJ;AAiBA,wCACCC,QADD,EAECC,aAFD,EAGCC,0BAHD,EAICC,0BAJD,EAKCE,YALD,EAMCI,eAND,EAOCG,WAPD,EAQCE,oBARD;AAWA,0CACCd,QADD,EAECI,QAFD,EAGCC,YAHD,EAICE,8BAJD;AAOA,QAAMQ,OAAO,GAAG,qBACbC,MAAF,IAAc;AACb,UAAMC,KAAK,GAAGD,MAAM,CAAEE,YAAF,CAAN,CAA2BC,QAA3B,CAAqCnB,QAArC,CAAd,CADa,CAGb;AACA;;AACA,QAAK,CAAEiB,KAAP,EAAe;AACd;AACA;;AAED,UAAMG,SAAS,GAAG,0BAAcH,KAAK,CAACI,IAApB,CAAlB;;AAEA,QAAK,CAAED,SAAF,IAAe,CAAEA,SAAS,CAACE,eAAhC,EAAkD;AACjD;AACA;;AAED,WAAO,8BAAiBL,KAAK,CAACM,UAAvB,EAAmCH,SAAnC,CAAP;AACA,GAjBc,EAkBf,CAAEpB,QAAF,CAlBe,CAAhB,CApCyC,CAyDzC;A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;AAWNe,IAAAA,QAAQ,EAAElD,QAAQ,GACjB,4BAAC,WAAD,6BAAkB2B,gBAAlB;AAAqC,MAAA,QAAQ,EAAG3B;AAAhD,OADiB,GAGjB,4BAAC,yBAAD,EAAqB6B,OAArB;AAdK,GAAP;AAiBA;;AAEDD,mBAAmB,CAACuB,IAApB,GAA2BC,qCAA3B,C,CAEA;;AACA3B,oBAAoB,CAAC4B,oBAArB,GAA4CA,6BAA5C;AACA5B,oBAAoB,CAAC6B,mBAArB,GAA2CA,4BAA3C;;AAEA7B,oBAAoB,CAAC8B,OAArB,GAA+B,MAAM3B,mBAAmB,CAACuB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;eACezB,oB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockType,\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 getBlockContext from './get-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';\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\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\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst context = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif ( ! blockType || ! blockType.providesContext ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getBlockContext( block.attributes, blockType );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ __experimentalLayout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\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 { __unstableDisableLayoutClassNames, __unstableDisableDropZone } =\n\t\toptions;\n\tconst { clientId, __unstableLayoutClassNames: layoutClassNames = '' } =\n\t\tuseBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = 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} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).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};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\trootClientId: clientId,\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\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","name","select","block","blockEditorStore","getBlock","blockType","providesContext","attributes","allowSizingOnChildren","layout","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","__unstableLayoutClassNames","layoutClassNames","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","blocksStore","hasBlockSupport","blockDropZoneRef","rootClientId","InnerBlocks","value","onChange","className","children","save","getInnerBlocksProps","DefaultBlockAppender","ButtonBlockAppender","Content"],"mappings":";;;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AAUA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,uBAAT,CAAkCC,KAAlC,EAA0C;AACzC,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,0BAHK;AAILC,IAAAA,0BAJK;AAKLC,IAAAA,QALK;AAMLC,IAAAA,YANK;AAOLC,IAAAA,UAPK;AAQLC,IAAAA,8BARK;AASLC,IAAAA,6BAA6B,EAAEC,eAT1B;AAULC,IAAAA,6BAVK;AAWLC,IAAAA,cAXK;AAYLC,IAAAA,WAZK;AAaLC,IAAAA,WAbK;AAcLC,IAAAA;AAdK,MAeFf,KAfJ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D,mBAAmB,CAACuB,IAApB,GAA2BC,qCAA3B,C,CAEA;;AACA3B,oBAAoB,CAAC4B,oBAArB,GAA4CA,6BAA5C;AACA5B,oBAAoB,CAAC6B,mBAArB,GAA2CA,4BAA3C;;AAEA7B,oBAAoB,CAAC8B,OAArB,GAA+B,MAAM3B,mBAAmB,CAACuB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;eACezB,oB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\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 getBlockContext from './get-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';\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\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\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst { context, name } = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif ( ! blockType || ! blockType.providesContext ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcontext: getBlockContext( block.attributes, blockType ),\n\t\t\t\tname: block.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { allowSizingOnChildren = false } =\n\t\tgetBlockSupport( name, '__experimentalLayout' ) || {};\n\n\tconst layout = useMemo(\n\t\t() => ( {\n\t\t\t...__experimentalLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ __experimentalLayout, allowSizingOnChildren ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ layout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\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 { __unstableDisableLayoutClassNames, __unstableDisableDropZone } =\n\t\toptions;\n\tconst { clientId, __unstableLayoutClassNames: layoutClassNames = '' } =\n\t\tuseBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = 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} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).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};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\trootClientId: clientId,\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\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"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.default = useInnerBlockTemplateSync;
|
|
7
9
|
|
|
8
|
-
var
|
|
10
|
+
var _es = _interopRequireDefault(require("fast-deep-equal/es6"));
|
|
9
11
|
|
|
10
12
|
var _element = require("@wordpress/element");
|
|
11
13
|
|
|
@@ -48,29 +50,37 @@ var _store = require("../../store");
|
|
|
48
50
|
*/
|
|
49
51
|
function useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection) {
|
|
50
52
|
const {
|
|
53
|
+
getBlocks,
|
|
51
54
|
getSelectedBlocksInitialCaretPosition,
|
|
52
55
|
isBlockSelected
|
|
53
56
|
} = (0, _data.useSelect)(_store.store);
|
|
54
57
|
const {
|
|
55
|
-
replaceInnerBlocks
|
|
58
|
+
replaceInnerBlocks,
|
|
59
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
56
60
|
} = (0, _data.useDispatch)(_store.store);
|
|
57
|
-
const innerBlocks = (0, _data.useSelect)(select => select(_store.store).getBlocks(clientId), [clientId]);
|
|
58
61
|
const {
|
|
59
|
-
|
|
60
|
-
} = (0, _data.useSelect)(
|
|
62
|
+
innerBlocks
|
|
63
|
+
} = (0, _data.useSelect)(select => ({
|
|
64
|
+
innerBlocks: select(_store.store).getBlocks(clientId)
|
|
65
|
+
}), [clientId]); // Maintain a reference to the previous value so we can do a deep equality check.
|
|
61
66
|
|
|
62
67
|
const existingTemplate = (0, _element.useRef)(null);
|
|
63
68
|
(0, _element.useLayoutEffect)(() => {
|
|
64
|
-
// There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate
|
|
69
|
+
let isCancelled = false; // There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate
|
|
65
70
|
// The former needs to happen after the latter and since the latter is using microtasks to batch updates (performance optimization),
|
|
66
71
|
// we need to schedule this one in a microtask as well.
|
|
67
|
-
//
|
|
72
|
+
// Example: If you remove queueMicrotask here, ctrl + click to insert quote block won't close the inserter.
|
|
73
|
+
|
|
68
74
|
window.queueMicrotask(() => {
|
|
69
|
-
|
|
75
|
+
if (isCancelled) {
|
|
76
|
+
return;
|
|
77
|
+
} // Only synchronize innerBlocks with template if innerBlocks are empty
|
|
70
78
|
// or a locking "all" or "contentOnly" exists directly on the block.
|
|
79
|
+
|
|
80
|
+
|
|
71
81
|
const currentInnerBlocks = getBlocks(clientId);
|
|
72
82
|
const shouldApplyTemplate = currentInnerBlocks.length === 0 || templateLock === 'all' || templateLock === 'contentOnly';
|
|
73
|
-
const hasTemplateChanged = !(0,
|
|
83
|
+
const hasTemplateChanged = !(0, _es.default)(template, existingTemplate.current);
|
|
74
84
|
|
|
75
85
|
if (!shouldApplyTemplate || !hasTemplateChanged) {
|
|
76
86
|
return;
|
|
@@ -79,7 +89,9 @@ function useInnerBlockTemplateSync(clientId, template, templateLock, templateIns
|
|
|
79
89
|
existingTemplate.current = template;
|
|
80
90
|
const nextBlocks = (0, _blocks.synchronizeBlocksWithTemplate)(currentInnerBlocks, template);
|
|
81
91
|
|
|
82
|
-
if (!(0,
|
|
92
|
+
if (!(0, _es.default)(nextBlocks, currentInnerBlocks)) {
|
|
93
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
94
|
+
|
|
83
95
|
replaceInnerBlocks(clientId, nextBlocks, currentInnerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0 && isBlockSelected(clientId), // This ensures the "initialPosition" doesn't change when applying the template
|
|
84
96
|
// If we're supposed to focus the block, we'll focus the first inner block
|
|
85
97
|
// otherwise, we won't apply any auto-focus.
|
|
@@ -87,6 +99,9 @@ function useInnerBlockTemplateSync(clientId, template, templateLock, templateIns
|
|
|
87
99
|
getSelectedBlocksInitialCaretPosition());
|
|
88
100
|
}
|
|
89
101
|
});
|
|
102
|
+
return () => {
|
|
103
|
+
isCancelled = true;
|
|
104
|
+
};
|
|
90
105
|
}, [innerBlocks, template, templateLock, clientId]);
|
|
91
106
|
}
|
|
92
107
|
//# sourceMappingURL=use-inner-block-template-sync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js"],"names":["useInnerBlockTemplateSync","clientId","template","templateLock","templateInsertUpdatesSelection","getSelectedBlocksInitialCaretPosition","isBlockSelected","blockEditorStore","replaceInnerBlocks","innerBlocks","select","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js"],"names":["useInnerBlockTemplateSync","clientId","template","templateLock","templateInsertUpdatesSelection","getBlocks","getSelectedBlocksInitialCaretPosition","isBlockSelected","blockEditorStore","replaceInnerBlocks","__unstableMarkNextChangeAsNotPersistent","innerBlocks","select","existingTemplate","isCancelled","window","queueMicrotask","currentInnerBlocks","shouldApplyTemplate","length","hasTemplateChanged","current","nextBlocks"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,yBAAT,CACdC,QADc,EAEdC,QAFc,EAGdC,YAHc,EAIdC,8BAJc,EAKb;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,qCAFK;AAGLC,IAAAA;AAHK,M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B,CAFvB,IAGCZ,eAAe,CAAEN,QAAF,CANC,EAOjB;AACA;AACA;AACA;AACAK,QAAAA,qCAAqC,EAXpB,CAAlB;AAaA;AACD,KA5CD;AA8CA,WAAO,MAAM;AACZQ,MAAAA,WAAW,GAAG,IAAd;AACA,KAFD;AAGA,GAxDD,EAwDG,CAAEH,WAAF,EAAeT,QAAf,EAAyBC,YAAzB,EAAuCF,QAAvC,CAxDH;AAyDA","sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { synchronizeBlocksWithTemplate } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * This hook makes sure that a block's inner blocks stay in sync with the given\n * block \"template\". The template is a block hierarchy to which inner blocks must\n * conform. If the blocks get \"out of sync\" with the template and the template\n * is meant to be locked (e.g. templateLock = \"all\" or templateLock = \"contentOnly\"),\n * then we replace the inner blocks with the correct value after synchronizing it with the template.\n *\n * @param {string} clientId The block client ID.\n * @param {Object} template The template to match.\n * @param {string} templateLock The template lock state for the inner blocks. For\n * example, if the template lock is set to \"all\",\n * then the inner blocks will stay in sync with the\n * template. If not defined or set to false, then\n * the inner blocks will not be synchronized with\n * the given template.\n * @param {boolean} templateInsertUpdatesSelection Whether or not to update the\n * block-editor selection state when inner blocks\n * are replaced after template synchronization.\n */\nexport default function useInnerBlockTemplateSync(\n\tclientId,\n\ttemplate,\n\ttemplateLock,\n\ttemplateInsertUpdatesSelection\n) {\n\tconst {\n\t\tgetBlocks,\n\t\tgetSelectedBlocksInitialCaretPosition,\n\t\tisBlockSelected,\n\t} = useSelect( blockEditorStore );\n\tconst { replaceInnerBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { innerBlocks } = useSelect(\n\t\t( select ) => ( {\n\t\t\tinnerBlocks: select( blockEditorStore ).getBlocks( clientId ),\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\n\t// Maintain a reference to the previous value so we can do a deep equality check.\n\tconst existingTemplate = useRef( null );\n\n\tuseLayoutEffect( () => {\n\t\tlet isCancelled = false;\n\n\t\t// There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate\n\t\t// The former needs to happen after the latter and since the latter is using microtasks to batch updates (performance optimization),\n\t\t// we need to schedule this one in a microtask as well.\n\t\t// Example: If you remove queueMicrotask here, ctrl + click to insert quote block won't close the inserter.\n\t\twindow.queueMicrotask( () => {\n\t\t\tif ( isCancelled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Only synchronize innerBlocks with template if innerBlocks are empty\n\t\t\t// or a locking \"all\" or \"contentOnly\" exists directly on the block.\n\t\t\tconst currentInnerBlocks = getBlocks( clientId );\n\t\t\tconst shouldApplyTemplate =\n\t\t\t\tcurrentInnerBlocks.length === 0 ||\n\t\t\t\ttemplateLock === 'all' ||\n\t\t\t\ttemplateLock === 'contentOnly';\n\n\t\t\tconst hasTemplateChanged = ! fastDeepEqual(\n\t\t\t\ttemplate,\n\t\t\t\texistingTemplate.current\n\t\t\t);\n\n\t\t\tif ( ! shouldApplyTemplate || ! hasTemplateChanged ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\texistingTemplate.current = template;\n\t\t\tconst nextBlocks = synchronizeBlocksWithTemplate(\n\t\t\t\tcurrentInnerBlocks,\n\t\t\t\ttemplate\n\t\t\t);\n\n\t\t\tif ( ! fastDeepEqual( nextBlocks, currentInnerBlocks ) ) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\tclientId,\n\t\t\t\t\tnextBlocks,\n\t\t\t\t\tcurrentInnerBlocks.length === 0 &&\n\t\t\t\t\t\ttemplateInsertUpdatesSelection &&\n\t\t\t\t\t\tnextBlocks.length !== 0 &&\n\t\t\t\t\t\tisBlockSelected( clientId ),\n\t\t\t\t\t// This ensures the \"initialPosition\" doesn't change when applying the template\n\t\t\t\t\t// If we're supposed to focus the block, we'll focus the first inner block\n\t\t\t\t\t// otherwise, we won't apply any auto-focus.\n\t\t\t\t\t// This ensures for instance that the focus stays in the inserter when inserting the \"buttons\" block.\n\t\t\t\t\tgetSelectedBlocksInitialCaretPosition()\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tisCancelled = true;\n\t\t};\n\t}, [ innerBlocks, template, templateLock, clientId ] );\n}\n"]}
|
|
@@ -49,6 +49,7 @@ function PatternsExplorerSearch(_ref3) {
|
|
|
49
49
|
return (0, _element.createElement)("div", {
|
|
50
50
|
className: baseClassName
|
|
51
51
|
}, (0, _element.createElement)(_components.SearchControl, {
|
|
52
|
+
__nextHasNoMarginBottom: true,
|
|
52
53
|
onChange: setFilterValue,
|
|
53
54
|
value: filterValue,
|
|
54
55
|
label: (0, _i18n.__)('Search for patterns'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/sidebar.js"],"names":["PatternCategoriesList","selectedCategory","patternCategories","onClickCategory","baseClassName","map","name","label","PatternsExplorerSearch","filterValue","setFilterValue","PatternExplorerSidebar"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,SAASA,qBAAT,OAII;AAAA,MAJ4B;AAC/BC,IAAAA,gBAD+B;AAE/BC,IAAAA,iBAF+B;AAG/BC,IAAAA;AAH+B,GAI5B;AACH,QAAMC,aAAa,GAAG,+CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAI,GAAGA,aAAe;AAApC,KACGF,iBAAiB,CAACG,GAAlB,CAAuB,SAAuB;AAAA,QAArB;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAAqB;AAC/C,WACC,4BAAC,kBAAD;AACC,MAAA,GAAG,EAAGD,IADP;AAEC,MAAA,KAAK,EAAGC,KAFT;AAGC,MAAA,SAAS,EAAI,GAAGH,aAAe,yBAHhC;AAIC,MAAA,SAAS,EAAGH,gBAAgB,KAAKK,IAJlC;AAKC,MAAA,OAAO,EAAG,MAAM;AACfH,QAAAA,eAAe,CAAEG,IAAF,CAAf;AACA;AAPF,OASGC,KATH,CADD;AAaA,GAdC,CADH,CADD;AAmBA;;AAED,SAASC,sBAAT,QAAmE;AAAA,MAAlC;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,GAAkC;AAClE,QAAMN,aAAa,GAAG,8CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAGA;AAAjB,KACC,4BAAC,yBAAD;AACC,IAAA,QAAQ,EAAGM,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/sidebar.js"],"names":["PatternCategoriesList","selectedCategory","patternCategories","onClickCategory","baseClassName","map","name","label","PatternsExplorerSearch","filterValue","setFilterValue","PatternExplorerSidebar"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,SAASA,qBAAT,OAII;AAAA,MAJ4B;AAC/BC,IAAAA,gBAD+B;AAE/BC,IAAAA,iBAF+B;AAG/BC,IAAAA;AAH+B,GAI5B;AACH,QAAMC,aAAa,GAAG,+CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAI,GAAGA,aAAe;AAApC,KACGF,iBAAiB,CAACG,GAAlB,CAAuB,SAAuB;AAAA,QAArB;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAAqB;AAC/C,WACC,4BAAC,kBAAD;AACC,MAAA,GAAG,EAAGD,IADP;AAEC,MAAA,KAAK,EAAGC,KAFT;AAGC,MAAA,SAAS,EAAI,GAAGH,aAAe,yBAHhC;AAIC,MAAA,SAAS,EAAGH,gBAAgB,KAAKK,IAJlC;AAKC,MAAA,OAAO,EAAG,MAAM;AACfH,QAAAA,eAAe,CAAEG,IAAF,CAAf;AACA;AAPF,OASGC,KATH,CADD;AAaA,GAdC,CADH,CADD;AAmBA;;AAED,SAASC,sBAAT,QAAmE;AAAA,MAAlC;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,GAAkC;AAClE,QAAMN,aAAa,GAAG,8CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAGA;AAAjB,KACC,4BAAC,yBAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,QAAQ,EAAGM,cAFZ;AAGC,IAAA,KAAK,EAAGD,WAHT;AAIC,IAAA,KAAK,EAAG,cAAI,qBAAJ,CAJT;AAKC,IAAA,WAAW,EAAG,cAAI,QAAJ;AALf,IADD,CADD;AAWA;;AAED,SAASE,sBAAT,QAMI;AAAA,MAN6B;AAChCV,IAAAA,gBADgC;AAEhCC,IAAAA,iBAFgC;AAGhCC,IAAAA,eAHgC;AAIhCM,IAAAA,WAJgC;AAKhCC,IAAAA;AALgC,GAM7B;AACH,QAAMN,aAAa,GAAG,+CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAGA;AAAjB,KACC,4BAAC,sBAAD;AACC,IAAA,WAAW,EAAGK,WADf;AAEC,IAAA,cAAc,EAAGC;AAFlB,IADD,EAKG,CAAED,WAAF,IACD,4BAAC,qBAAD;AACC,IAAA,gBAAgB,EAAGR,gBADpB;AAEC,IAAA,iBAAiB,EAAGC,iBAFrB;AAGC,IAAA,eAAe,EAAGC;AAHnB,IANF,CADD;AAeA;;eAEcQ,sB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, SearchControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nfunction PatternCategoriesList( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ `${ baseClassName }__categories-list` }>\n\t\t\t{ patternCategories.map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tclassName={ `${ baseClassName }__categories-list__item` }\n\t\t\t\t\t\tisPressed={ selectedCategory === name }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonClickCategory( name );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerSearch( { filterValue, setFilterValue } ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__search';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tonChange={ setFilterValue }\n\t\t\t\tvalue={ filterValue }\n\t\t\t\tlabel={ __( 'Search for patterns' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternExplorerSidebar( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\tfilterValue,\n\tsetFilterValue,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<PatternsExplorerSearch\n\t\t\t\tfilterValue={ filterValue }\n\t\t\t\tsetFilterValue={ setFilterValue }\n\t\t\t/>\n\t\t\t{ ! filterValue && (\n\t\t\t\t<PatternCategoriesList\n\t\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default PatternExplorerSidebar;\n"]}
|
|
@@ -27,6 +27,8 @@ var _blockPatternsList = _interopRequireDefault(require("../block-patterns-list"
|
|
|
27
27
|
|
|
28
28
|
var _explorer = _interopRequireDefault(require("./block-patterns-explorer/explorer"));
|
|
29
29
|
|
|
30
|
+
var _mobileTabNavigation = _interopRequireDefault(require("./mobile-tab-navigation"));
|
|
31
|
+
|
|
30
32
|
/**
|
|
31
33
|
* WordPress dependencies
|
|
32
34
|
*/
|
|
@@ -57,11 +59,12 @@ function usePatternsCategories() {
|
|
|
57
59
|
name: nextName
|
|
58
60
|
} = _ref2;
|
|
59
61
|
|
|
60
|
-
if (![currentName, nextName].
|
|
62
|
+
if (![currentName, nextName].some(categoryName => ['featured', 'text'].includes(categoryName))) {
|
|
61
63
|
return 0;
|
|
62
|
-
}
|
|
64
|
+
} // Move `featured` category to the top and `text` to the bottom.
|
|
65
|
+
|
|
63
66
|
|
|
64
|
-
return currentName === 'featured' ? -1 : 1;
|
|
67
|
+
return currentName === 'featured' || nextName === 'text' ? -1 : 1;
|
|
65
68
|
});
|
|
66
69
|
|
|
67
70
|
if (allPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
|
|
@@ -80,7 +83,8 @@ function BlockPatternsCategoryDialog(_ref3) {
|
|
|
80
83
|
let {
|
|
81
84
|
rootClientId,
|
|
82
85
|
onInsert,
|
|
83
|
-
category
|
|
86
|
+
category,
|
|
87
|
+
showTitlesAsTooltip
|
|
84
88
|
} = _ref3;
|
|
85
89
|
const container = (0, _element.useRef)();
|
|
86
90
|
(0, _element.useEffect)(() => {
|
|
@@ -93,11 +97,12 @@ function BlockPatternsCategoryDialog(_ref3) {
|
|
|
93
97
|
}, [category]);
|
|
94
98
|
return (0, _element.createElement)("div", {
|
|
95
99
|
ref: container,
|
|
96
|
-
className: "block-editor-inserter__patterns-category-
|
|
100
|
+
className: "block-editor-inserter__patterns-category-dialog"
|
|
97
101
|
}, (0, _element.createElement)(BlockPatternsCategoryPanel, {
|
|
98
102
|
rootClientId: rootClientId,
|
|
99
103
|
onInsert: onInsert,
|
|
100
|
-
category: category
|
|
104
|
+
category: category,
|
|
105
|
+
showTitlesAsTooltip: showTitlesAsTooltip
|
|
101
106
|
}));
|
|
102
107
|
}
|
|
103
108
|
|
|
@@ -105,7 +110,8 @@ function BlockPatternsCategoryPanel(_ref4) {
|
|
|
105
110
|
let {
|
|
106
111
|
rootClientId,
|
|
107
112
|
onInsert,
|
|
108
|
-
category
|
|
113
|
+
category,
|
|
114
|
+
showTitlesAsTooltip
|
|
109
115
|
} = _ref4;
|
|
110
116
|
const [allPatterns,, onClick] = (0, _usePatternsState.default)(onInsert, rootClientId);
|
|
111
117
|
const availableCategories = usePatternsCategories();
|
|
@@ -129,7 +135,9 @@ function BlockPatternsCategoryPanel(_ref4) {
|
|
|
129
135
|
return null;
|
|
130
136
|
}
|
|
131
137
|
|
|
132
|
-
return (0, _element.createElement)("div",
|
|
138
|
+
return (0, _element.createElement)("div", {
|
|
139
|
+
className: "block-editor-inserter__patterns-category-panel"
|
|
140
|
+
}, (0, _element.createElement)("div", {
|
|
133
141
|
className: "block-editor-inserter__patterns-category-panel-title"
|
|
134
142
|
}, category.label), (0, _element.createElement)("p", null, category.description), (0, _element.createElement)(_blockPatternsList.default, {
|
|
135
143
|
shownPatterns: currentShownPatterns,
|
|
@@ -138,7 +146,8 @@ function BlockPatternsCategoryPanel(_ref4) {
|
|
|
138
146
|
label: category.label,
|
|
139
147
|
orientation: "vertical",
|
|
140
148
|
category: category.label,
|
|
141
|
-
isDraggable: true
|
|
149
|
+
isDraggable: true,
|
|
150
|
+
showTitlesAsTooltip: showTitlesAsTooltip
|
|
142
151
|
}));
|
|
143
152
|
}
|
|
144
153
|
|
|
@@ -169,55 +178,25 @@ function BlockPatternsTabs(_ref5) {
|
|
|
169
178
|
}, (0, _element.createElement)(_components.__experimentalHStack, null, (0, _element.createElement)(_components.FlexBlock, null, category.label), (0, _element.createElement)(_icons.Icon, {
|
|
170
179
|
icon: _icons.chevronRight
|
|
171
180
|
})))), (0, _element.createElement)("div", {
|
|
172
|
-
role: "presentation",
|
|
173
|
-
className: "block-editor-inserter__patterns-fill-space"
|
|
174
|
-
}), (0, _element.createElement)("div", {
|
|
175
181
|
role: "listitem"
|
|
176
182
|
}, (0, _element.createElement)(_components.Button, {
|
|
177
183
|
className: "block-editor-inserter__patterns-explore-button",
|
|
178
184
|
onClick: () => setShowPatternsExplorer(true),
|
|
179
185
|
variant: "secondary"
|
|
180
|
-
}, (0, _i18n.__)('Explore all patterns')))))), isMobile && (0, _element.createElement)(
|
|
186
|
+
}, (0, _i18n.__)('Explore all patterns')))))), isMobile && (0, _element.createElement)(_mobileTabNavigation.default, {
|
|
187
|
+
categories: categories
|
|
188
|
+
}, category => (0, _element.createElement)(BlockPatternsCategoryPanel, {
|
|
181
189
|
onInsert: onInsert,
|
|
182
|
-
rootClientId: rootClientId
|
|
183
|
-
|
|
190
|
+
rootClientId: rootClientId,
|
|
191
|
+
category: category,
|
|
192
|
+
showTitlesAsTooltip: false
|
|
193
|
+
})), showPatternsExplorer && (0, _element.createElement)(_explorer.default, {
|
|
184
194
|
initialCategory: selectedCategory,
|
|
185
195
|
patternCategories: categories,
|
|
186
196
|
onModalClose: () => setShowPatternsExplorer(false)
|
|
187
197
|
}));
|
|
188
198
|
}
|
|
189
199
|
|
|
190
|
-
function BlockPatternsTabNavigation(_ref6) {
|
|
191
|
-
let {
|
|
192
|
-
onInsert,
|
|
193
|
-
rootClientId
|
|
194
|
-
} = _ref6;
|
|
195
|
-
const categories = usePatternsCategories();
|
|
196
|
-
return (0, _element.createElement)(_components.__experimentalNavigatorProvider, {
|
|
197
|
-
initialPath: "/"
|
|
198
|
-
}, (0, _element.createElement)(_components.__experimentalNavigatorScreen, {
|
|
199
|
-
path: "/"
|
|
200
|
-
}, (0, _element.createElement)(_components.__experimentalItemGroup, null, categories.map(category => (0, _element.createElement)(_components.__experimentalNavigatorButton, {
|
|
201
|
-
key: category.name,
|
|
202
|
-
path: `/category/${category.name}`,
|
|
203
|
-
as: _components.__experimentalItem,
|
|
204
|
-
isAction: true
|
|
205
|
-
}, (0, _element.createElement)(_components.__experimentalHStack, null, (0, _element.createElement)(_components.FlexBlock, null, category.label), (0, _element.createElement)(_icons.Icon, {
|
|
206
|
-
icon: (0, _i18n.isRTL)() ? _icons.chevronLeft : _icons.chevronRight
|
|
207
|
-
})))))), categories.map(category => (0, _element.createElement)(_components.__experimentalNavigatorScreen, {
|
|
208
|
-
key: category.name,
|
|
209
|
-
path: `/category/${category.name}`
|
|
210
|
-
}, (0, _element.createElement)(_components.__experimentalNavigatorBackButton, {
|
|
211
|
-
icon: (0, _i18n.isRTL)() ? _icons.chevronRight : _icons.chevronLeft,
|
|
212
|
-
isSmall: true,
|
|
213
|
-
"aria-label": (0, _i18n.__)('Navigate to the categories list')
|
|
214
|
-
}, (0, _i18n.__)('Back')), (0, _element.createElement)(BlockPatternsCategoryPanel, {
|
|
215
|
-
category: category,
|
|
216
|
-
rootClientId: rootClientId,
|
|
217
|
-
onInsert: onInsert
|
|
218
|
-
}))));
|
|
219
|
-
}
|
|
220
|
-
|
|
221
200
|
var _default = BlockPatternsTabs;
|
|
222
201
|
exports.default = _default;
|
|
223
202
|
//# sourceMappingURL=block-patterns-tab.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["usePatternsCategories","allPatterns","allCategories","hasRegisteredCategory","pattern","categories","length","some","cat","category","name","populatedCategories","filter","includes","sort","currentName","nextName","find","push","label","BlockPatternsCategoryDialog","rootClientId","onInsert","container","timeout","setTimeout","firstTabbable","focus","tabbable","current","clearTimeout","BlockPatternsCategoryPanel","onClick","availableCategories","currentCategoryPatterns","availablePatternCategories","availableCategory","currentShownPatterns","description","BlockPatternsTabs","onSelectCategory","selectedCategory","showPatternsExplorer","setShowPatternsExplorer","isMobile","map","undefined","chevronRight","BlockPatternsTabNavigation","Item","chevronLeft"],"mappings":";;;;;;;;;;;AAGA;;AAOA;;AACA;;AACA;;AAWA;;AACA;;AAKA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAwBA;AACA;AACA;AAKA,SAASA,qBAAT,GAAiC;AAChC,QAAM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AY,EAAGY,YAFhB;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IAXD,CADC,CAvBH,CADD;AA6CA;;eAEciB,iB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { _x, __, isRTL } from '@wordpress/i18n';\nimport { useAsyncList, useViewportMatch } from '@wordpress/compose';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\t__experimentalNavigatorProvider as NavigatorProvider,\n\t__experimentalNavigatorScreen as NavigatorScreen,\n\t__experimentalNavigatorButton as NavigatorButton,\n\t__experimentalNavigatorBackButton as NavigatorBackButton,\n\tFlexBlock,\n\tButton,\n} from '@wordpress/components';\nimport { Icon, chevronRight, chevronLeft } from '@wordpress/icons';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from './hooks/use-patterns-state';\nimport BlockPatternList from '../block-patterns-list';\nimport PatternsExplorerModal from './block-patterns-explorer/explorer';\n\nfunction usePatternsCategories() {\n\tconst [ allPatterns, allCategories ] = usePatternsState();\n\n\tconst hasRegisteredCategory = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn pattern.categories.some( ( cat ) =>\n\t\t\t\tallCategories.some( ( category ) => category.name === cat )\n\t\t\t);\n\t\t},\n\t\t[ allCategories ]\n\t);\n\n\t// Remove any empty categories.\n\tconst populatedCategories = useMemo( () => {\n\t\tconst categories = allCategories\n\t\t\t.filter( ( category ) =>\n\t\t\t\tallPatterns.some( ( pattern ) =>\n\t\t\t\t\tpattern.categories?.includes( category.name )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.sort( ( { name: currentName }, { name: nextName } ) => {\n\t\t\t\tif ( ! [ currentName, nextName ].includes( 'featured' ) ) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn currentName === 'featured' ? -1 : 1;\n\t\t\t} );\n\n\t\tif (\n\t\t\tallPatterns.some(\n\t\t\t\t( pattern ) => ! hasRegisteredCategory( pattern )\n\t\t\t) &&\n\t\t\t! categories.find(\n\t\t\t\t( category ) => category.name === 'uncategorized'\n\t\t\t)\n\t\t) {\n\t\t\tcategories.push( {\n\t\t\t\tname: 'uncategorized',\n\t\t\t\tlabel: _x( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\n\t\treturn categories;\n\t}, [ allPatterns, allCategories ] );\n\n\treturn populatedCategories;\n}\n\nexport function BlockPatternsCategoryDialog( {\n\trootClientId,\n\tonInsert,\n\tcategory,\n} ) {\n\tconst container = useRef();\n\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tconst [ firstTabbable ] = focus.tabbable.find( container.current );\n\t\t\tfirstTabbable?.focus();\n\t\t} );\n\t\treturn () => clearTimeout( timeout );\n\t}, [ category ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ container }\n\t\t\tclassName=\"block-editor-inserter__patterns-category-panel\"\n\t\t>\n\t\t\t<BlockPatternsCategoryPanel\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t\tcategory={ category }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport function BlockPatternsCategoryPanel( {\n\trootClientId,\n\tonInsert,\n\tcategory,\n} ) {\n\tconst [ allPatterns, , onClick ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\n\tconst availableCategories = usePatternsCategories();\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) => {\n\t\t\t\tif ( category.name !== 'uncategorized' ) {\n\t\t\t\t\treturn pattern.categories?.includes( category.name );\n\t\t\t\t}\n\n\t\t\t\t// The uncategorized category should show all the patterns without any category\n\t\t\t\t// or with no available category.\n\t\t\t\tconst availablePatternCategories =\n\t\t\t\t\tpattern.categories?.filter( ( cat ) =>\n\t\t\t\t\t\tavailableCategories.find(\n\t\t\t\t\t\t\t( availableCategory ) =>\n\t\t\t\t\t\t\t\tavailableCategory.name === cat\n\t\t\t\t\t\t)\n\t\t\t\t\t) ?? [];\n\n\t\t\t\treturn availablePatternCategories.length === 0;\n\t\t\t} ),\n\t\t[ allPatterns, category ]\n\t);\n\n\tconst currentShownPatterns = useAsyncList( currentCategoryPatterns );\n\n\tif ( ! currentCategoryPatterns.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div>\n\t\t\t<div className=\"block-editor-inserter__patterns-category-panel-title\">\n\t\t\t\t{ category.label }\n\t\t\t</div>\n\t\t\t<p>{ category.description }</p>\n\t\t\t<BlockPatternList\n\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\tblockPatterns={ currentCategoryPatterns }\n\t\t\t\tonClickPattern={ onClick }\n\t\t\t\tlabel={ category.label }\n\t\t\t\torientation=\"vertical\"\n\t\t\t\tcategory={ category.label }\n\t\t\t\tisDraggable\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction BlockPatternsTabs( {\n\tonSelectCategory,\n\tselectedCategory,\n\tonInsert,\n\trootClientId,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\tconst categories = usePatternsCategories();\n\tconst isMobile = useViewportMatch( 'medium', '<' );\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<nav aria-label={ __( 'Block pattern categories' ) }>\n\t\t\t\t\t\t<ItemGroup\n\t\t\t\t\t\t\trole=\"list\"\n\t\t\t\t\t\t\tclassName=\"block-editor-inserter__block-patterns-tabs\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t\t\t\t<Item\n\t\t\t\t\t\t\t\t\trole=\"listitem\"\n\t\t\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tonSelectCategory( category )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category'\n\t\t\t\t\t\t\t\t\t\t\t: 'block-editor-inserter__patterns-category'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-label={ category.label }\n\t\t\t\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ chevronRight } />\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) ) }\n\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\trole=\"presentation\"\n\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-fill-space\"\n\t\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t\t<div role=\"listitem\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explore-button\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowPatternsExplorer( true )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Explore all patterns' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t</nav>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isMobile && (\n\t\t\t\t<BlockPatternsTabNavigation\n\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showPatternsExplorer && (\n\t\t\t\t<PatternsExplorerModal\n\t\t\t\t\tinitialCategory={ selectedCategory }\n\t\t\t\t\tpatternCategories={ categories }\n\t\t\t\t\tonModalClose={ () => setShowPatternsExplorer( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction BlockPatternsTabNavigation( { onInsert, rootClientId } ) {\n\tconst categories = usePatternsCategories();\n\n\treturn (\n\t\t<NavigatorProvider initialPath=\"/\">\n\t\t\t<NavigatorScreen path=\"/\">\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t\t<NavigatorButton\n\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\tpath={ `/category/${ category.name }` }\n\t\t\t\t\t\t\tas={ Item }\n\t\t\t\t\t\t\tisAction\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t\t<FlexBlock>{ category.label }</FlexBlock>\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\tisRTL() ? chevronLeft : chevronRight\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t</NavigatorButton>\n\t\t\t\t\t) ) }\n\t\t\t\t</ItemGroup>\n\t\t\t</NavigatorScreen>\n\n\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t<NavigatorScreen\n\t\t\t\t\tkey={ category.name }\n\t\t\t\t\tpath={ `/category/${ category.name }` }\n\t\t\t\t>\n\t\t\t\t\t<NavigatorBackButton\n\t\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\t\tisSmall\n\t\t\t\t\t\taria-label={ __( 'Navigate to the categories list' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</NavigatorBackButton>\n\t\t\t\t\t<BlockPatternsCategoryPanel\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t/>\n\t\t\t\t</NavigatorScreen>\n\t\t\t) ) }\n\t\t</NavigatorProvider>\n\t);\n}\n\nexport default BlockPatternsTabs;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["usePatternsCategories","allPatterns","allCategories","hasRegisteredCategory","pattern","categories","length","some","cat","category","name","populatedCategories","filter","includes","sort","currentName","nextName","categoryName","find","push","label","BlockPatternsCategoryDialog","rootClientId","onInsert","showTitlesAsTooltip","container","timeout","setTimeout","firstTabbable","focus","tabbable","current","clearTimeout","BlockPatternsCategoryPanel","onClick","availableCategories","currentCategoryPatterns","availablePatternCategories","availableCategory","currentShownPatterns","description","BlockPatternsTabs","onSelectCategory","selectedCategory","showPatternsExplorer","setShowPatternsExplorer","isMobile","map","undefined","chevronRight"],"mappings":";;;;;;;;;;;AAGA;;AAOA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA5BA;AACA;AACA;;AAoBA;AACA;AACA;AAMA,SAASA,qBAAT,GAAiC;AAChC,QAAM,CAAEC,WAAF,EAAeC,aAAf,IAAiC,gCAAvC;AAEA,QAAMC,qBAAqB,GAAG,0BAC3BC,OAAF,IAAe;AACd,QAAK,CAAEA,OAAO,CAACC,UAAV,IAAwB,CAAED,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QAAF,IACD,4BAAC,0BAAD;AACC,IAAA,QAAQ,EAAGc,QADZ;AAEC,IAAA,YAAY,EAAGD,YAFhB;AAGC,IAAA,QAAQ,EAAGb,QAHZ;AAIC,IAAA,mBAAmB,EAAG;AAJvB,IAFF,CAnDF,EA8DGmC,oBAAoB,IACrB,4BAAC,iBAAD;AACC,IAAA,eAAe,EAAGD,gBADnB;AAEC,IAAA,iBAAiB,EAAGtC,UAFrB;AAGC,IAAA,YAAY,EAAG,MAAMwC,uBAAuB,CAAE,KAAF;AAH7C,IA/DF,CADD;AAwEA;;eAEcJ,iB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { _x, __ } from '@wordpress/i18n';\nimport { useAsyncList, useViewportMatch } from '@wordpress/compose';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\tFlexBlock,\n\tButton,\n} from '@wordpress/components';\nimport { Icon, chevronRight } from '@wordpress/icons';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from './hooks/use-patterns-state';\nimport BlockPatternList from '../block-patterns-list';\nimport PatternsExplorerModal from './block-patterns-explorer/explorer';\nimport MobileTabNavigation from './mobile-tab-navigation';\n\nfunction usePatternsCategories() {\n\tconst [ allPatterns, allCategories ] = usePatternsState();\n\n\tconst hasRegisteredCategory = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn pattern.categories.some( ( cat ) =>\n\t\t\t\tallCategories.some( ( category ) => category.name === cat )\n\t\t\t);\n\t\t},\n\t\t[ allCategories ]\n\t);\n\n\t// Remove any empty categories.\n\tconst populatedCategories = useMemo( () => {\n\t\tconst categories = allCategories\n\t\t\t.filter( ( category ) =>\n\t\t\t\tallPatterns.some( ( pattern ) =>\n\t\t\t\t\tpattern.categories?.includes( category.name )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.sort( ( { name: currentName }, { name: nextName } ) => {\n\t\t\t\tif (\n\t\t\t\t\t! [ currentName, nextName ].some( ( categoryName ) =>\n\t\t\t\t\t\t[ 'featured', 'text' ].includes( categoryName )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\t// Move `featured` category to the top and `text` to the bottom.\n\t\t\t\treturn currentName === 'featured' || nextName === 'text'\n\t\t\t\t\t? -1\n\t\t\t\t\t: 1;\n\t\t\t} );\n\n\t\tif (\n\t\t\tallPatterns.some(\n\t\t\t\t( pattern ) => ! hasRegisteredCategory( pattern )\n\t\t\t) &&\n\t\t\t! categories.find(\n\t\t\t\t( category ) => category.name === 'uncategorized'\n\t\t\t)\n\t\t) {\n\t\t\tcategories.push( {\n\t\t\t\tname: 'uncategorized',\n\t\t\t\tlabel: _x( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\n\t\treturn categories;\n\t}, [ allPatterns, allCategories ] );\n\n\treturn populatedCategories;\n}\n\nexport function BlockPatternsCategoryDialog( {\n\trootClientId,\n\tonInsert,\n\tcategory,\n\tshowTitlesAsTooltip,\n} ) {\n\tconst container = useRef();\n\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tconst [ firstTabbable ] = focus.tabbable.find( container.current );\n\t\t\tfirstTabbable?.focus();\n\t\t} );\n\t\treturn () => clearTimeout( timeout );\n\t}, [ category ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ container }\n\t\t\tclassName=\"block-editor-inserter__patterns-category-dialog\"\n\t\t>\n\t\t\t<BlockPatternsCategoryPanel\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t\tcategory={ category }\n\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport function BlockPatternsCategoryPanel( {\n\trootClientId,\n\tonInsert,\n\tcategory,\n\tshowTitlesAsTooltip,\n} ) {\n\tconst [ allPatterns, , onClick ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\n\tconst availableCategories = usePatternsCategories();\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) => {\n\t\t\t\tif ( category.name !== 'uncategorized' ) {\n\t\t\t\t\treturn pattern.categories?.includes( category.name );\n\t\t\t\t}\n\n\t\t\t\t// The uncategorized category should show all the patterns without any category\n\t\t\t\t// or with no available category.\n\t\t\t\tconst availablePatternCategories =\n\t\t\t\t\tpattern.categories?.filter( ( cat ) =>\n\t\t\t\t\t\tavailableCategories.find(\n\t\t\t\t\t\t\t( availableCategory ) =>\n\t\t\t\t\t\t\t\tavailableCategory.name === cat\n\t\t\t\t\t\t)\n\t\t\t\t\t) ?? [];\n\n\t\t\t\treturn availablePatternCategories.length === 0;\n\t\t\t} ),\n\t\t[ allPatterns, category ]\n\t);\n\n\tconst currentShownPatterns = useAsyncList( currentCategoryPatterns );\n\n\tif ( ! currentCategoryPatterns.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-editor-inserter__patterns-category-panel\">\n\t\t\t<div className=\"block-editor-inserter__patterns-category-panel-title\">\n\t\t\t\t{ category.label }\n\t\t\t</div>\n\t\t\t<p>{ category.description }</p>\n\t\t\t<BlockPatternList\n\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\tblockPatterns={ currentCategoryPatterns }\n\t\t\t\tonClickPattern={ onClick }\n\t\t\t\tlabel={ category.label }\n\t\t\t\torientation=\"vertical\"\n\t\t\t\tcategory={ category.label }\n\t\t\t\tisDraggable\n\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction BlockPatternsTabs( {\n\tonSelectCategory,\n\tselectedCategory,\n\tonInsert,\n\trootClientId,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\tconst categories = usePatternsCategories();\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn (\n\t\t<>\n\t\t\t{ ! isMobile && (\n\t\t\t\t<div className=\"block-editor-inserter__block-patterns-tabs-container\">\n\t\t\t\t\t<nav aria-label={ __( 'Block pattern categories' ) }>\n\t\t\t\t\t\t<ItemGroup\n\t\t\t\t\t\t\trole=\"list\"\n\t\t\t\t\t\t\tclassName=\"block-editor-inserter__block-patterns-tabs\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t\t\t\t<Item\n\t\t\t\t\t\t\t\t\trole=\"listitem\"\n\t\t\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tonSelectCategory( category )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category'\n\t\t\t\t\t\t\t\t\t\t\t: 'block-editor-inserter__patterns-category'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-label={ category.label }\n\t\t\t\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ chevronRight } />\n\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t<div role=\"listitem\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explore-button\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowPatternsExplorer( true )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Explore all patterns' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t</nav>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isMobile && (\n\t\t\t\t<MobileTabNavigation categories={ categories }>\n\t\t\t\t\t{ ( category ) => (\n\t\t\t\t\t\t<BlockPatternsCategoryPanel\n\t\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\tshowTitlesAsTooltip={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</MobileTabNavigation>\n\t\t\t) }\n\t\t\t{ showPatternsExplorer && (\n\t\t\t\t<PatternsExplorerModal\n\t\t\t\t\tinitialCategory={ selectedCategory }\n\t\t\t\t\tpatternCategories={ categories }\n\t\t\t\t\tonModalClose={ () => setShowPatternsExplorer( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default BlockPatternsTabs;\n"]}
|
|
@@ -24,6 +24,8 @@ var _useBlockTypesState = _interopRequireDefault(require("./hooks/use-block-type
|
|
|
24
24
|
|
|
25
25
|
var _inserterListbox = _interopRequireDefault(require("../inserter-listbox"));
|
|
26
26
|
|
|
27
|
+
var _sorting = require("../../utils/sorting");
|
|
28
|
+
|
|
27
29
|
/**
|
|
28
30
|
* External dependencies
|
|
29
31
|
*/
|
|
@@ -56,7 +58,7 @@ function BlockTypesTab(_ref) {
|
|
|
56
58
|
} = _ref;
|
|
57
59
|
const [items, categories, collections, onSelectItem] = (0, _useBlockTypesState.default)(rootClientId, onInsert);
|
|
58
60
|
const suggestedItems = (0, _element.useMemo)(() => {
|
|
59
|
-
return (0,
|
|
61
|
+
return (0, _sorting.orderBy)(items, 'frecency', 'desc').slice(0, MAX_SUGGESTED_ITEMS);
|
|
60
62
|
}, [items]);
|
|
61
63
|
const uncategorizedItems = (0, _element.useMemo)(() => {
|
|
62
64
|
return items.filter(item => !item.category);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-types-tab.js"],"names":["getBlockNamespace","item","name","split","MAX_SUGGESTED_ITEMS","EMPTY_ARRAY","BlockTypesTab","rootClientId","onInsert","onHover","showMostUsedBlocks","items","categories","collections","onSelectItem","suggestedItems","slice","uncategorizedItems","filter","category","itemsPerCategory","itemList","itemsPerCollection","result","Object","keys","forEach","namespace","length","currentlyRenderedCategories","didRenderAllCategories","collectionEntries","entries","currentlyRenderedCollections","categoryItems","slug","title","icon","collection","collectionItems"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAKA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-types-tab.js"],"names":["getBlockNamespace","item","name","split","MAX_SUGGESTED_ITEMS","EMPTY_ARRAY","BlockTypesTab","rootClientId","onInsert","onHover","showMostUsedBlocks","items","categories","collections","onSelectItem","suggestedItems","slice","uncategorizedItems","filter","category","itemsPerCategory","itemList","itemsPerCollection","result","Object","keys","forEach","namespace","length","currentlyRenderedCategories","didRenderAllCategories","collectionEntries","entries","currentlyRenderedCollections","categoryItems","slug","title","icon","collection","collectionItems"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA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,SADP;AAEC,MAAA,KAAK,EAAGW,UAAU,CAACF,KAFpB;AAGC,MAAA,IAAI,EAAGE,UAAU,CAACD;AAHnB,OAKC,4BAAC,uBAAD;AACC,MAAA,KAAK,EAAGE,eADT;AAEC,MAAA,QAAQ,EAAGzB,YAFZ;AAGC,MAAA,OAAO,EAAGL,OAHX;AAIC,MAAA,KAAK,EAAG6B,UAAU,CAACF;AAJpB,MALD,CADD;AAcA,GAtBA,CA/CH,CADD,CADD;AA4EA;;eAEc9B,a","sourcesContent":["/**\n * External dependencies\n */\nimport { map, groupBy } from 'lodash';\n\n/**\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 ) => groupBy( itemList, 'category' )\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{ map( currentlyRenderedCategories, ( 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{ map(\n\t\t\t\t\tcurrentlyRenderedCollections,\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"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useDebouncedInput;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _compose = require("@wordpress/compose");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
function useDebouncedInput() {
|
|
16
|
+
let defaultValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
17
|
+
const [input, setInput] = (0, _element.useState)(defaultValue);
|
|
18
|
+
const [debounced, setter] = (0, _element.useState)(defaultValue);
|
|
19
|
+
const setDebounced = (0, _compose.useDebounce)(setter, 250);
|
|
20
|
+
(0, _element.useEffect)(() => {
|
|
21
|
+
if (debounced !== input) {
|
|
22
|
+
setDebounced(input);
|
|
23
|
+
}
|
|
24
|
+
}, [debounced, input]);
|
|
25
|
+
return [input, setInput, debounced];
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=use-debounced-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-debounced-input.js"],"names":["useDebouncedInput","defaultValue","input","setInput","debounced","setter","setDebounced"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIe,SAASA,iBAAT,GAAgD;AAAA,MAApBC,YAAoB,uEAAL,EAAK;AAC9D,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAUF,YAAV,CAA5B;AACA,QAAM,CAAEG,SAAF,EAAaC,MAAb,IAAwB,uBAAUJ,YAAV,CAA9B;AACA,QAAMK,YAAY,GAAG,0BAAaD,MAAb,EAAqB,GAArB,CAArB;AACA,0BAAW,MAAM;AAChB,QAAKD,SAAS,KAAKF,KAAnB,EAA2B;AAC1BI,MAAAA,YAAY,CAAEJ,KAAF,CAAZ;AACA;AACD,GAJD,EAIG,CAAEE,SAAF,EAAaF,KAAb,CAJH;AAKA,SAAO,CAAEA,KAAF,EAASC,QAAT,EAAmBC,SAAnB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\nexport default function useDebouncedInput( defaultValue = '' ) {\n\tconst [ input, setInput ] = useState( defaultValue );\n\tconst [ debounced, setter ] = useState( defaultValue );\n\tconst setDebounced = useDebounce( setter, 250 );\n\tuseEffect( () => {\n\t\tif ( debounced !== input ) {\n\t\t\tsetDebounced( input );\n\t\t}\n\t}, [ debounced, input ] );\n\treturn [ input, setInput, debounced ];\n}\n"]}
|
|
@@ -283,7 +283,8 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)((select, _ref4) => {
|
|
|
283
283
|
hasSingleBlockType,
|
|
284
284
|
allowedBlockType,
|
|
285
285
|
directInsertBlock,
|
|
286
|
-
onSelectOrClose
|
|
286
|
+
onSelectOrClose,
|
|
287
|
+
selectBlockOnInsert
|
|
287
288
|
} = ownProps;
|
|
288
289
|
|
|
289
290
|
if (!hasSingleBlockType && !directInsertBlock) {
|
|
@@ -375,10 +376,14 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)((select, _ref4) => {
|
|
|
375
376
|
blockToInsert = (0, _blocks.createBlock)(allowedBlockType.name);
|
|
376
377
|
}
|
|
377
378
|
|
|
378
|
-
insertBlock(blockToInsert, getInsertionIndex(), rootClientId);
|
|
379
|
+
insertBlock(blockToInsert, getInsertionIndex(), rootClientId, selectBlockOnInsert);
|
|
379
380
|
|
|
380
381
|
if (onSelectOrClose) {
|
|
381
|
-
|
|
382
|
+
var _blockToInsert;
|
|
383
|
+
|
|
384
|
+
onSelectOrClose({
|
|
385
|
+
insertedBlockId: (_blockToInsert = blockToInsert) === null || _blockToInsert === void 0 ? void 0 : _blockToInsert.clientId
|
|
386
|
+
});
|
|
382
387
|
}
|
|
383
388
|
|
|
384
389
|
const message = (0, _i18n.sprintf)( // translators: %s: the name of the block that has been added
|