@wordpress/block-editor 12.15.0 → 12.16.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 +2 -0
- package/README.md +9 -4
- package/build/components/block-canvas/index.js +22 -6
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-card/index.js +1 -1
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-controls/hook.js +3 -23
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-edit/context.js +5 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +18 -9
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-info-slot-fill/index.js +3 -4
- package/build/components/block-info-slot-fill/index.js.map +1 -1
- package/build/components/block-list/block.js +28 -9
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +14 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +61 -18
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-patterns-list/index.js +1 -1
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -9
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-rename/modal.js +3 -0
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-settings/container.native.js +6 -4
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +1 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/index.native.js +3 -2
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-toolbar/index.js +89 -27
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +49 -0
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build/components/block-tools/block-toolbar-popover.js +86 -0
- package/build/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build/components/block-tools/index.js +27 -24
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +4 -3
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/block-variation-picker/index.native.js +2 -1
- package/build/components/block-variation-picker/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +28 -17
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -4
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/global-styles/color-panel.js +22 -20
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +9 -3
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +20 -31
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/image-link-destinations/index.native.js +118 -0
- package/build/components/image-link-destinations/index.native.js.map +1 -0
- package/build/components/index.native.js +8 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +2 -2
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/menu.js +14 -7
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +2 -2
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter-button/index.native.js +98 -0
- package/build/components/inserter-button/index.native.js.map +1 -0
- package/build/components/inserter-button/sparkles.js +23 -0
- package/build/components/inserter-button/sparkles.js.map +1 -0
- package/build/components/inserter-draggable-blocks/index.js +8 -4
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/fill.js +3 -3
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +3 -3
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +2 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/preview-options/index.js +6 -62
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/content.js +26 -23
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +2 -1
- package/build/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build/components/rich-text/index.js +2 -30
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +9 -16
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +7 -34
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +5 -1
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/with-deprecations.js +50 -0
- package/build/components/rich-text/with-deprecations.js.map +1 -0
- package/build/components/use-block-drop-zone/index.js +70 -8
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +1 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +4 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +14 -0
- package/build/components/use-settings/index.js.map +1 -1
- package/build/hooks/align.js +20 -68
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +11 -1
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +13 -29
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +28 -31
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +24 -32
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-renaming.js +18 -22
- package/build/hooks/block-renaming.js.map +1 -1
- package/build/hooks/border.js +58 -80
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +76 -89
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +29 -29
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +12 -29
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-fields.js +24 -38
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/dimensions.js +21 -17
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +31 -61
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js +16 -25
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -119
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +25 -14
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +10 -3
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout-child.js +68 -0
- package/build/hooks/layout-child.js.map +1 -0
- package/build/hooks/layout.js +16 -101
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/padding.js +2 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/position.js +40 -62
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +51 -88
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +34 -14
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +154 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +0 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +8 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +34 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +8 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +10 -60
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +66 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/object.js +21 -61
- package/build/utils/object.js.map +1 -1
- package/build/utils/selection.js +9 -1
- package/build/utils/selection.js.map +1 -1
- package/build-module/components/block-canvas/index.js +23 -7
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-card/index.js +1 -1
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-controls/hook.js +4 -24
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-edit/context.js +2 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +19 -10
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-info-slot-fill/index.js +3 -3
- package/build-module/components/block-info-slot-fill/index.js.map +1 -1
- package/build-module/components/block-list/block.js +29 -10
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +14 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +62 -19
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -1
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -10
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +3 -0
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +4 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/index.native.js +3 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +88 -25
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +41 -0
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build-module/components/block-tools/block-toolbar-popover.js +76 -0
- package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build-module/components/block-tools/index.js +27 -24
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +2 -1
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +29 -18
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -4
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +23 -21
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +10 -4
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +20 -31
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/image-link-destinations/index.native.js +109 -0
- package/build-module/components/image-link-destinations/index.native.js.map +1 -0
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +14 -7
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +2 -2
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter-button/index.native.js +89 -0
- package/build-module/components/inserter-button/index.native.js.map +1 -0
- package/build-module/components/inserter-button/sparkles.js +15 -0
- package/build-module/components/inserter-button/sparkles.js.map +1 -0
- package/build-module/components/inserter-draggable-blocks/index.js +9 -5
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +3 -3
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +3 -3
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +2 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/preview-options/index.js +6 -62
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/content.js +25 -21
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +2 -1
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build-module/components/rich-text/index.js +4 -32
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +10 -18
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +7 -34
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +5 -1
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/with-deprecations.js +42 -0
- package/build-module/components/rich-text/with-deprecations.js.map +1 -0
- package/build-module/components/use-block-drop-zone/index.js +69 -8
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +1 -1
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +4 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +13 -1
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/hooks/align.js +19 -66
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +1 -0
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +11 -26
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +26 -28
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +22 -30
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-renaming.js +17 -21
- package/build-module/hooks/block-renaming.js.map +1 -1
- package/build-module/hooks/border.js +57 -78
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +74 -86
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +27 -27
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +11 -27
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-fields.js +20 -39
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/dimensions.js +21 -16
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +30 -61
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-family.js +14 -23
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +49 -119
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +18 -14
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +5 -3
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout-child.js +60 -0
- package/build-module/hooks/layout-child.js.map +1 -0
- package/build-module/hooks/layout.js +13 -98
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/padding.js +2 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/position.js +38 -59
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +51 -84
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +33 -12
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +149 -6
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +0 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +7 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +33 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +8 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +3 -53
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +56 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/object.js +21 -60
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/selection.js +9 -1
- package/build-module/utils/selection.js.map +1 -1
- package/build-style/style-rtl.css +113 -293
- package/build-style/style.css +113 -293
- package/package.json +31 -31
- package/src/components/block-canvas/index.js +31 -17
- package/src/components/block-caption/README.md +2 -2
- package/src/components/block-card/index.js +5 -3
- package/src/components/block-card/style.scss +7 -3
- package/src/components/block-controls/hook.js +8 -30
- package/src/components/block-controls/test/index.js +3 -3
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +36 -10
- package/src/components/block-info-slot-fill/index.js +6 -3
- package/src/components/block-inspector/style.scss +0 -4
- package/src/components/block-list/block.js +39 -5
- package/src/components/block-list/block.native.js +18 -4
- package/src/components/block-list/use-block-props/index.js +74 -21
- package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -34
- package/src/components/block-list/use-block-props/use-is-hovered.js +2 -13
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +1 -5
- package/src/components/block-patterns-list/index.js +1 -1
- package/src/components/block-removal-warning-modal/index.js +7 -14
- package/src/components/block-rename/modal.js +7 -1
- package/src/components/block-settings/container.native.js +3 -5
- package/src/components/block-styles/index.js +1 -1
- package/src/components/block-styles/index.native.js +4 -2
- package/src/components/block-styles/style.scss +0 -11
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +3 -1
- package/src/components/block-toolbar/index.js +180 -95
- package/src/components/block-toolbar/style.scss +50 -66
- package/src/components/block-tools/block-toolbar-breadcrumb.js +46 -0
- package/src/components/block-tools/block-toolbar-popover.js +90 -0
- package/src/components/block-tools/index.js +42 -29
- package/src/components/block-tools/style.scss +60 -172
- package/src/components/block-types-list/index.native.js +2 -1
- package/src/components/block-variation-picker/index.native.js +1 -1
- package/src/components/colors-gradients/control.js +49 -30
- package/src/components/colors-gradients/style.scss +0 -7
- package/src/components/duotone-control/index.js +2 -5
- package/src/components/duotone-control/style.scss +1 -6
- package/src/components/global-styles/color-panel.js +34 -25
- package/src/components/global-styles/filters-panel.js +8 -4
- package/src/components/global-styles/typography-panel.js +23 -43
- package/src/components/image-link-destinations/index.native.js +152 -0
- package/src/components/image-link-destinations/style.native.scss +16 -0
- package/src/components/index.native.js +1 -0
- package/src/components/inner-blocks/README.md +13 -2
- package/src/components/inserter/media-tab/media-panel.js +1 -1
- package/src/components/inserter/menu.js +16 -8
- package/src/components/inserter/preview-panel.js +2 -2
- package/src/components/inserter/style.scss +15 -17
- package/src/components/inserter-button/README.md +62 -0
- package/src/components/inserter-button/index.native.js +116 -0
- package/src/components/inserter-button/sparkles.js +15 -0
- package/src/components/inserter-button/style.native.scss +72 -0
- package/src/components/inserter-draggable-blocks/index.js +18 -5
- package/src/components/inspector-controls/fill.js +6 -3
- package/src/components/inspector-controls/fill.native.js +6 -3
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/navigable-toolbar/README.md +2 -0
- package/src/components/navigable-toolbar/index.js +2 -2
- package/src/components/preview-options/index.js +6 -86
- package/src/components/rich-text/content.js +27 -20
- package/src/components/rich-text/get-rich-text-values.js +6 -1
- package/src/components/rich-text/index.js +5 -46
- package/src/components/rich-text/index.native.js +8 -25
- package/src/components/rich-text/native/get-format-colors.native.js +33 -40
- package/src/components/rich-text/native/index.native.js +7 -48
- package/src/components/rich-text/use-input-rules.js +6 -1
- package/src/components/rich-text/with-deprecations.js +51 -0
- package/src/components/use-block-drop-zone/index.js +114 -14
- package/src/components/use-on-block-drop/index.js +2 -1
- package/src/components/use-resize-canvas/README.md +3 -3
- package/src/components/use-resize-canvas/index.js +4 -1
- package/src/components/use-settings/index.js +15 -1
- package/src/hooks/align.js +15 -76
- package/src/hooks/align.native.js +1 -0
- package/src/hooks/anchor.js +13 -33
- package/src/hooks/background.js +28 -23
- package/src/hooks/block-hooks.js +22 -51
- package/src/hooks/block-renaming.js +23 -37
- package/src/hooks/border.js +67 -118
- package/src/hooks/color.js +100 -132
- package/src/hooks/content-lock-ui.js +110 -122
- package/src/hooks/custom-class-name.js +8 -40
- package/src/hooks/custom-fields.js +20 -47
- package/src/hooks/dimensions.js +20 -16
- package/src/hooks/duotone.js +70 -127
- package/src/hooks/font-family.js +10 -29
- package/src/hooks/font-size.js +66 -162
- package/src/hooks/index.js +42 -14
- package/src/hooks/index.native.js +6 -3
- package/src/hooks/layout-child.js +53 -0
- package/src/hooks/layout.js +13 -102
- package/src/hooks/padding.js +2 -2
- package/src/hooks/position.js +50 -90
- package/src/hooks/style.js +117 -187
- package/src/hooks/test/align.js +1 -178
- package/src/hooks/typography.js +20 -16
- package/src/hooks/utils.js +187 -6
- package/src/private-apis.js +0 -2
- package/src/store/private-actions.js +8 -0
- package/src/store/private-selectors.js +45 -0
- package/src/store/reducer.js +8 -0
- package/src/store/selectors.js +5 -69
- package/src/store/utils.js +74 -0
- package/src/style.scss +0 -2
- package/src/utils/object.js +18 -69
- package/src/utils/selection.js +9 -2
- package/build/components/block-list/use-block-props/use-block-class-names.js +0 -67
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js +0 -46
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-default-class-name.js +0 -37
- package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build/components/block-tools/back-compat.js +0 -45
- package/build/components/block-tools/back-compat.js.map +0 -1
- package/build/components/block-tools/block-contextual-toolbar.js +0 -91
- package/build/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build/components/block-tools/selected-block-tools.js +0 -113
- package/build/components/block-tools/selected-block-tools.js.map +0 -1
- package/build/components/inserter/hooks/use-debounced-input.js +0 -22
- package/build/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build/components/use-display-block-controls/index.js +0 -39
- package/build/components/use-display-block-controls/index.js.map +0 -1
- package/build/components/use-display-block-controls/index.native.js +0 -39
- package/build/components/use-display-block-controls/index.native.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +0 -60
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +0 -40
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +0 -31
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build-module/components/block-tools/back-compat.js +0 -35
- package/build-module/components/block-tools/back-compat.js.map +0 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +0 -83
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build-module/components/block-tools/selected-block-tools.js +0 -105
- package/build-module/components/block-tools/selected-block-tools.js.map +0 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +0 -15
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.js +0 -32
- package/build-module/components/use-display-block-controls/index.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.native.js +0 -32
- package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
- package/src/components/block-list/use-block-props/use-block-class-names.js +0 -66
- package/src/components/block-list/use-block-props/use-block-custom-class-name.js +0 -44
- package/src/components/block-list/use-block-props/use-block-default-class-name.js +0 -35
- package/src/components/block-parent-selector/style.scss +0 -11
- package/src/components/block-tools/back-compat.js +0 -35
- package/src/components/block-tools/block-contextual-toolbar.js +0 -100
- package/src/components/block-tools/selected-block-tools.js +0 -127
- package/src/components/inserter/hooks/use-debounced-input.js +0 -18
- package/src/components/preview-options/README.md +0 -94
- package/src/components/preview-options/style.scss +0 -64
- package/src/components/use-display-block-controls/index.js +0 -36
- package/src/components/use-display-block-controls/index.native.js +0 -37
- package/src/hooks/test/color.js +0 -112
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","createHigherOrderComponent","addFilter","getBlockSupport","getBlockType","hasBlockSupport","BlockControls","BlockAlignmentControl","useAvailableAlignments","useBlockEditingMode","ALL_ALIGNMENTS","WIDE_ALIGNMENTS","getValidAlignments","blockAlign","hasWideBlockSupport","hasWideEnabled","validAlignments","Array","isArray","filter","value","includes","alignment","addAttribute","settings","_settings$attributes$","attributes","align","type","enum","BlockEditAlignmentToolbarControls","blockName","setAttributes","blockAllowedAlignments","map","name","blockEditingMode","length","updateAlignment","nextAlign","blockType","blockDefaultAlign","default","createElement","group","__experimentalShareWithChildBlocks","onChange","controls","withAlignmentControls","BlockEdit","props","hasAlignmentSupport","Fragment","key","BlockListBlockWithDataAlign","block","BlockListBlock","wrapperProps","some","withDataAlign","undefined","addAssignedAlign","isAlignValid","className"],"sources":["@wordpress/block-editor/src/hooks/align.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { BlockControls, BlockAlignmentControl } from '../components';\nimport useAvailableAlignments from '../components/block-alignment-control/use-available-alignments';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * An array which includes all possible valid alignments,\n * used to validate if an alignment is valid or not.\n *\n * @constant\n * @type {string[]}\n */\nconst ALL_ALIGNMENTS = [ 'left', 'center', 'right', 'wide', 'full' ];\n\n/**\n * An array which includes all wide alignments.\n * In order for this alignments to be valid they need to be supported by the block,\n * and by the theme.\n *\n * @constant\n * @type {string[]}\n */\nconst WIDE_ALIGNMENTS = [ 'wide', 'full' ];\n\n/**\n * Returns the valid alignments.\n * Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not.\n * Exported just for testing purposes, not exported outside the module.\n *\n * @param {?boolean|string[]} blockAlign Aligns supported by the block.\n * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise.\n * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise.\n *\n * @return {string[]} Valid alignments.\n */\nexport function getValidAlignments(\n\tblockAlign,\n\thasWideBlockSupport = true,\n\thasWideEnabled = true\n) {\n\tlet validAlignments;\n\tif ( Array.isArray( blockAlign ) ) {\n\t\tvalidAlignments = ALL_ALIGNMENTS.filter( ( value ) =>\n\t\t\tblockAlign.includes( value )\n\t\t);\n\t} else if ( blockAlign === true ) {\n\t\t// `true` includes all alignments...\n\t\tvalidAlignments = [ ...ALL_ALIGNMENTS ];\n\t} else {\n\t\tvalidAlignments = [];\n\t}\n\n\tif (\n\t\t! hasWideEnabled ||\n\t\t( blockAlign === true && ! hasWideBlockSupport )\n\t) {\n\t\treturn validAlignments.filter(\n\t\t\t( alignment ) => ! WIDE_ALIGNMENTS.includes( alignment )\n\t\t);\n\t}\n\n\treturn validAlignments;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `align`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.align ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'align' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\talign: {\n\t\t\t\ttype: 'string',\n\t\t\t\t// Allow for '' since it is used by the `updateAlignment` function\n\t\t\t\t// in toolbar controls for special cases with defined default values.\n\t\t\t\tenum: [ ...ALL_ALIGNMENTS, '' ],\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAlignmentToolbarControls( {\n\tblockName,\n\tattributes,\n\tsetAttributes,\n} ) {\n\t// Compute the block valid alignments by taking into account,\n\t// if the theme supports wide alignments or not and the layout's\n\t// available alignments. We do that for conditionally rendering\n\t// Slot.\n\tconst blockAllowedAlignments = getValidAlignments(\n\t\tgetBlockSupport( blockName, 'align' ),\n\t\thasBlockSupport( blockName, 'alignWide', true )\n\t);\n\n\tconst validAlignments = useAvailableAlignments(\n\t\tblockAllowedAlignments\n\t).map( ( { name } ) => name );\n\tconst blockEditingMode = useBlockEditingMode();\n\tif ( ! validAlignments.length || blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst updateAlignment = ( nextAlign ) => {\n\t\tif ( ! nextAlign ) {\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tconst blockDefaultAlign = blockType?.attributes?.align?.default;\n\t\t\tif ( blockDefaultAlign ) {\n\t\t\t\tnextAlign = '';\n\t\t\t}\n\t\t}\n\t\tsetAttributes( { align: nextAlign } );\n\t};\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<BlockAlignmentControl\n\t\t\t\tvalue={ attributes.align }\n\t\t\t\tonChange={ updateAlignment }\n\t\t\t\tcontrols={ validAlignments }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Override the default edit UI to include new toolbar controls for block\n * alignment, if block defines support.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withAlignmentControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasAlignmentSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'align',\n\t\t\tfalse\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasAlignmentSupport && (\n\t\t\t\t\t<BlockEditAlignmentToolbarControls\n\t\t\t\t\t\tblockName={ props.name }\n\t\t\t\t\t\tattributes={ props.attributes }\n\t\t\t\t\t\tsetAttributes={ props.setAttributes }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withAlignmentControls'\n);\n\nfunction BlockListBlockWithDataAlign( { block: BlockListBlock, props } ) {\n\tconst { name, attributes } = props;\n\tconst { align } = attributes;\n\tconst blockAllowedAlignments = getValidAlignments(\n\t\tgetBlockSupport( name, 'align' ),\n\t\thasBlockSupport( name, 'alignWide', true )\n\t);\n\tconst validAlignments = useAvailableAlignments( blockAllowedAlignments );\n\n\tlet wrapperProps = props.wrapperProps;\n\tif ( validAlignments.some( ( alignment ) => alignment.name === align ) ) {\n\t\twrapperProps = { ...wrapperProps, 'data-align': align };\n\t}\n\n\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n}\n\n/**\n * Override the default block element to add alignment wrapper props.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withDataAlign = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\t// If an alignment is not assigned, there's no need to go through the\n\t\t// effort to validate or assign its value.\n\t\tif ( props.attributes.align === undefined ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\treturn (\n\t\t\t<BlockListBlockWithDataAlign\n\t\t\t\tblock={ BlockListBlock }\n\t\t\t\tprops={ props }\n\t\t\t/>\n\t\t);\n\t},\n\t'withDataAlign'\n);\n\n/**\n * Override props assigned to save component to inject alignment class name if\n * block supports it.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addAssignedAlign( props, blockType, attributes ) {\n\tconst { align } = attributes;\n\tconst blockAlign = getBlockSupport( blockType, 'align' );\n\tconst hasWideBlockSupport = hasBlockSupport( blockType, 'alignWide', true );\n\n\t// Compute valid alignments without taking into account if\n\t// the theme supports wide alignments or not.\n\t// This way changing themes does not impact the block save.\n\tconst isAlignValid = getValidAlignments(\n\t\tblockAlign,\n\t\thasWideBlockSupport\n\t).includes( align );\n\tif ( isAlignValid ) {\n\t\tprops.className = classnames( `align${ align }`, props.className );\n\t}\n\n\treturn props;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/align/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/align/with-data-align',\n\twithDataAlign\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/align/with-toolbar-controls',\n\twithAlignmentControls\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/editor/align/addAssignedAlign',\n\taddAssignedAlign\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SACCC,eAAe,EACfC,YAAY,EACZC,eAAe,QACT,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,aAAa,EAAEC,qBAAqB,QAAQ,eAAe;AACpE,OAAOC,sBAAsB,MAAM,gEAAgE;AACnG,SAASC,mBAAmB,QAAQ,kCAAkC;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,CAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAE;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CACjCC,UAAU,EACVC,mBAAmB,GAAG,IAAI,EAC1BC,cA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CAACW,2BAA2B;IAC3BC,KAAK,EAAGC,cAAgB;IACxBN,KAAK,EAAGA;EAAO,CACf,CAAC;AAEJ,CAAC,EACD,eACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASW,gBAAgBA,CAAEX,KAAK,EAAEV,SAAS,EAAEd,UAAU,EAAG;EAChE,MAAM;IAAEC;EAAM,CAAC,GAAGD,UAAU;EAC5B,MAAMb,UAAU,GAAGV,eAAe,CAAEqC,SAAS,EAAE,OAAQ,CAAC;EACxD,MAAM1B,mBAAmB,GAAGT,eAAe,CAAEmC,SAAS,EAAE,WAAW,EAAE,IAAK,CAAC;;EAE3E;EACA;EACA;EACA,MAAMsB,YAAY,GAAGlD,kBAAkB,CACtCC,UAAU,EACVC,mBACD,CAAC,CAACO,QAAQ,CAAEM,KAAM,CAAC;EACnB,IAAKmC,YAAY,EAAG;IACnBZ,KAAK,CAACa,SAAS,GAAG/D,UAAU,CAAG,QAAQ2B,KAAO,EAAC,EAAEuB,KAAK,CAACa,SAAU,CAAC;EACnE;EAEA,OAAOb,KAAK;AACb;AAEAhD,SAAS,CACR,0BAA0B,EAC1B,gCAAgC,EAChCqB,YACD,CAAC;AACDrB,SAAS,CACR,uBAAuB,EACvB,mCAAmC,EACnCyD,aACD,CAAC;AACDzD,SAAS,CACR,kBAAkB,EAClB,yCAAyC,EACzC8C,qBACD,CAAC;AACD9C,SAAS,CACR,kCAAkC,EAClC,oCAAoC,EACpC2D,gBACD,CAAC"}
|
|
1
|
+
{"version":3,"names":["classnames","addFilter","getBlockSupport","getBlockType","hasBlockSupport","BlockControls","BlockAlignmentControl","useAvailableAlignments","useBlockEditingMode","ALL_ALIGNMENTS","WIDE_ALIGNMENTS","getValidAlignments","blockAlign","hasWideBlockSupport","hasWideEnabled","validAlignments","Array","isArray","filter","value","includes","alignment","addAttribute","settings","_settings$attributes$","attributes","align","type","enum","BlockEditAlignmentToolbarControlsPure","name","blockName","setAttributes","blockAllowedAlignments","map","blockEditingMode","length","updateAlignment","nextAlign","blockType","blockDefaultAlign","default","createElement","group","__experimentalShareWithChildBlocks","onChange","controls","shareWithChildBlocks","edit","useBlockProps","attributeKeys","hasSupport","some","addAssignedAlign","props","isAlignValid","className"],"sources":["@wordpress/block-editor/src/hooks/align.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { BlockControls, BlockAlignmentControl } from '../components';\nimport useAvailableAlignments from '../components/block-alignment-control/use-available-alignments';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * An array which includes all possible valid alignments,\n * used to validate if an alignment is valid or not.\n *\n * @constant\n * @type {string[]}\n */\nconst ALL_ALIGNMENTS = [ 'left', 'center', 'right', 'wide', 'full' ];\n\n/**\n * An array which includes all wide alignments.\n * In order for this alignments to be valid they need to be supported by the block,\n * and by the theme.\n *\n * @constant\n * @type {string[]}\n */\nconst WIDE_ALIGNMENTS = [ 'wide', 'full' ];\n\n/**\n * Returns the valid alignments.\n * Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not.\n * Exported just for testing purposes, not exported outside the module.\n *\n * @param {?boolean|string[]} blockAlign Aligns supported by the block.\n * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise.\n * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise.\n *\n * @return {string[]} Valid alignments.\n */\nexport function getValidAlignments(\n\tblockAlign,\n\thasWideBlockSupport = true,\n\thasWideEnabled = true\n) {\n\tlet validAlignments;\n\tif ( Array.isArray( blockAlign ) ) {\n\t\tvalidAlignments = ALL_ALIGNMENTS.filter( ( value ) =>\n\t\t\tblockAlign.includes( value )\n\t\t);\n\t} else if ( blockAlign === true ) {\n\t\t// `true` includes all alignments...\n\t\tvalidAlignments = [ ...ALL_ALIGNMENTS ];\n\t} else {\n\t\tvalidAlignments = [];\n\t}\n\n\tif (\n\t\t! hasWideEnabled ||\n\t\t( blockAlign === true && ! hasWideBlockSupport )\n\t) {\n\t\treturn validAlignments.filter(\n\t\t\t( alignment ) => ! WIDE_ALIGNMENTS.includes( alignment )\n\t\t);\n\t}\n\n\treturn validAlignments;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `align`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.align ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'align' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\talign: {\n\t\t\t\ttype: 'string',\n\t\t\t\t// Allow for '' since it is used by the `updateAlignment` function\n\t\t\t\t// in toolbar controls for special cases with defined default values.\n\t\t\t\tenum: [ ...ALL_ALIGNMENTS, '' ],\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAlignmentToolbarControlsPure( {\n\tname: blockName,\n\talign,\n\tsetAttributes,\n} ) {\n\t// Compute the block valid alignments by taking into account,\n\t// if the theme supports wide alignments or not and the layout's\n\t// available alignments. We do that for conditionally rendering\n\t// Slot.\n\tconst blockAllowedAlignments = getValidAlignments(\n\t\tgetBlockSupport( blockName, 'align' ),\n\t\thasBlockSupport( blockName, 'alignWide', true )\n\t);\n\n\tconst validAlignments = useAvailableAlignments(\n\t\tblockAllowedAlignments\n\t).map( ( { name } ) => name );\n\tconst blockEditingMode = useBlockEditingMode();\n\tif ( ! validAlignments.length || blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst updateAlignment = ( nextAlign ) => {\n\t\tif ( ! nextAlign ) {\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tconst blockDefaultAlign = blockType?.attributes?.align?.default;\n\t\t\tif ( blockDefaultAlign ) {\n\t\t\t\tnextAlign = '';\n\t\t\t}\n\t\t}\n\t\tsetAttributes( { align: nextAlign } );\n\t};\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<BlockAlignmentControl\n\t\t\t\tvalue={ align }\n\t\t\t\tonChange={ updateAlignment }\n\t\t\t\tcontrols={ validAlignments }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: BlockEditAlignmentToolbarControlsPure,\n\tuseBlockProps,\n\tattributeKeys: [ 'align' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'align', false );\n\t},\n};\n\nfunction useBlockProps( { name, align } ) {\n\tconst blockAllowedAlignments = getValidAlignments(\n\t\tgetBlockSupport( name, 'align' ),\n\t\thasBlockSupport( name, 'alignWide', true )\n\t);\n\tconst validAlignments = useAvailableAlignments( blockAllowedAlignments );\n\n\tif ( validAlignments.some( ( alignment ) => alignment.name === align ) ) {\n\t\treturn { 'data-align': align };\n\t}\n\n\treturn {};\n}\n\n/**\n * Override props assigned to save component to inject alignment class name if\n * block supports it.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addAssignedAlign( props, blockType, attributes ) {\n\tconst { align } = attributes;\n\tconst blockAlign = getBlockSupport( blockType, 'align' );\n\tconst hasWideBlockSupport = hasBlockSupport( blockType, 'alignWide', true );\n\n\t// Compute valid alignments without taking into account if\n\t// the theme supports wide alignments or not.\n\t// This way changing themes does not impact the block save.\n\tconst isAlignValid = getValidAlignments(\n\t\tblockAlign,\n\t\thasWideBlockSupport\n\t).includes( align );\n\tif ( isAlignValid ) {\n\t\tprops.className = classnames( `align${ align }`, props.className );\n\t}\n\n\treturn props;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/align/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/editor/align/addAssignedAlign',\n\taddAssignedAlign\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SACCC,eAAe,EACfC,YAAY,EACZC,eAAe,QACT,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,aAAa,EAAEC,qBAAqB,QAAQ,eAAe;AACpE,OAAOC,sBAAsB,MAAM,gEAAgE;AACnG,SAASC,mBAAmB,QAAQ,kCAAkC;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,CAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAE;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CACjCC,UAAU,EACVC,mBAAmB,GAAG,IAAI,EAC1BC,cAAc,GAAG,IAAI,EACpB;EACD,IAAIC,eAAe;EACnB,IAAKC,KAAK,CAACC,OAAO,CAAEL,UAAW,CAAC,EAAG;IAClCG,eAAe,GAAGN,cAAc,CAACS,MAAM,CAAIC,KAAK,IAC/CP,UAAU,CAACQ,QAAQ,CAAED,KAAM,CAC5B,CAAC;EACF,CAAC,MAAM,IAAKP,UAAU,KAAK,IAAI,EAAG;IACjC;IACAG,eAAe,GAAG,CAAE,GAAGN,cAAc,CAAE;EACxC,CAAC,MAAM;IACNM,eAAe,GAAG,EAAE;EACrB;EAEA,IACC,CAAED,cAAc,IACdF,UAAU,KAAK,IAAI,IAAI,CAAEC,mBAAqB,EAC/C;IACD,O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;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS2B,gBAAgBA,CAAEC,KAAK,EAAEf,SAAS,EAAEd,UAAU,EAAG;EAChE,MAAM;IAAEC;EAAM,CAAC,GAAGD,UAAU;EAC5B,MAAMb,UAAU,GAAGV,eAAe,CAAEqC,SAAS,EAAE,OAAQ,CAAC;EACxD,MAAM1B,mBAAmB,GAAGT,eAAe,CAAEmC,SAAS,EAAE,WAAW,EAAE,IAAK,CAAC;;EAE3E;EACA;EACA;EACA,MAAMgB,YAAY,GAAG5C,kBAAkB,CACtCC,UAAU,EACVC,mBACD,CAAC,CAACO,QAAQ,CAAEM,KAAM,CAAC;EACnB,IAAK6B,YAAY,EAAG;IACnBD,KAAK,CAACE,SAAS,GAAGxD,UAAU,CAAG,QAAQ0B,KAAO,EAAC,EAAE4B,KAAK,CAACE,SAAU,CAAC;EACnE;EAEA,OAAOF,KAAK;AACb;AAEArD,SAAS,CACR,0BAA0B,EAC1B,gCAAgC,EAChCqB,YACD,CAAC;AACDrB,SAAS,CACR,kCAAkC,EAClC,oCAAoC,EACpCoD,gBACD,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { hasBlockSupport } from '@wordpress/blocks';
|
|
|
6
6
|
import { WIDE_ALIGNMENTS } from '@wordpress/components';
|
|
7
7
|
const ALIGNMENTS = ['left', 'center', 'right'];
|
|
8
8
|
export * from './align.js';
|
|
9
|
+
export { default } from './align.js';
|
|
9
10
|
|
|
10
11
|
// Used to filter out blocks that don't support wide/full alignment on mobile
|
|
11
12
|
addFilter('blocks.registerBlockType', 'core/react-native-editor/align', (settings, name) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["addFilter","hasBlockSupport","WIDE_ALIGNMENTS","ALIGNMENTS","settings","name","excludeBlocks","includes","blockAlign","supports","align","Array","isArray","filter","alignment","Object","values","alignments","alignWide","attributes","type","enum"],"sources":["@wordpress/block-editor/src/hooks/align.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { WIDE_ALIGNMENTS } from '@wordpress/components';\n\nconst ALIGNMENTS = [ 'left', 'center', 'right' ];\n\nexport * from './align.js';\n\n// Used to filter out blocks that don't support wide/full alignment on mobile\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/react-native-editor/align',\n\t( settings, name ) => {\n\t\tif (\n\t\t\tWIDE_ALIGNMENTS.excludeBlocks.includes( name ) &&\n\t\t\thasBlockSupport( settings, 'align' )\n\t\t) {\n\t\t\tconst blockAlign = settings.supports.align;\n\n\t\t\tsettings.supports = {\n\t\t\t\t...settings.supports,\n\t\t\t\talign: Array.isArray( blockAlign )\n\t\t\t\t\t? blockAlign.filter(\n\t\t\t\t\t\t\t( alignment ) =>\n\t\t\t\t\t\t\t\t! Object.values(\n\t\t\t\t\t\t\t\t\tWIDE_ALIGNMENTS.alignments\n\t\t\t\t\t\t\t\t).includes( alignment )\n\t\t\t\t\t )\n\t\t\t\t\t: blockAlign,\n\t\t\t\talignWide: false,\n\t\t\t};\n\t\t\tsettings.attributes = {\n\t\t\t\t...settings.attributes,\n\t\t\t\talign: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\t// Allow for '' since it is used by the `updateAlignment` function\n\t\t\t\t\t// in toolbar controls for special cases with defined default values.\n\t\t\t\t\tenum: [ ...ALIGNMENTS, '' ],\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn settings;\n\t}\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,MAAMC,UAAU,GAAG,CAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAE;AAEhD,cAAc,YAAY;;
|
|
1
|
+
{"version":3,"names":["addFilter","hasBlockSupport","WIDE_ALIGNMENTS","ALIGNMENTS","default","settings","name","excludeBlocks","includes","blockAlign","supports","align","Array","isArray","filter","alignment","Object","values","alignments","alignWide","attributes","type","enum"],"sources":["@wordpress/block-editor/src/hooks/align.native.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { WIDE_ALIGNMENTS } from '@wordpress/components';\n\nconst ALIGNMENTS = [ 'left', 'center', 'right' ];\n\nexport * from './align.js';\nexport { default } from './align.js';\n\n// Used to filter out blocks that don't support wide/full alignment on mobile\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/react-native-editor/align',\n\t( settings, name ) => {\n\t\tif (\n\t\t\tWIDE_ALIGNMENTS.excludeBlocks.includes( name ) &&\n\t\t\thasBlockSupport( settings, 'align' )\n\t\t) {\n\t\t\tconst blockAlign = settings.supports.align;\n\n\t\t\tsettings.supports = {\n\t\t\t\t...settings.supports,\n\t\t\t\talign: Array.isArray( blockAlign )\n\t\t\t\t\t? blockAlign.filter(\n\t\t\t\t\t\t\t( alignment ) =>\n\t\t\t\t\t\t\t\t! Object.values(\n\t\t\t\t\t\t\t\t\tWIDE_ALIGNMENTS.alignments\n\t\t\t\t\t\t\t\t).includes( alignment )\n\t\t\t\t\t )\n\t\t\t\t\t: blockAlign,\n\t\t\t\talignWide: false,\n\t\t\t};\n\t\t\tsettings.attributes = {\n\t\t\t\t...settings.attributes,\n\t\t\t\talign: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\t// Allow for '' since it is used by the `updateAlignment` function\n\t\t\t\t\t// in toolbar controls for special cases with defined default values.\n\t\t\t\t\tenum: [ ...ALIGNMENTS, '' ],\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn settings;\n\t}\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,MAAMC,UAAU,GAAG,CAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAE;AAEhD,cAAc,YAAY;AAC1B,SAASC,OAAO,QAAQ,YAAY;;AAEpC;AACAJ,SAAS,CACR,0BAA0B,EAC1B,gCAAgC,EAChC,CAAEK,QAAQ,EAAEC,IAAI,KAAM;EACrB,IACCJ,eAAe,CAACK,aAAa,CAACC,QAAQ,CAAEF,IAAK,CAAC,IAC9CL,eAAe,CAAEI,QAAQ,EAAE,OAAQ,CAAC,EACnC;IACD,MAAMI,UAAU,GAAGJ,QAAQ,CAACK,QAAQ,CAACC,KAAK;IAE1CN,QAAQ,CAACK,QAAQ,GAAG;MACnB,GAAGL,QAAQ,CAACK,QAAQ;MACpBC,KAAK,EAAEC,KAAK,CAACC,OAAO,CAAEJ,UAAW,CAAC,GAC/BA,UAAU,CAACK,MAAM,CACfC,SAAS,IACV,CAAEC,MAAM,CAACC,MAAM,CACdf,eAAe,CAACgB,UACjB,CAAC,CAACV,QAAQ,CAAEO,SAAU,CACvB,CAAC,GACDN,UAAU;MACbU,SAAS,EAAE;IACZ,CAAC;IACDd,QAAQ,CAACe,UAAU,GAAG;MACrB,GAAGf,QAAQ,CAACe,UAAU;MACtBT,KAAK,EAAE;QACNU,IAAI,EAAE,QAAQ;QACd;QACA;QACAC,IAAI,EAAE,CAAE,GAAGnB,UAAU,EAAE,EAAE;MAC1B;IACD,CAAC;EACF;EAEA,OAAOE,QAAQ;AAChB,CACD,CAAC"}
|
|
@@ -6,7 +6,6 @@ import { addFilter } from '@wordpress/hooks';
|
|
|
6
6
|
import { PanelBody, TextControl, ExternalLink } from '@wordpress/components';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { hasBlockSupport } from '@wordpress/blocks';
|
|
9
|
-
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
10
9
|
import { Platform } from '@wordpress/element';
|
|
11
10
|
|
|
12
11
|
/**
|
|
@@ -51,9 +50,9 @@ export function addAttribute(settings) {
|
|
|
51
50
|
}
|
|
52
51
|
return settings;
|
|
53
52
|
}
|
|
54
|
-
function
|
|
55
|
-
blockName,
|
|
56
|
-
|
|
53
|
+
function BlockEditAnchorControlPure({
|
|
54
|
+
name: blockName,
|
|
55
|
+
anchor,
|
|
57
56
|
setAttributes
|
|
58
57
|
}) {
|
|
59
58
|
const blockEditingMode = useBlockEditingMode();
|
|
@@ -66,7 +65,7 @@ function BlockEditAnchorControl({
|
|
|
66
65
|
help: createElement(Fragment, null, __('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), isWeb && createElement(ExternalLink, {
|
|
67
66
|
href: __('https://wordpress.org/documentation/article/page-jumps/')
|
|
68
67
|
}, __('Learn more about anchors'))),
|
|
69
|
-
value:
|
|
68
|
+
value: anchor || '',
|
|
70
69
|
placeholder: !isWeb ? __('Add an anchor') : null,
|
|
71
70
|
onChange: nextValue => {
|
|
72
71
|
nextValue = nextValue.replace(ANCHOR_REGEX, '-');
|
|
@@ -83,26 +82,13 @@ function BlockEditAnchorControl({
|
|
|
83
82
|
title: __('Heading settings')
|
|
84
83
|
}, textControl)));
|
|
85
84
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
* @return {Component} Wrapped component.
|
|
94
|
-
*/
|
|
95
|
-
export const withAnchorControls = createHigherOrderComponent(BlockEdit => {
|
|
96
|
-
return props => {
|
|
97
|
-
return createElement(Fragment, null, createElement(BlockEdit, {
|
|
98
|
-
...props
|
|
99
|
-
}), props.isSelected && hasBlockSupport(props.name, 'anchor') && createElement(BlockEditAnchorControl, {
|
|
100
|
-
blockName: props.name,
|
|
101
|
-
attributes: props.attributes,
|
|
102
|
-
setAttributes: props.setAttributes
|
|
103
|
-
}));
|
|
104
|
-
};
|
|
105
|
-
}, 'withAnchorControls');
|
|
85
|
+
export default {
|
|
86
|
+
edit: BlockEditAnchorControlPure,
|
|
87
|
+
attributeKeys: ['anchor'],
|
|
88
|
+
hasSupport(name) {
|
|
89
|
+
return hasBlockSupport(name, 'anchor');
|
|
90
|
+
}
|
|
91
|
+
};
|
|
106
92
|
|
|
107
93
|
/**
|
|
108
94
|
* Override props assigned to save component to inject anchor ID, if block
|
|
@@ -122,6 +108,5 @@ export function addSaveProps(extraProps, blockType, attributes) {
|
|
|
122
108
|
return extraProps;
|
|
123
109
|
}
|
|
124
110
|
addFilter('blocks.registerBlockType', 'core/anchor/attribute', addAttribute);
|
|
125
|
-
addFilter('editor.BlockEdit', 'core/editor/anchor/with-inspector-controls', withAnchorControls);
|
|
126
111
|
addFilter('blocks.getSaveContent.extraProps', 'core/editor/anchor/save-props', addSaveProps);
|
|
127
112
|
//# sourceMappingURL=anchor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","
|
|
1
|
+
{"version":3,"names":["addFilter","PanelBody","TextControl","ExternalLink","__","hasBlockSupport","Platform","InspectorControls","useBlockEditingMode","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","_settings$attributes$","attributes","anchor","BlockEditAnchorControlPure","name","blockName","setAttributes","blockEditingMode","isWeb","OS","textControl","createElement","__nextHasNoMarginBottom","__next40pxDefaultSize","className","label","help","Fragment","href","value","placeholder","onChange","nextValue","replace","autoCapitalize","autoComplete","group","title","edit","attributeKeys","hasSupport","addSaveProps","extraProps","blockType","id"],"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { PanelBody, TextControl, ExternalLink } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Regular expression matching invalid anchor characters for replacement.\n *\n * @type {RegExp}\n */\nconst ANCHOR_REGEX = /[\\s#]/g;\n\nconst ANCHOR_SCHEMA = {\n\ttype: 'string',\n\tsource: 'attribute',\n\tattribute: 'id',\n\tselector: '*',\n};\n\n/**\n * Filters registered block settings, extending attributes with anchor using ID\n * of the first node.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( 'type' in ( settings.attributes?.anchor ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, 'anchor' ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tanchor: ANCHOR_SCHEMA,\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction BlockEditAnchorControlPure( {\n\tname: blockName,\n\tanchor,\n\tsetAttributes,\n} ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst isWeb = Platform.OS === 'web';\n\tconst textControl = (\n\t\t<TextControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tclassName=\"html-anchor-control\"\n\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\thelp={\n\t\t\t\t<>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t}\n\t\t\tvalue={ anchor || '' }\n\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tanchor: nextValue,\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tautoCapitalize=\"none\"\n\t\t\tautoComplete=\"off\"\n\t\t/>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ isWeb && blockEditingMode === 'default' && (\n\t\t\t\t<InspectorControls group=\"advanced\">\n\t\t\t\t\t{ textControl }\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t\t{ /*\n\t\t\t * We plan to remove scoping anchors to 'core/heading' to support\n\t\t\t * anchors for all eligble blocks. Additionally we plan to explore\n\t\t\t * leveraging InspectorAdvancedControls instead of a custom\n\t\t\t * PanelBody title. https://github.com/WordPress/gutenberg/issues/28363\n\t\t\t */ }\n\t\t\t{ ! isWeb && blockName === 'core/heading' && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<PanelBody title={ __( 'Heading settings' ) }>\n\t\t\t\t\t\t{ textControl }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tedit: BlockEditAnchorControlPure,\n\tattributeKeys: [ 'anchor' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'anchor' );\n\t},\n};\n\n/**\n * Override props assigned to save component to inject anchor ID, if block\n * supports anchor. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockSupport( blockType, 'anchor' ) ) {\n\t\textraProps.id = attributes.anchor === '' ? null : attributes.anchor;\n\t}\n\n\treturn extraProps;\n}\n\naddFilter( 'blocks.registerBlockType', 'core/anchor/attribute', addAttribute );\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/editor/anchor/save-props',\n\taddSaveProps\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,EAAEC,WAAW,EAAEC,YAAY,QAAQ,uBAAuB;AAC5E,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,mBAAmB,QAAQ,kCAAkC;;AAEtE;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAG,QAAQ;AAE7B,MAAMC,aAAa,GAAG;EACrBC,IAAI,EAAE,QAAQ;EACdC,MAAM,EAAE,WAAW;EACnBC,SAAS,EAAE,IAAI;EACfC,QAAQ,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAEC,QAAQ,EAAG;EAAA,IAAAC,qBAAA;EACxC;EACA,IAAK,MAAM,MAAAA,qBAAA,GAAMD,QAAQ,CAACE,UAAU,EAAEC,MAAM,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC,CAAE,EAAG;IACtD,OAAOD,QAAQ;EAChB;EACA,IAAKX,eAAe,CAAEW,QAAQ,EAAE,QAAS,CAAC,EAAG;IAC5C;IACAA,QAAQ,CAACE,UAAU,GAAG;MACrB,GAAGF,QAAQ,CAACE,UAAU;MACtBC,MAAM,EAAET;IACT,CAAC;EACF;EAEA,OAAOM,QAAQ;AAChB;AAEA,SAASI,0BAA0BA,CAAE;EACpCC,IAAI,EAAEC,SAAS;EACfH,MAAM;EACNI;AACD,CAAC,EAAG;EACH,MAAMC,gBAAgB,GAAGhB,mBAAmB,CAAC,CAAC;EAE9C,MAAMiB,KA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,IAAI,EAAE,QAAS,CAAC;EACzC;AACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS2B,YAAYA,CAAEC,UAAU,EAAEC,SAAS,EAAEhC,UAAU,EAAG;EACjE,IAAKb,eAAe,CAAE6C,SAAS,EAAE,QAAS,CAAC,EAAG;IAC7CD,UAAU,CAACE,EAAE,GAAGjC,UAAU,CAACC,MAAM,KAAK,EAAE,GAAG,IAAI,GAAGD,UAAU,CAACC,MAAM;EACpE;EAEA,OAAO8B,UAAU;AAClB;AAEAjD,SAAS,CAAE,0BAA0B,EAAE,uBAAuB,EAAEe,YAAa,CAAC;AAC9Ef,SAAS,CACR,kCAAkC,EAClC,+BAA+B,EAC/BgD,YACD,CAAC"}
|
|
@@ -16,6 +16,7 @@ import { Platform, useCallback, useRef } from '@wordpress/element';
|
|
|
16
16
|
import { __, sprintf } from '@wordpress/i18n';
|
|
17
17
|
import { store as noticesStore } from '@wordpress/notices';
|
|
18
18
|
import { getFilename } from '@wordpress/url';
|
|
19
|
+
import { pure } from '@wordpress/compose';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Internal dependencies
|
|
@@ -32,11 +33,11 @@ export const IMAGE_BACKGROUND_TYPE = 'image';
|
|
|
32
33
|
* Checks if there is a current value in the background image block support
|
|
33
34
|
* attributes.
|
|
34
35
|
*
|
|
35
|
-
* @param {Object}
|
|
36
|
+
* @param {Object} style Style attribute.
|
|
36
37
|
* @return {boolean} Whether or not the block has a background image value set.
|
|
37
38
|
*/
|
|
38
|
-
export function hasBackgroundImageValue(
|
|
39
|
-
const hasValue = !!
|
|
39
|
+
export function hasBackgroundImageValue(style) {
|
|
40
|
+
const hasValue = !!style?.background?.backgroundImage?.id || !!style?.background?.backgroundImage?.url;
|
|
40
41
|
return hasValue;
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -66,17 +67,10 @@ export function hasBackgroundSupport(blockName, feature = 'any') {
|
|
|
66
67
|
* Resets the background image block support attributes. This can be used when disabling
|
|
67
68
|
* the background image controls for a block via a `ToolsPanel`.
|
|
68
69
|
*
|
|
69
|
-
* @param {Object}
|
|
70
|
-
* @param {
|
|
71
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
70
|
+
* @param {Object} style Style attribute.
|
|
71
|
+
* @param {Function} setAttributes Function to set block's attributes.
|
|
72
72
|
*/
|
|
73
|
-
export function resetBackgroundImage({
|
|
74
|
-
attributes = {},
|
|
75
|
-
setAttributes
|
|
76
|
-
}) {
|
|
77
|
-
const {
|
|
78
|
-
style = {}
|
|
79
|
-
} = attributes;
|
|
73
|
+
export function resetBackgroundImage(style = {}, setAttributes) {
|
|
80
74
|
setAttributes({
|
|
81
75
|
style: cleanEmptyObject({
|
|
82
76
|
...style,
|
|
@@ -118,17 +112,16 @@ function InspectorImagePreview({
|
|
|
118
112
|
}, filename ? sprintf( /* translators: %s: file name */
|
|
119
113
|
__('Selected image: %s'), filename) : __('No image selected')))));
|
|
120
114
|
}
|
|
121
|
-
function BackgroundImagePanelItem(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
} = props;
|
|
115
|
+
function BackgroundImagePanelItem({
|
|
116
|
+
clientId,
|
|
117
|
+
setAttributes
|
|
118
|
+
}) {
|
|
119
|
+
const style = useSelect(select => select(blockEditorStore).getBlockAttributes(clientId)?.style, [clientId]);
|
|
127
120
|
const {
|
|
128
121
|
id,
|
|
129
122
|
title,
|
|
130
123
|
url
|
|
131
|
-
} =
|
|
124
|
+
} = style?.background?.backgroundImage || {};
|
|
132
125
|
const replaceContainerRef = useRef();
|
|
133
126
|
const {
|
|
134
127
|
mediaUpload
|
|
@@ -148,9 +141,9 @@ function BackgroundImagePanelItem(props) {
|
|
|
148
141
|
const onSelectMedia = media => {
|
|
149
142
|
if (!media || !media.url) {
|
|
150
143
|
const newStyle = {
|
|
151
|
-
...
|
|
144
|
+
...style,
|
|
152
145
|
background: {
|
|
153
|
-
...
|
|
146
|
+
...style?.background,
|
|
154
147
|
backgroundImage: undefined
|
|
155
148
|
}
|
|
156
149
|
};
|
|
@@ -170,9 +163,9 @@ function BackgroundImagePanelItem(props) {
|
|
|
170
163
|
return;
|
|
171
164
|
}
|
|
172
165
|
const newStyle = {
|
|
173
|
-
...
|
|
166
|
+
...style,
|
|
174
167
|
background: {
|
|
175
|
-
...
|
|
168
|
+
...style?.background,
|
|
176
169
|
backgroundImage: {
|
|
177
170
|
url: media.url,
|
|
178
171
|
id: media.id,
|
|
@@ -208,12 +201,12 @@ function BackgroundImagePanelItem(props) {
|
|
|
208
201
|
}
|
|
209
202
|
};
|
|
210
203
|
}, []);
|
|
211
|
-
const hasValue = hasBackgroundImageValue(
|
|
204
|
+
const hasValue = hasBackgroundImageValue(style);
|
|
212
205
|
return createElement(ToolsPanelItem, {
|
|
213
206
|
className: "single-column",
|
|
214
207
|
hasValue: () => hasValue,
|
|
215
208
|
label: __('Background image'),
|
|
216
|
-
onDeselect: () => resetBackgroundImage(
|
|
209
|
+
onDeselect: () => resetBackgroundImage(style, setAttributes),
|
|
217
210
|
isShownByDefault: true,
|
|
218
211
|
resetAllFilter: resetAllFilter,
|
|
219
212
|
panelId: clientId
|
|
@@ -240,14 +233,14 @@ function BackgroundImagePanelItem(props) {
|
|
|
240
233
|
// closed and focus is redirected to the dropdown toggle button.
|
|
241
234
|
toggleButton?.focus();
|
|
242
235
|
toggleButton?.click();
|
|
243
|
-
resetBackgroundImage(
|
|
236
|
+
resetBackgroundImage(style, setAttributes);
|
|
244
237
|
}
|
|
245
238
|
}, __('Reset '))), createElement(DropZone, {
|
|
246
239
|
onFilesDrop: onFilesDrop,
|
|
247
240
|
label: __('Drop to upload')
|
|
248
241
|
})));
|
|
249
242
|
}
|
|
250
|
-
|
|
243
|
+
function BackgroundImagePanelPure(props) {
|
|
251
244
|
const [backgroundImage] = useSettings('background.backgroundImage');
|
|
252
245
|
if (!backgroundImage || !hasBackgroundSupport(props.name, 'backgroundImage')) {
|
|
253
246
|
return null;
|
|
@@ -258,4 +251,9 @@ export function BackgroundImagePanel(props) {
|
|
|
258
251
|
...props
|
|
259
252
|
}));
|
|
260
253
|
}
|
|
254
|
+
|
|
255
|
+
// We don't want block controls to re-render when typing inside a block. `pure`
|
|
256
|
+
// will prevent re-renders unless props change, so only pass the needed props
|
|
257
|
+
// and not the whole attributes object.
|
|
258
|
+
export const BackgroundImagePanel = pure(BackgroundImagePanelPure);
|
|
261
259
|
//# sourceMappingURL=background.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","isBlobURL","getBlockSupport","focus","__experimentalToolsPanelItem","ToolsPanelItem","DropZone","FlexItem","MenuItem","VisuallyHidden","__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalTruncate","Truncate","useDispatch","useSelect","Platform","useCallback","useRef","__","sprintf","store","noticesStore","getFilename","InspectorControls","MediaReplaceFlow","useSettings","cleanEmptyObject","blockEditorStore","BACKGROUND_SUPPORT_KEY","IMAGE_BACKGROUND_TYPE","hasBackgroundImageValue","props","hasValue","attributes","style","background","backgroundImage","id","url","hasBackgroundSupport","blockName","feature","OS","support","resetBackgroundImage","setAttributes","undefined","InspectorImagePreview","label","filename","imgUrl","imgLabel","createElement","as","justify","className","numberOfLines","BackgroundImagePanelItem","clientId","title","replaceContainerRef","mediaUpload","select","getSettings","createErrorNotice","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","media_type","source","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","previousValue","onDeselect","isShownByDefault","panelId","ref","mediaId","mediaURL","accept","onSelect","name","variant","onClick","toggleButton","tabbable","find","current","click","BackgroundImagePanel","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 { focus } from '@wordpress/dom';\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, useRef } 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 { useSettings } from '../components/use-settings';\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 replaceContainerRef = useRef();\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\tconst hasValue = hasBackgroundImageValue( props );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasValue }\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\n\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-container\"\n\t\t\t\tref={ replaceContainerRef }\n\t\t\t>\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{ hasValue && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst [ toggleButton ] = focus.tabbable.find(\n\t\t\t\t\t\t\t\t\treplaceContainerRef.current\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t// Focus the toggle button and close the dropdown menu.\n\t\t\t\t\t\t\t\t// This ensures similar behaviour as to selecting an image, where the dropdown is\n\t\t\t\t\t\t\t\t// closed and focus is redirected to the dropdown toggle button.\n\t\t\t\t\t\t\t\ttoggleButton?.focus();\n\t\t\t\t\t\t\t\ttoggleButton?.click();\n\t\t\t\t\t\t\t\tresetBackgroundImage( props );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset ' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\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 [ backgroundImage ] = useSettings( 'background.backgroundImage' );\n\tif (\n\t\t! backgroundImage ||\n\t\t! hasBackgroundSupport( props.name, 'backgroundImage' )\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t<BackgroundImagePanelItem { ...props } />\n\t\t</InspectorControls>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,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;MACA;MACAH,YAAY,EAAE7F,KAAK,CAAC,CAAC;MACrB6F,YAAY,EAAEI,KAAK,CAAC,CAAC;MACrBrD,oBAAoB,CAAEb,KAAM,CAAC;IAC9B;EAAG,GAEDb,EAAE,CAAE,QAAS,CACN,CAEM,CAAC,EACnBkC,aAAA,CAACjD,QAAQ;IACRuE,WAAW,EAAGA,WAAa;IAC3B1B,KAAK,EAAG9B,EAAE,CAAE,gBAAiB;EAAG,CAChC,CACG,CACU,CAAC;AAEnB;AAEA,OAAO,SAASgF,oBAAoBA,CAAEnE,KAAK,EAAG;EAC7C,MAAM,CAAEK,eAAe,CAAE,GAAGX,WAAW,CAAE,4BAA6B,CAAC;EACvE,IACC,CAAEW,eAAe,IACjB,CAAEG,oBAAoB,CAAER,KAAK,CAAC2D,IAAI,EAAE,iBAAkB,CAAC,EACtD;IACD,OAAO,IAAI;EACZ;EAEA,OACCtC,aAAA,CAAC7B,iBAAiB;IAAC4E,KAAK,EAAC;EAAY,GACpC/C,aAAA,CAACK,wBAAwB;IAAA,GAAM1B;EAAK,CAAI,CACtB,CAAC;AAEtB"}
|
|
1
|
+
{"version":3,"names":["classnames","isBlobURL","getBlockSupport","focus","__experimentalToolsPanelItem","ToolsPanelItem","DropZone","FlexItem","MenuItem","VisuallyHidden","__experimentalItemGroup","ItemGroup","__experimentalHStack","HStack","__experimentalTruncate","Truncate","useDispatch","useSelect","Platform","useCallback","useRef","__","sprintf","store","noticesStore","getFilename","pure","InspectorControls","MediaReplaceFlow","useSettings","cleanEmptyObject","blockEditorStore","BACKGROUND_SUPPORT_KEY","IMAGE_BACKGROUND_TYPE","hasBackgroundImageValue","style","hasValue","background","backgroundImage","id","url","hasBackgroundSupport","blockName","feature","OS","support","resetBackgroundImage","setAttributes","undefined","InspectorImagePreview","label","filename","imgUrl","imgLabel","createElement","as","justify","className","numberOfLines","BackgroundImagePanelItem","clientId","select","getBlockAttributes","title","replaceContainerRef","mediaUpload","getSettings","createErrorNotice","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","media_type","source","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","previousValue","onDeselect","isShownByDefault","panelId","ref","mediaId","mediaURL","accept","onSelect","name","variant","onClick","toggleButton","tabbable","find","current","click","BackgroundImagePanelPure","props","group","BackgroundImagePanel"],"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 { focus } from '@wordpress/dom';\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, useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { getFilename } from '@wordpress/url';\nimport { pure } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport MediaReplaceFlow from '../components/media-replace-flow';\nimport { useSettings } from '../components/use-settings';\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} style Style attribute.\n * @return {boolean} Whether or not the block has a background image value set.\n */\nexport function hasBackgroundImageValue( style ) {\n\tconst hasValue =\n\t\t!! style?.background?.backgroundImage?.id ||\n\t\t!! 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} style Style attribute.\n * @param {Function} setAttributes Function to set block's attributes.\n */\nexport function resetBackgroundImage( style = {}, setAttributes ) {\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( { clientId, setAttributes } ) {\n\tconst style = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId )?.style,\n\t\t[ clientId ]\n\t);\n\tconst { id, title, url } = style?.background?.backgroundImage || {};\n\n\tconst replaceContainerRef = useRef();\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...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...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...style,\n\t\t\tbackground: {\n\t\t\t\t...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\tconst hasValue = hasBackgroundImageValue( style );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasValue }\n\t\t\tlabel={ __( 'Background image' ) }\n\t\t\tonDeselect={ () => resetBackgroundImage( style, setAttributes ) }\n\t\t\tisShownByDefault={ true }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-hooks__background__inspector-media-replace-container\"\n\t\t\t\tref={ replaceContainerRef }\n\t\t\t>\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{ hasValue && (\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tconst [ toggleButton ] = focus.tabbable.find(\n\t\t\t\t\t\t\t\t\treplaceContainerRef.current\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t// Focus the toggle button and close the dropdown menu.\n\t\t\t\t\t\t\t\t// This ensures similar behaviour as to selecting an image, where the dropdown is\n\t\t\t\t\t\t\t\t// closed and focus is redirected to the dropdown toggle button.\n\t\t\t\t\t\t\t\ttoggleButton?.focus();\n\t\t\t\t\t\t\t\ttoggleButton?.click();\n\t\t\t\t\t\t\t\tresetBackgroundImage( style, setAttributes );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Reset ' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t) }\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\nfunction BackgroundImagePanelPure( props ) {\n\tconst [ backgroundImage ] = useSettings( 'background.backgroundImage' );\n\tif (\n\t\t! backgroundImage ||\n\t\t! hasBackgroundSupport( props.name, 'backgroundImage' )\n\t) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t<BackgroundImagePanelItem { ...props } />\n\t\t</InspectorControls>\n\t);\n}\n\n// We don't want block controls to re-render when typing inside a block. `pure`\n// will prevent re-renders unless props change, so only pass the needed props\n// and not the whole attributes object.\nexport const BackgroundImagePanel = pure( BackgroundImagePanelPure );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SACCC,4BAA4B,IAAIC,cAAc,EAC9CC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,uBAAuB,IAAIC,SAAS,EACpCC,oBAAoB,IAAIC,MAAM,EAC9BC,sBAAsB,IAAIC,QAAQ,QAC5B,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,QAAQ,EAAEC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AAClE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,IAAI,QAAQ,oBAAoB;;AAEzC;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,kCAAkC;AAChE,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASP,KAAK,IAAIQ,gBAAgB,QAAQ,UAAU;AAEp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BAAyB,CAAC"}
|
|
@@ -3,10 +3,8 @@ import { createElement } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { addFilter } from '@wordpress/hooks';
|
|
7
6
|
import { Fragment, useMemo } from '@wordpress/element';
|
|
8
7
|
import { __experimentalHStack as HStack, PanelBody, ToggleControl } from '@wordpress/components';
|
|
9
|
-
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
10
8
|
import { createBlock, store as blocksStore } from '@wordpress/blocks';
|
|
11
9
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
10
|
|
|
@@ -16,11 +14,14 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
16
14
|
import { BlockIcon, InspectorControls } from '../components';
|
|
17
15
|
import { store as blockEditorStore } from '../store';
|
|
18
16
|
const EMPTY_OBJECT = {};
|
|
19
|
-
function
|
|
17
|
+
function BlockHooksControlPure({
|
|
18
|
+
name,
|
|
19
|
+
clientId
|
|
20
|
+
}) {
|
|
20
21
|
const blockTypes = useSelect(select => select(blocksStore).getBlockTypes(), []);
|
|
21
22
|
const hookedBlocksForCurrentBlock = useMemo(() => blockTypes?.filter(({
|
|
22
23
|
blockHooks
|
|
23
|
-
}) => blockHooks &&
|
|
24
|
+
}) => blockHooks && name in blockHooks), [blockTypes, name]);
|
|
24
25
|
const {
|
|
25
26
|
blockIndex,
|
|
26
27
|
rootClientId,
|
|
@@ -32,11 +33,11 @@ function BlockHooksControl(props) {
|
|
|
32
33
|
getBlockRootClientId
|
|
33
34
|
} = select(blockEditorStore);
|
|
34
35
|
return {
|
|
35
|
-
blockIndex: getBlockIndex(
|
|
36
|
-
innerBlocksLength: getBlock(
|
|
37
|
-
rootClientId: getBlockRootClientId(
|
|
36
|
+
blockIndex: getBlockIndex(clientId),
|
|
37
|
+
innerBlocksLength: getBlock(clientId)?.innerBlocks?.length,
|
|
38
|
+
rootClientId: getBlockRootClientId(clientId)
|
|
38
39
|
};
|
|
39
|
-
}, [
|
|
40
|
+
}, [clientId]);
|
|
40
41
|
const hookedBlockClientIds = useSelect(select => {
|
|
41
42
|
const {
|
|
42
43
|
getBlock,
|
|
@@ -49,7 +50,7 @@ function BlockHooksControl(props) {
|
|
|
49
50
|
if (getGlobalBlockCount(block.name) === 0) {
|
|
50
51
|
return clientIds;
|
|
51
52
|
}
|
|
52
|
-
const relativePosition = block?.blockHooks?.[
|
|
53
|
+
const relativePosition = block?.blockHooks?.[name];
|
|
53
54
|
let candidates;
|
|
54
55
|
switch (relativePosition) {
|
|
55
56
|
case 'before':
|
|
@@ -64,12 +65,10 @@ function BlockHooksControl(props) {
|
|
|
64
65
|
// Any of the current block's child blocks (with the right block type) qualifies
|
|
65
66
|
// as a hooked first or last child block, as the block might've been automatically
|
|
66
67
|
// inserted and then moved around a bit by the user.
|
|
67
|
-
candidates = getBlock(
|
|
68
|
+
candidates = getBlock(clientId).innerBlocks;
|
|
68
69
|
break;
|
|
69
70
|
}
|
|
70
|
-
const hookedBlock = candidates?.find(
|
|
71
|
-
name
|
|
72
|
-
}) => name === block.name);
|
|
71
|
+
const hookedBlock = candidates?.find(candidate => name === candidate.name);
|
|
73
72
|
|
|
74
73
|
// If the block exists in the designated location, we consider it hooked
|
|
75
74
|
// and show the toggle as enabled.
|
|
@@ -93,7 +92,7 @@ function BlockHooksControl(props) {
|
|
|
93
92
|
return _hookedBlockClientIds;
|
|
94
93
|
}
|
|
95
94
|
return EMPTY_OBJECT;
|
|
96
|
-
}, [hookedBlocksForCurrentBlock,
|
|
95
|
+
}, [hookedBlocksForCurrentBlock, name, clientId, rootClientId]);
|
|
97
96
|
const {
|
|
98
97
|
insertBlock,
|
|
99
98
|
removeBlock
|
|
@@ -126,7 +125,7 @@ function BlockHooksControl(props) {
|
|
|
126
125
|
case 'last_child':
|
|
127
126
|
insertBlock(block,
|
|
128
127
|
// TODO: It'd be great if insertBlock() would accept negative indices for insertion.
|
|
129
|
-
relativePosition === 'first_child' ? 0 : innerBlocksLength,
|
|
128
|
+
relativePosition === 'first_child' ? 0 : innerBlocksLength, clientId,
|
|
130
129
|
// Insert as a child of the current block.
|
|
131
130
|
false);
|
|
132
131
|
break;
|
|
@@ -152,29 +151,22 @@ function BlockHooksControl(props) {
|
|
|
152
151
|
onChange: () => {
|
|
153
152
|
if (!checked) {
|
|
154
153
|
// Create and insert block.
|
|
155
|
-
const relativePosition = block.blockHooks[
|
|
154
|
+
const relativePosition = block.blockHooks[name];
|
|
156
155
|
insertBlockIntoDesignatedLocation(createBlock(block.name), relativePosition);
|
|
157
156
|
return;
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
// Remove block.
|
|
161
|
-
|
|
162
|
-
removeBlock(clientId, false);
|
|
160
|
+
removeBlock(hookedBlockClientIds[block.name], false);
|
|
163
161
|
}
|
|
164
162
|
});
|
|
165
163
|
}));
|
|
166
164
|
})));
|
|
167
165
|
}
|
|
168
|
-
export
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
blockName: props.name,
|
|
175
|
-
clientId: props.clientId
|
|
176
|
-
}));
|
|
177
|
-
};
|
|
178
|
-
}, 'withBlockHooksControls');
|
|
179
|
-
addFilter('editor.BlockEdit', 'core/editor/block-hooks/with-inspector-controls', withBlockHooksControls);
|
|
166
|
+
export default {
|
|
167
|
+
edit: BlockHooksControlPure,
|
|
168
|
+
hasSupport() {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
180
172
|
//# sourceMappingURL=block-hooks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","addFilter","Fragment","useMemo","__experimentalHStack","HStack","PanelBody","ToggleControl","createHigherOrderComponent","createBlock","store","blocksStore","useDispatch","useSelect","BlockIcon","InspectorControls","blockEditorStore","EMPTY_OBJECT","BlockHooksControl","props","blockTypes","select","getBlockTypes","hookedBlocksForCurrentBlock","filter","blockHooks","blockName","blockIndex","rootClientId","innerBlocksLength","getBlock","getBlockIndex","getBlockRootClientId","clientId","innerBlocks","length","hookedBlockClientIds","getGlobalBlockCount","_hookedBlockClientIds","reduce","clientIds","block","name","relativePosition","candidates","hookedBlock","find","Object","values","insertBlock","removeBlock","hookedBlocksForCurrentBlockIfNotPresentElsewhere","groupedHookedBlocks","groups","namespace","split","push","insertBlockIntoDesignatedLocation","createElement","className","title","initialOpen","keys","map","vendor","key","checked","label","justify","icon","onChange","withBlockHooksControls","BlockEdit","isSelected"],"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 withBlockHooksControls = createHigherOrderComponent(\n\t( BlockEdit ) => {\n\t\treturn ( props ) => {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t\t{ props.isSelected && (\n\t\t\t\t\t\t<BlockHooksControl\n\t\t\t\t\t\t\tblockName={ props.name }\n\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t);\n\t\t};\n\t},\n\t'withBlockHooksControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/block-hooks/with-inspector-controls',\n\twithBlockHooksControls\n);\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SACCC,oBAAoB,IAAIC,MAAM,EAC9BC,SAAS,EACTC,aAAa,QACP,uBAAuB;AAC9B,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,WAAW,EAAEC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACrE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,eAAe;AAC5D,SAASL,KAAK,IAAIM,gBAAgB,QAAQ,UAAU;AAEpD,MAAMC,YAAY,GAAG,CAAC,CAAC;AAEvB,SAASC,iBAAiBA,CAAEC,KAAK,EAAG;EACnC,MAAMC,UAAU,GAAGP,SAAS,CACzBQ,MAAM,IAAMA,MAAM,CAAEV,WAAY,CAAC,CAACW,aAAa,CAAC,CAAC,EACnD,EACD,CAAC;EAED,MAAMC,2BAA2B,GAAGpB,OAAO,CAC1C,MACCiB,UAAU,EAAEI,MAAM,CACjB,CAAE;IAAEC;EAAW,CAAC,KACfA,UAAU,IAAIN,KAAK,CAACO,SAAS,IAAID,UACnC,CAAC,EACF,CAAEL,UAAU,EAAED,KAAK,CAACO,SAAS,CAC9B,CAAC;EAED,MAAM;IAAEC,UAAU;IAA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,CAAA,KAAM;UAChB,IAAK,CAAEJ,OAAO,EAAG;YAChB;YACA,MAAMvB,gBAAgB,GACrBF,KAAK,CAAChB,UAAU,CACfN,KAAK,CAACO,SAAS,CACf;YACF+B,iCAAiC,CAChChD,WAAW,CAAEgC,KAAK,CAACC,IAAK,CAAC,EACzBC,gBACD,CAAC;YACD;UACD;;UAEA;UACA,MAAMV,QAAQ,GACbG,oBAAoB,CACnBK,KAAK,CAACC,IAAI,CACV;UACFQ,WAAW,CAAEjB,QAAQ,EAAE,KAAM,CAAC;QAC/B;MAAG,CACH,CAAC;IAEJ,CAAE,CACO,CAAC;EAEb,CAAE,CACQ,CACO,CAAC;AAEtB;AAEA,OAAO,MAAMsC,sBAAsB,GAAG/D,0BAA0B,CAC7DgE,SAAS,IAAM;EAChB,OAASrD,KAAK,IAAM;IACnB,OACCuC,aAAA,CAAAxD,QAAA,QACCwD,aAAA,CAACc,SAAS;MAACP,GAAG,EAAC,MAAM;MAAA,GAAM9C;IAAK,CAAI,CAAC,EACnCA,KAAK,CAACsD,UAAU,IACjBf,aAAA,CAACxC,iBAAiB;MACjBQ,SAAS,EAAGP,KAAK,CAACuB,IAAM;MACxBT,QAAQ,EAAGd,KAAK,CAACc;IAAU,CAC3B,CAED,CAAC;EAEL,CAAC;AACF,CAAC,EACD,wBACD,CAAC;AAEDhC,SAAS,CACR,kBAAkB,EAClB,iDAAiD,EACjDsE,sBACD,CAAC"}
|
|
1
|
+
{"version":3,"names":["__","Fragment","useMemo","__experimentalHStack","HStack","PanelBody","ToggleControl","createBlock","store","blocksStore","useDispatch","useSelect","BlockIcon","InspectorControls","blockEditorStore","EMPTY_OBJECT","BlockHooksControlPure","name","clientId","blockTypes","select","getBlockTypes","hookedBlocksForCurrentBlock","filter","blockHooks","blockIndex","rootClientId","innerBlocksLength","getBlock","getBlockIndex","getBlockRootClientId","innerBlocks","length","hookedBlockClientIds","getGlobalBlockCount","_hookedBlockClientIds","reduce","clientIds","block","relativePosition","candidates","hookedBlock","find","candidate","Object","values","insertBlock","removeBlock","hookedBlocksForCurrentBlockIfNotPresentElsewhere","groupedHookedBlocks","groups","namespace","split","push","insertBlockIntoDesignatedLocation","createElement","className","title","initialOpen","keys","map","vendor","key","checked","label","justify","icon","onChange","edit","hasSupport"],"sources":["@wordpress/block-editor/src/hooks/block-hooks.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Fragment, useMemo } from '@wordpress/element';\nimport {\n\t__experimentalHStack as HStack,\n\tPanelBody,\n\tToggleControl,\n} from '@wordpress/components';\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 BlockHooksControlPure( { name, clientId } ) {\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 } ) => blockHooks && name in blockHooks\n\t\t\t),\n\t\t[ blockTypes, name ]\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( clientId ),\n\t\t\t\tinnerBlocksLength: getBlock( clientId )?.innerBlocks?.length,\n\t\t\t\trootClientId: getBlockRootClientId( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ 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 = block?.blockHooks?.[ name ];\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( 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( candidate ) => name === candidate.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[ hookedBlocksForCurrentBlock, name, clientId, rootClientId ]\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\tclientId, // 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[ name ];\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\tremoveBlock(\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\t\tfalse\n\t\t\t\t\t\t\t\t\t\t\t);\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 default {\n\tedit: BlockHooksControlPure,\n\thasSupport() {\n\t\treturn true;\n\t},\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SACCC,oBAAoB,IAAIC,MAAM,EAC9BC,SAAS,EACTC,aAAa,QACP,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACrE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;;AAExD;AACA;AACA;AACA,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,eAAe;AAC5D,SAASL,KAAK,IAAIM,gBAAgB,QAAQ,UAAU;AAEpD,MAAMC,YAAY,GAAG,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