@wordpress/block-editor 10.2.0 → 10.4.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 +41 -0
- package/build/components/alignment-control/ui.js +1 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/constants.js +1 -1
- package/build/components/block-alignment-control/constants.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +1 -1
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-compare/index.js +1 -3
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.js +4 -2
- package/build/components/block-draggable/draggable-chip.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +4 -4
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-compact.native.js +1 -0
- package/build/components/block-list/block-list-compact.native.js.map +1 -1
- package/build/components/block-list/block.js +75 -15
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +79 -12
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +7 -23
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/modal.js +9 -6
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-parent-selector/index.js +3 -3
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +5 -4
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/drop-zone.js +85 -0
- package/build/components/block-popover/drop-zone.js.map +1 -0
- package/build/components/block-popover/inbetween.js +2 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +4 -2
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js +2 -2
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +8 -13
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-preview/live.js +3 -7
- package/build/components/block-preview/live.js.map +1 -1
- package/build/components/block-selection-clearer/index.js +9 -1
- package/build/components/block-selection-clearer/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +19 -19
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +18 -42
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/index.js +2 -8
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/preview-block-popover.js +1 -1
- package/build/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build/components/block-toolbar/index.js +4 -4
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -1
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +56 -16
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +15 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +1 -1
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/all-input-control.js +2 -1
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +2 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/colors-gradients/control.js +1 -1
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -2
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +256 -0
- package/build/components/font-sizes/fluid-utils.js.map +1 -0
- package/build/components/font-sizes/index.js +8 -0
- package/build/components/font-sizes/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +1 -1
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -1
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/index.js +0 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +6 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +151 -78
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +2 -7
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/menu.js +14 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/search-items.js +23 -2
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +4 -2
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/line-height-control/index.js +2 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +2 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +1 -14
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-replace-flow/index.js +1 -1
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/preview-options/index.js +2 -3
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +1 -1
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +1 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +1 -1
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +6 -2
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls.js +6 -2
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +45 -8
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +98 -57
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +12 -12
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-on-block-drop/types.js +6 -0
- package/build/components/use-on-block-drop/types.js.map +1 -0
- package/build/hooks/align.js +1 -3
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +1 -7
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/border.js +1 -0
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +32 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +61 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/layout.js +4 -3
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +24 -17
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +20 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +126 -4
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/use-typography-props.js +17 -3
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/hooks/utils.js +8 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +0 -1
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +63 -45
- package/build/store/actions.js.map +1 -1
- package/build/store/array.js +1 -7
- package/build/store/array.js.map +1 -1
- package/build/store/defaults.js +3 -0
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +31 -15
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +46 -29
- package/build/store/selectors.js.map +1 -1
- package/build/utils/math.js +14 -0
- package/build/utils/math.js.map +1 -1
- package/build/utils/pre-parse-patterns.js +19 -2
- package/build/utils/pre-parse-patterns.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +1 -1
- package/build-module/components/block-alignment-control/constants.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -3
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.js +7 -3
- package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
- package/build-module/components/block-edit/index.js +4 -2
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +4 -4
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-compact.native.js +1 -0
- package/build-module/components/block-list/block-list-compact.native.js.map +1 -1
- package/build-module/components/block-list/block.js +75 -15
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +80 -13
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +8 -24
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/modal.js +10 -8
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +3 -3
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +5 -4
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/drop-zone.js +70 -0
- package/build-module/components/block-popover/drop-zone.js.map +1 -0
- package/build-module/components/block-popover/inbetween.js +2 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +4 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +8 -12
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-preview/live.js +3 -6
- package/build-module/components/block-preview/live.js.map +1 -1
- package/build-module/components/block-selection-clearer/index.js +9 -1
- package/build-module/components/block-selection-clearer/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +20 -19
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +19 -44
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +2 -7
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js +1 -1
- package/build-module/components/block-switcher/preview-block-popover.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +4 -4
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +2 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +54 -16
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +15 -3
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/all-input-control.js +2 -1
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +2 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +2 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +3 -3
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +245 -0
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -0
- package/build-module/components/font-sizes/index.js +1 -0
- package/build-module/components/font-sizes/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +2 -2
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -1
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/index.js +0 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +148 -81
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +2 -6
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/menu.js +10 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/search-items.js +23 -3
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +4 -2
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +2 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +2 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +1 -14
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +1 -1
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -3
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +1 -1
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +6 -2
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +6 -2
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +44 -8
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +98 -58
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +12 -12
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/types.js +2 -0
- package/build-module/components/use-on-block-drop/types.js.map +1 -0
- package/build-module/hooks/align.js +1 -2
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +1 -6
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/border.js +1 -0
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +32 -4
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +60 -1
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/layout.js +5 -4
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +25 -18
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +21 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +124 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +17 -4
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/hooks/utils.js +8 -8
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +0 -1
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +1 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +59 -42
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/array.js +1 -6
- package/build-module/store/array.js.map +1 -1
- package/build-module/store/defaults.js +3 -0
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +32 -16
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +47 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/math.js +12 -0
- package/build-module/utils/math.js.map +1 -1
- package/build-module/utils/pre-parse-patterns.js +19 -2
- package/build-module/utils/pre-parse-patterns.js.map +1 -1
- package/build-style/style-rtl.css +292 -206
- package/build-style/style.css +288 -202
- package/package.json +29 -28
- package/src/components/alignment-control/ui.js +1 -1
- package/src/components/block-alignment-control/constants.js +1 -1
- package/src/components/block-alignment-matrix-control/index.js +1 -1
- package/src/components/block-breadcrumb/test/__snapshots__/index.js.snap +13 -11
- package/src/components/block-breadcrumb/test/index.js +2 -2
- package/src/components/block-compare/index.js +3 -2
- package/src/components/block-draggable/draggable-chip.js +4 -2
- package/src/components/block-edit/index.js +2 -1
- package/src/components/block-inspector/index.js +8 -7
- package/src/components/block-list/block-list-compact.native.js +1 -0
- package/src/components/block-list/block.js +113 -7
- package/src/components/block-list/block.native.js +123 -9
- package/src/components/block-list/style.scss +93 -126
- package/src/components/block-list/use-in-between-inserter.js +8 -19
- package/src/components/block-lock/modal.js +12 -7
- package/src/components/block-mover/stories/index.js +1 -1
- package/src/components/block-mover/style.scss +35 -1
- package/src/components/block-parent-selector/index.js +3 -3
- package/src/components/block-patterns-list/index.js +9 -5
- package/src/components/block-patterns-list/style.scss +7 -3
- package/src/components/block-popover/README.md +8 -0
- package/src/components/block-popover/drop-zone.js +63 -0
- package/src/components/block-popover/inbetween.js +1 -0
- package/src/components/block-popover/index.js +3 -1
- package/src/components/block-popover/style.scss +17 -5
- package/src/components/block-preview/auto.js +1 -1
- package/src/components/block-preview/index.js +15 -11
- package/src/components/block-preview/live.js +2 -7
- package/src/components/block-preview/test/index.js +1 -7
- package/src/components/block-selection-clearer/index.js +7 -2
- package/src/components/block-selection-clearer/test/index.js +118 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +29 -18
- package/src/components/block-settings-menu/test/block-mode-toggle.js +17 -17
- package/src/components/block-styles/index.js +26 -49
- package/src/components/block-switcher/index.js +2 -7
- package/src/components/block-switcher/preview-block-popover.js +1 -1
- package/src/components/block-switcher/test/index.js +2 -2
- package/src/components/block-toolbar/index.js +4 -6
- package/src/components/block-toolbar/style.scss +38 -14
- package/src/components/block-tools/back-compat.js +1 -0
- package/src/components/block-tools/insertion-point.js +49 -15
- package/src/components/block-tools/selected-block-popover.js +14 -1
- package/src/components/block-variation-picker/README.md +1 -1
- package/src/components/block-vertical-alignment-control/ui.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +1 -0
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/input-controls.js +1 -0
- package/src/components/border-radius-control/style.scss +15 -24
- package/src/components/button-block-appender/style.scss +4 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +86 -104
- package/src/components/color-palette/test/control.js +11 -15
- package/src/components/colors-gradients/control.js +2 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +3 -4
- package/src/components/colors-gradients/test/control.js +49 -77
- package/src/components/duotone-control/index.js +1 -1
- package/src/components/font-sizes/fluid-utils.js +296 -0
- package/src/components/font-sizes/index.js +1 -0
- package/src/components/font-sizes/test/fluid-utils.js +168 -0
- package/src/components/font-sizes/with-font-sizes.js +2 -3
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-editor/constants.js +1 -1
- package/src/components/image-size-control/test/index.js +47 -60
- package/src/components/index.js +0 -1
- package/src/components/inner-blocks/index.js +5 -1
- package/src/components/inner-blocks/test/index.js +4 -0
- package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -2
- package/src/components/inserter/block-patterns-tab.js +232 -98
- package/src/components/inserter/hooks/use-insertion-point.js +3 -11
- package/src/components/inserter/menu.js +15 -2
- package/src/components/inserter/search-items.js +23 -3
- package/src/components/inserter/style.scss +94 -9
- package/src/components/inserter/test/reusable-blocks-tab.js +6 -6
- package/src/components/inserter/test/search-items.js +6 -0
- package/src/components/inserter-draggable-blocks/index.js +12 -2
- package/src/components/inserter-list-item/style.scss +22 -1
- package/src/components/letter-spacing-control/README.md +55 -0
- package/src/components/line-height-control/index.js +1 -0
- package/src/components/link-control/README.md +3 -3
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/list-view/drop-indicator.js +1 -0
- package/src/components/list-view/style.scss +1 -36
- package/src/components/list-view/use-list-view-drop-zone.js +4 -18
- package/src/components/media-replace-flow/index.js +1 -1
- package/src/components/media-replace-flow/test/index.js +69 -51
- package/src/components/panel-color-settings/test/index.js +4 -4
- package/src/components/preview-options/index.js +2 -2
- package/src/components/preview-options/style.scss +1 -1
- package/src/components/provider/test/use-block-sync.js +131 -165
- package/src/components/responsive-block-control/test/index.js +4 -4
- package/src/components/rich-text/format-toolbar/index.js +1 -1
- package/src/components/rich-text/format-toolbar-container.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +1 -1
- package/src/components/spacing-sizes-control/all-input-control.js +4 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +4 -0
- package/src/components/spacing-sizes-control/index.js +4 -0
- package/src/components/spacing-sizes-control/input-controls.js +4 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +26 -3
- package/src/components/spacing-sizes-control/style.scss +27 -19
- package/src/components/url-input/index.js +1 -1
- package/src/components/use-block-drop-zone/index.js +136 -79
- package/src/components/use-block-drop-zone/test/index.js +333 -81
- package/src/components/use-on-block-drop/index.js +11 -12
- package/src/components/use-on-block-drop/types.ts +1 -0
- package/src/hooks/align.js +3 -2
- package/src/hooks/align.native.js +5 -8
- package/src/hooks/border.js +1 -0
- package/src/hooks/dimensions.js +32 -5
- package/src/hooks/font-size.js +76 -0
- package/src/hooks/layout.js +7 -9
- package/src/hooks/margin.js +20 -14
- package/src/hooks/padding.js +20 -16
- package/src/hooks/style.js +122 -3
- package/src/hooks/test/align.js +96 -72
- package/src/hooks/test/style.js +206 -1
- package/src/hooks/test/use-typography-props.js +22 -0
- package/src/hooks/use-typography-props.js +18 -3
- package/src/hooks/utils.js +10 -7
- package/src/layouts/constrained.js +0 -1
- package/src/layouts/flex.js +1 -1
- package/src/store/actions.js +24 -12
- package/src/store/array.js +1 -6
- package/src/store/defaults.js +3 -0
- package/src/store/reducer.js +31 -24
- package/src/store/selectors.js +28 -21
- package/src/store/test/actions.js +0 -9
- package/src/store/test/selectors.js +1 -1
- package/src/utils/math.js +17 -0
- package/src/utils/pre-parse-patterns.js +12 -7
- package/build/components/inserter/pattern-panel.js +0 -87
- package/build/components/inserter/pattern-panel.js.map +0 -1
- package/build-module/components/inserter/pattern-panel.js +0 -74
- package/build-module/components/inserter/pattern-panel.js.map +0 -1
- package/src/components/inserter/pattern-panel.js +0 -93
|
@@ -129,7 +129,11 @@ export function useInnerBlocksProps() {
|
|
|
129
129
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
130
130
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
131
131
|
const {
|
|
132
|
-
|
|
132
|
+
__unstableDisableLayoutClassNames
|
|
133
|
+
} = options;
|
|
134
|
+
const {
|
|
135
|
+
clientId,
|
|
136
|
+
__unstableLayoutClassNames: layoutClassNames = ''
|
|
133
137
|
} = useBlockEditContext();
|
|
134
138
|
const isSmallScreen = useViewportMatch('medium', '<');
|
|
135
139
|
const {
|
|
@@ -163,7 +167,7 @@ export function useInnerBlocksProps() {
|
|
|
163
167
|
const InnerBlocks = innerBlocksProps.value && innerBlocksProps.onChange ? ControlledInnerBlocks : UncontrolledInnerBlocks;
|
|
164
168
|
return { ...props,
|
|
165
169
|
ref,
|
|
166
|
-
className: classnames(props.className, 'block-editor-block-list__layout', {
|
|
170
|
+
className: classnames(props.className, 'block-editor-block-list__layout', __unstableDisableLayoutClassNames ? '' : layoutClassNames, {
|
|
167
171
|
'has-overlay': hasOverlay
|
|
168
172
|
}),
|
|
169
173
|
children: clientId ? createElement(InnerBlocks, _extends({}, innerBlocksProps, {
|
|
@@ -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","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","hasBlockSupport","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,aAFsB,EAGtBC,0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/D;AAiCA,QAAMJ,GAAG,GAAG9C,YAAY,CAAE,CACzBoB,KAAK,CAAC0B,GADmB,EAEzB5B,gBAAgB,CAAE;AACjByC,IAAAA,YAAY,EAAEtC;AADG,GAAF,CAFS,CAAF,CAAxB;AAOA,QAAM0B,gBAAgB,GAAG;AACxBlB,IAAAA,6BADwB;AAExB,OAAGoB;AAFqB,GAAzB;AAIA,QAAMW,WAAW,GAChBb,gBAAgB,CAACc,KAAjB,IAA0Bd,gBAAgB,CAACe,QAA3C,GACGlB,qBADH,GAEGzB,uBAHJ;AAIA,SAAO,EACN,GAAGC,KADG;AAEN0B,IAAAA,GAFM;AAGNiB,IAAAA,SAAS,EAAEjE,UAAU,CACpBsB,KAAK,CAAC2C,SADc,EAEpB,iCAFoB,EAGpB;AACC,qBAAeZ;AADhB,KAHoB,CAHf;AAUNa,IAAAA,QAAQ,EAAE3C,QAAQ,GACjB,cAAC,WAAD,eAAkB0B,gBAAlB;AAAqC,MAAA,QAAQ,EAAG1B;AAAhD,OADiB,GAGjB,cAAC,cAAD,EAAqB4B,OAArB;AAbK,GAAP;AAgBA;AAEDD,mBAAmB,CAACiB,IAApB,GAA2B1D,mBAA3B,C,CAEA;;AACAsC,oBAAoB,CAACpC,oBAArB,GAA4CA,oBAA5C;AACAoC,oBAAoB,CAACrC,mBAArB,GAA2CA,mBAA3C;;AAEAqC,oBAAoB,CAACqB,OAArB,GAA+B,MAAMlB,mBAAmB,CAACiB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;AACA,eAAenB,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockType,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport getBlockContext from './get-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst context = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif ( ! blockType || ! blockType.providesContext ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getBlockContext( block.attributes, blockType );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ __experimentalLayout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { clientId } = useBlockEditContext();\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 ref = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseBlockDropZone( {\n\t\t\trootClientId: clientId,\n\t\t} ),\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\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{\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","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","__unstableLayoutClassNames","layoutClassNames","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","hasBlockSupport","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;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YAAY,EAAEzC;AADG,GAAF,CAFS,CAAF,CAAxB;AAOA,QAAM0B,gBAAgB,GAAG;AACxBlB,IAAAA,6BADwB;AAExB,OAAGoB;AAFqB,GAAzB;AAIA,QAAMc,WAAW,GAChBhB,gBAAgB,CAACiB,KAAjB,IAA0BjB,gBAAgB,CAACkB,QAA3C,GACGrB,qBADH,GAEGzB,uBAHJ;AAKA,SAAO,EACN,GAAGC,KADG;AAEN0B,IAAAA,GAFM;AAGNoB,IAAAA,SAAS,EAAEpE,UAAU,CACpBsB,KAAK,CAAC8C,SADc,EAEpB,iCAFoB,EAGpBhB,iCAAiC,GAAG,EAAH,GAAQE,gBAHrB,EAIpB;AACC,qBAAeE;AADhB,KAJoB,CAHf;AAWNa,IAAAA,QAAQ,EAAE9C,QAAQ,GACjB,cAAC,WAAD,eAAkB0B,gBAAlB;AAAqC,MAAA,QAAQ,EAAG1B;AAAhD,OADiB,GAGjB,cAAC,cAAD,EAAqB4B,OAArB;AAdK,GAAP;AAiBA;AAEDD,mBAAmB,CAACoB,IAApB,GAA2B7D,mBAA3B,C,CAEA;;AACAsC,oBAAoB,CAACpC,oBAArB,GAA4CA,oBAA5C;AACAoC,oBAAoB,CAACrC,mBAArB,GAA2CA,mBAA3C;;AAEAqC,oBAAoB,CAACwB,OAArB,GAA+B,MAAMrB,mBAAmB,CAACoB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;AACA,eAAetB,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockType,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport getBlockContext from './get-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst context = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif ( ! blockType || ! blockType.providesContext ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\treturn getBlockContext( block.attributes, blockType );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ __experimentalLayout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { __unstableDisableLayoutClassNames } = options;\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 ref = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseBlockDropZone( {\n\t\t\trootClientId: clientId,\n\t\t} ),\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"]}
|
|
@@ -36,7 +36,8 @@ import { store as blockEditorStore } from '../../store';
|
|
|
36
36
|
|
|
37
37
|
export default function useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection) {
|
|
38
38
|
const {
|
|
39
|
-
getSelectedBlocksInitialCaretPosition
|
|
39
|
+
getSelectedBlocksInitialCaretPosition,
|
|
40
|
+
isBlockSelected
|
|
40
41
|
} = useSelect(blockEditorStore);
|
|
41
42
|
const {
|
|
42
43
|
replaceInnerBlocks
|
|
@@ -67,7 +68,7 @@ export default function useInnerBlockTemplateSync(clientId, template, templateLo
|
|
|
67
68
|
const nextBlocks = synchronizeBlocksWithTemplate(currentInnerBlocks, template);
|
|
68
69
|
|
|
69
70
|
if (!isEqual(nextBlocks, currentInnerBlocks)) {
|
|
70
|
-
replaceInnerBlocks(clientId, nextBlocks, currentInnerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0, // This ensures the "initialPosition" doesn't change when applying the template
|
|
71
|
+
replaceInnerBlocks(clientId, nextBlocks, currentInnerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0 && isBlockSelected(clientId), // This ensures the "initialPosition" doesn't change when applying the template
|
|
71
72
|
// If we're supposed to focus the block, we'll focus the first inner block
|
|
72
73
|
// otherwise, we won't apply any auto-focus.
|
|
73
74
|
// This ensures for instance that the focus stays in the inserter when inserting the "buttons" block.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js"],"names":["isEqual","useRef","useLayoutEffect","useSelect","useDispatch","synchronizeBlocksWithTemplate","store","blockEditorStore","useInnerBlockTemplateSync","clientId","template","templateLock","templateInsertUpdatesSelection","getSelectedBlocksInitialCaretPosition","replaceInnerBlocks","innerBlocks","select","getBlocks","existingTemplate","window","queueMicrotask","currentInnerBlocks","shouldApplyTemplate","length","hasTemplateChanged","current","nextBlocks"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,eAAjB,QAAwC,oBAAxC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,6BAAT,QAA8C,mBAA9C;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,yBAAT,CACdC,QADc,EAEdC,QAFc,EAGdC,YAHc,EAIdC,8BAJc,EAKb;AACD,QAAM;AAAEC,IAAAA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js"],"names":["isEqual","useRef","useLayoutEffect","useSelect","useDispatch","synchronizeBlocksWithTemplate","store","blockEditorStore","useInnerBlockTemplateSync","clientId","template","templateLock","templateInsertUpdatesSelection","getSelectedBlocksInitialCaretPosition","isBlockSelected","replaceInnerBlocks","innerBlocks","select","getBlocks","existingTemplate","window","queueMicrotask","currentInnerBlocks","shouldApplyTemplate","length","hasTemplateChanged","current","nextBlocks"],"mappings":"AAAA;AACA;AACA;AAC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AAK,CAAEH,mBAAF,IAAyB,CAAEE,kBAAhC,EAAqD;AACpD;AACA;;AAEDN,MAAAA,gBAAgB,CAACO,OAAjB,GAA2BhB,QAA3B;AACA,YAAMiB,UAAU,GAAGtB,6BAA6B,CAC/CiB,kBAD+C,EAE/CZ,QAF+C,CAAhD;;AAKA,UAAK,CAAEV,OAAO,CAAE2B,UAAF,EAAcL,kBAAd,CAAd,EAAmD;AAClDP,QAAAA,kBAAkB,CACjBN,QADiB,EAEjBkB,UAFiB,EAGjBL,kBAAkB,CAACE,MAAnB,KAA8B,CAA9B,IACCZ,8BADD,IAECe,UAAU,CAACH,MAAX,KAAsB,CAFvB,IAGCV,eAAe,CAAEL,QAAF,CANC,EAOjB;AACA;AACA;AACA;AACAI,QAAAA,qCAAqC,EAXpB,CAAlB;AAaA;AACD,KAvCD;AAwCA,GA7Cc,EA6CZ,CAAEG,WAAF,EAAeN,QAAf,EAAyBC,YAAzB,EAAuCF,QAAvC,CA7CY,CAAf;AA8CA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\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 { getSelectedBlocksInitialCaretPosition, isBlockSelected } =\n\t\tuseSelect( blockEditorStore );\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst innerBlocks = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlocks( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\n\t// Maintain a reference to the previous value so we can do a deep equality check.\n\tconst existingTemplate = useRef( null );\n\tuseLayoutEffect( () => {\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// Exemple: If you remove queueMicrotask here, ctrl + click to insert quote block won't close the inserter.\n\t\twindow.queueMicrotask( () => {\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 = ! isEqual(\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 ( ! isEqual( nextBlocks, currentInnerBlocks ) ) {\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\t}, [ innerBlocks, template, templateLock, clientId ] );\n}\n"]}
|
|
@@ -3,79 +3,21 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { useMemo, useState, useCallback } from '@wordpress/element';
|
|
7
|
-
import { _x } from '@wordpress/i18n';
|
|
8
|
-
import { useAsyncList } from '@wordpress/compose';
|
|
6
|
+
import { useMemo, useState, useCallback, useRef, useEffect } from '@wordpress/element';
|
|
7
|
+
import { _x, __, isRTL } from '@wordpress/i18n';
|
|
8
|
+
import { useAsyncList, useViewportMatch } from '@wordpress/compose';
|
|
9
|
+
import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, __experimentalHStack as HStack, __experimentalNavigatorProvider as NavigatorProvider, __experimentalNavigatorScreen as NavigatorScreen, __experimentalNavigatorButton as NavigatorButton, __experimentalNavigatorBackButton as NavigatorBackButton, FlexBlock, Button } from '@wordpress/components';
|
|
10
|
+
import { Icon, chevronRight, chevronLeft } from '@wordpress/icons';
|
|
11
|
+
import { focus } from '@wordpress/dom';
|
|
9
12
|
/**
|
|
10
13
|
* Internal dependencies
|
|
11
14
|
*/
|
|
12
15
|
|
|
13
|
-
import PatternInserterPanel from './pattern-panel';
|
|
14
16
|
import usePatternsState from './hooks/use-patterns-state';
|
|
15
17
|
import BlockPatternList from '../block-patterns-list';
|
|
16
18
|
import PatternsExplorerModal from './block-patterns-explorer/explorer';
|
|
17
19
|
|
|
18
|
-
function
|
|
19
|
-
let {
|
|
20
|
-
rootClientId,
|
|
21
|
-
onInsert,
|
|
22
|
-
selectedCategory,
|
|
23
|
-
populatedCategories
|
|
24
|
-
} = _ref;
|
|
25
|
-
const [allPatterns,, onClick] = usePatternsState(onInsert, rootClientId);
|
|
26
|
-
const getPatternIndex = useCallback(pattern => {
|
|
27
|
-
var _pattern$categories;
|
|
28
|
-
|
|
29
|
-
if (!((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length)) {
|
|
30
|
-
return Infinity;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const indexedCategories = populatedCategories.reduce((accumulator, _ref2, index) => {
|
|
34
|
-
let {
|
|
35
|
-
name
|
|
36
|
-
} = _ref2;
|
|
37
|
-
accumulator[name] = index;
|
|
38
|
-
return accumulator;
|
|
39
|
-
}, {});
|
|
40
|
-
return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity));
|
|
41
|
-
}, [populatedCategories]);
|
|
42
|
-
const currentCategoryPatterns = useMemo(() => allPatterns.filter(pattern => {
|
|
43
|
-
var _pattern$categories2;
|
|
44
|
-
|
|
45
|
-
return selectedCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory.name);
|
|
46
|
-
}), [allPatterns, selectedCategory]); // Ordering the patterns is important for the async rendering.
|
|
47
|
-
|
|
48
|
-
const orderedPatterns = useMemo(() => {
|
|
49
|
-
return currentCategoryPatterns.sort((a, b) => {
|
|
50
|
-
return getPatternIndex(a) - getPatternIndex(b);
|
|
51
|
-
});
|
|
52
|
-
}, [currentCategoryPatterns, getPatternIndex]);
|
|
53
|
-
const currentShownPatterns = useAsyncList(orderedPatterns);
|
|
54
|
-
|
|
55
|
-
if (!currentCategoryPatterns.length) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return createElement("div", {
|
|
60
|
-
className: "block-editor-inserter__panel-content"
|
|
61
|
-
}, createElement(BlockPatternList, {
|
|
62
|
-
shownPatterns: currentShownPatterns,
|
|
63
|
-
blockPatterns: currentCategoryPatterns,
|
|
64
|
-
onClickPattern: onClick,
|
|
65
|
-
label: selectedCategory.label,
|
|
66
|
-
orientation: "vertical",
|
|
67
|
-
isDraggable: true
|
|
68
|
-
}));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function BlockPatternsTabs(_ref3) {
|
|
72
|
-
let {
|
|
73
|
-
rootClientId,
|
|
74
|
-
onInsert,
|
|
75
|
-
onClickCategory,
|
|
76
|
-
selectedCategory
|
|
77
|
-
} = _ref3;
|
|
78
|
-
const [showPatternsExplorer, setShowPatternsExplorer] = useState(false);
|
|
20
|
+
function usePatternsCategories() {
|
|
79
21
|
const [allPatterns, allCategories] = usePatternsState();
|
|
80
22
|
const hasRegisteredCategory = useCallback(pattern => {
|
|
81
23
|
if (!pattern.categories || !pattern.categories.length) {
|
|
@@ -87,16 +29,16 @@ function BlockPatternsTabs(_ref3) {
|
|
|
87
29
|
|
|
88
30
|
const populatedCategories = useMemo(() => {
|
|
89
31
|
const categories = allCategories.filter(category => allPatterns.some(pattern => {
|
|
90
|
-
var _pattern$
|
|
32
|
+
var _pattern$categories;
|
|
91
33
|
|
|
92
|
-
return (_pattern$
|
|
93
|
-
})).sort((
|
|
34
|
+
return (_pattern$categories = pattern.categories) === null || _pattern$categories === void 0 ? void 0 : _pattern$categories.includes(category.name);
|
|
35
|
+
})).sort((_ref, _ref2) => {
|
|
94
36
|
let {
|
|
95
37
|
name: currentName
|
|
96
|
-
} =
|
|
38
|
+
} = _ref;
|
|
97
39
|
let {
|
|
98
40
|
name: nextName
|
|
99
|
-
} =
|
|
41
|
+
} = _ref2;
|
|
100
42
|
|
|
101
43
|
if (![currentName, nextName].includes('featured')) {
|
|
102
44
|
return 0;
|
|
@@ -114,23 +56,148 @@ function BlockPatternsTabs(_ref3) {
|
|
|
114
56
|
|
|
115
57
|
return categories;
|
|
116
58
|
}, [allPatterns, allCategories]);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
59
|
+
return populatedCategories;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function BlockPatternsCategoryDialog(_ref3) {
|
|
63
|
+
let {
|
|
64
|
+
rootClientId,
|
|
65
|
+
onInsert,
|
|
66
|
+
category
|
|
67
|
+
} = _ref3;
|
|
68
|
+
const container = useRef();
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
const timeout = setTimeout(() => {
|
|
71
|
+
const [firstTabbable] = focus.tabbable.find(container.current);
|
|
72
|
+
firstTabbable === null || firstTabbable === void 0 ? void 0 : firstTabbable.focus();
|
|
73
|
+
});
|
|
74
|
+
return () => clearTimeout(timeout);
|
|
75
|
+
}, [category]);
|
|
76
|
+
return createElement("div", {
|
|
77
|
+
ref: container,
|
|
78
|
+
className: "block-editor-inserter__patterns-category-panel"
|
|
79
|
+
}, createElement(BlockPatternsCategoryPanel, {
|
|
124
80
|
rootClientId: rootClientId,
|
|
125
81
|
onInsert: onInsert,
|
|
126
|
-
|
|
127
|
-
|
|
82
|
+
category: category
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
export function BlockPatternsCategoryPanel(_ref4) {
|
|
86
|
+
let {
|
|
87
|
+
rootClientId,
|
|
88
|
+
onInsert,
|
|
89
|
+
category
|
|
90
|
+
} = _ref4;
|
|
91
|
+
const [allPatterns,, onClick] = usePatternsState(onInsert, rootClientId);
|
|
92
|
+
const availableCategories = usePatternsCategories();
|
|
93
|
+
const currentCategoryPatterns = useMemo(() => allPatterns.filter(pattern => {
|
|
94
|
+
var _pattern$categories$f, _pattern$categories3;
|
|
95
|
+
|
|
96
|
+
if (category.name !== 'uncategorized') {
|
|
97
|
+
var _pattern$categories2;
|
|
98
|
+
|
|
99
|
+
return (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(category.name);
|
|
100
|
+
} // The uncategorized category should show all the patterns without any category
|
|
101
|
+
// or with no available category.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
const availablePatternCategories = (_pattern$categories$f = (_pattern$categories3 = pattern.categories) === null || _pattern$categories3 === void 0 ? void 0 : _pattern$categories3.filter(cat => availableCategories.find(availableCategory => availableCategory.name === cat))) !== null && _pattern$categories$f !== void 0 ? _pattern$categories$f : [];
|
|
105
|
+
return availablePatternCategories.length === 0;
|
|
106
|
+
}), [allPatterns, category]);
|
|
107
|
+
const currentShownPatterns = useAsyncList(currentCategoryPatterns);
|
|
108
|
+
|
|
109
|
+
if (!currentCategoryPatterns.length) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return createElement("div", null, createElement("div", {
|
|
114
|
+
className: "block-editor-inserter__patterns-category-panel-title"
|
|
115
|
+
}, category.label), createElement("p", null, category.description), createElement(BlockPatternList, {
|
|
116
|
+
shownPatterns: currentShownPatterns,
|
|
117
|
+
blockPatterns: currentCategoryPatterns,
|
|
118
|
+
onClickPattern: onClick,
|
|
119
|
+
label: category.label,
|
|
120
|
+
orientation: "vertical",
|
|
121
|
+
category: category.label,
|
|
122
|
+
isDraggable: true
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function BlockPatternsTabs(_ref5) {
|
|
127
|
+
let {
|
|
128
|
+
onSelectCategory,
|
|
129
|
+
selectedCategory,
|
|
130
|
+
onInsert,
|
|
131
|
+
rootClientId
|
|
132
|
+
} = _ref5;
|
|
133
|
+
const [showPatternsExplorer, setShowPatternsExplorer] = useState(false);
|
|
134
|
+
const categories = usePatternsCategories();
|
|
135
|
+
const isMobile = useViewportMatch('medium', '<');
|
|
136
|
+
return createElement(Fragment, null, !isMobile && createElement("div", {
|
|
137
|
+
className: "block-editor-inserter__block-patterns-tabs-container"
|
|
138
|
+
}, createElement("nav", {
|
|
139
|
+
"aria-label": __('Block pattern categories')
|
|
140
|
+
}, createElement(ItemGroup, {
|
|
141
|
+
role: "list",
|
|
142
|
+
className: "block-editor-inserter__block-patterns-tabs"
|
|
143
|
+
}, categories.map(category => createElement(Item, {
|
|
144
|
+
role: "listitem",
|
|
145
|
+
key: category.name,
|
|
146
|
+
onClick: () => onSelectCategory(category),
|
|
147
|
+
className: category === selectedCategory ? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category' : 'block-editor-inserter__patterns-category',
|
|
148
|
+
"aria-label": category.label,
|
|
149
|
+
"aria-current": category === selectedCategory ? 'true' : undefined
|
|
150
|
+
}, createElement(HStack, null, createElement(FlexBlock, null, category.label), createElement(Icon, {
|
|
151
|
+
icon: chevronRight
|
|
152
|
+
})))), createElement("div", {
|
|
153
|
+
role: "presentation",
|
|
154
|
+
className: "block-editor-inserter__patterns-fill-space"
|
|
155
|
+
}), createElement("div", {
|
|
156
|
+
role: "listitem"
|
|
157
|
+
}, createElement(Button, {
|
|
158
|
+
className: "block-editor-inserter__patterns-explore-button",
|
|
159
|
+
onClick: () => setShowPatternsExplorer(true),
|
|
160
|
+
variant: "secondary"
|
|
161
|
+
}, __('Explore all patterns')))))), isMobile && createElement(BlockPatternsTabNavigation, {
|
|
162
|
+
onInsert: onInsert,
|
|
163
|
+
rootClientId: rootClientId
|
|
128
164
|
}), showPatternsExplorer && createElement(PatternsExplorerModal, {
|
|
129
|
-
initialCategory:
|
|
130
|
-
patternCategories:
|
|
165
|
+
initialCategory: selectedCategory,
|
|
166
|
+
patternCategories: categories,
|
|
131
167
|
onModalClose: () => setShowPatternsExplorer(false)
|
|
132
168
|
}));
|
|
133
169
|
}
|
|
134
170
|
|
|
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
|
+
|
|
135
202
|
export default BlockPatternsTabs;
|
|
136
203
|
//# 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","_x","useAsyncList","PatternInserterPanel","usePatternsState","BlockPatternList","PatternsExplorerModal","BlockPatternsCategory","rootClientId","onInsert","selectedCategory","populatedCategories","allPatterns","onClick","getPatternIndex","pattern","categories","length","Infinity","indexedCategories","reduce","accumulator","index","name","Math","min","map","cat","undefined","currentCategoryPatterns","filter","includes","orderedPatterns","sort","a","b","currentShownPatterns","label","BlockPatternsTabs","onClickCategory","showPatternsExplorer","setShowPatternsExplorer","allCategories","hasRegisteredCategory","some","category","currentName","nextName","find","push","patternCategory"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,QAAlB,EAA4BC,WAA5B,QAA+C,oBAA/C;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,iBAAjC;AACA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AACA,OAAOC,qBAAP,MAAkC,oCAAlC;;AAEA,SAASC,qBAAT,OAKI;AAAA,MAL4B;AAC/BC,IAAAA,YAD+B;AAE/BC,IAAAA,QAF+B;AAG/BC,IAAAA,gBAH+B;AAI/BC,IAAAA;AAJ+B,GAK5B;AACH,QAAM,CAAEC,WAAF,GAAiBC,OAAjB,IAA6BT,gBAAgB,CAClDK,QADkD,EAElDD,YAFkD,CAAnD;AAKA,QAAMM,eAAe,GAAGd,WAAW,CAChCe,OAAF,IAAe;AAAA;;AACd,QAAK,yBAAEA,OAAO,CAACC,UAAV,gDAAE,oBAAoBC,MAAtB,CAAL,EAAoC;AACnC,aAAOC,QAAP;AACA;;AACD,UAAMC,iBAAiB,GAAGR,mBAAmB,CAACS,MAApB,CACzB,CAAEC,WAAF,SAAyBC,KAAzB,KAAoC;AAAA,UAArB;AAAEC,QAAAA;AAAF,OAAqB;AACnCF,MAAAA,WAAW,CAAEE,IAAF,CAAX,GAAsBD,KAAtB;AACA,aAAOD,WAAP;AACA,KAJwB,EAKzB,EALyB,CAA1B;AAOA,WAAOG,IAAI,CAACC,GAAL,CACN,GAAGV,OAAO,CAACC,UAAR,CAAmBU,GAAnB,CAA0BC,GAAF,IAC1BR,iBAAiB,CAAEQ,GAAF,CAAjB,KAA6BC,SAA7B,GACGT,iBAAiB,CAAEQ,GAAF,CADpB,GAE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Ae,CAAE4B,qBAAqB,CAAE5B,OAAF,CADvC,KAGA,CAAEC,UAAU,CAACgC,IAAX,CACCH,QAAF,IAAgBA,QAAQ,CAACtB,IAAT,KAAkB,eADjC,CAJH,EAOE;AACDP,MAAAA,UAAU,CAACiC,IAAX,CAAiB;AAChB1B,QAAAA,IAAI,EAAE,eADU;AAEhBc,QAAAA,KAAK,EAAEpC,EAAE,CAAE,eAAF;AAFO,OAAjB;AAIA;;AAED,WAAOe,UAAP;AACA,GA7BkC,EA6BhC,CAAEJ,WAAF,EAAe8B,aAAf,CA7BgC,CAAnC;AA+BA,QAAMQ,eAAe,GAAGxC,gBAAgB,GACrCA,gBADqC,GAErCC,mBAAmB,CAAE,CAAF,CAFtB;AAIA,SACC,8BACC,cAAC,oBAAD;AACC,IAAA,gBAAgB,EAAGuC,eADpB;AAEC,IAAA,iBAAiB,EAAGvC,mBAFrB;AAGC,IAAA,eAAe,EAAG4B,eAHnB;AAIC,IAAA,mBAAmB,EAAG,MAAME,uBAAuB,CAAE,IAAF;AAJpD,IADD,EAOG,CAAED,oBAAF,IACD,cAAC,qBAAD;AACC,IAAA,YAAY,EAAGhC,YADhB;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,gBAAgB,EAAGyC,eAHpB;AAIC,IAAA,mBAAmB,EAAGvC;AAJvB,IARF,EAeG6B,oBAAoB,IACrB,cAAC,qBAAD;AACC,IAAA,eAAe,EAAGU,eADnB;AAEC,IAAA,iBAAiB,EAAGvC,mBAFrB;AAGC,IAAA,YAAY,EAAG,MAAM8B,uBAAuB,CAAE,KAAF;AAH7C,IAhBF,CADD;AAyBA;;AAED,eAAeH,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState, useCallback } from '@wordpress/element';\nimport { _x } from '@wordpress/i18n';\nimport { useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PatternInserterPanel from './pattern-panel';\nimport usePatternsState from './hooks/use-patterns-state';\nimport BlockPatternList from '../block-patterns-list';\nimport PatternsExplorerModal from './block-patterns-explorer/explorer';\n\nfunction BlockPatternsCategory( {\n\trootClientId,\n\tonInsert,\n\tselectedCategory,\n\tpopulatedCategories,\n} ) {\n\tconst [ allPatterns, , onClick ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\n\tconst getPatternIndex = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories?.length ) {\n\t\t\t\treturn Infinity;\n\t\t\t}\n\t\t\tconst indexedCategories = populatedCategories.reduce(\n\t\t\t\t( accumulator, { name }, index ) => {\n\t\t\t\t\taccumulator[ name ] = index;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t\treturn Math.min(\n\t\t\t\t...pattern.categories.map( ( cat ) =>\n\t\t\t\t\tindexedCategories[ cat ] !== undefined\n\t\t\t\t\t\t? indexedCategories[ cat ]\n\t\t\t\t\t\t: Infinity\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\t[ populatedCategories ]\n\t);\n\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) =>\n\t\t\t\tselectedCategory.name === 'uncategorized'\n\t\t\t\t\t? getPatternIndex( pattern ) === Infinity\n\t\t\t\t\t: pattern.categories?.includes( selectedCategory.name )\n\t\t\t),\n\t\t[ allPatterns, selectedCategory ]\n\t);\n\n\t// Ordering the patterns is important for the async rendering.\n\tconst orderedPatterns = useMemo( () => {\n\t\treturn currentCategoryPatterns.sort( ( a, b ) => {\n\t\t\treturn getPatternIndex( a ) - getPatternIndex( b );\n\t\t} );\n\t}, [ currentCategoryPatterns, getPatternIndex ] );\n\n\tconst currentShownPatterns = useAsyncList( orderedPatterns );\n\n\tif ( ! currentCategoryPatterns.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-editor-inserter__panel-content\">\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={ selectedCategory.label }\n\t\t\t\torientation=\"vertical\"\n\t\t\t\tisDraggable\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction BlockPatternsTabs( {\n\trootClientId,\n\tonInsert,\n\tonClickCategory,\n\tselectedCategory,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\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\tconst patternCategory = selectedCategory\n\t\t? selectedCategory\n\t\t: populatedCategories[ 0 ];\n\n\treturn (\n\t\t<>\n\t\t\t<PatternInserterPanel\n\t\t\t\tselectedCategory={ patternCategory }\n\t\t\t\tpatternCategories={ populatedCategories }\n\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\topenPatternExplorer={ () => setShowPatternsExplorer( true ) }\n\t\t\t/>\n\t\t\t{ ! showPatternsExplorer && (\n\t\t\t\t<BlockPatternsCategory\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\tselectedCategory={ patternCategory }\n\t\t\t\t\tpopulatedCategories={ populatedCategories }\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={ patternCategory }\n\t\t\t\t\tpatternCategories={ populatedCategories }\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"]}
|
|
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,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AACA,OAAOC,qBAAP,MAAkC,oCAAlC;;AAEA,SAASC,qBAAT,GAAiC;AAChC,QAAM,CAAEC,WAAF,EAAeC,aAAf,IAAiCL,gBAAgB,EAAvD;AAEA,QAAMM,qBAAqB,GAAGlC,WAAW,CACtCmC,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,CAVw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xC;AAEA,SACC,cAAC,iBAAD;AAAmB,IAAA,WAAW,EAAC;AAA/B,KACC,cAAC,eAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,KACC,cAAC,SAAD,QACGK,UAAU,CAACuC,GAAX,CAAkBnC,QAAF,IACjB,cAAC,eAAD;AACC,IAAA,GAAG,EAAGA,QAAQ,CAACC,IADhB;AAEC,IAAA,IAAI,EAAI,aAAaD,QAAQ,CAACC,IAAM,EAFrC;AAGC,IAAA,EAAE,EAAG9B,IAHN;AAIC,IAAA,QAAQ;AAJT,KAMC,cAAC,MAAD,QACC,cAAC,SAAD,QAAa6B,QAAQ,CAACU,KAAtB,CADD,EAEC,cAAC,IAAD;AACC,IAAA,IAAI,EACH7C,KAAK,KAAKqB,WAAL,GAAmBD;AAF1B,IAFD,CAND,CADC,CADH,CADD,CADD,EAuBGW,UAAU,CAACuC,GAAX,CAAkBnC,QAAF,IACjB,cAAC,eAAD;AACC,IAAA,GAAG,EAAGA,QAAQ,CAACC,IADhB;AAEC,IAAA,IAAI,EAAI,aAAaD,QAAQ,CAACC,IAAM;AAFrC,KAIC,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,11 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { castArray } from 'lodash';
|
|
5
1
|
/**
|
|
6
2
|
* WordPress dependencies
|
|
7
3
|
*/
|
|
8
|
-
|
|
9
4
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
10
5
|
import { isUnmodifiedDefaultBlock } from '@wordpress/blocks';
|
|
11
6
|
import { _n, sprintf } from '@wordpress/i18n';
|
|
@@ -99,8 +94,9 @@ function useInsertionPoint(_ref) {
|
|
|
99
94
|
insertBlocks(blocks, destinationIndex, destinationRootClientId, true, shouldFocusBlock || shouldForceFocusBlock ? 0 : null, meta);
|
|
100
95
|
}
|
|
101
96
|
|
|
97
|
+
const blockLength = Array.isArray(blocks) ? blocks.length : 1;
|
|
102
98
|
const message = sprintf( // translators: %d: the name of the block that has been added
|
|
103
|
-
_n('%d block added.', '%d blocks added.',
|
|
99
|
+
_n('%d block added.', '%d blocks added.', blockLength), blockLength);
|
|
104
100
|
speak(message);
|
|
105
101
|
|
|
106
102
|
if (onSelect) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-insertion-point.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-insertion-point.js"],"names":["useDispatch","useSelect","isUnmodifiedDefaultBlock","_n","sprintf","speak","useCallback","store","blockEditorStore","useInsertionPoint","rootClientId","insertionIndex","clientId","isAppender","onSelect","shouldFocusBlock","getSelectedBlock","destinationRootClientId","destinationIndex","select","getSelectedBlockClientId","getBlockRootClientId","getBlockIndex","getBlockOrder","selectedBlockClientId","_destinationRootClientId","_destinationIndex","undefined","length","replaceBlocks","insertBlocks","showInsertionPoint","hideInsertionPoint","onInsertBlocks","blocks","meta","shouldForceFocusBlock","selectedBlock","blockLength","Array","isArray","message","onToggleInsertionPoint","show"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,gBAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,OAOI;AAAA,MAPwB;AAC3BC,IAAAA,YAAY,GAAG,EADY;AAE3BC,IAAAA,cAF2B;AAG3BC,IAAAA,QAH2B;AAI3BC,IAAAA,UAJ2B;AAK3BC,IAAAA,QAL2B;AAM3BC,IAAAA,gBAAgB,GAAG;AANQ,GAOxB;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAuBf,SAAS,CAAEO,gBAAF,CAAtC;AACA,QAAM;AAAES,IAAAA,uBAAF;AAA2BC,IAAAA;AAA3B,MAAgDjB,SAAS,CAC5DkB,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,wBADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,aAHK;AAILC,MAAAA;AAJK,QAKFJ,MAAM,CAAEX,gBAAF,CALV;AAMA,UAAMgB,qBAAqB,GAAGJ,wBAAwB,EAAtD;AAEA,QAAIK,wBAAwB,GAAGf,YAA/B;;AACA,QAAIgB,iBAAJ;;AAEA,QAAKf,cAAc,KAAKgB,SAAxB,EAAoC;AACnC;AACAD,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IAAIqB,qBAApB,GAA4C,CAA5C,GAAgD,IALrC,EAMXD,IANW,CAAZ;AAQA;;AACD,UAAMG,WAAW,GAAGC,KAAK,CAACC,OAAN,CAAeN,MAAf,IAA0BA,MAAM,CAACN,MAAjC,GAA0C,CAA9D;AACA,UAAMa,OAAO,GAAGrC,OAAO,EACtB;AACAD,IAAAA,EAAE,CAAE,iBAAF,EAAqB,kBAArB,EAAyCmC,WAAzC,CAFoB,EAGtBA,WAHsB,CAAvB;AAKAjC,IAAAA,KAAK,CAAEoC,OAAF,CAAL;;AAEA,QAAK3B,QAAL,EAAgB;AACfA,MAAAA,QAAQ;AACR;AACD,GArCgC,EAsCjC,CACCD,UADD,EAECG,gBAFD,EAGCa,aAHD,EAICC,YAJD,EAKCb,uBALD,EAMCC,gBAND,EAOCJ,QAPD,EAQCC,gBARD,CAtCiC,CAAlC;AAkDA,QAAM2B,sBAAsB,GAAGpC,WAAW,CACvCqC,IAAF,IAAY;AACX,QAAKA,IAAL,EAAY;AACXZ,MAAAA,kBAAkB,CAAEd,uBAAF,EAA2BC,gBAA3B,CAAlB;AACA,KAFD,MAEO;AACNc,MAAAA,kBAAkB;AAClB;AACD,GAPwC,EAQzC,CACCD,kBADD,EAECC,kBAFD,EAGCf,uBAHD,EAICC,gBAJD,CARyC,CAA1C;AAgBA,SAAO,CAAED,uBAAF,EAA2BgB,cAA3B,EAA2CS,sBAA3C,CAAP;AACA;;AAED,eAAejC,iBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * @typedef WPInserterConfig\n *\n * @property {string=} rootClientId If set, insertion will be into the\n * block with this ID.\n * @property {number=} insertionIndex If set, insertion will be into this\n * explicit position.\n * @property {string=} clientId If set, insertion will be after the\n * block with this ID.\n * @property {boolean=} isAppender Whether the inserter is an appender\n * or not.\n * @property {Function=} onSelect Called after insertion.\n */\n\n/**\n * Returns the insertion point state given the inserter config.\n *\n * @param {WPInserterConfig} config Inserter Config.\n * @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).\n */\nfunction useInsertionPoint( {\n\trootClientId = '',\n\tinsertionIndex,\n\tclientId,\n\tisAppender,\n\tonSelect,\n\tshouldFocusBlock = true,\n} ) {\n\tconst { getSelectedBlock } = useSelect( blockEditorStore );\n\tconst { destinationRootClientId, destinationIndex } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\tlet _destinationRootClientId = rootClientId;\n\t\t\tlet _destinationIndex;\n\n\t\t\tif ( insertionIndex !== undefined ) {\n\t\t\t\t// Insert into a specific index.\n\t\t\t\t_destinationIndex = insertionIndex;\n\t\t\t} else if ( clientId ) {\n\t\t\t\t// Insert after a specific client ID.\n\t\t\t\t_destinationIndex = getBlockIndex( clientId );\n\t\t\t} else if ( ! isAppender && selectedBlockClientId ) {\n\t\t\t\t_destinationRootClientId = getBlockRootClientId(\n\t\t\t\t\tselectedBlockClientId\n\t\t\t\t);\n\t\t\t\t_destinationIndex = getBlockIndex( selectedBlockClientId ) + 1;\n\t\t\t} else {\n\t\t\t\t// Insert at the end of the list.\n\t\t\t\t_destinationIndex = getBlockOrder(\n\t\t\t\t\t_destinationRootClientId\n\t\t\t\t).length;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tdestinationRootClientId: _destinationRootClientId,\n\t\t\t\tdestinationIndex: _destinationIndex,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId, insertionIndex, clientId, isAppender ]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tinsertBlocks,\n\t\tshowInsertionPoint,\n\t\thideInsertionPoint,\n\t} = useDispatch( blockEditorStore );\n\n\tconst onInsertBlocks = useCallback(\n\t\t( blocks, meta, shouldForceFocusBlock = false ) => {\n\t\t\tconst selectedBlock = getSelectedBlock();\n\n\t\t\tif (\n\t\t\t\t! isAppender &&\n\t\t\t\tselectedBlock &&\n\t\t\t\tisUnmodifiedDefaultBlock( selectedBlock )\n\t\t\t) {\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tselectedBlock.clientId,\n\t\t\t\t\tblocks,\n\t\t\t\t\tnull,\n\t\t\t\t\tshouldFocusBlock || shouldForceFocusBlock ? 0 : null,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\tdestinationIndex,\n\t\t\t\t\tdestinationRootClientId,\n\t\t\t\t\ttrue,\n\t\t\t\t\tshouldFocusBlock || shouldForceFocusBlock ? 0 : null,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst blockLength = Array.isArray( blocks ) ? blocks.length : 1;\n\t\t\tconst message = sprintf(\n\t\t\t\t// translators: %d: the name of the block that has been added\n\t\t\t\t_n( '%d block added.', '%d blocks added.', blockLength ),\n\t\t\t\tblockLength\n\t\t\t);\n\t\t\tspeak( message );\n\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect();\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tisAppender,\n\t\t\tgetSelectedBlock,\n\t\t\treplaceBlocks,\n\t\t\tinsertBlocks,\n\t\t\tdestinationRootClientId,\n\t\t\tdestinationIndex,\n\t\t\tonSelect,\n\t\t\tshouldFocusBlock,\n\t\t]\n\t);\n\n\tconst onToggleInsertionPoint = useCallback(\n\t\t( show ) => {\n\t\t\tif ( show ) {\n\t\t\t\tshowInsertionPoint( destinationRootClientId, destinationIndex );\n\t\t\t} else {\n\t\t\t\thideInsertionPoint();\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tshowInsertionPoint,\n\t\t\thideInsertionPoint,\n\t\t\tdestinationRootClientId,\n\t\t\tdestinationIndex,\n\t\t]\n\t);\n\n\treturn [ destinationRootClientId, onInsertBlocks, onToggleInsertionPoint ];\n}\n\nexport default useInsertionPoint;\n"]}
|
|
@@ -19,7 +19,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
19
19
|
import Tips from './tips';
|
|
20
20
|
import InserterPreviewPanel from './preview-panel';
|
|
21
21
|
import BlockTypesTab from './block-types-tab';
|
|
22
|
-
import BlockPatternsTabs from './block-patterns-tab';
|
|
22
|
+
import BlockPatternsTabs, { BlockPatternsCategoryDialog } from './block-patterns-tab';
|
|
23
23
|
import ReusableBlocksTab from './reusable-blocks-tab';
|
|
24
24
|
import InserterSearchResults from './search-results';
|
|
25
25
|
import useInsertionPoint from './hooks/use-insertion-point';
|
|
@@ -42,6 +42,7 @@ function InserterMenu(_ref, ref) {
|
|
|
42
42
|
const [filterValue, setFilterValue] = useState(__experimentalFilterValue);
|
|
43
43
|
const [hoveredItem, setHoveredItem] = useState(null);
|
|
44
44
|
const [selectedPatternCategory, setSelectedPatternCategory] = useState(null);
|
|
45
|
+
const [selectedTab, setSelectedTab] = useState(null);
|
|
45
46
|
const [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint] = useInsertionPoint({
|
|
46
47
|
rootClientId,
|
|
47
48
|
clientId,
|
|
@@ -96,7 +97,7 @@ function InserterMenu(_ref, ref) {
|
|
|
96
97
|
const patternsTab = useMemo(() => createElement(BlockPatternsTabs, {
|
|
97
98
|
rootClientId: destinationRootClientId,
|
|
98
99
|
onInsert: onInsertPattern,
|
|
99
|
-
|
|
100
|
+
onSelectCategory: onClickPatternCategory,
|
|
100
101
|
selectedCategory: selectedPatternCategory
|
|
101
102
|
}), [destinationRootClientId, onInsertPattern, onClickPatternCategory, selectedPatternCategory]);
|
|
102
103
|
const reusableBlocksTab = useMemo(() => createElement(ReusableBlocksTab, {
|
|
@@ -119,6 +120,7 @@ function InserterMenu(_ref, ref) {
|
|
|
119
120
|
searchRef.current.focus();
|
|
120
121
|
}
|
|
121
122
|
}));
|
|
123
|
+
const showPatternPanel = selectedTab === 'patterns' && !filterValue && selectedPatternCategory;
|
|
122
124
|
const showAsTabs = !filterValue && (showPatterns || hasReusableBlocks);
|
|
123
125
|
return createElement("div", {
|
|
124
126
|
className: "block-editor-inserter__menu"
|
|
@@ -151,11 +153,16 @@ function InserterMenu(_ref, ref) {
|
|
|
151
153
|
})), showAsTabs && createElement(InserterTabs, {
|
|
152
154
|
showPatterns: showPatterns,
|
|
153
155
|
showReusableBlocks: hasReusableBlocks,
|
|
154
|
-
prioritizePatterns: prioritizePatterns
|
|
156
|
+
prioritizePatterns: prioritizePatterns,
|
|
157
|
+
onSelect: setSelectedTab
|
|
155
158
|
}, getCurrentTab), !filterValue && !showAsTabs && createElement("div", {
|
|
156
159
|
className: "block-editor-inserter__no-tab-container"
|
|
157
160
|
}, blocksTab)), showInserterHelpPanel && hoveredItem && createElement(InserterPreviewPanel, {
|
|
158
161
|
item: hoveredItem
|
|
162
|
+
}), showPatternPanel && createElement(BlockPatternsCategoryDialog, {
|
|
163
|
+
rootClientId: destinationRootClientId,
|
|
164
|
+
onInsert: onInsertPattern,
|
|
165
|
+
category: selectedPatternCategory
|
|
159
166
|
}));
|
|
160
167
|
}
|
|
161
168
|
|