@wordpress/block-editor 12.9.1-next.5a1d1283.0 → 12.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +33 -3
- package/build/components/block-canvas/index.js +107 -0
- package/build/components/block-canvas/index.js.map +1 -0
- package/build/components/block-inspector/index.js +4 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +28 -8
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +68 -0
- package/build/components/block-patterns-paging/index.js.map +1 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js +28 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +4 -7
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -0
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js +3 -7
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +18 -7
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +5 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +1 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +2 -4
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/default-block-appender/index.native.js +20 -1
- package/build/components/default-block-appender/index.native.js.map +1 -1
- package/build/components/duotone/utils.js +68 -0
- package/build/components/duotone/utils.js.map +1 -1
- package/build/components/editor-styles/index.js +28 -9
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -101
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +61 -0
- package/build/components/global-styles/image-settings-panel.js.map +1 -0
- package/build/components/global-styles/index.js +11 -17
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +19 -15
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +67 -33
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +2 -5
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/use-transform-image.js +9 -9
- package/build/components/image-editor/use-transform-image.js.map +1 -1
- package/build/components/index.js +8 -12
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +6 -5
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +13 -7
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +12 -6
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +45 -22
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +9 -9
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-filter.js +137 -0
- package/build/components/inserter/block-patterns-filter.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +128 -42
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.js +61 -0
- package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -0
- package/build/components/inserter/hooks/use-patterns-state.js +21 -10
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/menu.js +13 -11
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/search-results.js +4 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -12
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +12 -1
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build/components/inspector-controls/fill.js +24 -13
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/groups.js +5 -3
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +13 -0
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/link-control/index.js +12 -2
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -3
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +13 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +29 -24
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-placeholder/index.js +2 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +11 -11
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js +2 -3
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/constants.js +30 -0
- package/build/components/media-upload/constants.js.map +1 -0
- package/build/components/media-upload/index.native.js +63 -53
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +1 -1
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/index.js +34 -35
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +14 -32
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/multiline.js +95 -0
- package/build/components/rich-text/multiline.js.map +1 -0
- package/build/components/rich-text/split-value.js +10 -16
- package/build/components/rich-text/split-value.js.map +1 -1
- package/build/components/rich-text/use-enter.js +31 -40
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +18 -33
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/use-block-commands/index.js +30 -18
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +5 -2
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/background.js +263 -0
- package/build/hooks/background.js.map +1 -0
- package/build/hooks/block-hooks.js +188 -0
- package/build/hooks/block-hooks.js.map +1 -0
- package/build/hooks/block-rename-ui.js +161 -0
- package/build/hooks/block-rename-ui.js.map +1 -0
- package/build/hooks/duotone.js +29 -42
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +2 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +31 -14
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +4 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +10 -3
- package/build/hooks/style.js.map +1 -1
- package/build/private-apis.js +2 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +33 -10
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +42 -8
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +25 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +43 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +84 -23
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +0 -4
- package/build/store/utils.js.map +1 -1
- package/build-module/components/block-canvas/index.js +97 -0
- package/build-module/components/block-canvas/index.js.map +1 -0
- package/build-module/components/block-inspector/index.js +4 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +30 -10
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +61 -0
- package/build-module/components/block-patterns-paging/index.js.map +1 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +28 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +4 -7
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -0
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js +3 -7
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +18 -7
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +5 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +1 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +2 -4
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/default-block-appender/index.native.js +20 -1
- package/build-module/components/default-block-appender/index.native.js.map +1 -1
- package/build-module/components/duotone/utils.js +65 -0
- package/build-module/components/duotone/utils.js.map +1 -1
- package/build-module/components/editor-styles/index.js +28 -9
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +3 -100
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +53 -0
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -0
- package/build-module/components/global-styles/index.js +2 -2
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +18 -16
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +66 -33
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -5
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/use-transform-image.js +9 -9
- package/build-module/components/image-editor/use-transform-image.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +14 -8
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +12 -6
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +47 -24
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +9 -9
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-filter.js +128 -0
- package/build-module/components/inserter/block-patterns-filter.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +125 -44
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.js +54 -0
- package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -0
- package/build-module/components/inserter/hooks/use-patterns-state.js +22 -10
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/menu.js +13 -11
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/search-results.js +4 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -12
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +13 -2
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +25 -14
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +5 -3
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +15 -1
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/link-control/index.js +12 -2
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +1 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +13 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +30 -25
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +2 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +7 -7
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +2 -3
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/constants.js +14 -0
- package/build-module/components/media-upload/constants.js.map +1 -0
- package/build-module/components/media-upload/index.native.js +53 -34
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +1 -1
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +35 -37
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +15 -33
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/multiline.js +87 -0
- package/build-module/components/rich-text/multiline.js.map +1 -0
- package/build-module/components/rich-text/split-value.js +10 -16
- package/build-module/components/rich-text/split-value.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +33 -42
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +19 -34
- package/build-module/components/rich-text/use-paste-handler.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-commands/index.js +28 -16
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +5 -2
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/background.js +249 -0
- package/build-module/hooks/background.js.map +1 -0
- package/build-module/hooks/block-hooks.js +181 -0
- package/build-module/hooks/block-hooks.js.map +1 -0
- package/build-module/hooks/block-rename-ui.js +154 -0
- package/build-module/hooks/block-rename-ui.js.map +1 -0
- package/build-module/hooks/duotone.js +26 -39
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -2
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +33 -16
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +4 -2
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +10 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +33 -10
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +39 -8
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +23 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +41 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +78 -22
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +0 -4
- package/build-module/store/utils.js.map +1 -1
- package/build-style/content-rtl.css +0 -1
- package/build-style/content.css +0 -1
- package/build-style/style-rtl.css +201 -131
- package/build-style/style.css +201 -131
- package/package.json +32 -32
- package/src/components/block-canvas/index.js +108 -0
- package/src/components/block-inspector/index.js +5 -1
- package/src/components/block-list/content.scss +0 -1
- package/src/components/block-patterns-list/index.js +53 -19
- package/src/components/block-patterns-list/style.scss +26 -9
- package/src/components/block-patterns-paging/index.js +92 -0
- package/src/components/block-patterns-paging/style.scss +45 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +44 -0
- package/src/components/block-settings-menu-controls/index.js +4 -9
- package/src/components/block-styles/index.js +1 -0
- package/src/components/block-styles/style.scss +3 -3
- package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -6
- package/src/components/block-tools/block-contextual-toolbar.js +16 -5
- package/src/components/block-tools/block-selection-button.js +9 -1
- package/src/components/block-tools/style.scss +0 -98
- package/src/components/border-radius-control/input-controls.js +1 -1
- package/src/components/border-radius-control/linked-button.js +8 -11
- package/src/components/color-palette/test/__snapshots__/control.js.snap +34 -21
- package/src/components/colors/with-colors.js +3 -2
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -35
- package/src/components/default-block-appender/index.native.js +26 -3
- package/src/components/duotone/utils.js +65 -0
- package/src/components/editor-styles/index.js +32 -23
- package/src/components/global-styles/hooks.js +4 -112
- package/src/components/global-styles/image-settings-panel.js +71 -0
- package/src/components/global-styles/index.js +4 -3
- package/src/components/global-styles/use-global-styles-output.js +25 -16
- package/src/components/global-styles/utils.js +1 -2
- package/src/components/iframe/index.js +72 -33
- package/src/components/image-editor/use-save-image.js +2 -9
- package/src/components/image-editor/use-transform-image.js +9 -9
- package/src/components/index.js +1 -1
- package/src/components/index.native.js +2 -2
- package/src/components/inner-blocks/use-nested-settings-update.js +15 -10
- package/src/components/inserter/block-patterns-explorer/explorer.js +17 -5
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +68 -43
- package/src/components/inserter/block-patterns-explorer/sidebar.js +8 -8
- package/src/components/inserter/block-patterns-filter.js +183 -0
- package/src/components/inserter/block-patterns-tab.js +217 -58
- package/src/components/inserter/hooks/use-patterns-paging.js +76 -0
- package/src/components/inserter/hooks/use-patterns-state.js +27 -16
- package/src/components/inserter/menu.js +15 -17
- package/src/components/inserter/search-results.js +6 -4
- package/src/components/inserter/style.scss +36 -7
- package/src/components/inserter/tabs.js +2 -12
- package/src/components/inserter/test/index.native.js +8 -12
- package/src/components/inspector-controls/block-support-slot-container.js +19 -3
- package/src/components/inspector-controls/fill.js +28 -14
- package/src/components/inspector-controls/groups.js +6 -2
- package/src/components/inspector-controls/slot.js +28 -3
- package/src/components/inspector-controls-tabs/styles-tab.js +4 -0
- package/src/components/link-control/index.js +13 -0
- package/src/components/link-control/style.scss +23 -2
- package/src/components/link-control/test/index.js +88 -6
- package/src/components/list-view/block-select-button.js +1 -3
- package/src/components/list-view/block.js +19 -1
- package/src/components/list-view/style.scss +1 -2
- package/src/components/list-view/use-block-selection.js +38 -32
- package/src/components/media-placeholder/README.md +2 -2
- package/src/components/media-placeholder/index.js +2 -2
- package/src/components/media-placeholder/index.native.js +11 -12
- package/src/components/media-replace-flow/index.js +2 -2
- package/src/components/media-replace-flow/test/index.js +5 -23
- package/src/components/media-upload/README.md +3 -2
- package/src/components/media-upload/constants.js +15 -0
- package/src/components/media-upload/index.native.js +66 -40
- package/src/components/media-upload/style.native.scss +4 -0
- package/src/components/media-upload/test/index.native.js +2 -2
- package/src/components/preview-options/README.md +7 -0
- package/src/components/preview-options/index.js +1 -1
- package/src/components/rich-text/index.js +48 -44
- package/src/components/rich-text/index.native.js +14 -42
- package/src/components/rich-text/multiline.js +121 -0
- package/src/components/rich-text/split-value.js +10 -35
- package/src/components/rich-text/use-enter.js +32 -42
- package/src/components/rich-text/use-paste-handler.js +16 -40
- package/src/components/spacing-sizes-control/style.scss +5 -7
- package/src/components/spacing-sizes-control/utils.js +1 -2
- package/src/components/use-block-commands/index.js +28 -20
- package/src/components/use-block-display-information/index.js +3 -0
- package/src/hooks/background.js +299 -0
- package/src/hooks/background.scss +75 -0
- package/src/hooks/block-hooks.js +257 -0
- package/src/hooks/block-hooks.scss +16 -0
- package/src/hooks/block-rename-ui.js +231 -0
- package/src/hooks/block-rename-ui.scss +3 -0
- package/src/hooks/duotone.js +42 -43
- package/src/hooks/index.js +2 -2
- package/src/hooks/layout.js +31 -33
- package/src/hooks/position.js +4 -3
- package/src/hooks/style.js +11 -2
- package/src/hooks/test/align.native.js +4 -3
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +52 -10
- package/src/store/private-actions.js +37 -6
- package/src/store/private-selectors.js +28 -3
- package/src/store/reducer.js +38 -0
- package/src/store/selectors.js +107 -26
- package/src/store/test/actions.js +19 -8
- package/src/store/test/private-actions.js +17 -0
- package/src/store/test/reducer.js +25 -0
- package/src/store/test/selectors.js +130 -123
- package/src/store/utils.js +3 -10
- package/src/style.scss +4 -0
- package/build/components/duotone/components.js +0 -135
- package/build/components/duotone/components.js.map +0 -1
- package/build/components/duotone/index.js +0 -38
- package/build/components/duotone/index.js.map +0 -1
- package/build/components/global-styles/behaviors-panel.js +0 -64
- package/build/components/global-styles/behaviors-panel.js.map +0 -1
- package/build/components/inserter/reusable-blocks-tab.js +0 -85
- package/build/components/inserter/reusable-blocks-tab.js.map +0 -1
- package/build/hooks/auto-inserting-blocks.js +0 -174
- package/build/hooks/auto-inserting-blocks.js.map +0 -1
- package/build/hooks/behaviors.js +0 -173
- package/build/hooks/behaviors.js.map +0 -1
- package/build-module/components/duotone/components.js +0 -126
- package/build-module/components/duotone/components.js.map +0 -1
- package/build-module/components/duotone/index.js +0 -3
- package/build-module/components/duotone/index.js.map +0 -1
- package/build-module/components/global-styles/behaviors-panel.js +0 -57
- package/build-module/components/global-styles/behaviors-panel.js.map +0 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +0 -76
- package/build-module/components/inserter/reusable-blocks-tab.js.map +0 -1
- package/build-module/hooks/auto-inserting-blocks.js +0 -167
- package/build-module/hooks/auto-inserting-blocks.js.map +0 -1
- package/build-module/hooks/behaviors.js +0 -166
- package/build-module/hooks/behaviors.js.map +0 -1
- package/src/components/duotone/components.js +0 -133
- package/src/components/duotone/index.js +0 -7
- package/src/components/global-styles/behaviors-panel.js +0 -71
- package/src/components/inserter/reusable-blocks-tab.js +0 -84
- package/src/components/inserter/test/reusable-blocks-tab.js +0 -73
- package/src/hooks/auto-inserting-blocks.js +0 -232
- package/src/hooks/behaviors.js +0 -206
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.BACKGROUND_SUPPORT_KEY = void 0;
|
|
8
|
+
exports.BackgroundImagePanel = BackgroundImagePanel;
|
|
9
|
+
exports.IMAGE_BACKGROUND_TYPE = void 0;
|
|
10
|
+
exports.hasBackgroundImageValue = hasBackgroundImageValue;
|
|
11
|
+
exports.hasBackgroundSupport = hasBackgroundSupport;
|
|
12
|
+
exports.resetBackgroundImage = resetBackgroundImage;
|
|
13
|
+
var _element = require("@wordpress/element");
|
|
14
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
var _blob = require("@wordpress/blob");
|
|
16
|
+
var _blocks = require("@wordpress/blocks");
|
|
17
|
+
var _components = require("@wordpress/components");
|
|
18
|
+
var _data = require("@wordpress/data");
|
|
19
|
+
var _i18n = require("@wordpress/i18n");
|
|
20
|
+
var _notices = require("@wordpress/notices");
|
|
21
|
+
var _url = require("@wordpress/url");
|
|
22
|
+
var _inspectorControls = _interopRequireDefault(require("../components/inspector-controls"));
|
|
23
|
+
var _mediaReplaceFlow = _interopRequireDefault(require("../components/media-replace-flow"));
|
|
24
|
+
var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
25
|
+
var _utils = require("./utils");
|
|
26
|
+
var _store = require("../store");
|
|
27
|
+
/**
|
|
28
|
+
* External dependencies
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* WordPress dependencies
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Internal dependencies
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
const BACKGROUND_SUPPORT_KEY = 'background';
|
|
40
|
+
exports.BACKGROUND_SUPPORT_KEY = BACKGROUND_SUPPORT_KEY;
|
|
41
|
+
const IMAGE_BACKGROUND_TYPE = 'image';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Checks if there is a current value in the background image block support
|
|
45
|
+
* attributes.
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} props Block props.
|
|
48
|
+
* @return {boolean} Whether or not the block has a background image value set.
|
|
49
|
+
*/
|
|
50
|
+
exports.IMAGE_BACKGROUND_TYPE = IMAGE_BACKGROUND_TYPE;
|
|
51
|
+
function hasBackgroundImageValue(props) {
|
|
52
|
+
const hasValue = !!props.attributes.style?.background?.backgroundImage?.id || !!props.attributes.style?.background?.backgroundImage?.url;
|
|
53
|
+
return hasValue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Determine whether there is block support for background.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} blockName Block name.
|
|
60
|
+
* @param {string} feature Background image feature to check for.
|
|
61
|
+
*
|
|
62
|
+
* @return {boolean} Whether there is support.
|
|
63
|
+
*/
|
|
64
|
+
function hasBackgroundSupport(blockName, feature = 'any') {
|
|
65
|
+
if (_element.Platform.OS !== 'web') {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const support = (0, _blocks.getBlockSupport)(blockName, BACKGROUND_SUPPORT_KEY);
|
|
69
|
+
if (support === true) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
if (feature === 'any') {
|
|
73
|
+
return !!support?.backgroundImage;
|
|
74
|
+
}
|
|
75
|
+
return !!support?.[feature];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Resets the background image block support attributes. This can be used when disabling
|
|
80
|
+
* the background image controls for a block via a `ToolsPanel`.
|
|
81
|
+
*
|
|
82
|
+
* @param {Object} props Block props.
|
|
83
|
+
* @param {Object} props.attributes Block's attributes.
|
|
84
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
85
|
+
*/
|
|
86
|
+
function resetBackgroundImage({
|
|
87
|
+
attributes = {},
|
|
88
|
+
setAttributes
|
|
89
|
+
}) {
|
|
90
|
+
const {
|
|
91
|
+
style = {}
|
|
92
|
+
} = attributes;
|
|
93
|
+
setAttributes({
|
|
94
|
+
style: (0, _utils.cleanEmptyObject)({
|
|
95
|
+
...style,
|
|
96
|
+
background: {
|
|
97
|
+
...style?.background,
|
|
98
|
+
backgroundImage: undefined
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
function InspectorImagePreview({
|
|
104
|
+
label,
|
|
105
|
+
filename,
|
|
106
|
+
url: imgUrl
|
|
107
|
+
}) {
|
|
108
|
+
const imgLabel = label || (0, _url.getFilename)(imgUrl);
|
|
109
|
+
return (0, _element.createElement)(_components.__experimentalItemGroup, {
|
|
110
|
+
as: "span"
|
|
111
|
+
}, (0, _element.createElement)(_components.__experimentalHStack, {
|
|
112
|
+
justify: "flex-start",
|
|
113
|
+
as: "span"
|
|
114
|
+
}, (0, _element.createElement)("span", {
|
|
115
|
+
className: (0, _classnames.default)('block-editor-hooks__background__inspector-image-indicator-wrapper', {
|
|
116
|
+
'has-image': imgUrl
|
|
117
|
+
}),
|
|
118
|
+
"aria-hidden": true
|
|
119
|
+
}, imgUrl && (0, _element.createElement)("span", {
|
|
120
|
+
className: "block-editor-hooks__background__inspector-image-indicator",
|
|
121
|
+
style: {
|
|
122
|
+
backgroundImage: `url(${imgUrl})`
|
|
123
|
+
}
|
|
124
|
+
})), (0, _element.createElement)(_components.FlexItem, {
|
|
125
|
+
as: "span"
|
|
126
|
+
}, (0, _element.createElement)(_components.__experimentalTruncate, {
|
|
127
|
+
numberOfLines: 1,
|
|
128
|
+
className: "block-editor-hooks__background__inspector-media-replace-title"
|
|
129
|
+
}, imgLabel), (0, _element.createElement)(_components.VisuallyHidden, {
|
|
130
|
+
as: "span"
|
|
131
|
+
}, filename ? (0, _i18n.sprintf)( /* translators: %s: file name */
|
|
132
|
+
(0, _i18n.__)('Selected image: %s'), filename) : (0, _i18n.__)('No image selected')))));
|
|
133
|
+
}
|
|
134
|
+
function BackgroundImagePanelItem(props) {
|
|
135
|
+
const {
|
|
136
|
+
attributes,
|
|
137
|
+
clientId,
|
|
138
|
+
setAttributes
|
|
139
|
+
} = props;
|
|
140
|
+
const {
|
|
141
|
+
id,
|
|
142
|
+
title,
|
|
143
|
+
url
|
|
144
|
+
} = attributes.style?.background?.backgroundImage || {};
|
|
145
|
+
const {
|
|
146
|
+
mediaUpload
|
|
147
|
+
} = (0, _data.useSelect)(select => {
|
|
148
|
+
return {
|
|
149
|
+
mediaUpload: select(_store.store).getSettings().mediaUpload
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
const {
|
|
153
|
+
createErrorNotice
|
|
154
|
+
} = (0, _data.useDispatch)(_notices.store);
|
|
155
|
+
const onUploadError = message => {
|
|
156
|
+
createErrorNotice(message, {
|
|
157
|
+
type: 'snackbar'
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
const onSelectMedia = media => {
|
|
161
|
+
if (!media || !media.url) {
|
|
162
|
+
const newStyle = {
|
|
163
|
+
...attributes.style,
|
|
164
|
+
background: {
|
|
165
|
+
...attributes.style?.background,
|
|
166
|
+
backgroundImage: undefined
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const newAttributes = {
|
|
170
|
+
style: (0, _utils.cleanEmptyObject)(newStyle)
|
|
171
|
+
};
|
|
172
|
+
setAttributes(newAttributes);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if ((0, _blob.isBlobURL)(media.url)) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// For media selections originated from a file upload.
|
|
180
|
+
if (media.media_type && media.media_type !== IMAGE_BACKGROUND_TYPE || !media.media_type && media.type && media.type !== IMAGE_BACKGROUND_TYPE) {
|
|
181
|
+
onUploadError((0, _i18n.__)('Only images can be used as a background image.'));
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const newStyle = {
|
|
185
|
+
...attributes.style,
|
|
186
|
+
background: {
|
|
187
|
+
...attributes.style?.background,
|
|
188
|
+
backgroundImage: {
|
|
189
|
+
url: media.url,
|
|
190
|
+
id: media.id,
|
|
191
|
+
source: 'file',
|
|
192
|
+
title: media.title || undefined
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const newAttributes = {
|
|
197
|
+
style: (0, _utils.cleanEmptyObject)(newStyle)
|
|
198
|
+
};
|
|
199
|
+
setAttributes(newAttributes);
|
|
200
|
+
};
|
|
201
|
+
const onFilesDrop = filesList => {
|
|
202
|
+
mediaUpload({
|
|
203
|
+
allowedTypes: ['image'],
|
|
204
|
+
filesList,
|
|
205
|
+
onFileChange([image]) {
|
|
206
|
+
if ((0, _blob.isBlobURL)(image?.url)) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
onSelectMedia(image);
|
|
210
|
+
},
|
|
211
|
+
onError: onUploadError
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
const resetAllFilter = (0, _element.useCallback)(previousValue => {
|
|
215
|
+
return {
|
|
216
|
+
...previousValue,
|
|
217
|
+
style: {
|
|
218
|
+
...previousValue.style,
|
|
219
|
+
background: undefined
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}, []);
|
|
223
|
+
return (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
|
|
224
|
+
className: "single-column",
|
|
225
|
+
hasValue: () => hasBackgroundImageValue(props),
|
|
226
|
+
label: (0, _i18n.__)('Background image'),
|
|
227
|
+
onDeselect: () => resetBackgroundImage(props),
|
|
228
|
+
isShownByDefault: true,
|
|
229
|
+
resetAllFilter: resetAllFilter,
|
|
230
|
+
panelId: clientId
|
|
231
|
+
}, (0, _element.createElement)("div", {
|
|
232
|
+
className: "block-editor-hooks__background__inspector-media-replace-container"
|
|
233
|
+
}, (0, _element.createElement)(_mediaReplaceFlow.default, {
|
|
234
|
+
mediaId: id,
|
|
235
|
+
mediaURL: url,
|
|
236
|
+
allowedTypes: [IMAGE_BACKGROUND_TYPE],
|
|
237
|
+
accept: "image/*",
|
|
238
|
+
onSelect: onSelectMedia,
|
|
239
|
+
name: (0, _element.createElement)(InspectorImagePreview, {
|
|
240
|
+
label: (0, _i18n.__)('Background image'),
|
|
241
|
+
filename: title,
|
|
242
|
+
url: url
|
|
243
|
+
}),
|
|
244
|
+
variant: "secondary"
|
|
245
|
+
}, (0, _element.createElement)(_components.MenuItem, {
|
|
246
|
+
onClick: () => resetBackgroundImage(props)
|
|
247
|
+
}, (0, _i18n.__)('Reset '))), (0, _element.createElement)(_components.DropZone, {
|
|
248
|
+
onFilesDrop: onFilesDrop,
|
|
249
|
+
label: (0, _i18n.__)('Drop to upload')
|
|
250
|
+
})));
|
|
251
|
+
}
|
|
252
|
+
function BackgroundImagePanel(props) {
|
|
253
|
+
const isBackgroundImageSupported = (0, _useSetting.default)('background.backgroundImage') && hasBackgroundSupport(props.name, 'backgroundImage');
|
|
254
|
+
if (!isBackgroundImageSupported) {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
return (0, _element.createElement)(_inspectorControls.default, {
|
|
258
|
+
group: "background"
|
|
259
|
+
}, isBackgroundImageSupported && (0, _element.createElement)(BackgroundImagePanelItem, {
|
|
260
|
+
...props
|
|
261
|
+
}));
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=background.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_element","require","_classnames","_interopRequireDefault","_blob","_blocks","_components","_data","_i18n","_notices","_url","_inspectorControls","_mediaReplaceFlow","_useSetting","_utils","_store","BACKGROUND_SUPPORT_KEY","exports","IMAGE_BACKGROUND_TYPE","hasBackgroundImageValue","props","hasValue","attributes","style","background","backgroundImage","id","url","hasBackgroundSupport","blockName","feature","Platform","OS","support","getBlockSupport","resetBackgroundImage","setAttributes","cleanEmptyObject","undefined","InspectorImagePreview","label","filename","imgUrl","imgLabel","getFilename","createElement","__experimentalItemGroup","as","__experimentalHStack","justify","className","classnames","FlexItem","__experimentalTruncate","numberOfLines","VisuallyHidden","sprintf","__","BackgroundImagePanelItem","clientId","title","mediaUpload","useSelect","select","blockEditorStore","getSettings","createErrorNotice","useDispatch","noticesStore","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","isBlobURL","media_type","source","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","useCallback","previousValue","__experimentalToolsPanelItem","onDeselect","isShownByDefault","panelId","default","mediaId","mediaURL","accept","onSelect","name","variant","MenuItem","onClick","DropZone","BackgroundImagePanel","isBackgroundImageSupported","useSetting","group"],"sources":["@wordpress/block-editor/src/hooks/background.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\tDropZone,\n\tFlexItem,\n\tMenuItem,\n\tVisuallyHidden,\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Platform, useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { getFilename } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport MediaReplaceFlow from '../components/media-replace-flow';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\nexport const IMAGE_BACKGROUND_TYPE = 'image';\n\n/**\n * Checks if there is a current value in the background image block support\n * attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a background image value set.\n */\nexport function hasBackgroundImageValue( props ) {\n\tconst hasValue =\n\t\t!! props.attributes.style?.background?.backgroundImage?.id ||\n\t\t!! props.attributes.style?.background?.backgroundImage?.url;\n\n\treturn hasValue;\n}\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! support?.backgroundImage;\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\n/**\n * Resets the background image block support attributes. This can be used when disabling\n * the background image controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetBackgroundImage( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tbackground: {\n\t\t\t\t...style?.background,\n\t\t\t\tbackgroundImage: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\nfunction InspectorImagePreview( { label, filename, url: imgUrl } ) {\n\tconst imgLabel = label || getFilename( imgUrl );\n\treturn (\n\t\t<ItemGroup as=\"span\">\n\t\t\t<HStack justify=\"flex-start\" as=\"span\">\n\t\t\t\t<span\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-hooks__background__inspector-image-indicator-wrapper',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-image': imgUrl,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\taria-hidden\n\t\t\t\t>\n\t\t\t\t\t{ imgUrl && (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-image-indicator\"\n\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\tbackgroundImage: `url(${ imgUrl })`,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t<FlexItem as=\"span\">\n\t\t\t\t\t<Truncate\n\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ imgLabel }\n\t\t\t\t\t</Truncate>\n\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t{ filename\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: file name */\n\t\t\t\t\t\t\t\t\t__( 'Selected image: %s' ),\n\t\t\t\t\t\t\t\t\tfilename\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __( 'No image selected' ) }\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t</FlexItem>\n\t\t\t</HStack>\n\t\t</ItemGroup>\n\t);\n}\n\nfunction BackgroundImagePanelItem( props ) {\n\tconst { attributes, clientId, setAttributes } = props;\n\n\tconst { id, title, url } =\n\t\tattributes.style?.background?.backgroundImage || {};\n\n\tconst { mediaUpload } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tmediaUpload: select( blockEditorStore ).getSettings().mediaUpload,\n\t\t};\n\t} );\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst onSelectMedia = ( media ) => {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...attributes.style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...attributes.style?.background,\n\t\t\t\t\tbackgroundImage: undefined,\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst newAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t};\n\n\t\t\tsetAttributes( newAttributes );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For media selections originated from a file upload.\n\t\tif (\n\t\t\t( media.media_type &&\n\t\t\t\tmedia.media_type !== IMAGE_BACKGROUND_TYPE ) ||\n\t\t\t( ! media.media_type &&\n\t\t\t\tmedia.type &&\n\t\t\t\tmedia.type !== IMAGE_BACKGROUND_TYPE )\n\t\t) {\n\t\t\tonUploadError(\n\t\t\t\t__( 'Only images can be used as a background image.' )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...attributes.style,\n\t\t\tbackground: {\n\t\t\t\t...attributes.style?.background,\n\t\t\t\tbackgroundImage: {\n\t\t\t\t\turl: media.url,\n\t\t\t\t\tid: media.id,\n\t\t\t\t\tsource: 'file',\n\t\t\t\t\ttitle: media.title || undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t};\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\tconst onFilesDrop = ( filesList ) => {\n\t\tmediaUpload( {\n\t\t\tallowedTypes: [ 'image' ],\n\t\t\tfilesList,\n\t\t\tonFileChange( [ image ] ) {\n\t\t\t\tif ( isBlobURL( image?.url ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonSelectMedia( image );\n\t\t\t},\n\t\t\tonError: onUploadError,\n\t\t} );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tstyle: {\n\t\t\t\t...previousValue.style,\n\t\t\t\tbackground: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasBackgroundImageValue( props ) }\n\t\t\tlabel={ __( 'Background image' ) }\n\t\t\tonDeselect={ () => resetBackgroundImage( props ) }\n\t\t\tisShownByDefault={ true }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<div className=\"block-editor-hooks__background__inspector-media-replace-container\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ url }\n\t\t\t\t\tallowedTypes={ [ IMAGE_BACKGROUND_TYPE ] }\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tonSelect={ onSelectMedia }\n\t\t\t\t\tname={\n\t\t\t\t\t\t<InspectorImagePreview\n\t\t\t\t\t\t\tlabel={ __( 'Background image' ) }\n\t\t\t\t\t\t\tfilename={ title }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t>\n\t\t\t\t\t<MenuItem onClick={ () => resetBackgroundImage( props ) }>\n\t\t\t\t\t\t{ __( 'Reset ' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t<DropZone\n\t\t\t\t\tonFilesDrop={ onFilesDrop }\n\t\t\t\t\tlabel={ __( 'Drop to upload' ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</ToolsPanelItem>\n\t);\n}\n\nexport function BackgroundImagePanel( props ) {\n\tconst isBackgroundImageSupported =\n\t\tuseSetting( 'background.backgroundImage' ) &&\n\t\thasBackgroundSupport( props.name, 'backgroundImage' );\n\n\tif ( ! isBackgroundImageSupported ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t{ isBackgroundImage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AK,EAAG,IAAAiB,QAAE,EAAE,kBAAmB,CAAG;MAClChB,QAAQ,EAAGmB,KAAO;MAClBjC,GAAG,EAAGA;IAAK,CACX,CACD;IACDuE,OAAO,EAAC;EAAW,GAEnB,IAAAlG,QAAA,CAAA6C,aAAA,EAACvC,WAAA,CAAA6F,QAAQ;IAACC,OAAO,EAAGA,CAAA,KAAMjE,oBAAoB,CAAEf,KAAM;EAAG,GACtD,IAAAqC,QAAE,EAAE,QAAS,CACN,CACO,CAAC,EACnB,IAAAzD,QAAA,CAAA6C,aAAA,EAACvC,WAAA,CAAA+F,QAAQ;IACRtB,WAAW,EAAGA,WAAa;IAC3BvC,KAAK,EAAG,IAAAiB,QAAE,EAAE,gBAAiB;EAAG,CAChC,CACG,CACU,CAAC;AAEnB;AAEO,SAAS6C,oBAAoBA,CAAElF,KAAK,EAAG;EAC7C,MAAMmF,0BAA0B,GAC/B,IAAAC,mBAAU,EAAE,4BAA6B,CAAC,IAC1C5E,oBAAoB,CAAER,KAAK,CAAC6E,IAAI,EAAE,iBAAkB,CAAC;EAEtD,IAAK,CAAEM,0BAA0B,EAAG;IACnC,OAAO,IAAI;EACZ;EAEA,OACC,IAAAvG,QAAA,CAAA6C,aAAA,EAAClC,kBAAA,CAAAiF,OAAiB;IAACa,KAAK,EAAC;EAAY,GAClCF,0BAA0B,IAC3B,IAAAvG,QAAA,CAAA6C,aAAA,EAACa,wBAAwB;IAAA,GAAMtC;EAAK,CAAI,CAEvB,CAAC;AAEtB"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withBlockHooks = void 0;
|
|
7
|
+
var _element = require("@wordpress/element");
|
|
8
|
+
var _i18n = require("@wordpress/i18n");
|
|
9
|
+
var _hooks = require("@wordpress/hooks");
|
|
10
|
+
var _components = require("@wordpress/components");
|
|
11
|
+
var _compose = require("@wordpress/compose");
|
|
12
|
+
var _blocks = require("@wordpress/blocks");
|
|
13
|
+
var _data = require("@wordpress/data");
|
|
14
|
+
var _components2 = require("../components");
|
|
15
|
+
var _store = require("../store");
|
|
16
|
+
/**
|
|
17
|
+
* WordPress dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const EMPTY_OBJECT = {};
|
|
25
|
+
function BlockHooksControl(props) {
|
|
26
|
+
const blockTypes = (0, _data.useSelect)(select => select(_blocks.store).getBlockTypes(), []);
|
|
27
|
+
const hookedBlocksForCurrentBlock = (0, _element.useMemo)(() => blockTypes?.filter(({
|
|
28
|
+
blockHooks
|
|
29
|
+
}) => blockHooks && props.blockName in blockHooks), [blockTypes, props.blockName]);
|
|
30
|
+
const {
|
|
31
|
+
blockIndex,
|
|
32
|
+
rootClientId,
|
|
33
|
+
innerBlocksLength
|
|
34
|
+
} = (0, _data.useSelect)(select => {
|
|
35
|
+
const {
|
|
36
|
+
getBlock,
|
|
37
|
+
getBlockIndex,
|
|
38
|
+
getBlockRootClientId
|
|
39
|
+
} = select(_store.store);
|
|
40
|
+
return {
|
|
41
|
+
blockIndex: getBlockIndex(props.clientId),
|
|
42
|
+
innerBlocksLength: getBlock(props.clientId)?.innerBlocks?.length,
|
|
43
|
+
rootClientId: getBlockRootClientId(props.clientId)
|
|
44
|
+
};
|
|
45
|
+
}, [props.clientId]);
|
|
46
|
+
const hookedBlockClientIds = (0, _data.useSelect)(select => {
|
|
47
|
+
const {
|
|
48
|
+
getBlock,
|
|
49
|
+
getGlobalBlockCount
|
|
50
|
+
} = select(_store.store);
|
|
51
|
+
const _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce((clientIds, block) => {
|
|
52
|
+
// If the block doesn't exist anywhere in the block tree,
|
|
53
|
+
// we know that we have to display the toggle for it, and set
|
|
54
|
+
// it to disabled.
|
|
55
|
+
if (getGlobalBlockCount(block.name) === 0) {
|
|
56
|
+
return clientIds;
|
|
57
|
+
}
|
|
58
|
+
const relativePosition = block?.blockHooks?.[props.blockName];
|
|
59
|
+
let candidates;
|
|
60
|
+
switch (relativePosition) {
|
|
61
|
+
case 'before':
|
|
62
|
+
case 'after':
|
|
63
|
+
// Any of the current block's siblings (with the right block type) qualifies
|
|
64
|
+
// as a hooked block (inserted `before` or `after` the current one), as the block
|
|
65
|
+
// might've been automatically inserted and then moved around a bit by the user.
|
|
66
|
+
candidates = getBlock(rootClientId)?.innerBlocks;
|
|
67
|
+
break;
|
|
68
|
+
case 'first_child':
|
|
69
|
+
case 'last_child':
|
|
70
|
+
// Any of the current block's child blocks (with the right block type) qualifies
|
|
71
|
+
// as a hooked first or last child block, as the block might've been automatically
|
|
72
|
+
// inserted and then moved around a bit by the user.
|
|
73
|
+
candidates = getBlock(props.clientId).innerBlocks;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
const hookedBlock = candidates?.find(({
|
|
77
|
+
name
|
|
78
|
+
}) => name === block.name);
|
|
79
|
+
|
|
80
|
+
// If the block exists in the designated location, we consider it hooked
|
|
81
|
+
// and show the toggle as enabled.
|
|
82
|
+
if (hookedBlock) {
|
|
83
|
+
return {
|
|
84
|
+
...clientIds,
|
|
85
|
+
[block.name]: hookedBlock.clientId
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// If no hooked block was found in any of its designated locations,
|
|
90
|
+
// but it exists elsewhere in the block tree, we consider it manually inserted.
|
|
91
|
+
// In this case, we take note and will remove the corresponding toggle from the
|
|
92
|
+
// block inspector panel.
|
|
93
|
+
return {
|
|
94
|
+
...clientIds,
|
|
95
|
+
[block.name]: false
|
|
96
|
+
};
|
|
97
|
+
}, {});
|
|
98
|
+
if (Object.values(_hookedBlockClientIds).length > 0) {
|
|
99
|
+
return _hookedBlockClientIds;
|
|
100
|
+
}
|
|
101
|
+
return EMPTY_OBJECT;
|
|
102
|
+
}, [hookedBlocksForCurrentBlock, props.blockName, props.clientId, rootClientId]);
|
|
103
|
+
const {
|
|
104
|
+
insertBlock,
|
|
105
|
+
removeBlock
|
|
106
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
107
|
+
|
|
108
|
+
// Remove toggle if block isn't present in the designated location but elsewhere in the block tree.
|
|
109
|
+
const hookedBlocksForCurrentBlockIfNotPresentElsewhere = hookedBlocksForCurrentBlock?.filter(block => hookedBlockClientIds?.[block.name] !== false);
|
|
110
|
+
if (!hookedBlocksForCurrentBlockIfNotPresentElsewhere.length) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Group by block namespace (i.e. prefix before the slash).
|
|
115
|
+
const groupedHookedBlocks = hookedBlocksForCurrentBlock.reduce((groups, block) => {
|
|
116
|
+
const [namespace] = block.name.split('/');
|
|
117
|
+
if (!groups[namespace]) {
|
|
118
|
+
groups[namespace] = [];
|
|
119
|
+
}
|
|
120
|
+
groups[namespace].push(block);
|
|
121
|
+
return groups;
|
|
122
|
+
}, {});
|
|
123
|
+
const insertBlockIntoDesignatedLocation = (block, relativePosition) => {
|
|
124
|
+
switch (relativePosition) {
|
|
125
|
+
case 'before':
|
|
126
|
+
case 'after':
|
|
127
|
+
insertBlock(block, relativePosition === 'after' ? blockIndex + 1 : blockIndex, rootClientId,
|
|
128
|
+
// Insert as a child of the current block's parent
|
|
129
|
+
false);
|
|
130
|
+
break;
|
|
131
|
+
case 'first_child':
|
|
132
|
+
case 'last_child':
|
|
133
|
+
insertBlock(block,
|
|
134
|
+
// TODO: It'd be great if insertBlock() would accept negative indices for insertion.
|
|
135
|
+
relativePosition === 'first_child' ? 0 : innerBlocksLength, props.clientId,
|
|
136
|
+
// Insert as a child of the current block.
|
|
137
|
+
false);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
return (0, _element.createElement)(_components2.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
|
|
142
|
+
className: "block-editor-hooks__block-hooks",
|
|
143
|
+
title: (0, _i18n.__)('Plugins'),
|
|
144
|
+
initialOpen: true
|
|
145
|
+
}, Object.keys(groupedHookedBlocks).map(vendor => {
|
|
146
|
+
return (0, _element.createElement)(_element.Fragment, {
|
|
147
|
+
key: vendor
|
|
148
|
+
}, (0, _element.createElement)("h3", null, vendor), groupedHookedBlocks[vendor].map(block => {
|
|
149
|
+
const checked = (block.name in hookedBlockClientIds);
|
|
150
|
+
return (0, _element.createElement)(_components.ToggleControl, {
|
|
151
|
+
checked: checked,
|
|
152
|
+
key: block.title,
|
|
153
|
+
label: (0, _element.createElement)(_components.__experimentalHStack, {
|
|
154
|
+
justify: "flex-start"
|
|
155
|
+
}, (0, _element.createElement)(_components2.BlockIcon, {
|
|
156
|
+
icon: block.icon
|
|
157
|
+
}), (0, _element.createElement)("span", null, block.title)),
|
|
158
|
+
onChange: () => {
|
|
159
|
+
if (!checked) {
|
|
160
|
+
// Create and insert block.
|
|
161
|
+
const relativePosition = block.blockHooks[props.blockName];
|
|
162
|
+
insertBlockIntoDesignatedLocation((0, _blocks.createBlock)(block.name), relativePosition);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Remove block.
|
|
167
|
+
const clientId = hookedBlockClientIds[block.name];
|
|
168
|
+
removeBlock(clientId, false);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}));
|
|
172
|
+
})));
|
|
173
|
+
}
|
|
174
|
+
const withBlockHooks = (0, _compose.createHigherOrderComponent)(BlockEdit => {
|
|
175
|
+
return props => {
|
|
176
|
+
const blockEdit = (0, _element.createElement)(BlockEdit, {
|
|
177
|
+
key: "edit",
|
|
178
|
+
...props
|
|
179
|
+
});
|
|
180
|
+
return (0, _element.createElement)(_element.Fragment, null, blockEdit, (0, _element.createElement)(BlockHooksControl, {
|
|
181
|
+
blockName: props.name,
|
|
182
|
+
clientId: props.clientId
|
|
183
|
+
}));
|
|
184
|
+
};
|
|
185
|
+
}, 'withBlockHooks');
|
|
186
|
+
exports.withBlockHooks = withBlockHooks;
|
|
187
|
+
(0, _hooks.addFilter)('editor.BlockEdit', 'core/block-hooks/with-inspector-control', withBlockHooks);
|
|
188
|
+
//# sourceMappingURL=block-hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_element","require","_i18n","_hooks","_components","_compose","_blocks","_data","_components2","_store","EMPTY_OBJECT","BlockHooksControl","props","blockTypes","useSelect","select","blocksStore","getBlockTypes","hookedBlocksForCurrentBlock","useMemo","filter","blockHooks","blockName","blockIndex","rootClientId","innerBlocksLength","getBlock","getBlockIndex","getBlockRootClientId","blockEditorStore","clientId","innerBlocks","length","hookedBlockClientIds","getGlobalBlockCount","_hookedBlockClientIds","reduce","clientIds","block","name","relativePosition","candidates","hookedBlock","find","Object","values","insertBlock","removeBlock","useDispatch","hookedBlocksForCurrentBlockIfNotPresentElsewhere","groupedHookedBlocks","groups","namespace","split","push","insertBlockIntoDesignatedLocation","createElement","InspectorControls","PanelBody","className","title","__","initialOpen","keys","map","vendor","Fragment","key","checked","ToggleControl","label","__experimentalHStack","justify","BlockIcon","icon","onChange","createBlock","withBlockHooks","createHigherOrderComponent","BlockEdit","blockEdit","exports","addFilter"],"sources":["@wordpress/block-editor/src/hooks/block-hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { addFilter } from '@wordpress/hooks';\nimport { Fragment, useMemo } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\tPanelBody,\n\tToggleControl,\n} from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { BlockIcon, InspectorControls } from '../components';\nimport { store as blockEditorStore } from '../store';\n\nconst EMPTY_OBJECT = {};\n\nfunction BlockHooksControl( props ) {\n\tconst blockTypes = useSelect(\n\t\t( select ) => select( blocksStore ).getBlockTypes(),\n\t\t[]\n\t);\n\n\tconst hookedBlocksForCurrentBlock = useMemo(\n\t\t() =>\n\t\t\tblockTypes?.filter(\n\t\t\t\t( { blockHooks } ) =>\n\t\t\t\t\tblockHooks && props.blockName in blockHooks\n\t\t\t),\n\t\t[ blockTypes, props.blockName ]\n\t);\n\n\tconst { blockIndex, rootClientId, innerBlocksLength } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getBlockIndex, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tblockIndex: getBlockIndex( props.clientId ),\n\t\t\t\tinnerBlocksLength: getBlock( props.clientId )?.innerBlocks\n\t\t\t\t\t?.length,\n\t\t\t\trootClientId: getBlockRootClientId( props.clientId ),\n\t\t\t};\n\t\t},\n\t\t[ props.clientId ]\n\t);\n\n\tconst hookedBlockClientIds = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getGlobalBlockCount } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\tconst _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce(\n\t\t\t\t( clientIds, block ) => {\n\t\t\t\t\t// If the block doesn't exist anywhere in the block tree,\n\t\t\t\t\t// we know that we have to display the toggle for it, and set\n\t\t\t\t\t// it to disabled.\n\t\t\t\t\tif ( getGlobalBlockCount( block.name ) === 0 ) {\n\t\t\t\t\t\treturn clientIds;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst relativePosition =\n\t\t\t\t\t\tblock?.blockHooks?.[ props.blockName ];\n\t\t\t\t\tlet candidates;\n\n\t\t\t\t\tswitch ( relativePosition ) {\n\t\t\t\t\t\tcase 'before':\n\t\t\t\t\t\tcase 'after':\n\t\t\t\t\t\t\t// Any of the current block's siblings (with the right block type) qualifies\n\t\t\t\t\t\t\t// as a hooked block (inserted `before` or `after` the current one), as the block\n\t\t\t\t\t\t\t// might've been automatically inserted and then moved around a bit by the user.\n\t\t\t\t\t\t\tcandidates = getBlock( rootClientId )?.innerBlocks;\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'first_child':\n\t\t\t\t\t\tcase 'last_child':\n\t\t\t\t\t\t\t// Any of the current block's child blocks (with the right block type) qualifies\n\t\t\t\t\t\t\t// as a hooked first or last child block, as the block might've been automatically\n\t\t\t\t\t\t\t// inserted and then moved around a bit by the user.\n\t\t\t\t\t\t\tcandidates = getBlock( props.clientId ).innerBlocks;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst hookedBlock = candidates?.find(\n\t\t\t\t\t\t( { name } ) => name === block.name\n\t\t\t\t\t);\n\n\t\t\t\t\t// If the block exists in the designated location, we consider it hooked\n\t\t\t\t\t// and show the toggle as enabled.\n\t\t\t\t\tif ( hookedBlock ) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...clientIds,\n\t\t\t\t\t\t\t[ block.name ]: hookedBlock.clientId,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\t// If no hooked block was found in any of its designated locations,\n\t\t\t\t\t// but it exists elsewhere in the block tree, we consider it manually inserted.\n\t\t\t\t\t// In this case, we take note and will remove the corresponding toggle from the\n\t\t\t\t\t// block inspector panel.\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...clientIds,\n\t\t\t\t\t\t[ block.name ]: false,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\n\t\t\tif ( Object.values( _hookedBlockClientIds ).length > 0 ) {\n\t\t\t\treturn _hookedBlockClientIds;\n\t\t\t}\n\n\t\t\treturn EMPTY_OBJECT;\n\t\t},\n\t\t[\n\t\t\thookedBlocksForCurrentBlock,\n\t\t\tprops.blockName,\n\t\t\tprops.clientId,\n\t\t\trootClientId,\n\t\t]\n\t);\n\n\tconst { insertBlock, removeBlock } = useDispatch( blockEditorStore );\n\n\t// Remove toggle if block isn't present in the designated location but elsewhere in the block tree.\n\tconst hookedBlocksForCurrentBlockIfNotPresentElsewhere =\n\t\thookedBlocksForCurrentBlock?.filter(\n\t\t\t( block ) => hookedBlockClientIds?.[ block.name ] !== false\n\t\t);\n\n\tif ( ! hookedBlocksForCurrentBlockIfNotPresentElsewhere.length ) {\n\t\treturn null;\n\t}\n\n\t// Group by block namespace (i.e. prefix before the slash).\n\tconst groupedHookedBlocks = hookedBlocksForCurrentBlock.reduce(\n\t\t( groups, block ) => {\n\t\t\tconst [ namespace ] = block.name.split( '/' );\n\t\t\tif ( ! groups[ namespace ] ) {\n\t\t\t\tgroups[ namespace ] = [];\n\t\t\t}\n\t\t\tgroups[ namespace ].push( block );\n\t\t\treturn groups;\n\t\t},\n\t\t{}\n\t);\n\n\tconst insertBlockIntoDesignatedLocation = ( block, relativePosition ) => {\n\t\tswitch ( relativePosition ) {\n\t\t\tcase 'before':\n\t\t\tcase 'after':\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblock,\n\t\t\t\t\trelativePosition === 'after' ? blockIndex + 1 : blockIndex,\n\t\t\t\t\trootClientId, // Insert as a child of the current block's parent\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tbreak;\n\n\t\t\tcase 'first_child':\n\t\t\tcase 'last_child':\n\t\t\t\tinsertBlock(\n\t\t\t\t\tblock,\n\t\t\t\t\t// TODO: It'd be great if insertBlock() would accept negative indices for insertion.\n\t\t\t\t\trelativePosition === 'first_child' ? 0 : innerBlocksLength,\n\t\t\t\t\tprops.clientId, // Insert as a child of the current block.\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t}\n\t};\n\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody\n\t\t\t\tclassName=\"block-editor-hooks__block-hooks\"\n\t\t\t\ttitle={ __( 'Plugins' ) }\n\t\t\t\tinitialOpen={ true }\n\t\t\t>\n\t\t\t\t{ Object.keys( groupedHookedBlocks ).map( ( vendor ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Fragment key={ vendor }>\n\t\t\t\t\t\t\t<h3>{ vendor }</h3>\n\t\t\t\t\t\t\t{ groupedHookedBlocks[ vendor ].map( ( block ) => {\n\t\t\t\t\t\t\t\tconst checked =\n\t\t\t\t\t\t\t\t\tblock.name in hookedBlockClientIds;\n\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t\t\tchecked={ checked }\n\t\t\t\t\t\t\t\t\t\tkey={ block.title }\n\t\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ block.icon }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t<span>{ block.title }</span>\n\t\t\t\t\t\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonChange={ () => {\n\t\t\t\t\t\t\t\t\t\t\tif ( ! checked ) {\n\t\t\t\t\t\t\t\t\t\t\t\t// Create and insert block.\n\t\t\t\t\t\t\t\t\t\t\t\tconst relativePosition =\n\t\t\t\t\t\t\t\t\t\t\t\t\tblock.blockHooks[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tprops.blockName\n\t\t\t\t\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\t\t\t\tinsertBlockIntoDesignatedLocation(\n\t\t\t\t\t\t\t\t\t\t\t\t\tcreateBlock( block.name ),\n\t\t\t\t\t\t\t\t\t\t\t\t\trelativePosition\n\t\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t\t\t// Remove block.\n\t\t\t\t\t\t\t\t\t\t\tconst clientId =\n\t\t\t\t\t\t\t\t\t\t\t\thookedBlockClientIds[\n\t\t\t\t\t\t\t\t\t\t\t\t\tblock.name\n\t\t\t\t\t\t\t\t\t\t\t\t];\n\t\t\t\t\t\t\t\t\t\t\tremoveBlock( clientId, false );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n\nexport const withBlockHooks = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn ( props ) => {\n\t\tconst blockEdit = <BlockEdit key=\"edit\" { ...props } />;\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ blockEdit }\n\t\t\t\t<BlockHooksControl\n\t\t\t\t\tblockName={ props.name }\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t};\n}, 'withBlockHooks' );\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/block-hooks/with-inspector-control',\n\twithBlockHooks\n);\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AAFA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AAnBA;AACA;AACA;;AAaA;AACA;AACA;;AAIA,MAAMS,YAAY,GAAG,CAAC,CAAC;AAEvB,SAASC,iBAAiBA,CAAEC,KAAK,EAAG;EACnC,MAAMC,UAAU,GAAG,IAAAC,eAAS,EACzBC,MAAM,IAAMA,MAAM,CAAEC,aAAY,CAAC,CAACC,aAAa,CAAC,CAAC,EAC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