@wordpress/block-editor 9.8.1-next.957ca95e4c.0 → 10.0.1
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 +6 -0
- package/README.md +13 -1
- package/build/components/alignment-control/ui.js +6 -5
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/autocomplete/index.js +2 -2
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-actions/index.js +5 -9
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +5 -5
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-content-overlay/index.js +2 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.js +2 -1
- package/build/components/block-draggable/draggable-chip.js.map +1 -1
- package/build/components/block-edit/edit.js +1 -1
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-inspector/index.js +125 -17
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-compact.native.js +2 -1
- package/build/components/block-list/block-list-compact.native.js.map +1 -1
- package/build/components/block-list/block.js +40 -9
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/index.js +4 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +14 -11
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +3 -2
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +3 -9
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +1 -2
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +7 -12
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js +20 -21
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-list-appender/index.native.js +1 -7
- package/build/components/block-list-appender/index.native.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +3 -1
- package/build/components/block-lock/use-block-lock.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +20 -10
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mover/button.js +4 -6
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +4 -6
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +24 -8
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-popover/inbetween.js +82 -52
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +31 -7
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js +4 -2
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +3 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +3 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/preview-panel.js +7 -1
- package/build/components/block-styles/preview-panel.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +114 -25
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/index.js +9 -8
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +3 -2
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +13 -5
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +33 -15
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +4 -9
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +9 -8
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +13 -8
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +71 -0
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -0
- package/build/components/block-vertical-alignment-control/ui.js +5 -2
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +5 -6
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +1 -1
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +8 -3
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/iframe/index.js +31 -4
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inner-blocks/default-block-appender.js +1 -7
- package/build/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build/components/inner-blocks/index.js +9 -3
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +28 -17
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +28 -4
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/index.js +3 -6
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/library.js +14 -3
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +21 -8
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +1 -1
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/tabs.js +11 -4
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +6 -3
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/search-item.js +36 -5
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/block.js +23 -11
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +19 -2
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +30 -28
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +8 -4
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +0 -1
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/provider/use-block-sync.js +1 -7
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +1 -1
- package/build/components/publish-date-time-picker/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +9 -9
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +31 -21
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +11 -20
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/spacing-sizes-control/linked-button.js +2 -3
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -4
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/text-decoration-control/index.js +19 -15
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +25 -17
- package/build/components/text-transform-control/index.js.map +1 -1
- package/build/components/tool-selector/index.js +6 -11
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +6 -4
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/url-popover/index.js +1 -1
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +7 -4
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +9 -28
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +1 -7
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/hooks/align.js +14 -2
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/color-panel.js +2 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/content-lock-ui.js +145 -0
- package/build/hooks/content-lock-ui.js.map +1 -0
- package/build/hooks/duotone.js +8 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +14 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +11 -9
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/metadata-name.js +55 -0
- package/build/hooks/metadata-name.js.map +1 -0
- package/build/hooks/metadata.js +65 -0
- package/build/hooks/metadata.js.map +1 -0
- package/build/hooks/typography.js +10 -11
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-typography-props.js +51 -0
- package/build/hooks/use-typography-props.js.map +1 -0
- package/build/hooks/utils.js +3 -1
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/constrained.js +59 -20
- package/build/layouts/constrained.js.map +1 -1
- package/build/store/actions.js +65 -21
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +43 -19
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +96 -10
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +1 -1
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +6 -5
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/autocomplete/index.js +2 -2
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +5 -8
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +5 -5
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +2 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.js +2 -1
- package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
- package/build-module/components/block-edit/edit.js +1 -1
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-inspector/index.js +127 -19
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-compact.native.js +2 -1
- package/build-module/components/block-list/block-list-compact.native.js.map +1 -1
- package/build-module/components/block-list/block.js +41 -9
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/index.js +4 -4
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +13 -11
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +3 -2
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +3 -8
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +1 -2
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +7 -12
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +20 -20
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.native.js +1 -6
- package/build-module/components/block-list-appender/index.native.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +3 -1
- package/build-module/components/block-lock/use-block-lock.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +20 -9
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +4 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +4 -5
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +24 -7
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +83 -53
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +31 -7
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +4 -2
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +3 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +3 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/preview-panel.js +6 -1
- package/build-module/components/block-styles/preview-panel.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +115 -27
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +9 -8
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +3 -2
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +12 -5
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +30 -15
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +4 -9
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +9 -8
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +13 -8
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +59 -0
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -0
- package/build-module/components/block-vertical-alignment-control/ui.js +5 -2
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +5 -6
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +1 -1
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +8 -3
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/iframe/index.js +32 -5
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inner-blocks/default-block-appender.js +1 -6
- package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +9 -3
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +28 -17
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +28 -4
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -6
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/library.js +14 -3
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +20 -8
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +1 -1
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/tabs.js +11 -4
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +6 -2
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/search-item.js +37 -6
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/block.js +23 -11
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +19 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +30 -28
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +8 -4
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +0 -1
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +1 -6
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +1 -1
- package/build-module/components/publish-date-time-picker/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +10 -10
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +31 -20
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +11 -18
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/spacing-sizes-control/linked-button.js +2 -3
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -4
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/text-decoration-control/index.js +21 -16
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +28 -20
- package/build-module/components/text-transform-control/index.js.map +1 -1
- package/build-module/components/tool-selector/index.js +6 -11
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +6 -4
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/url-popover/index.js +1 -1
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +7 -4
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +9 -28
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +1 -6
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/hooks/align.js +12 -2
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/color-panel.js +2 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +128 -0
- package/build-module/hooks/content-lock-ui.js.map +1 -0
- package/build-module/hooks/duotone.js +6 -1
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +4 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +11 -9
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/metadata-name.js +45 -0
- package/build-module/hooks/metadata-name.js.map +1 -0
- package/build-module/hooks/metadata.js +50 -0
- package/build-module/hooks/metadata.js.map +1 -0
- package/build-module/hooks/typography.js +10 -11
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +38 -0
- package/build-module/hooks/use-typography-props.js.map +1 -0
- package/build-module/hooks/utils.js +4 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/constrained.js +61 -22
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/store/actions.js +58 -20
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +41 -19
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +81 -10
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +1 -1
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +142 -46
- package/build-style/style.css +142 -46
- package/package.json +28 -28
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +137 -108
- package/src/components/alignment-control/test/index.js +124 -33
- package/src/components/alignment-control/ui.js +8 -3
- package/src/components/autocomplete/index.js +2 -5
- package/src/components/block-actions/index.js +9 -8
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +108 -65
- package/src/components/block-alignment-control/test/index.js +95 -31
- package/src/components/block-alignment-control/ui.js +2 -2
- package/src/components/block-compare/test/__snapshots__/block-view.js.snap +28 -26
- package/src/components/block-compare/test/block-view.js +3 -3
- package/src/components/block-content-overlay/index.js +2 -6
- package/src/components/block-content-overlay/style.scss +24 -3
- package/src/components/block-draggable/draggable-chip.js +4 -1
- package/src/components/block-edit/edit.js +5 -1
- package/src/components/block-edit/test/edit.js +23 -21
- package/src/components/block-icon/test/__snapshots__/index.js.snap +22 -0
- package/src/components/block-icon/test/index.js +31 -16
- package/src/components/block-inspector/index.js +126 -12
- package/src/components/block-inspector/style.scss +7 -1
- package/src/components/block-list/block-list-compact.native.js +1 -1
- package/src/components/block-list/block.js +53 -13
- package/src/components/block-list/index.js +4 -4
- package/src/components/block-list/style.scss +57 -11
- package/src/components/block-list/test/block-list-context.native.js +11 -13
- package/src/components/block-list/use-block-props/index.js +10 -10
- package/src/components/block-list/use-block-props/use-block-class-names.js +4 -1
- package/src/components/block-list/use-block-props/use-focus-first-element.js +3 -8
- package/src/components/block-list/use-block-props/use-is-hovered.js +2 -2
- package/src/components/block-list/use-in-between-inserter.js +11 -13
- package/src/components/block-list-appender/index.js +27 -18
- package/src/components/block-list-appender/index.native.js +3 -6
- package/src/components/block-lock/use-block-lock.js +2 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +15 -9
- package/src/components/block-mover/button.js +6 -5
- package/src/components/block-mover/index.js +8 -7
- package/src/components/block-mover/index.native.js +20 -13
- package/src/components/block-popover/inbetween.js +124 -62
- package/src/components/block-popover/index.js +47 -8
- package/src/components/block-popover/style.scss +3 -4
- package/src/components/block-preview/auto.js +4 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -0
- package/src/components/block-settings-menu-controls/README.md +9 -0
- package/src/components/block-settings-menu-controls/index.js +13 -2
- package/src/components/block-styles/preview-panel.js +3 -0
- package/src/components/block-switcher/block-transformations-menu.js +127 -33
- package/src/components/block-switcher/style.scss +4 -2
- package/src/components/block-title/test/index.js +28 -25
- package/src/components/block-toolbar/index.js +27 -17
- package/src/components/block-tools/block-contextual-toolbar.js +10 -3
- package/src/components/block-tools/block-selection-button.js +35 -16
- package/src/components/block-tools/index.js +40 -24
- package/src/components/block-tools/insertion-point.js +3 -7
- package/src/components/block-tools/selected-block-popover.js +9 -7
- package/src/components/block-tools/style.scss +5 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +19 -6
- package/src/components/block-tools/zoom-out-mode-inserters.js +57 -0
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +91 -51
- package/src/components/block-vertical-alignment-control/test/index.js +92 -23
- package/src/components/block-vertical-alignment-control/ui.js +3 -2
- package/src/components/border-radius-control/linked-button.js +12 -11
- package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -12
- package/src/components/colors/test/with-colors.js +37 -12
- package/src/components/colors-gradients/dropdown.js +1 -1
- package/src/components/contrast-checker/test/index.js +135 -116
- package/src/components/convert-to-group-buttons/toolbar.js +6 -2
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +39 -57
- package/src/components/default-block-appender/test/index.js +32 -18
- package/src/components/font-sizes/README.MD +9 -0
- package/src/components/iframe/index.js +64 -5
- package/src/components/inner-blocks/README.md +2 -1
- package/src/components/inner-blocks/default-block-appender.js +1 -6
- package/src/components/inner-blocks/index.js +10 -2
- package/src/components/inner-blocks/use-inner-block-template-sync.js +40 -25
- package/src/components/inner-blocks/use-nested-settings-update.js +32 -3
- package/src/components/inserter/index.js +2 -8
- package/src/components/inserter/library.js +11 -5
- package/src/components/inserter/menu.js +42 -29
- package/src/components/inserter/preview-panel.js +1 -1
- package/src/components/inserter/stories/fixtures.js +44 -0
- package/src/components/inserter/stories/index.js +90 -0
- package/src/components/inserter/style.scss +21 -27
- package/src/components/inserter/tabs.js +8 -4
- package/src/components/link-control/link-preview.js +5 -3
- package/src/components/link-control/search-input.js +2 -2
- package/src/components/link-control/search-item.js +39 -7
- package/src/components/list-view/block.js +29 -10
- package/src/components/list-view/branch.js +27 -4
- package/src/components/list-view/drop-indicator.js +33 -32
- package/src/components/list-view/index.js +8 -3
- package/src/components/list-view/use-block-selection.js +0 -1
- package/src/components/media-placeholder/test/index.js +2 -2
- package/src/components/media-replace-flow/README.md +1 -1
- package/src/components/provider/use-block-sync.js +3 -6
- package/src/components/publish-date-time-picker/index.js +1 -1
- package/src/components/rich-text/format-toolbar-container.js +18 -10
- package/src/components/rich-text/index.js +26 -37
- package/src/components/rich-text/index.native.js +8 -21
- package/src/components/spacing-sizes-control/linked-button.js +2 -3
- package/src/components/spacing-sizes-control/style.scss +4 -1
- package/src/components/spacing-sizes-control/utils.js +1 -8
- package/src/components/text-decoration-control/index.js +31 -23
- package/src/components/text-decoration-control/style.scss +18 -0
- package/src/components/text-transform-control/index.js +42 -26
- package/src/components/text-transform-control/style.scss +18 -0
- package/src/components/tool-selector/index.js +9 -11
- package/src/components/url-input/test/button.js +145 -71
- package/src/components/url-popover/image-url-input-ui.js +5 -3
- package/src/components/url-popover/index.js +1 -1
- package/src/components/url-popover/test/__snapshots__/index.js.snap +108 -80
- package/src/components/url-popover/test/index.js +14 -12
- package/src/components/use-block-drop-zone/index.js +15 -4
- package/src/components/use-moving-animation/index.js +9 -24
- package/src/components/warning/test/__snapshots__/index.js.snap +11 -14
- package/src/components/warning/test/index.js +32 -29
- package/src/components/writing-flow/use-select-all.js +4 -6
- package/src/hooks/align.js +22 -13
- package/src/hooks/color-panel.js +2 -1
- package/src/hooks/content-lock-ui.js +161 -0
- package/src/hooks/duotone.js +13 -1
- package/src/hooks/index.js +4 -0
- package/src/hooks/layout.js +25 -19
- package/src/hooks/layout.scss +7 -1
- package/src/hooks/metadata-name.js +48 -0
- package/src/hooks/metadata.js +64 -0
- package/src/hooks/test/use-typography-props.js +28 -0
- package/src/hooks/typography.js +13 -14
- package/src/hooks/use-typography-props.js +41 -0
- package/src/hooks/utils.js +2 -11
- package/src/index.js +1 -0
- package/src/layouts/constrained.js +73 -24
- package/src/store/actions.js +45 -4
- package/src/store/reducer.js +36 -21
- package/src/store/selectors.js +99 -20
- package/src/store/test/reducer.js +8 -5
- package/src/store/test/selectors.js +4 -4
- package/src/style.scss +2 -0
- package/src/utils/parse-css-unit-to-px.js +1 -1
- package/src/components/colors/test/__snapshots__/with-colors.js.snap +0 -23
|
@@ -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","isNavigationMode","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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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\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\tisNavigationMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough = isNavigationMode() || 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","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,0BAHsB,EAItBC,0BAJsB,EAKtBE,YALsB,EAMtBI,eANsB,EAOtB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K,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"]}
|
|
@@ -18,8 +18,8 @@ import { store as blockEditorStore } from '../../store';
|
|
|
18
18
|
* This hook makes sure that a block's inner blocks stay in sync with the given
|
|
19
19
|
* block "template". The template is a block hierarchy to which inner blocks must
|
|
20
20
|
* conform. If the blocks get "out of sync" with the template and the template
|
|
21
|
-
* is meant to be locked (e.g. templateLock = "all"
|
|
22
|
-
* blocks with the correct value after synchronizing it with the template.
|
|
21
|
+
* is meant to be locked (e.g. templateLock = "all" or templateLock = "contentOnly"),
|
|
22
|
+
* then we replace the inner blocks with the correct value after synchronizing it with the template.
|
|
23
23
|
*
|
|
24
24
|
* @param {string} clientId The block client ID.
|
|
25
25
|
* @param {Object} template The template to match.
|
|
@@ -41,28 +41,39 @@ export default function useInnerBlockTemplateSync(clientId, template, templateLo
|
|
|
41
41
|
const {
|
|
42
42
|
replaceInnerBlocks
|
|
43
43
|
} = useDispatch(blockEditorStore);
|
|
44
|
-
const innerBlocks = useSelect(select => select(blockEditorStore).getBlocks(clientId), [clientId]);
|
|
44
|
+
const innerBlocks = useSelect(select => select(blockEditorStore).getBlocks(clientId), [clientId]);
|
|
45
|
+
const {
|
|
46
|
+
getBlocks
|
|
47
|
+
} = useSelect(blockEditorStore); // Maintain a reference to the previous value so we can do a deep equality check.
|
|
45
48
|
|
|
46
49
|
const existingTemplate = useRef(null);
|
|
47
50
|
useLayoutEffect(() => {
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
+
// There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate
|
|
52
|
+
// The former needs to happen after the latter and since the latter is using microtasks to batch updates (performance optimization),
|
|
53
|
+
// we need to schedule this one in a microtask as well.
|
|
54
|
+
// Exemple: If you remove queueMicrotask here, ctrl + click to insert quote block won't close the inserter.
|
|
55
|
+
window.queueMicrotask(() => {
|
|
56
|
+
// Only synchronize innerBlocks with template if innerBlocks are empty
|
|
57
|
+
// or a locking "all" or "contentOnly" exists directly on the block.
|
|
58
|
+
const currentInnerBlocks = getBlocks(clientId);
|
|
59
|
+
const shouldApplyTemplate = currentInnerBlocks.length === 0 || templateLock === 'all' || templateLock === 'contentOnly';
|
|
51
60
|
const hasTemplateChanged = !isEqual(template, existingTemplate.current);
|
|
52
61
|
|
|
53
|
-
if (hasTemplateChanged) {
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
if (!shouldApplyTemplate || !hasTemplateChanged) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
existingTemplate.current = template;
|
|
67
|
+
const nextBlocks = synchronizeBlocksWithTemplate(currentInnerBlocks, template);
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
69
|
+
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
|
+
// If we're supposed to focus the block, we'll focus the first inner block
|
|
72
|
+
// otherwise, we won't apply any auto-focus.
|
|
73
|
+
// This ensures for instance that the focus stays in the inserter when inserting the "buttons" block.
|
|
74
|
+
getSelectedBlocksInitialCaretPosition());
|
|
64
75
|
}
|
|
65
|
-
}
|
|
76
|
+
});
|
|
66
77
|
}, [innerBlocks, template, templateLock, clientId]);
|
|
67
78
|
}
|
|
68
79
|
//# sourceMappingURL=use-inner-block-template-sync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js"],"names":["isEqual","useRef","useLayoutEffect","useSelect","useDispatch","synchronizeBlocksWithTemplate","store","blockEditorStore","useInnerBlockTemplateSync","clientId","template","templateLock","templateInsertUpdatesSelection","getSelectedBlocksInitialCaretPosition","replaceInnerBlocks","innerBlocks","select","getBlocks","existingTemplate","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;AAAF,MACLV,SAAS,CAAEI,gBAAF,CADV;AAEA,QAAM;AAAEO,IAAAA;AAAF,MAAyBV,WAAW,CAAEG,gBAAF,CAA1C;AACA,QAAMQ,WAAW,GAAGZ,SAAS,CAC1Ba,MAAF,IAAcA,MAAM,CAAET,gBAAF,CAAN,CAA2BU,SAA3B,CAAsCR,QAAtC,CADc,EAE5B,CAAEA,QAAF,CAF4B,CAA7B,
|
|
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;AAAF,MACLV,SAAS,CAAEI,gBAAF,CADV;AAEA,QAAM;AAAEO,IAAAA;AAAF,MAAyBV,WAAW,CAAEG,gBAAF,CAA1C;AACA,QAAMQ,WAAW,GAAGZ,SAAS,CAC1Ba,MAAF,IAAcA,MAAM,CAAET,gBAAF,CAAN,CAA2BU,SAA3B,CAAsCR,QAAtC,CADc,EAE5B,CAAEA,QAAF,CAF4B,CAA7B;AAIA,QAAM;AAAEQ,IAAAA;AAAF,MAAgBd,SAAS,CAAEI,gBAAF,CAA/B,CARC,CAUD;;AACA,QAAMW,gBAAgB,GAAGjB,MAAM,CAAE,IAAF,CAA/B;AACAC,EAAAA,eAAe,CAAE,MAAM;AACtB;AACA;AACA;AACA;AACAiB,IAAAA,MAAM,CAACC,cAAP,CAAuB,MAAM;AAC5B;AACA;AACA,YAAMC,kBAAkB,GAAGJ,SAAS,CAAER,QAAF,CAApC;AACA,YAAMa,mBAAmB,GACxBD,kBAAkB,CAACE,MAAnB,KAA8B,CAA9B,IACAZ,YAAY,KAAK,KADjB,IAEAA,YAAY,KAAK,aAHlB;AAKA,YAAMa,kBAAkB,GAAG,CAAExB,OAAO,CACnCU,QADmC,EAEnCQ,gBAAgB,CAACO,OAFkB,CAApC;;AAKA,UAAK,CAAEH,mBAAF,IAAyB,CAAEE,kBAAhC,EAAqD;AACpD;AACA;;AAEDN,MAAAA,gBAAgB,CAACO,OAAjB,GAA2Bf,QAA3B;AACA,YAAMgB,UAAU,GAAGrB,6BAA6B,CAC/CgB,kBAD+C,EAE/CX,QAF+C,CAAhD;;AAKA,UAAK,CAAEV,OAAO,CAAE0B,UAAF,EAAcL,kBAAd,CAAd,EAAmD;AAClDP,QAAAA,kBAAkB,CACjBL,QADiB,EAEjBiB,UAFiB,EAGjBL,kBAAkB,CAACE,MAAnB,KAA8B,CAA9B,IACCX,8BADD,IAECc,UAAU,CAACH,MAAX,KAAsB,CALN,EAMjB;AACA;AACA;AACA;AACAV,QAAAA,qCAAqC,EAVpB,CAAlB;AAYA;AACD,KAtCD;AAuCA,GA5Cc,EA4CZ,CAAEE,WAAF,EAAeL,QAAf,EAAyBC,YAAzB,EAAuCF,QAAvC,CA5CY,CAAf;AA6CA","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 } =\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// 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"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useLayoutEffect, useMemo } from '@wordpress/element';
|
|
5
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
6
6
|
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
@@ -12,6 +12,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
12
12
|
import { getLayoutType } from '../../layouts';
|
|
13
13
|
/** @typedef {import('../../selectors').WPDirectInsertBlock } WPDirectInsertBlock */
|
|
14
14
|
|
|
15
|
+
const pendingSettingsUpdates = new WeakMap();
|
|
15
16
|
/**
|
|
16
17
|
* This hook is a side effect which updates the block-editor store when changes
|
|
17
18
|
* happen to inner block settings. The given props are transformed into a
|
|
@@ -39,6 +40,7 @@ export default function useNestedSettingsUpdate(clientId, allowedBlocks, __exper
|
|
|
39
40
|
const {
|
|
40
41
|
updateBlockListSettings
|
|
41
42
|
} = useDispatch(blockEditorStore);
|
|
43
|
+
const registry = useRegistry();
|
|
42
44
|
const {
|
|
43
45
|
blockListSettings,
|
|
44
46
|
parentLock
|
|
@@ -56,7 +58,7 @@ export default function useNestedSettingsUpdate(clientId, allowedBlocks, __exper
|
|
|
56
58
|
useLayoutEffect(() => {
|
|
57
59
|
const newSettings = {
|
|
58
60
|
allowedBlocks: _allowedBlocks,
|
|
59
|
-
templateLock: templateLock === undefined ? parentLock : templateLock
|
|
61
|
+
templateLock: templateLock === undefined || parentLock === 'contentOnly' ? parentLock : templateLock
|
|
60
62
|
}; // These values are not defined for RN, so only include them if they
|
|
61
63
|
// are defined.
|
|
62
64
|
|
|
@@ -82,8 +84,30 @@ export default function useNestedSettingsUpdate(clientId, allowedBlocks, __exper
|
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
if (!isShallowEqual(blockListSettings, newSettings)) {
|
|
85
|
-
|
|
87
|
+
// Batch updates to block list settings to avoid triggering cascading renders
|
|
88
|
+
// for each container block included in a tree and optimize initial render.
|
|
89
|
+
// To avoid triggering updateBlockListSettings for each container block
|
|
90
|
+
// causing X re-renderings for X container blocks,
|
|
91
|
+
// we batch all the updatedBlockListSettings in a single "data" batch
|
|
92
|
+
// which results in a single re-render.
|
|
93
|
+
if (!pendingSettingsUpdates.get(registry)) {
|
|
94
|
+
pendingSettingsUpdates.set(registry, []);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
pendingSettingsUpdates.get(registry).push([clientId, newSettings]);
|
|
98
|
+
window.queueMicrotask(() => {
|
|
99
|
+
var _pendingSettingsUpdat;
|
|
100
|
+
|
|
101
|
+
if ((_pendingSettingsUpdat = pendingSettingsUpdates.get(registry)) !== null && _pendingSettingsUpdat !== void 0 && _pendingSettingsUpdat.length) {
|
|
102
|
+
registry.batch(() => {
|
|
103
|
+
pendingSettingsUpdates.get(registry).forEach(args => {
|
|
104
|
+
updateBlockListSettings(...args);
|
|
105
|
+
});
|
|
106
|
+
pendingSettingsUpdates.set(registry, []);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
86
110
|
}
|
|
87
|
-
}, [clientId, blockListSettings, _allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings, layout]);
|
|
111
|
+
}, [clientId, blockListSettings, _allowedBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings, layout, registry]);
|
|
88
112
|
}
|
|
89
113
|
//# sourceMappingURL=use-nested-settings-update.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-nested-settings-update.js"],"names":["useLayoutEffect","useMemo","useSelect","useDispatch","isShallowEqual","store","blockEditorStore","getLayoutType","useNestedSettingsUpdate","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","templateLock","captureToolbars","orientation","layout","updateBlockListSettings","blockListSettings","parentLock","select","rootClientId","getBlockRootClientId","getBlockListSettings","getTemplateLock","_allowedBlocks","newSettings","undefined","__experimentalCaptureToolbars","layoutType","type","getOrientation"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,EAA0BC,OAA1B,QAAyC,oBAAzC;AACA,SAASC,SAAT,EAAoBC,WAApB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-nested-settings-update.js"],"names":["useLayoutEffect","useMemo","useSelect","useDispatch","useRegistry","isShallowEqual","store","blockEditorStore","getLayoutType","pendingSettingsUpdates","WeakMap","useNestedSettingsUpdate","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","templateLock","captureToolbars","orientation","layout","updateBlockListSettings","registry","blockListSettings","parentLock","select","rootClientId","getBlockRootClientId","getBlockListSettings","getTemplateLock","_allowedBlocks","newSettings","undefined","__experimentalCaptureToolbars","layoutType","type","getOrientation","get","set","push","window","queueMicrotask","length","batch","forEach","args"],"mappings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GAAvB,CAA4Bf,QAA5B,CAAL,kDAAK,sBAAwCoB,MAA7C,EAAsD;AACrDpB,UAAAA,QAAQ,CAACqB,KAAT,CAAgB,MAAM;AACrBjC,YAAAA,sBAAsB,CACpB2B,GADF,CACOf,QADP,EAEEsB,OAFF,CAEaC,IAAF,IAAY;AACrBxB,cAAAA,uBAAuB,CAAE,GAAGwB,IAAL,CAAvB;AACA,aAJF;AAKAnC,YAAAA,sBAAsB,CAAC4B,GAAvB,CAA4BhB,QAA5B,EAAsC,EAAtC;AACA,WAPD;AAQA;AACD,OAXD;AAYA;AACD,GA1Dc,EA0DZ,CACFT,QADE,EAEFU,iBAFE,EAGFO,cAHE,EAIFf,0BAJE,EAKFC,0BALE,EAMFC,YANE,EAOFO,UAPE,EAQFN,eARE,EASFC,WATE,EAUFE,uBAVE,EAWFD,MAXE,EAYFE,QAZE,CA1DY,CAAf;AAwEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getLayoutType } from '../../layouts';\n\n/** @typedef {import('../../selectors').WPDirectInsertBlock } WPDirectInsertBlock */\n\nconst pendingSettingsUpdates = new WeakMap();\n\n/**\n * This hook is a side effect which updates the block-editor store when changes\n * happen to inner block settings. The given props are transformed into a\n * settings object, and if that is different from the current settings object in\n * the block-editor store, then the store is updated with the new settings which\n * came from props.\n *\n * @param {string} clientId The client ID of the block to update.\n * @param {string[]} allowedBlocks An array of block names which are permitted\n * in inner blocks.\n * @param {?WPDirectInsertBlock} __experimentalDefaultBlock The default block to insert: [ blockName, { blockAttributes } ].\n * @param {?Function|boolean} __experimentalDirectInsert If a default block should be inserted directly by the\n * appender.\n * @param {string} [templateLock] The template lock specified for the inner\n * blocks component. (e.g. \"all\")\n * @param {boolean} captureToolbars Whether or children toolbars should be shown\n * in the inner blocks component rather than on\n * the child block.\n * @param {string} orientation The direction in which the block\n * should face.\n * @param {Object} layout The layout object for the block container.\n */\nexport default function useNestedSettingsUpdate(\n\tclientId,\n\tallowedBlocks,\n\t__experimentalDefaultBlock,\n\t__experimentalDirectInsert,\n\ttemplateLock,\n\tcaptureToolbars,\n\torientation,\n\tlayout\n) {\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst { blockListSettings, parentLock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst rootClientId =\n\t\t\t\tselect( blockEditorStore ).getBlockRootClientId( clientId );\n\t\t\treturn {\n\t\t\t\tblockListSettings:\n\t\t\t\t\tselect( blockEditorStore ).getBlockListSettings( clientId ),\n\t\t\t\tparentLock:\n\t\t\t\t\tselect( blockEditorStore ).getTemplateLock( rootClientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Memoize as inner blocks implementors often pass a new array on every\n\t// render.\n\tconst _allowedBlocks = useMemo( () => allowedBlocks, allowedBlocks );\n\n\tuseLayoutEffect( () => {\n\t\tconst newSettings = {\n\t\t\tallowedBlocks: _allowedBlocks,\n\t\t\ttemplateLock:\n\t\t\t\ttemplateLock === undefined || parentLock === 'contentOnly'\n\t\t\t\t\t? parentLock\n\t\t\t\t\t: templateLock,\n\t\t};\n\n\t\t// These values are not defined for RN, so only include them if they\n\t\t// are defined.\n\t\tif ( captureToolbars !== undefined ) {\n\t\t\tnewSettings.__experimentalCaptureToolbars = captureToolbars;\n\t\t}\n\n\t\t// Orientation depends on layout,\n\t\t// ideally the separate orientation prop should be deprecated.\n\t\tif ( orientation !== undefined ) {\n\t\t\tnewSettings.orientation = orientation;\n\t\t} else {\n\t\t\tconst layoutType = getLayoutType( layout?.type );\n\t\t\tnewSettings.orientation = layoutType.getOrientation( layout );\n\t\t}\n\n\t\tif ( __experimentalDefaultBlock !== undefined ) {\n\t\t\tnewSettings.__experimentalDefaultBlock = __experimentalDefaultBlock;\n\t\t}\n\n\t\tif ( __experimentalDirectInsert !== undefined ) {\n\t\t\tnewSettings.__experimentalDirectInsert = __experimentalDirectInsert;\n\t\t}\n\n\t\tif ( ! isShallowEqual( blockListSettings, newSettings ) ) {\n\t\t\t// Batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// To avoid triggering updateBlockListSettings for each container block\n\t\t\t// causing X re-renderings for X container blocks,\n\t\t\t// we batch all the updatedBlockListSettings in a single \"data\" batch\n\t\t\t// which results in a single re-render.\n\t\t\tif ( ! pendingSettingsUpdates.get( registry ) ) {\n\t\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t\t}\n\t\t\tpendingSettingsUpdates\n\t\t\t\t.get( registry )\n\t\t\t\t.push( [ clientId, newSettings ] );\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tif ( pendingSettingsUpdates.get( registry )?.length ) {\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tpendingSettingsUpdates\n\t\t\t\t\t\t\t.get( registry )\n\t\t\t\t\t\t\t.forEach( ( args ) => {\n\t\t\t\t\t\t\t\tupdateBlockListSettings( ...args );\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\tblockListSettings,\n\t\t_allowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tparentLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tupdateBlockListSettings,\n\t\tlayout,\n\t\tregistry,\n\t] );\n}\n"]}
|
|
@@ -173,7 +173,8 @@ class Inserter extends Component {
|
|
|
173
173
|
rootClientId: rootClientId,
|
|
174
174
|
clientId: clientId,
|
|
175
175
|
isAppender: isAppender,
|
|
176
|
-
showInserterHelpPanel: showInserterHelpPanel
|
|
176
|
+
showInserterHelpPanel: showInserterHelpPanel,
|
|
177
|
+
prioritizePatterns: prioritizePatterns
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
180
|
|
|
@@ -222,8 +223,6 @@ export default compose([withSelect((select, _ref4) => {
|
|
|
222
223
|
hasInserterItems,
|
|
223
224
|
__experimentalGetAllowedBlocks,
|
|
224
225
|
__experimentalGetDirectInsertBlock,
|
|
225
|
-
getBlockIndex,
|
|
226
|
-
getBlockCount,
|
|
227
226
|
getSettings
|
|
228
227
|
} = select(blockEditorStore);
|
|
229
228
|
const {
|
|
@@ -235,8 +234,6 @@ export default compose([withSelect((select, _ref4) => {
|
|
|
235
234
|
|
|
236
235
|
const directInsertBlock = __experimentalGetDirectInsertBlock(rootClientId);
|
|
237
236
|
|
|
238
|
-
const index = getBlockIndex(clientId);
|
|
239
|
-
const blockCount = getBlockCount();
|
|
240
237
|
const settings = getSettings();
|
|
241
238
|
const hasSingleBlockType = (allowedBlocks === null || allowedBlocks === void 0 ? void 0 : allowedBlocks.length) === 1 && ((_getBlockVariations = getBlockVariations(allowedBlocks[0].name, 'inserter')) === null || _getBlockVariations === void 0 ? void 0 : _getBlockVariations.length) === 0;
|
|
242
239
|
let allowedBlockType = false;
|
|
@@ -252,7 +249,7 @@ export default compose([withSelect((select, _ref4) => {
|
|
|
252
249
|
allowedBlockType,
|
|
253
250
|
directInsertBlock,
|
|
254
251
|
rootClientId,
|
|
255
|
-
prioritizePatterns: settings.__experimentalPreferPatternsOnRoot && !rootClientId
|
|
252
|
+
prioritizePatterns: settings.__experimentalPreferPatternsOnRoot && !rootClientId
|
|
256
253
|
};
|
|
257
254
|
}), withDispatch((dispatch, ownProps, _ref5) => {
|
|
258
255
|
let {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.js"],"names":["classnames","speak","__","_x","sprintf","Dropdown","Button","Component","withDispatch","withSelect","compose","ifCondition","createBlock","store","blocksStore","plus","InserterMenu","QuickInserter","blockEditorStore","defaultRenderToggle","onToggle","disabled","isOpen","blockTitle","hasSingleBlockType","toggleProps","prioritizePatterns","label","onClick","rest","handleClick","event","Inserter","constructor","arguments","bind","renderToggle","renderContent","props","directInsertBlock","hasItems","onClose","rootClientId","clientId","isAppender","showInserterHelpPanel","__experimentalIsQuick","isQuick","render","position","insertOnlyAllowedBlock","onSelectOrClose","select","getBlockRootClientId","hasInserterItems","__experimentalGetAllowedBlocks","__experimentalGetDirectInsertBlock","getBlockIndex","getBlockCount","getSettings","getBlockVariations","undefined","allowedBlocks","index","blockCount","settings","length","name","allowedBlockType","title","__experimentalPreferPatternsOnRoot","dispatch","ownProps","getAdjacentBlockAttributes","attributesToCopy","getBlock","getPreviousBlockClientId","result","adjacentAttributes","parentBlock","innerBlocks","lastInnerBlock","attributes","currentBlock","previousBlock","forEach","attribute","hasOwnProperty","getInsertionIndex","getBlockSelectionEnd","getBlockOrder","end","insertBlock","blockToInsert","newAttributes","message"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,uBAAjC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,WAAT,EAAsBC,KAAK,IAAIC,WAA/B,QAAkD,mBAAlD;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASJ,KAAK,IAAIK,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,mBAAmB,GAAG,QAQrB;AAAA,MARuB;AAC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F;AAAA,SACCH,QAAQ,IAAM,CAAEI,UAAF,IAAgB,CAAEF,YAAlB,IAAkC,CAAEC,QADnD;AAAA,CADU,CA5LY,CAAF,CAAP,CAgMVX,QAhMU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\ttoggleProps = {},\n\tprioritizePatterns,\n} ) => {\n\tlet label;\n\tif ( hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle\n\t\t);\n\t} else if ( prioritizePatterns ) {\n\t\tlabel = __( 'Add pattern' );\n\t} else {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\tconst { onClick, ...rest } = toggleProps;\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tprioritizePatterns,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\tprioritizePatterns,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tprioritizePatterns,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || directInsertBlock ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ classnames(\n\t\t\t\t\t'block-editor-inserter__popover',\n\t\t\t\t\t{ 'is-quick': isQuick }\n\t\t\t\t) }\n\t\t\t\tposition={ position }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { clientId, rootClientId } ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\thasInserterItems,\n\t\t\t__experimentalGetAllowedBlocks,\n\t\t\t__experimentalGetDirectInsertBlock,\n\t\t\tgetBlockIndex,\n\t\t\tgetBlockCount,\n\t\t\tgetSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\trootClientId =\n\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\tconst allowedBlocks = __experimentalGetAllowedBlocks( rootClientId );\n\n\t\tconst directInsertBlock =\n\t\t\t__experimentalGetDirectInsertBlock( rootClientId );\n\n\t\tconst index = getBlockIndex( clientId );\n\t\tconst blockCount = getBlockCount();\n\t\tconst settings = getSettings();\n\n\t\tconst hasSingleBlockType =\n\t\t\tallowedBlocks?.length === 1 &&\n\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t?.length === 0;\n\n\t\tlet allowedBlockType = false;\n\t\tif ( hasSingleBlockType ) {\n\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t}\n\n\t\treturn {\n\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\thasSingleBlockType,\n\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\tallowedBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\trootClientId,\n\t\t\tprioritizePatterns:\n\t\t\t\tsettings.__experimentalPreferPatternsOnRoot &&\n\t\t\t\t! rootClientId &&\n\t\t\t\tindex > 0 &&\n\t\t\t\t( index < blockCount || blockCount === 0 ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! directInsertBlock ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! attributesToCopy ||\n\t\t\t\t\t\t( ! clientId && ! rootClientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = {};\n\t\t\t\t\tlet adjacentAttributes = {};\n\n\t\t\t\t\t// If there is no clientId, then attempt to get attributes\n\t\t\t\t\t// from the last block within innerBlocks of the root block.\n\t\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\t\tconst parentBlock = getBlock( rootClientId );\n\n\t\t\t\t\t\tif ( parentBlock?.innerBlocks?.length ) {\n\t\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\t\tparentBlock.innerBlocks[\n\t\t\t\t\t\t\t\t\tparentBlock.innerBlocks.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdirectInsertBlock &&\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name === lastInnerBlock.name\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Otherwise, attempt to get attributes from the\n\t\t\t\t\t\t// previous block relative to the current clientId.\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes =\n\t\t\t\t\t\t\t\tpreviousBlock?.attributes || {};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Copy over only those attributes flagged to be copied.\n\t\t\t\t\tattributesToCopy.forEach( ( attribute ) => {\n\t\t\t\t\t\tif ( adjacentAttributes.hasOwnProperty( attribute ) ) {\n\t\t\t\t\t\t\tresult[ attribute ] =\n\t\t\t\t\t\t\t\tadjacentAttributes[ attribute ];\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\tlet blockToInsert;\n\n\t\t\t\t// Attempt to augment the directInsertBlock with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tif ( directInsertBlock ) {\n\t\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\t\tdirectInsertBlock.attributesToCopy\n\t\t\t\t\t);\n\n\t\t\t\t\tblockToInsert = createBlock( directInsertBlock.name, {\n\t\t\t\t\t\t...( directInsertBlock.attributes || {} ),\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tblockToInsert = createBlock( allowedBlockType.name );\n\t\t\t\t}\n\n\t\t\t\tinsertBlock( blockToInsert, getInsertionIndex(), rootClientId );\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose();\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( Inserter );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.js"],"names":["classnames","speak","__","_x","sprintf","Dropdown","Button","Component","withDispatch","withSelect","compose","ifCondition","createBlock","store","blocksStore","plus","InserterMenu","QuickInserter","blockEditorStore","defaultRenderToggle","onToggle","disabled","isOpen","blockTitle","hasSingleBlockType","toggleProps","prioritizePatterns","label","onClick","rest","handleClick","event","Inserter","constructor","arguments","bind","renderToggle","renderContent","props","directInsertBlock","hasItems","onClose","rootClientId","clientId","isAppender","showInserterHelpPanel","__experimentalIsQuick","isQuick","render","position","insertOnlyAllowedBlock","onSelectOrClose","select","getBlockRootClientId","hasInserterItems","__experimentalGetAllowedBlocks","__experimentalGetDirectInsertBlock","getSettings","getBlockVariations","undefined","allowedBlocks","settings","length","name","allowedBlockType","title","__experimentalPreferPatternsOnRoot","dispatch","ownProps","getAdjacentBlockAttributes","attributesToCopy","getBlock","getPreviousBlockClientId","result","adjacentAttributes","parentBlock","innerBlocks","lastInnerBlock","attributes","currentBlock","previousBlock","forEach","attribute","hasOwnProperty","getInsertionIndex","getBlockIndex","getBlockSelectionEnd","getBlockOrder","end","insertBlock","blockToInsert","newAttributes","message"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,uBAAjC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,YAAT,EAAuBC,UAAvB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AACA,SAASC,WAAT,EAAsBC,KAAK,IAAIC,WAA/B,QAAkD,mBAAlD;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASJ,KAAK,IAAIK,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,mBAAmB,GAAG,QAQrB;AAAA,MARuB;AAC7BC,IAAAA,QAD6B;AAE7BC,IAAAA,QAF6B;AAG7BC,IAAAA,MAH6B;AAI7BC,IAAAA,UAJ6B;AAK7BC,IAAAA,kBAL6B;AAM7BC,IAAAA,WAAW,GAAG,EANe;AAO7BC,IAAAA;AAP6B,GAQvB;AACN,MAAIC,KAAJ;;AACA,MAAKH,kBAAL,EAA0B;AACzBG,IAAAA,KAAK,GAAGvB,OAAO,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ACxB,cAAMoD,aAAa,GAAGtB,0BAA0B,CAC/C9B,iBAAiB,CAAC+B,gBAD6B,CAAhD;AAIAoB,QAAAA,aAAa,GAAG9E,WAAW,CAAE2B,iBAAiB,CAACwB,IAApB,EAA0B,EACpD,IAAKxB,iBAAiB,CAACuC,UAAlB,IAAgC,EAArC,CADoD;AAEpD,aAAGa;AAFiD,SAA1B,CAA3B;AAIA,OATD,MASO;AACND,QAAAA,aAAa,GAAG9E,WAAW,CAAEoD,gBAAgB,CAACD,IAAnB,CAA3B;AACA;;AAED0B,MAAAA,WAAW,CAAEC,aAAF,EAAiBN,iBAAiB,EAAlC,EAAsC1C,YAAtC,CAAX;;AAEA,UAAKS,eAAL,EAAuB;AACtBA,QAAAA,eAAe;AACf;;AAED,YAAMyC,OAAO,GAAGxF,OAAO,EACtB;AACAF,MAAAA,EAAE,CAAE,gBAAF,CAFoB,EAGtB8D,gBAAgB,CAACC,KAHK,CAAvB;AAKAhE,MAAAA,KAAK,CAAE2F,OAAF,CAAL;AACA;;AApIK,GAAP;AAsIA,CAvIW,CA3CW,EAmLvB;AACA;AACAjF,WAAW,CACV;AAAA,MAAE;AAAE6B,IAAAA,QAAF;AAAYI,IAAAA,UAAZ;AAAwBF,IAAAA,YAAxB;AAAsCC,IAAAA;AAAtC,GAAF;AAAA,SACCH,QAAQ,IAAM,CAAEI,UAAF,IAAgB,CAAEF,YAAlB,IAAkC,CAAEC,QADnD;AAAA,CADU,CArLY,CAAF,CAAP,CAyLVX,QAzLU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\ttoggleProps = {},\n\tprioritizePatterns,\n} ) => {\n\tlet label;\n\tif ( hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle\n\t\t);\n\t} else if ( prioritizePatterns ) {\n\t\tlabel = __( 'Add pattern' );\n\t} else {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\tconst { onClick, ...rest } = toggleProps;\n\n\t// Handle both onClick functions from the toggle and the parent component.\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component.\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t\tprioritizePatterns,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\tprioritizePatterns,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tprioritizePatterns,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || directInsertBlock ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ classnames(\n\t\t\t\t\t'block-editor-inserter__popover',\n\t\t\t\t\t{ 'is-quick': isQuick }\n\t\t\t\t) }\n\t\t\t\tposition={ position }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { clientId, rootClientId } ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\thasInserterItems,\n\t\t\t__experimentalGetAllowedBlocks,\n\t\t\t__experimentalGetDirectInsertBlock,\n\t\t\tgetSettings,\n\t\t} = select( blockEditorStore );\n\n\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\trootClientId =\n\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\tconst allowedBlocks = __experimentalGetAllowedBlocks( rootClientId );\n\n\t\tconst directInsertBlock =\n\t\t\t__experimentalGetDirectInsertBlock( rootClientId );\n\n\t\tconst settings = getSettings();\n\n\t\tconst hasSingleBlockType =\n\t\t\tallowedBlocks?.length === 1 &&\n\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t?.length === 0;\n\n\t\tlet allowedBlockType = false;\n\t\tif ( hasSingleBlockType ) {\n\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t}\n\n\t\treturn {\n\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\thasSingleBlockType,\n\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\tallowedBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\trootClientId,\n\t\t\tprioritizePatterns:\n\t\t\t\tsettings.__experimentalPreferPatternsOnRoot && ! rootClientId,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! directInsertBlock ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfunction getAdjacentBlockAttributes( attributesToCopy ) {\n\t\t\t\t\tconst { getBlock, getPreviousBlockClientId } =\n\t\t\t\t\t\tselect( blockEditorStore );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! attributesToCopy ||\n\t\t\t\t\t\t( ! clientId && ! rootClientId )\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn {};\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = {};\n\t\t\t\t\tlet adjacentAttributes = {};\n\n\t\t\t\t\t// If there is no clientId, then attempt to get attributes\n\t\t\t\t\t// from the last block within innerBlocks of the root block.\n\t\t\t\t\tif ( ! clientId ) {\n\t\t\t\t\t\tconst parentBlock = getBlock( rootClientId );\n\n\t\t\t\t\t\tif ( parentBlock?.innerBlocks?.length ) {\n\t\t\t\t\t\t\tconst lastInnerBlock =\n\t\t\t\t\t\t\t\tparentBlock.innerBlocks[\n\t\t\t\t\t\t\t\t\tparentBlock.innerBlocks.length - 1\n\t\t\t\t\t\t\t\t];\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tdirectInsertBlock &&\n\t\t\t\t\t\t\t\tdirectInsertBlock?.name === lastInnerBlock.name\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tadjacentAttributes = lastInnerBlock.attributes;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Otherwise, attempt to get attributes from the\n\t\t\t\t\t\t// previous block relative to the current clientId.\n\t\t\t\t\t\tconst currentBlock = getBlock( clientId );\n\t\t\t\t\t\tconst previousBlock = getBlock(\n\t\t\t\t\t\t\tgetPreviousBlockClientId( clientId )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( currentBlock?.name === previousBlock?.name ) {\n\t\t\t\t\t\t\tadjacentAttributes =\n\t\t\t\t\t\t\t\tpreviousBlock?.attributes || {};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Copy over only those attributes flagged to be copied.\n\t\t\t\t\tattributesToCopy.forEach( ( attribute ) => {\n\t\t\t\t\t\tif ( adjacentAttributes.hasOwnProperty( attribute ) ) {\n\t\t\t\t\t\t\tresult[ attribute ] =\n\t\t\t\t\t\t\t\tadjacentAttributes[ attribute ];\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId.\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\tlet blockToInsert;\n\n\t\t\t\t// Attempt to augment the directInsertBlock with attributes from an adjacent block.\n\t\t\t\t// This ensures styling from nearby blocks is preserved in the newly inserted block.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/issues/37904\n\t\t\t\tif ( directInsertBlock ) {\n\t\t\t\t\tconst newAttributes = getAdjacentBlockAttributes(\n\t\t\t\t\t\tdirectInsertBlock.attributesToCopy\n\t\t\t\t\t);\n\n\t\t\t\t\tblockToInsert = createBlock( directInsertBlock.name, {\n\t\t\t\t\t\t...( directInsertBlock.attributes || {} ),\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t} );\n\t\t\t\t} else {\n\t\t\t\t\tblockToInsert = createBlock( allowedBlockType.name );\n\t\t\t\t}\n\n\t\t\t\tinsertBlock( blockToInsert, getInsertionIndex(), rootClientId );\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose();\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( Inserter );\n"]}
|
|
@@ -26,11 +26,21 @@ function InserterLibrary(_ref, ref) {
|
|
|
26
26
|
onSelect = noop,
|
|
27
27
|
shouldFocusBlock = false
|
|
28
28
|
} = _ref;
|
|
29
|
-
const
|
|
29
|
+
const {
|
|
30
|
+
destinationRootClientId,
|
|
31
|
+
prioritizePatterns
|
|
32
|
+
} = useSelect(select => {
|
|
30
33
|
const {
|
|
31
|
-
getBlockRootClientId
|
|
34
|
+
getBlockRootClientId,
|
|
35
|
+
getSettings
|
|
32
36
|
} = select(blockEditorStore);
|
|
33
|
-
|
|
37
|
+
|
|
38
|
+
const _rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
destinationRootClientId: _rootClientId,
|
|
42
|
+
prioritizePatterns: getSettings().__experimentalPreferPatternsOnRoot
|
|
43
|
+
};
|
|
34
44
|
}, [clientId, rootClientId]);
|
|
35
45
|
return createElement(InserterMenu, {
|
|
36
46
|
onSelect: onSelect,
|
|
@@ -42,6 +52,7 @@ function InserterLibrary(_ref, ref) {
|
|
|
42
52
|
__experimentalInsertionIndex: __experimentalInsertionIndex,
|
|
43
53
|
__experimentalFilterValue: __experimentalFilterValue,
|
|
44
54
|
shouldFocusBlock: shouldFocusBlock,
|
|
55
|
+
prioritizePatterns: prioritizePatterns,
|
|
45
56
|
ref: ref
|
|
46
57
|
});
|
|
47
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/library.js"],"names":["useSelect","forwardRef","InserterMenu","store","blockEditorStore","noop","InserterLibrary","ref","rootClientId","clientId","isAppender","showInserterHelpPanel","showMostUsedBlocks","__experimentalInsertionIndex","__experimentalFilterValue","onSelect","shouldFocusBlock","destinationRootClientId","select","getBlockRootClientId","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,eAAT,OAYCC,GAZD,EAaE;AAAA,MAZD;AACCC,IAAAA,YADD;AAECC,IAAAA,QAFD;AAGCC,IAAAA,UAHD;AAICC,IAAAA,qBAJD;AAKCC,IAAAA,kBAAkB,GAAG,KALtB;AAMCC,IAAAA,4BAND;AAOCC,IAAAA,yBAPD;AAQCC,IAAAA,QAAQ,GAAGV,IARZ;AASCW,IAAAA,gBAAgB,GAAG;AATpB,GAYC;AACD,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/library.js"],"names":["useSelect","forwardRef","InserterMenu","store","blockEditorStore","noop","InserterLibrary","ref","rootClientId","clientId","isAppender","showInserterHelpPanel","showMostUsedBlocks","__experimentalInsertionIndex","__experimentalFilterValue","onSelect","shouldFocusBlock","destinationRootClientId","prioritizePatterns","select","getBlockRootClientId","getSettings","_rootClientId","undefined","__experimentalPreferPatternsOnRoot"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,eAAT,OAYCC,GAZD,EAaE;AAAA,MAZD;AACCC,IAAAA,YADD;AAECC,IAAAA,QAFD;AAGCC,IAAAA,UAHD;AAICC,IAAAA,qBAJD;AAKCC,IAAAA,kBAAkB,GAAG,KALtB;AAMCC,IAAAA,4BAND;AAOCC,IAAAA,yBAPD;AAQCC,IAAAA,QAAQ,GAAGV,IARZ;AASCW,IAAAA,gBAAgB,GAAG;AATpB,GAYC;AACD,QAAM;AAAEC,IAAAA,uBAAF;AAA2BC,IAAAA;AAA3B,MAAkDlB,SAAS,CAC9DmB,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,oBAAF;AAAwBC,MAAAA;AAAxB,QACLF,MAAM,CAAEf,gBAAF,CADP;;AAGA,UAAMkB,aAAa,GAClBd,YAAY,IAAIY,oBAAoB,CAAEX,QAAF,CAApC,IAAoDc,SADrD;;AAEA,WAAO;AACNN,MAAAA,uBAAuB,EAAEK,aADnB;AAENJ,MAAAA,kBAAkB,EACjBG,WAAW,GAAGG;AAHT,KAAP;AAKA,GAZ+D,EAahE,CAAEf,QAAF,EAAYD,YAAZ,CAbgE,CAAjE;AAgBA,SACC,cAAC,YAAD;AACC,IAAA,QAAQ,EAAGO,QADZ;AAEC,IAAA,YAAY,EAAGE,uBAFhB;AAGC,IAAA,QAAQ,EAAGR,QAHZ;AAIC,IAAA,UAAU,EAAGC,UAJd;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,kBAAkB,EAAGC,kBANtB;AAOC,IAAA,4BAA4B,EAAGC,4BAPhC;AAQC,IAAA,yBAAyB,EAAGC,yBAR7B;AASC,IAAA,gBAAgB,EAAGE,gBATpB;AAUC,IAAA,kBAAkB,EAAGE,kBAVtB;AAWC,IAAA,GAAG,EAAGX;AAXP,IADD;AAeA;;AAED,eAAeN,UAAU,CAAEK,eAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\nfunction InserterLibrary(\n\t{\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\tshowInserterHelpPanel,\n\t\tshowMostUsedBlocks = false,\n\t\t__experimentalInsertionIndex,\n\t\t__experimentalFilterValue,\n\t\tonSelect = noop,\n\t\tshouldFocusBlock = false,\n\t},\n\tref\n) {\n\tconst { destinationRootClientId, prioritizePatterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\tconst _rootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\t\t\treturn {\n\t\t\t\tdestinationRootClientId: _rootClientId,\n\t\t\t\tprioritizePatterns:\n\t\t\t\t\tgetSettings().__experimentalPreferPatternsOnRoot,\n\t\t\t};\n\t\t},\n\t\t[ clientId, rootClientId ]\n\t);\n\n\treturn (\n\t\t<InserterMenu\n\t\t\tonSelect={ onSelect }\n\t\t\trootClientId={ destinationRootClientId }\n\t\t\tclientId={ clientId }\n\t\t\tisAppender={ isAppender }\n\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\tshowMostUsedBlocks={ showMostUsedBlocks }\n\t\t\t__experimentalInsertionIndex={ __experimentalInsertionIndex }\n\t\t\t__experimentalFilterValue={ __experimentalFilterValue }\n\t\t\tshouldFocusBlock={ shouldFocusBlock }\n\t\t\tprioritizePatterns={ prioritizePatterns }\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( InserterLibrary );\n"]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { createElement, Fragment } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classnames from 'classnames';
|
|
3
7
|
/**
|
|
4
8
|
* WordPress dependencies
|
|
5
9
|
*/
|
|
10
|
+
|
|
6
11
|
import { forwardRef, useState, useCallback, useMemo, useImperativeHandle, useRef } from '@wordpress/element';
|
|
7
12
|
import { VisuallyHidden, SearchControl } from '@wordpress/components';
|
|
8
13
|
import { __ } from '@wordpress/i18n';
|
|
@@ -31,7 +36,8 @@ function InserterMenu(_ref, ref) {
|
|
|
31
36
|
showInserterHelpPanel,
|
|
32
37
|
showMostUsedBlocks,
|
|
33
38
|
__experimentalFilterValue = '',
|
|
34
|
-
shouldFocusBlock = true
|
|
39
|
+
shouldFocusBlock = true,
|
|
40
|
+
prioritizePatterns
|
|
35
41
|
} = _ref;
|
|
36
42
|
const [filterValue, setFilterValue] = useState(__experimentalFilterValue);
|
|
37
43
|
const [hoveredItem, setHoveredItem] = useState(null);
|
|
@@ -113,12 +119,13 @@ function InserterMenu(_ref, ref) {
|
|
|
113
119
|
searchRef.current.focus();
|
|
114
120
|
}
|
|
115
121
|
}));
|
|
122
|
+
const showAsTabs = !filterValue && (showPatterns || hasReusableBlocks);
|
|
116
123
|
return createElement("div", {
|
|
117
124
|
className: "block-editor-inserter__menu"
|
|
118
125
|
}, createElement("div", {
|
|
119
|
-
className:
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
className: classnames('block-editor-inserter__main-area', {
|
|
127
|
+
'show-as-tabs': showAsTabs
|
|
128
|
+
})
|
|
122
129
|
}, createElement(SearchControl, {
|
|
123
130
|
className: "block-editor-inserter__search",
|
|
124
131
|
onChange: value => {
|
|
@@ -129,7 +136,9 @@ function InserterMenu(_ref, ref) {
|
|
|
129
136
|
label: __('Search for blocks and patterns'),
|
|
130
137
|
placeholder: __('Search'),
|
|
131
138
|
ref: searchRef
|
|
132
|
-
}), !!filterValue && createElement(
|
|
139
|
+
}), !!filterValue && createElement("div", {
|
|
140
|
+
className: "block-editor-inserter__no-tab-container"
|
|
141
|
+
}, createElement(InserterSearchResults, {
|
|
133
142
|
filterValue: filterValue,
|
|
134
143
|
onSelect: onSelect,
|
|
135
144
|
onHover: onHover,
|
|
@@ -139,10 +148,13 @@ function InserterMenu(_ref, ref) {
|
|
|
139
148
|
__experimentalInsertionIndex: __experimentalInsertionIndex,
|
|
140
149
|
showBlockDirectory: true,
|
|
141
150
|
shouldFocusBlock: shouldFocusBlock
|
|
142
|
-
}),
|
|
151
|
+
})), showAsTabs && createElement(InserterTabs, {
|
|
143
152
|
showPatterns: showPatterns,
|
|
144
|
-
showReusableBlocks: hasReusableBlocks
|
|
145
|
-
|
|
153
|
+
showReusableBlocks: hasReusableBlocks,
|
|
154
|
+
prioritizePatterns: prioritizePatterns
|
|
155
|
+
}, getCurrentTab), !filterValue && !showAsTabs && createElement("div", {
|
|
156
|
+
className: "block-editor-inserter__no-tab-container"
|
|
157
|
+
}, blocksTab)), showInserterHelpPanel && hoveredItem && createElement(InserterPreviewPanel, {
|
|
146
158
|
item: hoveredItem
|
|
147
159
|
}));
|
|
148
160
|
}
|