@wordpress/block-editor 12.5.0 → 12.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +2 -6
- package/build/autocompleters/block.js +6 -2
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-draggable/index.js +6 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +2 -2
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +25 -13
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-editing-mode/index.js +1 -1
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +14 -18
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block.js +4 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +21 -42
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +2 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +1 -1
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js +6 -21
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +1 -4
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings/button.native.js +2 -2
- package/build/components/block-settings/button.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +3 -17
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +7 -5
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build/components/block-toolbar/index.js +4 -33
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +62 -3
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/block-toolbar/utils.js +56 -51
- package/build/components/block-toolbar/utils.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +4 -2
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-variation-picker/index.native.js +10 -20
- package/build/components/block-variation-picker/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +4 -2
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/editor-styles/index.js +2 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +11 -11
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/behaviors-panel.js +66 -0
- package/build/components/global-styles/behaviors-panel.js.map +1 -0
- package/build/components/global-styles/color-panel.js +21 -15
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +13 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +4 -8
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/hooks.js +131 -27
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +20 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +18 -3
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +4 -4
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +12 -18
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +7 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +36 -48
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +5 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build/components/index.js +1 -10
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +3 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +3 -1
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +33 -7
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +6 -2
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +5 -7
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +3 -2
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/index.js +2 -4
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +21 -32
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +23 -3
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +3 -2
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter-list-item/index.js +1 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/link-control/index.js +51 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +3 -3
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-item.js +1 -1
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +2 -2
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +65 -31
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.native.js +15 -3
- package/build/components/media-replace-flow/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +2 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/content.js +0 -36
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/format-edit.js +57 -28
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +111 -0
- package/build/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
- package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +2 -2
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/use-block-display-information/index.js +7 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +49 -8
- package/build/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build/components/use-setting/index.js +5 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/behaviors.js +5 -12
- package/build/hooks/behaviors.js.map +1 -1
- package/build/hooks/border.js +2 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +11 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +1 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +10 -3
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +3 -4
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js +5 -6
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +0 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +23 -79
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +38 -2
- package/build/utils/object.js.map +1 -1
- package/build-module/autocompleters/block.js +7 -3
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-draggable/index.js +6 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +2 -2
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +27 -10
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +1 -1
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +14 -18
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block.js +4 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +24 -43
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +2 -3
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +3 -3
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +7 -22
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +1 -4
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings/button.native.js +3 -3
- package/build-module/components/block-settings/button.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -18
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +9 -7
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +6 -35
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +60 -4
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-toolbar/utils.js +54 -49
- package/build-module/components/block-toolbar/utils.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +4 -2
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +13 -23
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +3 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/editor-styles/index.js +2 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +11 -11
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/behaviors-panel.js +57 -0
- package/build-module/components/global-styles/behaviors-panel.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +21 -15
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +13 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +4 -8
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +127 -27
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +18 -3
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +4 -4
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +13 -18
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +6 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +37 -49
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +5 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build-module/components/index.js +0 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +3 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +3 -1
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +30 -7
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +7 -3
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +5 -7
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +3 -2
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +22 -33
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +22 -3
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -2
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +1 -1
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/link-control/index.js +49 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +3 -3
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-item.js +1 -1
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +66 -33
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.native.js +15 -3
- package/build-module/components/media-replace-flow/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/content.js +1 -36
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +51 -26
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +100 -0
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
- package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +2 -2
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +7 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +50 -8
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build-module/components/use-setting/index.js +5 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/behaviors.js +5 -12
- package/build-module/hooks/behaviors.js.map +1 -1
- package/build-module/hooks/border.js +2 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +11 -2
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +2 -7
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +7 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +4 -5
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js +3 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +0 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +20 -75
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +34 -2
- package/build-module/utils/object.js.map +1 -1
- package/build-style/content-rtl.css +2 -1
- package/build-style/content.css +2 -1
- package/build-style/style-rtl.css +25 -6
- package/build-style/style.css +25 -6
- package/package.json +32 -32
- package/src/autocompleters/block.js +21 -6
- package/src/components/block-controls/README.md +89 -0
- package/src/components/block-draggable/index.js +13 -4
- package/src/components/block-draggable/index.native.js +7 -3
- package/src/components/block-draggable/test/index.native.js +2 -57
- package/src/components/block-edit/edit.js +26 -9
- package/src/components/block-edit/test/edit.js +1 -1
- package/src/components/block-editing-mode/index.js +1 -1
- package/src/components/block-list/block-outline.native.js +26 -25
- package/src/components/block-list/block.js +6 -1
- package/src/components/block-list/block.native.js +24 -38
- package/src/components/block-list/block.native.scss +18 -40
- package/src/components/block-list/index.js +3 -6
- package/src/components/block-list/style.native.scss +3 -3
- package/src/components/block-list/test/block-invalid-warning.native.js +8 -1
- package/src/components/block-mover/index.native.js +3 -3
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +40 -6
- package/src/components/block-parent-selector/index.js +30 -42
- package/src/components/block-preview/auto.js +8 -1
- package/src/components/block-preview/style.scss +2 -1
- package/src/components/block-removal-warning-modal/index.js +0 -3
- package/src/components/block-settings/button.native.js +12 -6
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -13
- package/src/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +15 -10
- package/src/components/block-toolbar/index.js +36 -64
- package/src/components/block-toolbar/index.native.js +86 -6
- package/src/components/{block-mobile-toolbar/test/block-actions-menu.native.js → block-toolbar/test/block-toolbar-menu.native.js} +20 -54
- package/src/components/block-toolbar/test/index.native.js +42 -0
- package/src/components/block-toolbar/utils.js +57 -45
- package/src/components/block-tools/block-contextual-toolbar.js +43 -35
- package/src/components/block-tools/style.scss +17 -5
- package/src/components/block-variation-picker/index.native.js +52 -72
- package/src/components/button-block-appender/styles.native.scss +2 -2
- package/src/components/caption/README.md +49 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +3 -2
- package/src/components/editor-styles/index.js +2 -2
- package/src/components/font-sizes/fluid-utils.js +17 -17
- package/src/components/font-sizes/test/fluid-utils.js +6 -6
- package/src/components/global-styles/behaviors-panel.js +71 -0
- package/src/components/global-styles/color-panel.js +23 -16
- package/src/components/global-styles/dimensions-panel.js +8 -2
- package/src/components/global-styles/get-block-css-selector.js +5 -9
- package/src/components/global-styles/hooks.js +134 -31
- package/src/components/global-styles/index.js +3 -0
- package/src/components/global-styles/test/typography-utils.js +6 -6
- package/src/components/global-styles/typography-panel.js +17 -5
- package/src/components/global-styles/typography-utils.js +4 -4
- package/src/components/global-styles/use-global-styles-output.js +36 -18
- package/src/components/global-styles/utils.js +17 -7
- package/src/components/iframe/index.js +30 -56
- package/src/components/iframe/use-compatibility-styles.js +5 -0
- package/src/components/index.js +0 -5
- package/src/components/inner-blocks/README.md +10 -0
- package/src/components/inner-blocks/index.js +4 -0
- package/src/components/inner-blocks/index.native.js +4 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +32 -5
- package/src/components/inserter/hooks/use-block-types-state.js +15 -6
- package/src/components/inserter/hooks/use-debounced-input.js +8 -7
- package/src/components/inserter/hooks/use-patterns-state.js +2 -1
- package/src/components/inserter/index.js +2 -3
- package/src/components/inserter/index.native.js +17 -36
- package/src/components/inserter/reusable-block-rename-hint.js +18 -1
- package/src/components/inserter/reusable-blocks-tab.js +4 -1
- package/src/components/inserter/style.native.scss +10 -15
- package/src/components/inserter-list-item/index.js +3 -1
- package/src/components/link-control/README.md +12 -3
- package/src/components/link-control/index.js +47 -7
- package/src/components/link-control/link-preview.js +6 -4
- package/src/components/link-control/search-item.js +1 -1
- package/src/components/link-control/style.scss +11 -3
- package/src/components/link-control/test/index.js +28 -1
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/list-view/use-list-view-drop-zone.js +5 -1
- package/src/components/media-placeholder/index.native.js +108 -59
- package/src/components/media-placeholder/styles.native.scss +59 -24
- package/src/components/media-replace-flow/index.native.js +12 -3
- package/src/components/media-upload/test/index.native.js +1 -0
- package/src/components/preview-options/README.md +18 -17
- package/src/components/preview-options/index.js +2 -2
- package/src/components/rich-text/content.js +1 -46
- package/src/components/rich-text/format-edit.js +62 -38
- package/src/components/rich-text/get-rich-text-values.js +99 -0
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
- package/src/components/spacing-sizes-control/test/utils.js +9 -1
- package/src/components/spacing-sizes-control/utils.js +2 -2
- package/src/components/text-transform-control/README.md +44 -0
- package/src/components/use-block-display-information/index.js +12 -5
- package/src/components/use-block-drop-zone/index.native.js +65 -28
- package/src/components/use-setting/index.js +8 -8
- package/src/hooks/behaviors.js +10 -16
- package/src/hooks/border.js +2 -1
- package/src/hooks/margin.js +4 -1
- package/src/hooks/padding.js +4 -1
- package/src/hooks/style.js +7 -3
- package/src/hooks/utils.js +5 -7
- package/src/private-apis.js +9 -1
- package/src/store/actions.js +23 -30
- package/src/store/private-selectors.js +3 -6
- package/src/store/reducer.js +0 -1
- package/src/store/selectors.js +36 -85
- package/src/store/test/actions.js +3 -0
- package/src/store/test/private-selectors.js +5 -5
- package/src/store/test/reducer.js +14 -7
- package/src/store/test/selectors.js +8 -7
- package/src/utils/object.js +32 -2
- package/src/utils/test/object.js +36 -0
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build/components/block-mobile-toolbar/index.native.js +0 -135
- package/build/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +0 -116
- package/build-module/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.native.js +0 -127
- package/src/components/block-mobile-toolbar/style.native.scss +0 -16
- /package/src/components/{block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap → block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap} +0 -0
|
@@ -68,6 +68,8 @@ function UncontrolledInnerBlocks(props) {
|
|
|
68
68
|
clientId,
|
|
69
69
|
allowedBlocks,
|
|
70
70
|
prioritizedInserterBlocks,
|
|
71
|
+
defaultBlock,
|
|
72
|
+
directInsert,
|
|
71
73
|
__experimentalDefaultBlock,
|
|
72
74
|
__experimentalDirectInsert,
|
|
73
75
|
template,
|
|
@@ -92,7 +94,7 @@ function UncontrolledInnerBlocks(props) {
|
|
|
92
94
|
gridProperties
|
|
93
95
|
} = props;
|
|
94
96
|
const context = useBlockContext(clientId);
|
|
95
|
-
useNestedSettingsUpdate(clientId, allowedBlocks, prioritizedInserterBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout);
|
|
97
|
+
useNestedSettingsUpdate(clientId, allowedBlocks, prioritizedInserterBlocks, defaultBlock, directInsert, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout);
|
|
96
98
|
useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection);
|
|
97
99
|
return createElement(LayoutProvider, {
|
|
98
100
|
value: layout
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.native.js"],"names":["__unstableGetInnerBlocksProps","getInnerBlocksProps","useRef","ButtonBlockAppender","DefaultBlockAppender","useNestedSettingsUpdate","useInnerBlockTemplateSync","useBlockContext","BlockList","useBlockEditContext","useBlockSync","BlockContextProvider","defaultLayout","LayoutProvider","useInnerBlocksProps","props","options","fallbackRef","clientId","ref","InnerBlocks","value","onChange","ControlledInnerBlocks","UncontrolledInnerBlocks","children","allowedBlocks","prioritizedInserterBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","orientation","renderAppender","renderFooterAppender","parentWidth","horizontal","contentResizeMode","contentStyle","onAddBlock","onDeleteBlock","marginVertical","marginHorizontal","horizontalAlignment","filterInnerBlocks","blockWidth","layout","gridProperties","context","allProps","save","Content"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,6BAA6B,IAAIC,mBAA1C,QAAqE,mBAArE;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;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;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,OAAOC,YAAP,MAAyB,4BAAzB;AACA,SAASC,oBAAT,QAAqC,kBAArC;AACA,SAASC,aAAT,EAAwBC,cAAxB,QAA8C,sBAA9C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,mBAAT,CAA8BC,KAAK,GAAG,EAAtC,EAA0CC,OAAO,GAAG,EAApD,EAAyD;AAC/D,QAAMC,WAAW,GAAGf,MAAM,EAA1B;AACA,QAAM;AAAEgB,IAAAA;AAAF,MAAeT,mBAAmB,EAAxC;AAEA,QAAMU,GAAG,GAAG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AACO,QAArB,GACN,cAAC,qBAAD,OAA4B8B;AAA5B,IADM,GAGN,cAAC,uBAAD,OAA8BA;AAA9B,IAHD;AAKA,CAdD,C,CAgBA;;;AACAhC,WAAW,CAAChB,oBAAZ,GAAmCA,oBAAnC;AACAgB,WAAW,CAACjB,mBAAZ,GAAkCA,mBAAlC;AAEAW,mBAAmB,CAACuC,IAApB,GAA2BpD,mBAA3B;;AAEAmB,WAAW,CAACkC,OAAZ,GAAsB,MAAMxC,mBAAmB,CAACuC,IAApB,GAA2B5B,QAAvD;AAEA;AACA;AACA;;;AACA,eAAeL,WAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableGetInnerBlocksProps as getInnerBlocksProps } from '@wordpress/blocks';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport useBlockContext from './use-block-context';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { BlockContextProvider } from '../block-context';\nimport { defaultLayout, LayoutProvider } from '../block-list/layout';\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/master/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst fallbackRef = useRef();\n\tconst { clientId } = useBlockEditContext();\n\n\tconst ref = props.ref || fallbackRef;\n\tconst InnerBlocks =\n\t\toptions.value && options.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tchildren: (\n\t\t\t<InnerBlocks\n\t\t\t\t{ ...options }\n\t\t\t\tclientId={ clientId }\n\t\t\t\twrapperRef={ ref }\n\t\t\t/>\n\t\t),\n\t};\n}\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\torientation,\n\t\trenderAppender,\n\t\trenderFooterAppender,\n\t\tparentWidth,\n\t\thorizontal,\n\t\tcontentResizeMode,\n\t\tcontentStyle,\n\t\tonAddBlock,\n\t\tonDeleteBlock,\n\t\tmarginVertical,\n\t\tmarginHorizontal,\n\t\thorizontalAlignment,\n\t\tfilterInnerBlocks,\n\t\tblockWidth,\n\t\tlayout = defaultLayout,\n\t\tgridProperties,\n\t} = props;\n\n\tconst context = useBlockContext( clientId );\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tlayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\treturn (\n\t\t<LayoutProvider value={ layout }>\n\t\t\t<BlockContextProvider value={ context }>\n\t\t\t\t<BlockList\n\t\t\t\t\tmarginVertical={ marginVertical }\n\t\t\t\t\tmarginHorizontal={ marginHorizontal }\n\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t\trenderFooterAppender={ renderFooterAppender }\n\t\t\t\t\twithFooter={ false }\n\t\t\t\t\torientation={ orientation }\n\t\t\t\t\tparentWidth={ parentWidth }\n\t\t\t\t\thorizontalAlignment={ horizontalAlignment }\n\t\t\t\t\thorizontal={ horizontal }\n\t\t\t\t\tcontentResizeMode={ contentResizeMode }\n\t\t\t\t\tcontentStyle={ contentStyle }\n\t\t\t\t\tonAddBlock={ onAddBlock }\n\t\t\t\t\tonDeleteBlock={ onDeleteBlock }\n\t\t\t\t\tfilterInnerBlocks={ filterInnerBlocks }\n\t\t\t\t\tgridProperties={ gridProperties }\n\t\t\t\t\tblockWidth={ blockWidth }\n\t\t\t\t/>\n\t\t\t</BlockContextProvider>\n\t\t</LayoutProvider>\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\n/**\n * Wrapped InnerBlocks component which detects whether to use the controlled or\n * uncontrolled variations of the InnerBlocks component. This is the component\n * which should be used throughout the application.\n *\n * @param {Object} props The component props.\n */\nconst InnerBlocks = ( props ) => {\n\tconst { clientId } = useBlockEditContext();\n\n\tconst allProps = {\n\t\tclientId,\n\t\t...props,\n\t};\n\n\t// Detects if the InnerBlocks should be controlled by an incoming value.\n\treturn props.value && props.onChange ? (\n\t\t<ControlledInnerBlocks { ...allProps } />\n\t) : (\n\t\t<UncontrolledInnerBlocks { ...allProps } />\n\t);\n};\n\n// Expose default appender placeholders as components.\nInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\nInnerBlocks.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 InnerBlocks;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.native.js"],"names":["__unstableGetInnerBlocksProps","getInnerBlocksProps","useRef","ButtonBlockAppender","DefaultBlockAppender","useNestedSettingsUpdate","useInnerBlockTemplateSync","useBlockContext","BlockList","useBlockEditContext","useBlockSync","BlockContextProvider","defaultLayout","LayoutProvider","useInnerBlocksProps","props","options","fallbackRef","clientId","ref","InnerBlocks","value","onChange","ControlledInnerBlocks","UncontrolledInnerBlocks","children","allowedBlocks","prioritizedInserterBlocks","defaultBlock","directInsert","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","orientation","renderAppender","renderFooterAppender","parentWidth","horizontal","contentResizeMode","contentStyle","onAddBlock","onDeleteBlock","marginVertical","marginHorizontal","horizontalAlignment","filterInnerBlocks","blockWidth","layout","gridProperties","context","allProps","save","Content"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,6BAA6B,IAAIC,mBAA1C,QAAqE,mBAArE;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;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;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,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iBC,IAAA,UAAU,EAAGF;AAjBd,IADD,CADD,CADD;AAyBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAAS3B,qBAAT,CAAgCR,KAAhC,EAAwC;AACvCL,EAAAA,YAAY,CAAEK,KAAF,CAAZ;AACA,SAAO,cAAC,uBAAD,OAA8BA;AAA9B,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMK,WAAW,GAAKL,KAAF,IAAa;AAChC,QAAM;AAAEG,IAAAA;AAAF,MAAeT,mBAAmB,EAAxC;AAEA,QAAM6C,QAAQ,GAAG;AAChBpC,IAAAA,QADgB;AAEhB,OAAGH;AAFa,GAAjB,CAHgC,CAQhC;;AACA,SAAOA,KAAK,CAACM,KAAN,IAAeN,KAAK,CAACO,QAArB,GACN,cAAC,qBAAD,OAA4BgC;AAA5B,IADM,GAGN,cAAC,uBAAD,OAA8BA;AAA9B,IAHD;AAKA,CAdD,C,CAgBA;;;AACAlC,WAAW,CAAChB,oBAAZ,GAAmCA,oBAAnC;AACAgB,WAAW,CAACjB,mBAAZ,GAAkCA,mBAAlC;AAEAW,mBAAmB,CAACyC,IAApB,GAA2BtD,mBAA3B;;AAEAmB,WAAW,CAACoC,OAAZ,GAAsB,MAAM1C,mBAAmB,CAACyC,IAApB,GAA2B9B,QAAvD;AAEA;AACA;AACA;;;AACA,eAAeL,WAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableGetInnerBlocksProps as getInnerBlocksProps } from '@wordpress/blocks';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport useBlockContext from './use-block-context';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { BlockContextProvider } from '../block-context';\nimport { defaultLayout, LayoutProvider } from '../block-list/layout';\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/master/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst fallbackRef = useRef();\n\tconst { clientId } = useBlockEditContext();\n\n\tconst ref = props.ref || fallbackRef;\n\tconst InnerBlocks =\n\t\toptions.value && options.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tchildren: (\n\t\t\t<InnerBlocks\n\t\t\t\t{ ...options }\n\t\t\t\tclientId={ clientId }\n\t\t\t\twrapperRef={ ref }\n\t\t\t/>\n\t\t),\n\t};\n}\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\torientation,\n\t\trenderAppender,\n\t\trenderFooterAppender,\n\t\tparentWidth,\n\t\thorizontal,\n\t\tcontentResizeMode,\n\t\tcontentStyle,\n\t\tonAddBlock,\n\t\tonDeleteBlock,\n\t\tmarginVertical,\n\t\tmarginHorizontal,\n\t\thorizontalAlignment,\n\t\tfilterInnerBlocks,\n\t\tblockWidth,\n\t\tlayout = defaultLayout,\n\t\tgridProperties,\n\t} = props;\n\n\tconst context = useBlockContext( clientId );\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\tprioritizedInserterBlocks,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tlayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\treturn (\n\t\t<LayoutProvider value={ layout }>\n\t\t\t<BlockContextProvider value={ context }>\n\t\t\t\t<BlockList\n\t\t\t\t\tmarginVertical={ marginVertical }\n\t\t\t\t\tmarginHorizontal={ marginHorizontal }\n\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t\trenderFooterAppender={ renderFooterAppender }\n\t\t\t\t\twithFooter={ false }\n\t\t\t\t\torientation={ orientation }\n\t\t\t\t\tparentWidth={ parentWidth }\n\t\t\t\t\thorizontalAlignment={ horizontalAlignment }\n\t\t\t\t\thorizontal={ horizontal }\n\t\t\t\t\tcontentResizeMode={ contentResizeMode }\n\t\t\t\t\tcontentStyle={ contentStyle }\n\t\t\t\t\tonAddBlock={ onAddBlock }\n\t\t\t\t\tonDeleteBlock={ onDeleteBlock }\n\t\t\t\t\tfilterInnerBlocks={ filterInnerBlocks }\n\t\t\t\t\tgridProperties={ gridProperties }\n\t\t\t\t\tblockWidth={ blockWidth }\n\t\t\t\t/>\n\t\t\t</BlockContextProvider>\n\t\t</LayoutProvider>\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\n/**\n * Wrapped InnerBlocks component which detects whether to use the controlled or\n * uncontrolled variations of the InnerBlocks component. This is the component\n * which should be used throughout the application.\n *\n * @param {Object} props The component props.\n */\nconst InnerBlocks = ( props ) => {\n\tconst { clientId } = useBlockEditContext();\n\n\tconst allProps = {\n\t\tclientId,\n\t\t...props,\n\t};\n\n\t// Detects if the InnerBlocks should be controlled by an incoming value.\n\treturn props.value && props.onChange ? (\n\t\t<ControlledInnerBlocks { ...allProps } />\n\t) : (\n\t\t<UncontrolledInnerBlocks { ...allProps } />\n\t);\n};\n\n// Expose default appender placeholders as components.\nInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\nInnerBlocks.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 InnerBlocks;\n"]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useLayoutEffect, useMemo } from '@wordpress/element';
|
|
5
5
|
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
6
|
+
import deprecated from '@wordpress/deprecated';
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
8
9
|
*/
|
|
@@ -23,9 +24,13 @@ const pendingSettingsUpdates = new WeakMap();
|
|
|
23
24
|
* @param {string[]} allowedBlocks An array of block names which are permitted
|
|
24
25
|
* in inner blocks.
|
|
25
26
|
* @param {string[]} prioritizedInserterBlocks Block names and/or block variations to be prioritized in the inserter, in the format {blockName}/{variationName}.
|
|
26
|
-
* @param {?WPDirectInsertBlock}
|
|
27
|
-
* @param {?Function|boolean}
|
|
28
|
-
*
|
|
27
|
+
* @param {?WPDirectInsertBlock} defaultBlock The default block to insert: [ blockName, { blockAttributes } ].
|
|
28
|
+
* @param {?Function|boolean} directInsert If a default block should be inserted directly by the appender.
|
|
29
|
+
*
|
|
30
|
+
* @param {?WPDirectInsertBlock} __experimentalDefaultBlock A deprecated prop for the default block to insert: [ blockName, { blockAttributes } ]. Use `defaultBlock` instead.
|
|
31
|
+
*
|
|
32
|
+
* @param {?Function|boolean} __experimentalDirectInsert A deprecated prop for whether a default block should be inserted directly by the appender. Use `directInsert` instead.
|
|
33
|
+
*
|
|
29
34
|
* @param {string} [templateLock] The template lock specified for the inner
|
|
30
35
|
* blocks component. (e.g. "all")
|
|
31
36
|
* @param {boolean} captureToolbars Whether or children toolbars should be shown
|
|
@@ -36,7 +41,7 @@ const pendingSettingsUpdates = new WeakMap();
|
|
|
36
41
|
* @param {Object} layout The layout object for the block container.
|
|
37
42
|
*/
|
|
38
43
|
|
|
39
|
-
export default function useNestedSettingsUpdate(clientId, allowedBlocks, prioritizedInserterBlocks, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout) {
|
|
44
|
+
export default function useNestedSettingsUpdate(clientId, allowedBlocks, prioritizedInserterBlocks, defaultBlock, directInsert, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout) {
|
|
40
45
|
const {
|
|
41
46
|
updateBlockListSettings
|
|
42
47
|
} = useDispatch(blockEditorStore);
|
|
@@ -83,11 +88,29 @@ export default function useNestedSettingsUpdate(clientId, allowedBlocks, priorit
|
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
if (__experimentalDefaultBlock !== undefined) {
|
|
86
|
-
|
|
91
|
+
deprecated('__experimentalDefaultBlock', {
|
|
92
|
+
alternative: 'defaultBlock',
|
|
93
|
+
since: '6.3',
|
|
94
|
+
version: '6.4'
|
|
95
|
+
});
|
|
96
|
+
newSettings.defaultBlock = __experimentalDefaultBlock;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (defaultBlock !== undefined) {
|
|
100
|
+
newSettings.defaultBlock = defaultBlock;
|
|
87
101
|
}
|
|
88
102
|
|
|
89
103
|
if (__experimentalDirectInsert !== undefined) {
|
|
90
|
-
|
|
104
|
+
deprecated('__experimentalDirectInsert', {
|
|
105
|
+
alternative: 'directInsert',
|
|
106
|
+
since: '6.3',
|
|
107
|
+
version: '6.4'
|
|
108
|
+
});
|
|
109
|
+
newSettings.directInsert = __experimentalDirectInsert;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (directInsert !== undefined) {
|
|
113
|
+
newSettings.directInsert = directInsert;
|
|
91
114
|
} // Batch updates to block list settings to avoid triggering cascading renders
|
|
92
115
|
// for each container block included in a tree and optimize initial render.
|
|
93
116
|
// To avoid triggering updateBlockListSettings for each container block
|
|
@@ -111,6 +134,6 @@ export default function useNestedSettingsUpdate(clientId, allowedBlocks, priorit
|
|
|
111
134
|
});
|
|
112
135
|
}
|
|
113
136
|
});
|
|
114
|
-
}, [clientId, _allowedBlocks, _prioritizedInserterBlocks, _templateLock, __experimentalDefaultBlock, __experimentalDirectInsert, captureToolbars, orientation, updateBlockListSettings, layout, registry]);
|
|
137
|
+
}, [clientId, _allowedBlocks, _prioritizedInserterBlocks, _templateLock, defaultBlock, directInsert, __experimentalDefaultBlock, __experimentalDirectInsert, captureToolbars, orientation, updateBlockListSettings, layout, registry]);
|
|
115
138
|
}
|
|
116
139
|
//# 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","useRegistry","store","blockEditorStore","getLayoutType","pendingSettingsUpdates","WeakMap","useNestedSettingsUpdate","clientId","allowedBlocks","prioritizedInserterBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","templateLock","captureToolbars","orientation","layout","updateBlockListSettings","registry","parentLock","select","rootClientId","getBlockRootClientId","getTemplateLock","_allowedBlocks","_prioritizedInserterBlocks","_templateLock","undefined","newSettings","__experimentalCaptureToolbars","layoutType","type","getOrientation","get","set","push","window","queueMicrotask","length","batch","forEach","args"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,EAA0BC,OAA1B,QAAyC,oBAAzC;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,WAAjC,QAAoD,iBAApD;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,aAAT,QAA8B,eAA9B;AAEA;;AAEA,MAAMC,sBAAsB,GAAG,IAAIC,OAAJ,EAA/B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,uBAAT,CACdC,QADc,EAEdC,aAFc,EAGdC,yBAHc,EAIdC,0BAJc,EAKdC,0BALc,EAMdC,YANc,EAOdC,eAPc,EAQdC,WARc,EASdC,MATc,EAUb;AACD,QAAM;AAAEC,IAAAA;AAAF,MAA8BjB,WAAW,CAAEG,gBAAF,CAA/C;AACA,QAAMe,QAAQ,GAAGjB,WAAW,EAA5B;AAEA,QAAM;AAAEkB,IAAAA;AAAF,MAAiBpB,SAAS,CAC7BqB,MAAF,IAAc;AACb,UAAMC,YAAY,GACjBD,MAAM,CAAEjB,gBAAF,CAAN,CAA2BmB,oBAA3B,CAAiDd,QAAjD,CADD;AAEA,WAAO;AACNW,MAAAA,UAAU,EACTC,MAAM,CAAEjB,gBAAF,CAAN,CAA2BoB,eAA3B,CAA4CF,YAA5C;AAFK,KAAP;AAIA,GAR8B,EAS/B,CAAEb,QAAF,CAT+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,sBAAsB,CAAC6B,GAAvB,CAA4BhB,QAA5B,EAAsC,EAAtC;AACA;;AACDb,IAAAA,sBAAsB,CACpB4B,GADF,CACOf,QADP,EAEEiB,IAFF,CAEQ,CAAE3B,QAAF,EAAYoB,WAAZ,CAFR;AAGAQ,IAAAA,MAAM,CAACC,cAAP,CAAuB,MAAM;AAC5B,UAAKhC,sBAAsB,CAAC4B,GAAvB,CAA4Bf,QAA5B,GAAwCoB,MAA7C,EAAsD;AACrDpB,QAAAA,QAAQ,CAACqB,KAAT,CAAgB,MAAM;AACrBlC,UAAAA,sBAAsB,CACpB4B,GADF,CACOf,QADP,EAEEsB,OAFF,CAEaC,IAAF,IAAY;AACrBxB,YAAAA,uBAAuB,CAAE,GAAGwB,IAAL,CAAvB;AACA,WAJF;AAKApC,UAAAA,sBAAsB,CAAC6B,GAAvB,CAA4BhB,QAA5B,EAAsC,EAAtC;AACA,SAPD;AAQA;AACD,KAXD;AAYA,GAtDc,EAsDZ,CACFV,QADE,EAEFgB,cAFE,EAGFC,0BAHE,EAIFC,aAJE,EAKFf,0BALE,EAMFC,0BANE,EAOFE,eAPE,EAQFC,WARE,EASFE,uBATE,EAUFD,MAVE,EAWFE,QAXE,CAtDY,CAAf;AAmEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\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 {string[]} prioritizedInserterBlocks Block names and/or block variations to be prioritized in the inserter, in the format {blockName}/{variationName}.\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\tprioritizedInserterBlocks,\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 { 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\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 allowedBlocks and prioritisedInnerBlocks based on the contents\n\t// of the arrays. Implementors often pass a new array on every render,\n\t// and the contents of the arrays are just strings, so the entire array\n\t// can be passed as dependencies.\n\n\tconst _allowedBlocks = useMemo(\n\t\t() => allowedBlocks,\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\tallowedBlocks\n\t);\n\n\tconst _prioritizedInserterBlocks = useMemo(\n\t\t() => prioritizedInserterBlocks,\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\tprioritizedInserterBlocks\n\t);\n\n\tconst _templateLock =\n\t\ttemplateLock === undefined || parentLock === 'contentOnly'\n\t\t\t? parentLock\n\t\t\t: templateLock;\n\n\tuseLayoutEffect( () => {\n\t\tconst newSettings = {\n\t\t\tallowedBlocks: _allowedBlocks,\n\t\t\tprioritizedInserterBlocks: _prioritizedInserterBlocks,\n\t\t\ttemplateLock: _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\t// Batch updates to block list settings to avoid triggering cascading renders\n\t\t// for each container block included in a tree and optimize initial render.\n\t\t// To avoid triggering updateBlockListSettings for each container block\n\t\t// causing X re-renderings for X container blocks,\n\t\t// we batch all the updatedBlockListSettings in a single \"data\" batch\n\t\t// which results in a single re-render.\n\t\tif ( ! pendingSettingsUpdates.get( registry ) ) {\n\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t}\n\t\tpendingSettingsUpdates\n\t\t\t.get( registry )\n\t\t\t.push( [ clientId, newSettings ] );\n\t\twindow.queueMicrotask( () => {\n\t\t\tif ( pendingSettingsUpdates.get( registry )?.length ) {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tpendingSettingsUpdates\n\t\t\t\t\t\t.get( registry )\n\t\t\t\t\t\t.forEach( ( args ) => {\n\t\t\t\t\t\t\tupdateBlockListSettings( ...args );\n\t\t\t\t\t\t} );\n\t\t\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [\n\t\tclientId,\n\t\t_allowedBlocks,\n\t\t_prioritizedInserterBlocks,\n\t\t_templateLock,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tupdateBlockListSettings,\n\t\tlayout,\n\t\tregistry,\n\t] );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/use-nested-settings-update.js"],"names":["useLayoutEffect","useMemo","useSelect","useDispatch","useRegistry","deprecated","store","blockEditorStore","getLayoutType","pendingSettingsUpdates","WeakMap","useNestedSettingsUpdate","clientId","allowedBlocks","prioritizedInserterBlocks","defaultBlock","directInsert","__experimentalDefaultBlock","__experimentalDirectInsert","templateLock","captureToolbars","orientation","layout","updateBlockListSettings","registry","parentLock","select","rootClientId","getBlockRootClientId","getTemplateLock","_allowedBlocks","_prioritizedInserterBlocks","_templateLock","undefined","newSettings","__experimentalCaptureToolbars","layoutType","type","getOrientation","alternative","since","version","get","set","push","window","queueMicrotask","length","batch","forEach","args"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,EAA0BC,OAA1B,QAAyC,oBAAzC;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,WAAjC,QAAoD,iBAApD;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,aAAT,QAA8B,eAA9B;AAEA;;AAEA,MAAMC,sBAAsB,GAAG,IAAIC,OAAJ,EAA/B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,uBAAT,CACdC,QADc,EAEdC,aAFc,EAGdC,yBAHc,EAIdC,YAJc,EAKdC,YALc,EAMdC,0BANc,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C,sBAAsB,CAACiC,GAAvB,CAA4BlB,QAA5B,GAAwCuB,MAA7C,EAAsD;AACrDvB,QAAAA,QAAQ,CAACwB,KAAT,CAAgB,MAAM;AACrBvC,UAAAA,sBAAsB,CACpBiC,GADF,CACOlB,QADP,EAEEyB,OAFF,CAEaC,IAAF,IAAY;AACrB3B,YAAAA,uBAAuB,CAAE,GAAG2B,IAAL,CAAvB;AACA,WAJF;AAKAzC,UAAAA,sBAAsB,CAACkC,GAAvB,CAA4BnB,QAA5B,EAAsC,EAAtC;AACA,SAPD;AAQA;AACD,KAXD;AAYA,GAxEc,EAwEZ,CACFZ,QADE,EAEFkB,cAFE,EAGFC,0BAHE,EAIFC,aAJE,EAKFjB,YALE,EAMFC,YANE,EAOFC,0BAPE,EAQFC,0BARE,EASFE,eATE,EAUFC,WAVE,EAWFE,uBAXE,EAYFD,MAZE,EAaFE,QAbE,CAxEY,CAAf;AAuFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\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 {string[]} prioritizedInserterBlocks Block names and/or block variations to be prioritized in the inserter, in the format {blockName}/{variationName}.\n * @param {?WPDirectInsertBlock} defaultBlock The default block to insert: [ blockName, { blockAttributes } ].\n * @param {?Function|boolean} directInsert If a default block should be inserted directly by the appender.\n *\n * @param {?WPDirectInsertBlock} __experimentalDefaultBlock A deprecated prop for the default block to insert: [ blockName, { blockAttributes } ]. Use `defaultBlock` instead.\n *\n * @param {?Function|boolean} __experimentalDirectInsert A deprecated prop for whether a default block should be inserted directly by the appender. Use `directInsert` instead.\n *\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\tprioritizedInserterBlocks,\n\tdefaultBlock,\n\tdirectInsert,\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 { 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\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 allowedBlocks and prioritisedInnerBlocks based on the contents\n\t// of the arrays. Implementors often pass a new array on every render,\n\t// and the contents of the arrays are just strings, so the entire array\n\t// can be passed as dependencies.\n\n\tconst _allowedBlocks = useMemo(\n\t\t() => allowedBlocks,\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\tallowedBlocks\n\t);\n\n\tconst _prioritizedInserterBlocks = useMemo(\n\t\t() => prioritizedInserterBlocks,\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\tprioritizedInserterBlocks\n\t);\n\n\tconst _templateLock =\n\t\ttemplateLock === undefined || parentLock === 'contentOnly'\n\t\t\t? parentLock\n\t\t\t: templateLock;\n\n\tuseLayoutEffect( () => {\n\t\tconst newSettings = {\n\t\t\tallowedBlocks: _allowedBlocks,\n\t\t\tprioritizedInserterBlocks: _prioritizedInserterBlocks,\n\t\t\ttemplateLock: _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\tdeprecated( '__experimentalDefaultBlock', {\n\t\t\t\talternative: 'defaultBlock',\n\t\t\t\tsince: '6.3',\n\t\t\t\tversion: '6.4',\n\t\t\t} );\n\t\t\tnewSettings.defaultBlock = __experimentalDefaultBlock;\n\t\t}\n\n\t\tif ( defaultBlock !== undefined ) {\n\t\t\tnewSettings.defaultBlock = defaultBlock;\n\t\t}\n\n\t\tif ( __experimentalDirectInsert !== undefined ) {\n\t\t\tdeprecated( '__experimentalDirectInsert', {\n\t\t\t\talternative: 'directInsert',\n\t\t\t\tsince: '6.3',\n\t\t\t\tversion: '6.4',\n\t\t\t} );\n\t\t\tnewSettings.directInsert = __experimentalDirectInsert;\n\t\t}\n\n\t\tif ( directInsert !== undefined ) {\n\t\t\tnewSettings.directInsert = directInsert;\n\t\t}\n\n\t\t// Batch updates to block list settings to avoid triggering cascading renders\n\t\t// for each container block included in a tree and optimize initial render.\n\t\t// To avoid triggering updateBlockListSettings for each container block\n\t\t// causing X re-renderings for X container blocks,\n\t\t// we batch all the updatedBlockListSettings in a single \"data\" batch\n\t\t// which results in a single re-render.\n\t\tif ( ! pendingSettingsUpdates.get( registry ) ) {\n\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t}\n\t\tpendingSettingsUpdates\n\t\t\t.get( registry )\n\t\t\t.push( [ clientId, newSettings ] );\n\t\twindow.queueMicrotask( () => {\n\t\t\tif ( pendingSettingsUpdates.get( registry )?.length ) {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tpendingSettingsUpdates\n\t\t\t\t\t\t.get( registry )\n\t\t\t\t\t\t.forEach( ( args ) => {\n\t\t\t\t\t\t\tupdateBlockListSettings( ...args );\n\t\t\t\t\t\t} );\n\t\t\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [\n\t\tclientId,\n\t\t_allowedBlocks,\n\t\t_prioritizedInserterBlocks,\n\t\t_templateLock,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tupdateBlockListSettings,\n\t\tlayout,\n\t\tregistry,\n\t] );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { createBlock, createBlocksFromInnerBlocksTemplate, store as blocksStore } from '@wordpress/blocks';
|
|
4
|
+
import { createBlock, createBlocksFromInnerBlocksTemplate, store as blocksStore, parse } from '@wordpress/blocks';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { useCallback } from '@wordpress/element';
|
|
7
7
|
/**
|
|
@@ -39,9 +39,13 @@ const useBlockTypesState = (rootClientId, onInsert) => {
|
|
|
39
39
|
const onSelectItem = useCallback(({
|
|
40
40
|
name,
|
|
41
41
|
initialAttributes,
|
|
42
|
-
innerBlocks
|
|
42
|
+
innerBlocks,
|
|
43
|
+
syncStatus,
|
|
44
|
+
content
|
|
43
45
|
}, shouldFocusBlock) => {
|
|
44
|
-
const insertedBlock =
|
|
46
|
+
const insertedBlock = syncStatus === 'unsynced' ? parse(content, {
|
|
47
|
+
__unstableSkipMigrationLogs: true
|
|
48
|
+
}) : createBlock(name, initialAttributes, createBlocksFromInnerBlocksTemplate(innerBlocks));
|
|
45
49
|
onInsert(insertedBlock, undefined, shouldFocusBlock);
|
|
46
50
|
}, [onInsert]);
|
|
47
51
|
return [items, categories, collections, onSelectItem];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-block-types-state.js"],"names":["createBlock","createBlocksFromInnerBlocksTemplate","store","blocksStore","useSelect","useCallback","blockEditorStore","useBlockTypesState","rootClientId","onInsert","categories","collections","items","select","getInserterItems","getCategories","getCollections","onSelectItem","name","initialAttributes","innerBlocks","shouldFocusBlock","insertedBlock","undefined"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WADD,EAECC,mCAFD,EAGCC,KAAK,IAAIC,WAHV,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-block-types-state.js"],"names":["createBlock","createBlocksFromInnerBlocksTemplate","store","blocksStore","parse","useSelect","useCallback","blockEditorStore","useBlockTypesState","rootClientId","onInsert","categories","collections","items","select","getInserterItems","getCategories","getCollections","onSelectItem","name","initialAttributes","innerBlocks","syncStatus","content","shouldFocusBlock","insertedBlock","__unstableSkipMigrationLogs","undefined"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WADD,EAECC,mCAFD,EAGCC,KAAK,IAAIC,WAHV,EAICC,KAJD,QAKO,mBALP;AAMA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,SAASJ,KAAK,IAAIK,gBAAlB,QAA0C,gBAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,kBAAkB,GAAG,CAAEC,YAAF,EAAgBC,QAAhB,KAA8B;AACxD,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,WAAd;AAA2BC,IAAAA;AAA3B,MAAqCR,SAAS,CACjDS,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAEP,gBAAF,CAAnC;AACA,UAAM;AAAES,MAAAA,aAAF;AAAiBC,MAAAA;AAAjB,QAAoCH,MAAM,CAAEX,WAAF,CAAhD;AAEA,WAAO;AACNQ,MAAAA,UAAU,EAAEK,aAAa,EADnB;AAENJ,MAAAA,WAAW,EAAEK,cAAc,EAFrB;AAGNJ,MAAAA,KAAK,EAAEE,gBAAgB,CAAEN,YAAF;AAHjB,KAAP;AAKA,GAVkD,EAWnD,CAAEA,YAAF,CAXmD,CAApD;AAcA,QAAMS,YAAY,GAAGZ,WAAW,CAC/B,CACC;AAAEa,IAAAA,IAAF;AAAQC,IAAAA,iBAAR;AAA2BC,IAAAA,WAA3B;AAAwCC,IAAAA,UAAxC;AAAoDC,IAAAA;AAApD,GADD,EAECC,gBAFD,KAGK;AACJ,UAAMC,aAAa,GAClBH,UAAU,KAAK,UAAf,GACGlB,KAAK,CAAEmB,OAAF,EAAW;AAChBG,MAAAA,2BAA2B,EAAE;AADb,KAAX,CADR,GAIG1B,WAAW,CACXmB,IADW,EAEXC,iBAFW,EAGXnB,mCAAmC,CAAEoB,WAAF,CAHxB,CALf;AAWAX,IAAAA,QAAQ,CAAEe,aAAF,EAAiBE,SAAjB,EAA4BH,gBAA5B,CAAR;AACA,GAjB8B,EAkB/B,CAAEd,QAAF,CAlB+B,CAAhC;AAqBA,SAAO,CAAEG,KAAF,EAASF,UAAT,EAAqBC,WAArB,EAAkCM,YAAlC,CAAP;AACA,CArCD;;AAuCA,eAAeV,kBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n\tparse,\n} from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Retrieves the block types inserter state.\n *\n * @param {string=} rootClientId Insertion's root client ID.\n * @param {Function} onInsert function called when inserter a list of blocks.\n * @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)\n */\nconst useBlockTypesState = ( rootClientId, onInsert ) => {\n\tconst { categories, collections, items } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getInserterItems } = select( blockEditorStore );\n\t\t\tconst { getCategories, getCollections } = select( blocksStore );\n\n\t\t\treturn {\n\t\t\t\tcategories: getCategories(),\n\t\t\t\tcollections: getCollections(),\n\t\t\t\titems: getInserterItems( rootClientId ),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst onSelectItem = useCallback(\n\t\t(\n\t\t\t{ name, initialAttributes, innerBlocks, syncStatus, content },\n\t\t\tshouldFocusBlock\n\t\t) => {\n\t\t\tconst insertedBlock =\n\t\t\t\tsyncStatus === 'unsynced'\n\t\t\t\t\t? parse( content, {\n\t\t\t\t\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t\t\t } )\n\t\t\t\t\t: createBlock(\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tinitialAttributes,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate( innerBlocks )\n\t\t\t\t\t );\n\n\t\t\tonInsert( insertedBlock, undefined, shouldFocusBlock );\n\t\t},\n\t\t[ onInsert ]\n\t);\n\n\treturn [ items, categories, collections, onSelectItem ];\n};\n\nexport default useBlockTypesState;\n"]}
|
|
@@ -5,13 +5,11 @@ import { useEffect, useState } from '@wordpress/element';
|
|
|
5
5
|
import { useDebounce } from '@wordpress/compose';
|
|
6
6
|
export default function useDebouncedInput(defaultValue = '') {
|
|
7
7
|
const [input, setInput] = useState(defaultValue);
|
|
8
|
-
const [
|
|
9
|
-
const
|
|
8
|
+
const [debouncedInput, setDebouncedState] = useState(defaultValue);
|
|
9
|
+
const setDebouncedInput = useDebounce(setDebouncedState, 250);
|
|
10
10
|
useEffect(() => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, [debounced, input]);
|
|
15
|
-
return [input, setInput, debounced];
|
|
11
|
+
setDebouncedInput(input);
|
|
12
|
+
}, [input]);
|
|
13
|
+
return [input, setInput, debouncedInput];
|
|
16
14
|
}
|
|
17
15
|
//# sourceMappingURL=use-debounced-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-debounced-input.js"],"names":["useEffect","useState","useDebounce","useDebouncedInput","defaultValue","input","setInput","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-debounced-input.js"],"names":["useEffect","useState","useDebounce","useDebouncedInput","defaultValue","input","setInput","debouncedInput","setDebouncedState","setDebouncedInput"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,QAAoC,oBAApC;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA,eAAe,SAASC,iBAAT,CAA4BC,YAAY,GAAG,EAA3C,EAAgD;AAC9D,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsBL,QAAQ,CAAEG,YAAF,CAApC;AACA,QAAM,CAAEG,cAAF,EAAkBC,iBAAlB,IAAwCP,QAAQ,CAAEG,YAAF,CAAtD;AAEA,QAAMK,iBAAiB,GAAGP,WAAW,CAAEM,iBAAF,EAAqB,GAArB,CAArC;AAEAR,EAAAA,SAAS,CAAE,MAAM;AAChBS,IAAAA,iBAAiB,CAAEJ,KAAF,CAAjB;AACA,GAFQ,EAEN,CAAEA,KAAF,CAFM,CAAT;AAIA,SAAO,CAAEA,KAAF,EAASC,QAAT,EAAmBC,cAAnB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\n\nexport default function useDebouncedInput( defaultValue = '' ) {\n\tconst [ input, setInput ] = useState( defaultValue );\n\tconst [ debouncedInput, setDebouncedState ] = useState( defaultValue );\n\n\tconst setDebouncedInput = useDebounce( setDebouncedState, 250 );\n\n\tuseEffect( () => {\n\t\tsetDebouncedInput( input );\n\t}, [ input ] );\n\n\treturn [ input, setInput, debouncedInput ];\n}\n"]}
|
|
@@ -14,7 +14,7 @@ import { store as blockEditorStore } from '../../../store';
|
|
|
14
14
|
const CUSTOM_CATEGORY = {
|
|
15
15
|
name: 'custom',
|
|
16
16
|
label: __('My patterns'),
|
|
17
|
-
description: __('Custom patterns
|
|
17
|
+
description: __('Custom patterns added by site users')
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Retrieves the block patterns inserter state.
|
|
@@ -48,7 +48,8 @@ const usePatternsState = (onInsert, rootClientId) => {
|
|
|
48
48
|
createSuccessNotice(sprintf(
|
|
49
49
|
/* translators: %s: block pattern title. */
|
|
50
50
|
__('Block pattern "%s" inserted.'), pattern.title), {
|
|
51
|
-
type: 'snackbar'
|
|
51
|
+
type: 'snackbar',
|
|
52
|
+
id: 'block-pattern-inserted-notice'
|
|
52
53
|
});
|
|
53
54
|
}, [createSuccessNotice, onInsert]);
|
|
54
55
|
return [patterns, allCategories, onClickPattern];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-patterns-state.js"],"names":["useCallback","useMemo","cloneBlock","useDispatch","useSelect","__","sprintf","store","noticesStore","blockEditorStore","CUSTOM_CATEGORY","name","label","description","usePatternsState","onInsert","rootClientId","patternCategories","patterns","select","__experimentalGetAllowedPatterns","getSettings","__experimentalBlockPatternCategories","allCategories","createSuccessNotice","onClickPattern","pattern","blocks","map","block","title","type"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,gBAA1C;AAEA,MAAMC,eAAe,GAAG;AACvBC,EAAAA,IAAI,EAAE,QADiB;AAEvBC,EAAAA,KAAK,EAAEP,EAAE,CAAE,aAAF,CAFc;AAGvBQ,EAAAA,WAAW,EAAER,EAAE,CAAE,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-patterns-state.js"],"names":["useCallback","useMemo","cloneBlock","useDispatch","useSelect","__","sprintf","store","noticesStore","blockEditorStore","CUSTOM_CATEGORY","name","label","description","usePatternsState","onInsert","rootClientId","patternCategories","patterns","select","__experimentalGetAllowedPatterns","getSettings","__experimentalBlockPatternCategories","allCategories","createSuccessNotice","onClickPattern","pattern","blocks","map","block","title","type","id"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,UAAT,QAA2B,mBAA3B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,gBAA1C;AAEA,MAAMC,eAAe,GAAG;AACvBC,EAAAA,IAAI,EAAE,QADiB;AAEvBC,EAAAA,KAAK,EAAEP,EAAE,CAAE,aAAF,CAFc;AAGvBQ,EAAAA,WAAW,EAAER,EAAE,CAAE,qCAAF;AAHQ,CAAxB;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMS,gBAAgB,GAAG,CAAEC,QAAF,EAAYC,YAAZ,KAA8B;AACtD,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAAkCd,SAAS,CAC9Ce,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,gCAAF;AAAoCC,MAAAA;AAApC,QACLF,MAAM,CAAEV,gBAAF,CADP;AAGA,WAAO;AACNS,MAAAA,QAAQ,EAAEE,gCAAgC,CAAEJ,YAAF,CADpC;AAENC,MAAAA,iBAAiB,EAChBI,WAAW,GAAGC;AAHT,KAAP;AAKA,GAV+C,EAWhD,CAAEN,YAAF,CAXgD,CAAjD;AAcA,QAAMO,aAAa,GAAGtB,OAAO,CAC5B,MAAM,CAAE,GAAGgB,iBAAL,EAAwBP,eAAxB,CADsB,EAE5B,CAAEO,iBAAF,CAF4B,CAA7B;AAKA,QAAM;AAAEO,IAAAA;AAAF,MAA0BrB,WAAW,CAAEK,YAAF,CAA3C;AACA,QAAMiB,cAAc,GAAGzB,WAAW,CACjC,CAAE0B,OAAF,EAAWC,MAAX,KAAuB;AACtBZ,IAAAA,QAAQ,CACP,CAAEY,MAAF,aAAEA,MAAF,cAAEA,MAAF,GAAY,EAAZ,EAAiBC,GAAjB,CAAwBC,KAAF,IAAa3B,UAAU,CAAE2B,KAAF,CAA7C,CADO,EAEPH,OAAO,CAACf,IAFD,CAAR;AAIAa,IAAAA,mBAAmB,CAClBlB,OAAO;AACN;AACAD,IAAAA,EAAE,CAAE,8BAAF,CAFI,EAGNqB,OAAO,CAACI,KAHF,CADW,EAMlB;AACCC,MAAAA,IAAI,EAAE,UADP;AAECC,MAAAA,EAAE,EAAE;AAFL,KANkB,CAAnB;AAWA,GAjBgC,EAkBjC,CAAER,mBAAF,EAAuBT,QAAvB,CAlBiC,CAAlC;AAqBA,SAAO,CAAEG,QAAF,EAAYK,aAAZ,EAA2BE,cAA3B,CAAP;AACA,CA3CD;;AA6CA,eAAeX,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\nconst CUSTOM_CATEGORY = {\n\tname: 'custom',\n\tlabel: __( 'My patterns' ),\n\tdescription: __( 'Custom patterns added by site users' ),\n};\n\n/**\n * Retrieves the block patterns inserter state.\n *\n * @param {Function} onInsert function called when inserter a list of blocks.\n * @param {string=} rootClientId Insertion's root client ID.\n *\n * @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)\n */\nconst usePatternsState = ( onInsert, rootClientId ) => {\n\tconst { patternCategories, patterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __experimentalGetAllowedPatterns, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tpatterns: __experimentalGetAllowedPatterns( rootClientId ),\n\t\t\t\tpatternCategories:\n\t\t\t\t\tgetSettings().__experimentalBlockPatternCategories,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst allCategories = useMemo(\n\t\t() => [ ...patternCategories, CUSTOM_CATEGORY ],\n\t\t[ patternCategories ]\n\t);\n\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst onClickPattern = useCallback(\n\t\t( pattern, blocks ) => {\n\t\t\tonInsert(\n\t\t\t\t( blocks ?? [] ).map( ( block ) => cloneBlock( block ) ),\n\t\t\t\tpattern.name\n\t\t\t);\n\t\t\tcreateSuccessNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t/* translators: %s: block pattern title. */\n\t\t\t\t\t__( 'Block pattern \"%s\" inserted.' ),\n\t\t\t\t\tpattern.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'block-pattern-inserted-notice',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t\t[ createSuccessNotice, onInsert ]\n\t);\n\n\treturn [ patterns, allCategories, onClickPattern ];\n};\n\nexport default usePatternsState;\n"]}
|
|
@@ -231,7 +231,7 @@ export const ComposedPrivateInserter = compose([withSelect((select, {
|
|
|
231
231
|
getBlockRootClientId,
|
|
232
232
|
hasInserterItems,
|
|
233
233
|
getAllowedBlocks,
|
|
234
|
-
|
|
234
|
+
getDirectInsertBlock,
|
|
235
235
|
getSettings
|
|
236
236
|
} = select(blockEditorStore);
|
|
237
237
|
const {
|
|
@@ -239,9 +239,7 @@ export const ComposedPrivateInserter = compose([withSelect((select, {
|
|
|
239
239
|
} = select(blocksStore);
|
|
240
240
|
rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
|
|
241
241
|
const allowedBlocks = getAllowedBlocks(rootClientId);
|
|
242
|
-
|
|
243
|
-
const directInsertBlock = shouldDirectInsert && __experimentalGetDirectInsertBlock(rootClientId);
|
|
244
|
-
|
|
242
|
+
const directInsertBlock = shouldDirectInsert && getDirectInsertBlock(rootClientId);
|
|
245
243
|
const settings = getSettings();
|
|
246
244
|
const hasSingleBlockType = allowedBlocks?.length === 1 && getBlockVariations(allowedBlocks[0].name, 'inserter')?.length === 0;
|
|
247
245
|
let allowedBlockType = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.js"],"names":["classnames","speak","__","_x","sprintf","Dropdown","Button","forwardRef","Component","withDispatch","withSelect","compose","ifCondition","createBlock","store","blocksStore","plus","InserterMenu","QuickInserter","blockEditorStore","defaultRenderToggle","onToggle","disabled","isOpen","blockTitle","hasSingleBlockType","toggleProps","prioritizePatterns","as","Wrapper","label","labelProp","onClick","rest","handleClick","event","PrivateInserter","constructor","arguments","bind","renderToggle","renderContent","props","directInsertBlock","hasItems","onClose","rootClientId","clientId","isAppender","showInserterHelpPanel","__experimentalIsQuick","isQuick","onSelectOrClose","selectBlockOnInsert","blocks","firstBlock","Array","isArray","length","render","position","insertOnlyAllowedBlock","shift","ComposedPrivateInserter","select","shouldDirectInsert","getBlockRootClientId","hasInserterItems","getAllowedBlocks","__experimentalGetDirectInsertBlock","getSettings","getBlockVariations","undefined","allowedBlocks","settings","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","Inserter","ref"],"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,UAAT,EAAqBC,SAArB,QAAsC,oBAAtC;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,CAAE;AAC7BC,EAAAA,QAD6B;AAE7BC,EAAAA,QAF6B;AAG7BC,EAAAA,MAH6B;AAI7BC,EAAAA,UAJ6B;AAK7BC,EAAAA,kBAL6B;AAM7BC,EAAAA,WAAW,GAAG,EANe;AAO7BC,EAAAA;AAP6B,CAAF,KAQrB;AACN,QAAM;AACLC,IAAAA,EAAE,EAAEC,OAAO,GAAGvB,MADT;AAELwB,IAAAA,KAAK,EAAEC,SAFF;AAGLC,IAAAA,OAHK;AAIL,OAAGC;AAJE,MAKFP,WALJ;AAOA,MAAII,KAAK,G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AAP,CAqMlCX,eArMkC,CAAhC;AAuMP,MAAMqE,QAAQ,GAAGlG,UAAU,CAAE,CAAEmC,KAAF,EAASgE,GAAT,KAAkB;AAC9C,SAAO,cAAC,uBAAD;AAAyB,IAAA,GAAG,EAAGA,GAA/B;AAAA,OAA0ChE;AAA1C,IAAP;AACA,CAF0B,CAA3B;AAIA,eAAe+D,QAAf","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 { forwardRef, 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\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && 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 ( ! label && prioritizePatterns ) {\n\t\tlabel = __( 'Add pattern' );\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\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<Wrapper\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 PrivateInserter 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\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\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={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\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\tselectBlockOnInsert={ selectBlockOnInsert }\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\tpopoverProps={ { position, shift: true } }\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 const ComposedPrivateInserter = compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\t__experimentalGetDirectInsertBlock,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert &&\n\t\t\t\t__experimentalGetDirectInsertBlock( rootClientId );\n\n\t\t\tconst settings = getSettings();\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\n\t\t\tlet allowedBlockType = false;\n\t\t\tif ( hasSingleBlockType ) {\n\t\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tdirectInsertBlock,\n\t\t\t\trootClientId,\n\t\t\t\tprioritizePatterns:\n\t\t\t\t\tsettings.__experimentalPreferPatternsOnRoot &&\n\t\t\t\t\t! rootClientId,\n\t\t\t};\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\tselectBlockOnInsert,\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(\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( {\n\t\t\t\t\t\tclientId: blockToInsert?.clientId,\n\t\t\t\t\t} );\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] )( PrivateInserter );\n\nconst Inserter = forwardRef( ( props, ref ) => {\n\treturn <ComposedPrivateInserter ref={ ref } { ...props } />;\n} );\n\nexport default Inserter;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.js"],"names":["classnames","speak","__","_x","sprintf","Dropdown","Button","forwardRef","Component","withDispatch","withSelect","compose","ifCondition","createBlock","store","blocksStore","plus","InserterMenu","QuickInserter","blockEditorStore","defaultRenderToggle","onToggle","disabled","isOpen","blockTitle","hasSingleBlockType","toggleProps","prioritizePatterns","as","Wrapper","label","labelProp","onClick","rest","handleClick","event","PrivateInserter","constructor","arguments","bind","renderToggle","renderContent","props","directInsertBlock","hasItems","onClose","rootClientId","clientId","isAppender","showInserterHelpPanel","__experimentalIsQuick","isQuick","onSelectOrClose","selectBlockOnInsert","blocks","firstBlock","Array","isArray","length","render","position","insertOnlyAllowedBlock","shift","ComposedPrivateInserter","select","shouldDirectInsert","getBlockRootClientId","hasInserterItems","getAllowedBlocks","getDirectInsertBlock","getSettings","getBlockVariations","undefined","allowedBlocks","settings","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","Inserter","ref"],"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,UAAT,EAAqBC,SAArB,QAAsC,oBAAtC;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,CAAE;AAC7BC,EAAAA,QAD6B;AAE7BC,EAAAA,QAF6B;AAG7BC,EAAAA,MAH6B;AAI7BC,EAAAA,UAJ6B;AAK7BC,EAAAA,kBAL6B;AAM7BC,EAAAA,WAAW,GAAG,EANe;AAO7BC,EAAAA;AAP6B,CAAF,KAQrB;AACN,QAAM;AACLC,IAAAA,EAAE,EAAEC,OAAO,GAAGvB,MADT;AAELwB,IAAAA,KAAK,EAAEC,SAFF;AAGLC,IAAAA,OAHK;AAIL,OAAGC;AAJE,MAKFP,WALJ;AAOA,MAAII,KAAK,GAAGC,SAAZ;;AACA,MAAK,CAAED,KAAF,IAAWL,kBAAhB,EAAqC;AACpCK,IAAAA,KAAK,GAAG1B,OAAO,EACd;AACAD,IAAAA,EAAE,CAAE,QAAF,EAAY,qCAAZ,CAFY,EAGdqB,UAHc,CAAf;AAKA,GAND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A1C,IAAP;AACA,CAF0B,CAA3B;AAIA,eAAe+D,QAAf","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 { forwardRef, 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\tconst {\n\t\tas: Wrapper = Button,\n\t\tlabel: labelProp,\n\t\tonClick,\n\t\t...rest\n\t} = toggleProps;\n\n\tlet label = labelProp;\n\tif ( ! label && 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 ( ! label && prioritizePatterns ) {\n\t\tlabel = __( 'Add pattern' );\n\t} else if ( ! label ) {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\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<Wrapper\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 PrivateInserter 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\tonSelectOrClose,\n\t\t\tselectBlockOnInsert,\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={ ( blocks ) => {\n\t\t\t\t\t\tconst firstBlock =\n\t\t\t\t\t\t\tArray.isArray( blocks ) && blocks?.length\n\t\t\t\t\t\t\t\t? blocks[ 0 ]\n\t\t\t\t\t\t\t\t: blocks;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tonSelectOrClose &&\n\t\t\t\t\t\t\ttypeof onSelectOrClose === 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tonSelectOrClose( firstBlock );\n\t\t\t\t\t\t}\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\tselectBlockOnInsert={ selectBlockOnInsert }\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\tpopoverProps={ { position, shift: true } }\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 const ComposedPrivateInserter = compose( [\n\twithSelect(\n\t\t( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\thasInserterItems,\n\t\t\t\tgetAllowedBlocks,\n\t\t\t\tgetDirectInsertBlock,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\t\trootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( rootClientId );\n\n\t\t\tconst directInsertBlock =\n\t\t\t\tshouldDirectInsert && getDirectInsertBlock( rootClientId );\n\n\t\t\tconst settings = getSettings();\n\n\t\t\tconst hasSingleBlockType =\n\t\t\t\tallowedBlocks?.length === 1 &&\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t\t\t?.length === 0;\n\n\t\t\tlet allowedBlockType = false;\n\t\t\tif ( hasSingleBlockType ) {\n\t\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\t\thasSingleBlockType,\n\t\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\t\tallowedBlockType,\n\t\t\t\tdirectInsertBlock,\n\t\t\t\trootClientId,\n\t\t\t\tprioritizePatterns:\n\t\t\t\t\tsettings.__experimentalPreferPatternsOnRoot &&\n\t\t\t\t\t! rootClientId,\n\t\t\t};\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\tselectBlockOnInsert,\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(\n\t\t\t\t\tblockToInsert,\n\t\t\t\t\tgetInsertionIndex(),\n\t\t\t\t\trootClientId,\n\t\t\t\t\tselectBlockOnInsert\n\t\t\t\t);\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose( {\n\t\t\t\t\t\tclientId: blockToInsert?.clientId,\n\t\t\t\t\t} );\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] )( PrivateInserter );\n\nconst Inserter = forwardRef( ( props, ref ) => {\n\treturn <ComposedPrivateInserter ref={ ref } { ...props } />;\n} );\n\nexport default Inserter;\n"]}
|
|
@@ -3,7 +3,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { AccessibilityInfo, Platform
|
|
6
|
+
import { AccessibilityInfo, Platform } from 'react-native';
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
@@ -29,31 +29,15 @@ const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
|
|
|
29
29
|
const defaultRenderToggle = ({
|
|
30
30
|
onToggle,
|
|
31
31
|
disabled,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
onLongPress
|
|
35
|
-
useExpandedMode
|
|
32
|
+
iconStyle,
|
|
33
|
+
buttonStyle,
|
|
34
|
+
onLongPress
|
|
36
35
|
}) => {
|
|
37
|
-
// The "expanded mode" refers to the editor's appearance when no blocks
|
|
38
|
-
// are currently selected. The "add block" button has a separate style
|
|
39
|
-
// for the "expanded mode", which are added via the below "expandedModeViewProps"
|
|
40
|
-
// and "expandedModeViewText" variables.
|
|
41
|
-
const expandedModeViewProps = useExpandedMode && {
|
|
42
|
-
icon: createElement(Icon, {
|
|
43
|
-
icon: plus,
|
|
44
|
-
style: style
|
|
45
|
-
}),
|
|
46
|
-
customContainerStyles: containerStyle,
|
|
47
|
-
fixedRatio: false
|
|
48
|
-
};
|
|
49
|
-
const expandedModeViewText = createElement(Text, {
|
|
50
|
-
style: styles['inserter-menu__add-block-button-text']
|
|
51
|
-
}, __('Add blocks'));
|
|
52
36
|
return createElement(ToolbarButton, {
|
|
53
37
|
title: _x('Add block', 'Generic label for block inserter button'),
|
|
54
38
|
icon: createElement(Icon, {
|
|
55
|
-
icon:
|
|
56
|
-
style:
|
|
39
|
+
icon: plus,
|
|
40
|
+
style: iconStyle
|
|
57
41
|
}),
|
|
58
42
|
onClick: onToggle,
|
|
59
43
|
extraProps: {
|
|
@@ -61,11 +45,18 @@ const defaultRenderToggle = ({
|
|
|
61
45
|
// testID is present to disambiguate this element for native UI tests. It's not
|
|
62
46
|
// usually required for components. See: https://github.com/WordPress/gutenberg/pull/18832#issuecomment-561411389.
|
|
63
47
|
testID: 'add-block-button',
|
|
64
|
-
onLongPress
|
|
48
|
+
onLongPress,
|
|
49
|
+
hitSlop: {
|
|
50
|
+
top: 10,
|
|
51
|
+
bottom: 10,
|
|
52
|
+
left: 10,
|
|
53
|
+
right: 10
|
|
54
|
+
}
|
|
65
55
|
},
|
|
66
56
|
isDisabled: disabled,
|
|
67
|
-
|
|
68
|
-
|
|
57
|
+
customContainerStyles: buttonStyle,
|
|
58
|
+
fixedRatio: false
|
|
59
|
+
});
|
|
69
60
|
};
|
|
70
61
|
|
|
71
62
|
export class Inserter extends Component {
|
|
@@ -228,16 +219,15 @@ export class Inserter extends Component {
|
|
|
228
219
|
disabled,
|
|
229
220
|
renderToggle = defaultRenderToggle,
|
|
230
221
|
getStylesFromColorScheme,
|
|
231
|
-
showSeparator
|
|
232
|
-
useExpandedMode
|
|
222
|
+
showSeparator
|
|
233
223
|
} = this.props;
|
|
234
224
|
|
|
235
225
|
if (showSeparator && isOpen) {
|
|
236
226
|
return createElement(BlockInsertionPoint, null);
|
|
237
227
|
}
|
|
238
228
|
|
|
239
|
-
const
|
|
240
|
-
const
|
|
229
|
+
const buttonStyle = getStylesFromColorScheme(styles['inserter-menu__add-block-button'], styles['inserter-menu__add-block-button--dark']);
|
|
230
|
+
const iconStyle = getStylesFromColorScheme(styles['inserter-menu__add-block-button-icon'], styles['inserter-menu__add-block-button-icon--dark']);
|
|
241
231
|
|
|
242
232
|
const onPress = () => {
|
|
243
233
|
this.setState({
|
|
@@ -265,10 +255,9 @@ export class Inserter extends Component {
|
|
|
265
255
|
onToggle: onPress,
|
|
266
256
|
isOpen,
|
|
267
257
|
disabled,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
onLongPress
|
|
271
|
-
useExpandedMode
|
|
258
|
+
iconStyle,
|
|
259
|
+
buttonStyle,
|
|
260
|
+
onLongPress
|
|
272
261
|
}), createElement(Picker, {
|
|
273
262
|
ref: instance => this.picker = instance,
|
|
274
263
|
options: this.getInsertionOptions(),
|