@wordpress/block-editor 10.5.0 → 11.1.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 +18 -0
- package/README.md +2 -1
- 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/alignment-control/ui.js +1 -7
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build/components/block-alignment-control/use-available-alignments.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-icon/index.js +4 -2
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +90 -37
- 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-list-appender/index.js +46 -34
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-list-appender/index.native.js +39 -34
- package/build/components/block-list-appender/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +30 -22
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +1 -1
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +16 -8
- 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-styles/index.native.js +1 -3
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-styles/utils.js +7 -10
- package/build/components/block-styles/utils.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-toolbar/index.native.js +6 -8
- package/build/components/block-toolbar/index.native.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-tools/selected-block-popover.js +1 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-variation-picker/index.js +2 -3
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/colors/utils.js +2 -6
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +0 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +0 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -19
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -3
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/copy-handler/index.js +37 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +5 -2
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/utils.js +10 -4
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +11 -6
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/gradients/use-gradient.js +2 -8
- package/build/components/gradients/use-gradient.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 +22 -101
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +93 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -0
- 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 +25 -7
- 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/hooks/use-insertion-point.js +4 -3
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +20 -6
- 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 +106 -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 +7 -3
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +15 -14
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +7 -3
- 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-select-button.js +1 -1
- package/build/components/list-view/block-select-button.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 +99 -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-select-button.js +3 -2
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/block.js +82 -38
- 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 +24 -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/off-canvas-editor/use-inserted-block.js +58 -0
- package/build/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build/components/responsive-block-control/label.js.map +1 -1
- package/build/components/rich-text/format-edit.js +12 -10
- package/build/components/rich-text/format-edit.js.map +1 -1
- 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-paste-handler.js +21 -12
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- 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/index.js +0 -1
- package/build/components/spacing-sizes-control/index.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/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.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/url-popover/image-url-input-ui.js +2 -2
- package/build/components/url-popover/image-url-input-ui.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/components/writing-flow/index.js +1 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/child-layout.js +209 -0
- package/build/hooks/child-layout.js.map +1 -0
- package/build/hooks/color-panel.js +0 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -2
- package/build/hooks/color.js.map +1 -1
- 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/font-family.js +4 -4
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +5 -3
- package/build/hooks/font-size.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/hooks/use-typography-props.js +11 -8
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/store/reducer.js +411 -274
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +58 -48
- package/build/store/selectors.js.map +1 -1
- package/build/utils/pasting.js +6 -11
- package/build/utils/pasting.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/alignment-control/ui.js +1 -6
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build-module/components/block-alignment-control/use-available-alignments.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-icon/index.js +4 -2
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +87 -34
- 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-list-appender/index.js +46 -34
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.native.js +39 -32
- package/build-module/components/block-list-appender/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +31 -24
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +16 -8
- 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-styles/index.native.js +1 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-styles/utils.js +7 -9
- package/build-module/components/block-styles/utils.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-toolbar/index.native.js +6 -8
- package/build-module/components/block-toolbar/index.native.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-tools/selected-block-popover.js +1 -2
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +2 -3
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/colors/utils.js +3 -7
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +0 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +0 -2
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +4 -19
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/copy-handler/index.js +38 -10
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +5 -2
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +11 -5
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +12 -7
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +2 -7
- package/build-module/components/gradients/use-gradient.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 +21 -101
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +85 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -0
- 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 +27 -9
- 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/hooks/use-insertion-point.js +4 -3
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +20 -6
- 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 +92 -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 +7 -3
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +15 -13
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +7 -4
- 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-select-button.js +1 -1
- package/build-module/components/list-view/block-select-button.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 +83 -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-select-button.js +3 -2
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/block.js +83 -41
- 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 +24 -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/off-canvas-editor/use-inserted-block.js +47 -0
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build-module/components/responsive-block-control/label.js +1 -2
- package/build-module/components/responsive-block-control/label.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +12 -9
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- 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-paste-handler.js +22 -12
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- 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/index.js +0 -1
- package/build-module/components/spacing-sizes-control/index.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/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.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/url-popover/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.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/components/writing-flow/index.js +1 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.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/color-panel.js +0 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -2
- package/build-module/hooks/color.js.map +1 -1
- 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/font-family.js +5 -5
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +5 -3
- package/build-module/hooks/font-size.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/hooks/use-typography-props.js +11 -8
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/store/reducer.js +409 -274
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +55 -48
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/pasting.js +6 -10
- package/build-module/utils/pasting.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 +17 -3
- package/build-style/default-editor-styles.css +17 -3
- package/build-style/style-rtl.css +313 -665
- package/build-style/style.css +313 -665
- 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 +6 -1
- package/src/components/alignment-control/ui.js +1 -7
- package/src/components/block-alignment-control/test/index.js +6 -1
- package/src/components/block-alignment-control/use-available-alignments.js +4 -3
- 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-icon/index.js +4 -2
- package/src/components/block-icon/test/index.js +9 -5
- package/src/components/block-inspector/index.js +173 -85
- package/src/components/block-inspector/style.scss +16 -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-list-appender/index.js +65 -54
- package/src/components/block-list-appender/index.native.js +45 -34
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +42 -28
- package/src/components/block-mobile-toolbar/index.native.js +1 -1
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +125 -0
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +439 -0
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +42 -2
- package/src/components/block-mover/test/index.native.js +157 -1
- package/src/components/block-pattern-setup/index.js +17 -7
- package/src/components/block-pattern-setup/style.scss +29 -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-styles/index.native.js +1 -2
- package/src/components/block-styles/utils.js +5 -7
- package/src/components/block-switcher/test/index.js +6 -1
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/index.native.js +8 -11
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/insertion-point.js +3 -47
- package/src/components/block-tools/selected-block-popover.js +1 -3
- package/src/components/block-tools/style.scss +12 -5
- package/src/components/block-variation-picker/index.js +6 -5
- package/src/components/block-vertical-alignment-control/test/index.js +6 -1
- package/src/components/colors/test/with-colors.js +2 -0
- package/src/components/colors/utils.js +5 -3
- package/src/components/colors-gradients/control.js +0 -7
- package/src/components/colors-gradients/dropdown.js +0 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -22
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/src/components/copy-handler/index.js +53 -7
- package/src/components/default-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/default-block-appender/test/index.js +2 -0
- package/src/components/font-sizes/fluid-utils.js +7 -1
- package/src/components/font-sizes/utils.js +5 -3
- package/src/components/font-sizes/with-font-sizes.js +4 -4
- package/src/components/gradients/use-gradient.js +2 -7
- 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 +33 -121
- package/src/components/iframe/use-compatibility-styles.js +95 -0
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/image-size-control/test/index.js +147 -79
- 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 +26 -7
- 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/hooks/use-insertion-point.js +3 -2
- package/src/components/inserter/index.js +24 -3
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +89 -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 +4 -0
- package/src/components/inserter/search-items.js +1 -2
- package/src/components/inserter/search-results.js +5 -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 +204 -403
- package/src/components/link-control/use-internal-input-value.js +3 -3
- package/src/components/list-view/block-select-button.js +1 -1
- 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 +21 -16
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +39 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/appender.js +98 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block-select-button.js +6 -2
- package/src/components/off-canvas-editor/block.js +160 -77
- package/src/components/off-canvas-editor/branch.js +3 -5
- package/src/components/off-canvas-editor/index.js +68 -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 +19 -386
- package/src/components/off-canvas-editor/test/use-inserted-block.js +108 -0
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/off-canvas-editor/use-inserted-block.js +47 -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/responsive-block-control/label.js +2 -3
- package/src/components/responsive-block-control/test/index.js +4 -2
- package/src/components/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-edit.js +6 -10
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +3 -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-paste-handler.js +33 -14
- 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/index.js +0 -1
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/typewriter/index.js +3 -1
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-input/test/button.js +2 -0
- package/src/components/url-popover/image-url-input-ui.js +5 -4
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +37 -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/components/warning/test/index.js +2 -0
- package/src/components/writing-flow/index.js +1 -1
- package/src/content.scss +10 -0
- package/src/hooks/border.js +0 -1
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/color-panel.js +0 -1
- package/src/hooks/color.js +0 -2
- package/src/hooks/content-lock-ui.js +1 -1
- package/src/hooks/dimensions.js +45 -7
- package/src/hooks/font-family.js +3 -5
- package/src/hooks/font-size.js +13 -4
- package/src/hooks/layout.js +60 -0
- package/src/hooks/min-height.js +2 -19
- package/src/hooks/test/use-typography-props.js +26 -0
- package/src/hooks/use-typography-props.js +15 -7
- package/src/store/reducer.js +471 -428
- package/src/store/selectors.js +57 -59
- 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/pasting.js +3 -9
- 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/components/colors-gradients/use-common-single-multiple-selects.js +0 -21
- package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build/components/rich-text/file-paste-handler.js +0 -21
- package/build/components/rich-text/file-paste-handler.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/build-module/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build-module/components/rich-text/file-paste-handler.js +0 -13
- package/build-module/components/rich-text/file-paste-handler.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
- package/src/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/src/components/rich-text/file-paste-handler.js +0 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["classnames","useViewportMatch","useMergeRefs","forwardRef","useSelect","getBlockType","store","blocksStore","__unstableGetInnerBlocksProps","getInnerBlocksProps","ButtonBlockAppender","DefaultBlockAppender","useNestedSettingsUpdate","useInnerBlockTemplateSync","getBlockContext","BlockListItems","BlockContextProvider","useBlockEditContext","useBlockSync","blockEditorStore","useBlockDropZone","UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","select","block","getBlock","blockType","name","providesContext","attributes","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","__unstableLayoutClassNames","layoutClassNames","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","hasBlockSupport","blockDropZoneRef","rootClientId","InnerBlocks","value","onChange","className","children","save","Content"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,oBAA/C;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,YADD,EAECC,KAAK,IAAIC,WAFV,EAGCC,6BAA6B,IAAIC,mBAHlC,QAIO,mBAJP;AAMA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SAASC,cAAT,QAA+B,eAA/B;AACA,SAASC,oBAAT,QAAqC,kBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,OAAOC,YAAP,MAAyB,4BAAzB;AACA,SAASZ,KAAK,IAAIa,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,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;AAiBAV,EAAAA,uBAAuB,CACtBW,QADsB,EAEtBC,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encies\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":["classnames","useViewportMatch","useMergeRefs","forwardRef","useMemo","useSelect","getBlockSupport","getBlockType","store","blocksStore","__unstableGetInnerBlocksProps","getInnerBlocksProps","ButtonBlockAppender","DefaultBlockAppender","useNestedSettingsUpdate","useInnerBlockTemplateSync","getBlockContext","BlockListItems","BlockContextProvider","useBlockEditContext","useBlockSync","blockEditorStore","useBlockDropZone","UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","name","select","block","getBlock","blockType","Object","keys","providesContext","length","attributes","allowSizingOnChildren","layout","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","__unstableLayoutClassNames","layoutClassNames","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","hasBlockSupport","blockDropZoneRef","rootClientId","InnerBlocks","value","onChange","className","children","save","Content"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,oBAA/C;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,eADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,WAHV,EAICC,6BAA6B,IAAIC,mBAJlC,QAKO,mBALP;AAOA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SAASC,cAAT,QAA+B,eAA/B;AACA,SAASC,oBAAT,QAAqC,kBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,OAAOC,YAAP,MAAyB,4BAAzB;AACA,SAASZ,KAAK,IAAIa,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,uBAAT,CAAkCC,KAAlC,EAA0C;AACzC,QAAM;AACLC,IAAAA,QADK;AAELC,IAAAA,aAFK;AAGLC,IAAAA,0BAHK;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CAAxB;AAKA,QAAMhB,gBAAgB,GAAG;AACxBvB,IAAAA,6BADwB;AAExB,OAAGyB;AAFqB,GAAzB;AAIA,QAAMgB,WAAW,GAChBlB,gBAAgB,CAACmB,KAAjB,IAA0BnB,gBAAgB,CAACoB,QAA3C,GACGvB,qBADH,GAEG9B,uBAHJ;AAKA,SAAO,EACN,GAAGC,KADG;AAEN+B,IAAAA,GAFM;AAGNsB,IAAAA,SAAS,EAAE7E,UAAU,CACpBwB,KAAK,CAACqD,SADc,EAEpB,iCAFoB,EAGpBlB,iCAAiC,GAAG,EAAH,GAAQG,gBAHrB,EAIpB;AACC,qBAAeE;AADhB,KAJoB,CAHf;AAWNc,IAAAA,QAAQ,EAAErD,QAAQ,GACjB,cAAC,WAAD,eAAkB+B,gBAAlB;AAAqC,MAAA,QAAQ,EAAG/B;AAAhD,OADiB,GAGjB,cAAC,cAAD,EAAqBiC,OAArB;AAdK,GAAP;AAiBA;AAEDD,mBAAmB,CAACsB,IAApB,GAA2BpE,mBAA3B,C,CAEA;;AACA2C,oBAAoB,CAACzC,oBAArB,GAA4CA,oBAA5C;AACAyC,oBAAoB,CAAC1C,mBAArB,GAA2CA,mBAA3C;;AAEA0C,oBAAoB,CAAC0B,OAArB,GAA+B,MAAMvB,mBAAmB,CAACsB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;AACA,eAAexB,oBAAf","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 (\n\t\t\t\tObject.keys( blockType?.providesContext ?? {} ).length === 0\n\t\t\t) {\n\t\t\t\treturn { name: block.name };\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,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
4
|
+
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
5
|
/**
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
@@ -36,29 +36,37 @@ import { store as blockEditorStore } from '../../store';
|
|
|
36
36
|
|
|
37
37
|
export default function useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection) {
|
|
38
38
|
const {
|
|
39
|
+
getBlocks,
|
|
39
40
|
getSelectedBlocksInitialCaretPosition,
|
|
40
41
|
isBlockSelected
|
|
41
42
|
} = useSelect(blockEditorStore);
|
|
42
43
|
const {
|
|
43
|
-
replaceInnerBlocks
|
|
44
|
+
replaceInnerBlocks,
|
|
45
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
44
46
|
} = useDispatch(blockEditorStore);
|
|
45
|
-
const innerBlocks = useSelect(select => select(blockEditorStore).getBlocks(clientId), [clientId]);
|
|
46
47
|
const {
|
|
47
|
-
|
|
48
|
-
} = useSelect(
|
|
48
|
+
innerBlocks
|
|
49
|
+
} = useSelect(select => ({
|
|
50
|
+
innerBlocks: select(blockEditorStore).getBlocks(clientId)
|
|
51
|
+
}), [clientId]); // Maintain a reference to the previous value so we can do a deep equality check.
|
|
49
52
|
|
|
50
53
|
const existingTemplate = useRef(null);
|
|
51
54
|
useLayoutEffect(() => {
|
|
52
|
-
// There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate
|
|
55
|
+
let isCancelled = false; // There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate
|
|
53
56
|
// The former needs to happen after the latter and since the latter is using microtasks to batch updates (performance optimization),
|
|
54
57
|
// we need to schedule this one in a microtask as well.
|
|
55
|
-
//
|
|
58
|
+
// Example: If you remove queueMicrotask here, ctrl + click to insert quote block won't close the inserter.
|
|
59
|
+
|
|
56
60
|
window.queueMicrotask(() => {
|
|
57
|
-
|
|
61
|
+
if (isCancelled) {
|
|
62
|
+
return;
|
|
63
|
+
} // Only synchronize innerBlocks with template if innerBlocks are empty
|
|
58
64
|
// or a locking "all" or "contentOnly" exists directly on the block.
|
|
65
|
+
|
|
66
|
+
|
|
59
67
|
const currentInnerBlocks = getBlocks(clientId);
|
|
60
68
|
const shouldApplyTemplate = currentInnerBlocks.length === 0 || templateLock === 'all' || templateLock === 'contentOnly';
|
|
61
|
-
const hasTemplateChanged = !
|
|
69
|
+
const hasTemplateChanged = !fastDeepEqual(template, existingTemplate.current);
|
|
62
70
|
|
|
63
71
|
if (!shouldApplyTemplate || !hasTemplateChanged) {
|
|
64
72
|
return;
|
|
@@ -67,7 +75,9 @@ export default function useInnerBlockTemplateSync(clientId, template, templateLo
|
|
|
67
75
|
existingTemplate.current = template;
|
|
68
76
|
const nextBlocks = synchronizeBlocksWithTemplate(currentInnerBlocks, template);
|
|
69
77
|
|
|
70
|
-
if (!
|
|
78
|
+
if (!fastDeepEqual(nextBlocks, currentInnerBlocks)) {
|
|
79
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
80
|
+
|
|
71
81
|
replaceInnerBlocks(clientId, nextBlocks, currentInnerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0 && isBlockSelected(clientId), // This ensures the "initialPosition" doesn't change when applying the template
|
|
72
82
|
// If we're supposed to focus the block, we'll focus the first inner block
|
|
73
83
|
// otherwise, we won't apply any auto-focus.
|
|
@@ -75,6 +85,9 @@ export default function useInnerBlockTemplateSync(clientId, template, templateLo
|
|
|
75
85
|
getSelectedBlocksInitialCaretPosition());
|
|
76
86
|
}
|
|
77
87
|
});
|
|
88
|
+
return () => {
|
|
89
|
+
isCancelled = true;
|
|
90
|
+
};
|
|
78
91
|
}, [innerBlocks, template, templateLock, clientId]);
|
|
79
92
|
}
|
|
80
93
|
//# 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":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js"],"names":["fastDeepEqual","useRef","useLayoutEffect","useSelect","useDispatch","synchronizeBlocksWithTemplate","store","blockEditorStore","useInnerBlockTemplateSync","clientId","template","templateLock","templateInsertUpdatesSelection","getBlocks","getSelectedBlocksInitialCaretPosition","isBlockSelected","replaceInnerBlocks","__unstableMarkNextChangeAsNotPersistent","innerBlocks","select","existingTemplate","isCancelled","window","queueMicrotask","currentInnerBlocks","shouldApplyTemplate","length","hasTemplate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AA8B,CAA9B,IACAf,YAAY,KAAK,KADjB,IAEAA,YAAY,KAAK,aAHlB;AAKA,YAAMgB,kBAAkB,GAAG,CAAE3B,aAAa,CACzCU,QADyC,EAEzCU,gBAAgB,CAACQ,OAFwB,CAA1C;;AAKA,UAAK,CAAEH,mBAAF,IAAyB,CAAEE,kBAAhC,EAAqD;AACpD;AACA;;AAEDP,MAAAA,gBAAgB,CAACQ,OAAjB,GAA2BlB,QAA3B;AACA,YAAMmB,UAAU,GAAGxB,6BAA6B,CAC/CmB,kBAD+C,EAE/Cd,QAF+C,CAAhD;;AAKA,UAAK,CAAEV,aAAa,CAAE6B,UAAF,EAAcL,kBAAd,CAApB,EAAyD;AACxDP,QAAAA,uCAAuC;;AACvCD,QAAAA,kBAAkB,CACjBP,QADiB,EAEjBoB,UAFiB,EAGjBL,kBAAkB,CAACE,MAAnB,KAA8B,CAA9B,IACCd,8BADD,IAECiB,UAAU,CAACH,MAAX,KAAsB,CAFvB,IAGCX,eAAe,CAAEN,QAAF,CANC,EAOjB;AACA;AACA;AACA;AACAK,QAAAA,qCAAqC,EAXpB,CAAlB;AAaA;AACD,KA5CD;AA8CA,WAAO,MAAM;AACZO,MAAAA,WAAW,GAAG,IAAd;AACA,KAFD;AAGA,GAxDc,EAwDZ,CAAEH,WAAF,EAAeR,QAAf,EAAyBC,YAAzB,EAAuCF,QAAvC,CAxDY,CAAf;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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/sidebar.js"],"names":["Button","SearchControl","__","PatternCategoriesList","selectedCategory","patternCategories","onClickCategory","baseClassName","map","name","label","PatternsExplorerSearch","filterValue","setFilterValue","PatternExplorerSidebar"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,aAAjB,QAAsC,uBAAtC;AACA,SAASC,EAAT,QAAmB,iBAAnB;;AAEA,SAASC,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,cAAC,MAAD;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,cAAC,aAAD;AACC,IAAA,QAAQ,EAAGM,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/sidebar.js"],"names":["Button","SearchControl","__","PatternCategoriesList","selectedCategory","patternCategories","onClickCategory","baseClassName","map","name","label","PatternsExplorerSearch","filterValue","setFilterValue","PatternExplorerSidebar"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,aAAjB,QAAsC,uBAAtC;AACA,SAASC,EAAT,QAAmB,iBAAnB;;AAEA,SAASC,qBAAT,OAII;AAAA,MAJ4B;AAC/BC,IAAAA,gBAD+B;AAE/BC,IAAAA,iBAF+B;A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ED,WAAF,IACD,cAAC,qBAAD;AACC,IAAA,gBAAgB,EAAGR,gBADpB;AAEC,IAAA,iBAAiB,EAAGC,iBAFrB;AAGC,IAAA,eAAe,EAAGC;AAHnB,IANF,CADD;AAeA;;AAED,eAAeQ,sBAAf","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"]}
|
|
@@ -4,10 +4,10 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { useMemo, useState, useCallback, useRef, useEffect } from '@wordpress/element';
|
|
7
|
-
import { _x, __
|
|
7
|
+
import { _x, __ } from '@wordpress/i18n';
|
|
8
8
|
import { useAsyncList, useViewportMatch } from '@wordpress/compose';
|
|
9
|
-
import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, __experimentalHStack as HStack,
|
|
10
|
-
import { Icon, chevronRight
|
|
9
|
+
import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, __experimentalHStack as HStack, FlexBlock, Button } from '@wordpress/components';
|
|
10
|
+
import { Icon, chevronRight } from '@wordpress/icons';
|
|
11
11
|
import { focus } from '@wordpress/dom';
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
@@ -16,6 +16,7 @@ import { focus } from '@wordpress/dom';
|
|
|
16
16
|
import usePatternsState from './hooks/use-patterns-state';
|
|
17
17
|
import BlockPatternList from '../block-patterns-list';
|
|
18
18
|
import PatternsExplorerModal from './block-patterns-explorer/explorer';
|
|
19
|
+
import MobileTabNavigation from './mobile-tab-navigation';
|
|
19
20
|
|
|
20
21
|
function usePatternsCategories() {
|
|
21
22
|
const [allPatterns, allCategories] = usePatternsState();
|
|
@@ -40,11 +41,12 @@ function usePatternsCategories() {
|
|
|
40
41
|
name: nextName
|
|
41
42
|
} = _ref2;
|
|
42
43
|
|
|
43
|
-
if (![currentName, nextName].
|
|
44
|
+
if (![currentName, nextName].some(categoryName => ['featured', 'text'].includes(categoryName))) {
|
|
44
45
|
return 0;
|
|
45
|
-
}
|
|
46
|
+
} // Move `featured` category to the top and `text` to the bottom.
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
|
|
49
|
+
return currentName === 'featured' || nextName === 'text' ? -1 : 1;
|
|
48
50
|
});
|
|
49
51
|
|
|
50
52
|
if (allPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
|
|
@@ -63,7 +65,8 @@ export function BlockPatternsCategoryDialog(_ref3) {
|
|
|
63
65
|
let {
|
|
64
66
|
rootClientId,
|
|
65
67
|
onInsert,
|
|
66
|
-
category
|
|
68
|
+
category,
|
|
69
|
+
showTitlesAsTooltip
|
|
67
70
|
} = _ref3;
|
|
68
71
|
const container = useRef();
|
|
69
72
|
useEffect(() => {
|
|
@@ -75,18 +78,20 @@ export function BlockPatternsCategoryDialog(_ref3) {
|
|
|
75
78
|
}, [category]);
|
|
76
79
|
return createElement("div", {
|
|
77
80
|
ref: container,
|
|
78
|
-
className: "block-editor-inserter__patterns-category-
|
|
81
|
+
className: "block-editor-inserter__patterns-category-dialog"
|
|
79
82
|
}, createElement(BlockPatternsCategoryPanel, {
|
|
80
83
|
rootClientId: rootClientId,
|
|
81
84
|
onInsert: onInsert,
|
|
82
|
-
category: category
|
|
85
|
+
category: category,
|
|
86
|
+
showTitlesAsTooltip: showTitlesAsTooltip
|
|
83
87
|
}));
|
|
84
88
|
}
|
|
85
89
|
export function BlockPatternsCategoryPanel(_ref4) {
|
|
86
90
|
let {
|
|
87
91
|
rootClientId,
|
|
88
92
|
onInsert,
|
|
89
|
-
category
|
|
93
|
+
category,
|
|
94
|
+
showTitlesAsTooltip
|
|
90
95
|
} = _ref4;
|
|
91
96
|
const [allPatterns,, onClick] = usePatternsState(onInsert, rootClientId);
|
|
92
97
|
const availableCategories = usePatternsCategories();
|
|
@@ -110,7 +115,9 @@ export function BlockPatternsCategoryPanel(_ref4) {
|
|
|
110
115
|
return null;
|
|
111
116
|
}
|
|
112
117
|
|
|
113
|
-
return createElement("div",
|
|
118
|
+
return createElement("div", {
|
|
119
|
+
className: "block-editor-inserter__patterns-category-panel"
|
|
120
|
+
}, createElement("div", {
|
|
114
121
|
className: "block-editor-inserter__patterns-category-panel-title"
|
|
115
122
|
}, category.label), createElement("p", null, category.description), createElement(BlockPatternList, {
|
|
116
123
|
shownPatterns: currentShownPatterns,
|
|
@@ -119,7 +126,8 @@ export function BlockPatternsCategoryPanel(_ref4) {
|
|
|
119
126
|
label: category.label,
|
|
120
127
|
orientation: "vertical",
|
|
121
128
|
category: category.label,
|
|
122
|
-
isDraggable: true
|
|
129
|
+
isDraggable: true,
|
|
130
|
+
showTitlesAsTooltip: showTitlesAsTooltip
|
|
123
131
|
}));
|
|
124
132
|
}
|
|
125
133
|
|
|
@@ -150,54 +158,24 @@ function BlockPatternsTabs(_ref5) {
|
|
|
150
158
|
}, createElement(HStack, null, createElement(FlexBlock, null, category.label), createElement(Icon, {
|
|
151
159
|
icon: chevronRight
|
|
152
160
|
})))), createElement("div", {
|
|
153
|
-
role: "presentation",
|
|
154
|
-
className: "block-editor-inserter__patterns-fill-space"
|
|
155
|
-
}), createElement("div", {
|
|
156
161
|
role: "listitem"
|
|
157
162
|
}, createElement(Button, {
|
|
158
163
|
className: "block-editor-inserter__patterns-explore-button",
|
|
159
164
|
onClick: () => setShowPatternsExplorer(true),
|
|
160
165
|
variant: "secondary"
|
|
161
|
-
}, __('Explore all patterns')))))), isMobile && createElement(
|
|
166
|
+
}, __('Explore all patterns')))))), isMobile && createElement(MobileTabNavigation, {
|
|
167
|
+
categories: categories
|
|
168
|
+
}, category => createElement(BlockPatternsCategoryPanel, {
|
|
162
169
|
onInsert: onInsert,
|
|
163
|
-
rootClientId: rootClientId
|
|
164
|
-
|
|
170
|
+
rootClientId: rootClientId,
|
|
171
|
+
category: category,
|
|
172
|
+
showTitlesAsTooltip: false
|
|
173
|
+
})), showPatternsExplorer && createElement(PatternsExplorerModal, {
|
|
165
174
|
initialCategory: selectedCategory,
|
|
166
175
|
patternCategories: categories,
|
|
167
176
|
onModalClose: () => setShowPatternsExplorer(false)
|
|
168
177
|
}));
|
|
169
178
|
}
|
|
170
179
|
|
|
171
|
-
function BlockPatternsTabNavigation(_ref6) {
|
|
172
|
-
let {
|
|
173
|
-
onInsert,
|
|
174
|
-
rootClientId
|
|
175
|
-
} = _ref6;
|
|
176
|
-
const categories = usePatternsCategories();
|
|
177
|
-
return createElement(NavigatorProvider, {
|
|
178
|
-
initialPath: "/"
|
|
179
|
-
}, createElement(NavigatorScreen, {
|
|
180
|
-
path: "/"
|
|
181
|
-
}, createElement(ItemGroup, null, categories.map(category => createElement(NavigatorButton, {
|
|
182
|
-
key: category.name,
|
|
183
|
-
path: `/category/${category.name}`,
|
|
184
|
-
as: Item,
|
|
185
|
-
isAction: true
|
|
186
|
-
}, createElement(HStack, null, createElement(FlexBlock, null, category.label), createElement(Icon, {
|
|
187
|
-
icon: isRTL() ? chevronLeft : chevronRight
|
|
188
|
-
})))))), categories.map(category => createElement(NavigatorScreen, {
|
|
189
|
-
key: category.name,
|
|
190
|
-
path: `/category/${category.name}`
|
|
191
|
-
}, createElement(NavigatorBackButton, {
|
|
192
|
-
icon: isRTL() ? chevronRight : chevronLeft,
|
|
193
|
-
isSmall: true,
|
|
194
|
-
"aria-label": __('Navigate to the categories list')
|
|
195
|
-
}, __('Back')), createElement(BlockPatternsCategoryPanel, {
|
|
196
|
-
category: category,
|
|
197
|
-
rootClientId: rootClientId,
|
|
198
|
-
onInsert: onInsert
|
|
199
|
-
}))));
|
|
200
|
-
}
|
|
201
|
-
|
|
202
180
|
export default BlockPatternsTabs;
|
|
203
181
|
//# sourceMappingURL=block-patterns-tab.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["useMemo","useState","useCallback","useRef","useEffect","_x","__","isRTL","useAsyncList","useViewportMatch","__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__experimentalHStack","HStack","__experimentalNavigatorProvider","NavigatorProvider","__experimentalNavigatorScreen","NavigatorScreen","__experimentalNavigatorButton","NavigatorButton","__experimentalNavigatorBackButton","NavigatorBackButton","FlexBlock","Button","Icon","chevronRight","chevronLeft","focus","usePatternsState","BlockPatternList","PatternsExplorerModal","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","tabbable","current","clearTimeout","BlockPatternsCategoryPanel","onClick","availableCategories","currentCategoryPatterns","availablePatternCategories","availableCategory","currentShownPatterns","description","BlockPatternsTabs","onSelectCategory","selectedCategory","showPatternsExplorer","setShowPatternsExplorer","isMobile","map","undefined","BlockPatternsTabNavigation"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,OADD,EAECC,QAFD,EAGCC,WAHD,EAICC,MAJD,EAKCC,SALD,QAMO,oBANP;AAOA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,KAAjB,QAA8B,iBAA9B;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,oBAA/C;AACA,SACCC,uBAAuB,IAAIC,SAD5B,EAECC,kBAAkB,IAAIC,IAFvB,EAGCC,oBAAoB,IAAIC,MAHzB,EAICC,+BAA+B,IAAIC,iBAJpC,EAKCC,6BAA6B,IAAIC,eALlC,EAMCC,6BAA6B,IAAIC,eANlC,EAOCC,iCAAiC,IAAIC,mBAPtC,EAQCC,SARD,EASCC,MATD,QAUO,uBAVP;AAWA,SAASC,IAAT,EAAeC,YAAf,EAA6BC,WAA7B,QAAgD,kBAAhD;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,g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IC,cAAC,mBAAD;AACC,IAAA,IAAI,EAAGpC,KAAK,KAAKoB,YAAL,GAAoBC,WADjC;AAEC,IAAA,OAAO,MAFR;AAGC,kBAAatB,EAAE,CAAE,iCAAF;AAHhB,KAKGA,EAAE,CAAE,MAAF,CALL,CAJD,EAWC,cAAC,0BAAD;AACC,IAAA,QAAQ,EAAGoC,QADZ;AAEC,IAAA,YAAY,EAAGY,YAFhB;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IAXD,CADC,CAvBH,CADD;AA6CA;;AAED,eAAegB,iBAAf","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":["useMemo","useState","useCallback","useRef","useEffect","_x","__","useAsyncList","useViewportMatch","__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__experimentalHStack","HStack","FlexBlock","Button","Icon","chevronRight","focus","usePatternsState","BlockPatternList","PatternsExplorerModal","MobileTabNavigation","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","tabbable","current","clearTimeout","BlockPatternsCategoryPanel","onClick","availableCategories","currentCategoryPatterns","availablePatternCategories","availableCategory","currentShownPatterns","description","BlockPatternsTabs","onSelectCategory","selectedCategory","showPatternsExplorer","setShowPatternsExplorer","isMobile","map","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,OADD,EAECC,QAFD,EAGCC,WAHD,EAICC,MAJD,EAKCC,SALD,QAMO,oBANP;AAOA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,YAAT,EAAuBC,gBAAvB,QAA+C,oBAA/C;AACA,SACCC,uBAAuB,IAAIC,SAD5B,EAECC,kBAAkB,IAAIC,IAFvB,EAGCC,oBAAoB,IAAIC,MAHzB,EAICC,SAJD,EAKCC,MALD,QAMO,uBANP;AAOA,SAASC,IAAT,EAAeC,YAAf,QAAmC,kBAAnC;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AACA,OAAOC,qBAAP,MAAkC,oCAAlC;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;;AAEA,SAASC,qBAAT,GAAiC;AAChC,QAAM,CAAEC,WAAF,EAAeC,aAAf,IAAiCN,gBAAgB,EAAvD;AAEA,QAAMO,qBAAqB,GAAGzB,WAAW,CACtC0B,OAAF,IAAe;AACd,QAAK,CAAEA,OAAO,CAACC,UAAV,IAAwB,CAAED,OAAO,CAACC,UAAR,CAAmBC,MAAlD,EAA2D;AAC1D,aAAO,KAAP;AACA;;AAED,WAAOF,OAAO,CAACC,UAAR,CAAmBE,IAAnB,CAA2BC,GAAF,IAC/BN,aAAa,CAACK,IAAd,CAAsBE,QAAF,IAAgBA,QAAQ,CAACC,IAAT,KAAkBF,GAAtD,CADM,CAAP;AAGA,GATuC,EAUxC,CAAEN,aAAF,CAVwC,CAAzC,CAHgC,CAgBhC;;AACA,QAAMS,mBAAmB,GAAGnC,OAAO,CAAE,MAAM;AAC1C,UAAM6B,UAAU,GAAG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GrC,UAFrB;AAGC,IAAA,YAAY,EAAG,MAAMuC,uBAAuB,CAAE,KAAF;AAH7C,IA/DF,CADD;AAwEA;;AAED,eAAeJ,iBAAf","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"]}
|
|
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { map, groupBy
|
|
6
|
+
import { map, groupBy } from 'lodash';
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
@@ -19,6 +19,7 @@ import BlockTypesList from '../block-types-list';
|
|
|
19
19
|
import InserterPanel from './panel';
|
|
20
20
|
import useBlockTypesState from './hooks/use-block-types-state';
|
|
21
21
|
import InserterListbox from '../inserter-listbox';
|
|
22
|
+
import { orderBy } from '../../utils/sorting';
|
|
22
23
|
|
|
23
24
|
const getBlockNamespace = item => item.name.split('/')[0];
|
|
24
25
|
|
|
@@ -40,7 +41,7 @@ export function BlockTypesTab(_ref) {
|
|
|
40
41
|
} = _ref;
|
|
41
42
|
const [items, categories, collections, onSelectItem] = useBlockTypesState(rootClientId, onInsert);
|
|
42
43
|
const suggestedItems = useMemo(() => {
|
|
43
|
-
return orderBy(items,
|
|
44
|
+
return orderBy(items, 'frecency', 'desc').slice(0, MAX_SUGGESTED_ITEMS);
|
|
44
45
|
}, [items]);
|
|
45
46
|
const uncategorizedItems = useMemo(() => {
|
|
46
47
|
return items.filter(item => !item.category);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-types-tab.js"],"names":["map","groupBy","orderBy","__","_x","useMemo","useEffect","pipe","useAsyncList","BlockTypesList","InserterPanel","useBlockTypesState","InserterListbox","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":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,OAAd,EAAuBC,OAAvB,QAAsC,QAAtC;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,OAAT,EAAkBC,SAAlB,QAAmC,oBAAnC;AACA,SAASC,IAAT,EAAeC,YAAf,QAAmC,oBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,OAAOC,aAAP,MAA0B,SAA1B;AACA,OAAOC,kBAAP,MAA+B,+BAA/B;AACA,OAAOC,eAAP,MAA4B,qBAA5B;;AAEA,MAAMC,iBAAiB,GAAKC,IAAF,IAA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ACpD,aAAO,IAAP;AACA;;AAED,WACC,cAAC,aAAD;AACC,MAAA,GAAG,EAAGD,SADP;AAEC,MAAA,KAAK,EAAGW,UAAU,CAACF,KAFpB;AAGC,MAAA,IAAI,EAAGE,UAAU,CAACD;AAHnB,OAKC,cAAC,cAAD;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,GAtBG,CA/CN,CADD,CADD;AA4EA;AAED,eAAe9B,aAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { map, groupBy, orderBy } 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';\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-types-tab.js"],"names":["map","groupBy","__","_x","useMemo","useEffect","pipe","useAsyncList","BlockTypesList","InserterPanel","useBlockTypesState","InserterListbox","orderBy","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":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,OAAd,QAA6B,QAA7B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,OAAT,EAAkBC,SAAlB,QAAmC,oBAAnC;AACA,SAASC,IAAT,EAAeC,YAAf,QAAmC,oBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA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AaW,UAAb,CAA+B;AAChC,UAAMC,eAAe,GAAGjB,kBAAkB,CAAEK,SAAF,CAA1C;;AACA,QAAK,CAAEY,eAAF,IAAqB,CAAEA,eAAe,CAACX,MAA5C,EAAqD;AACpD,aAAO,IAAP;AACA;;AAED,WACC,cAAC,aAAD;AACC,MAAA,GAAG,EAAGD,SADP;AAEC,MAAA,KAAK,EAAGW,UAAU,CAACF,KAFpB;AAGC,MAAA,IAAI,EAAGE,UAAU,CAACD;AAHnB,OAKC,cAAC,cAAD;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,GAtBG,CA/CN,CADD,CADD;AA4EA;AAED,eAAe9B,aAAf","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,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
5
|
+
import { useDebounce } from '@wordpress/compose';
|
|
6
|
+
export default function useDebouncedInput() {
|
|
7
|
+
let defaultValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
8
|
+
const [input, setInput] = useState(defaultValue);
|
|
9
|
+
const [debounced, setter] = useState(defaultValue);
|
|
10
|
+
const setDebounced = useDebounce(setter, 250);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (debounced !== input) {
|
|
13
|
+
setDebounced(input);
|
|
14
|
+
}
|
|
15
|
+
}, [debounced, input]);
|
|
16
|
+
return [input, setInput, debounced];
|
|
17
|
+
}
|
|
18
|
+
//# 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":["useEffect","useState","useDebounce","useDebouncedInput","defaultValue","input","setInput","debounced","setter","setDebounced"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA,eAAe,SAASC,iBAAT,GAAgD;AAAA,MAApBC,YAAoB,uEAAL,EAAK;AAC9D,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsBL,QAAQ,CAAEG,YAAF,CAApC;AACA,QAAM,CAAEG,SAAF,EAAaC,MAAb,IAAwBP,QAAQ,CAAEG,YAAF,CAAtC;AACA,QAAMK,YAAY,GAAGP,WAAW,CAAEM,MAAF,EAAU,GAAV,CAAhC;AACAR,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKO,SAAS,KAAKF,KAAnB,EAA2B;AAC1BI,MAAAA,YAAY,CAAEJ,KAAF,CAAZ;AACA;AACD,GAJQ,EAIN,CAAEE,SAAF,EAAaF,KAAb,CAJM,CAAT;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"]}
|
|
@@ -39,7 +39,8 @@ function useInsertionPoint(_ref) {
|
|
|
39
39
|
clientId,
|
|
40
40
|
isAppender,
|
|
41
41
|
onSelect,
|
|
42
|
-
shouldFocusBlock = true
|
|
42
|
+
shouldFocusBlock = true,
|
|
43
|
+
selectBlockOnInsert = true
|
|
43
44
|
} = _ref;
|
|
44
45
|
const {
|
|
45
46
|
getSelectedBlock
|
|
@@ -91,7 +92,7 @@ function useInsertionPoint(_ref) {
|
|
|
91
92
|
if (!isAppender && selectedBlock && isUnmodifiedDefaultBlock(selectedBlock)) {
|
|
92
93
|
replaceBlocks(selectedBlock.clientId, blocks, null, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
|
|
93
94
|
} else {
|
|
94
|
-
insertBlocks(blocks, destinationIndex, destinationRootClientId,
|
|
95
|
+
insertBlocks(blocks, destinationIndex, destinationRootClientId, selectBlockOnInsert, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
const blockLength = Array.isArray(blocks) ? blocks.length : 1;
|
|
@@ -100,7 +101,7 @@ function useInsertionPoint(_ref) {
|
|
|
100
101
|
speak(message);
|
|
101
102
|
|
|
102
103
|
if (onSelect) {
|
|
103
|
-
onSelect();
|
|
104
|
+
onSelect(blocks);
|
|
104
105
|
}
|
|
105
106
|
}, [isAppender, getSelectedBlock, replaceBlocks, insertBlocks, destinationRootClientId, destinationIndex, onSelect, shouldFocusBlock]);
|
|
106
107
|
const onToggleInsertionPoint = useCallback(show => {
|