@wordpress/block-editor 12.20.0 → 12.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/block-actions/index.js +47 -36
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-bindings-toolbar-indicator/index.js +25 -0
- package/build/components/block-bindings-toolbar-indicator/index.js.map +1 -0
- package/build/components/block-edit/context.js +2 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +8 -3
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.js +5 -5
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build/components/block-inspector/index.js +5 -4
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-crash-boundary.native.js +49 -0
- package/build/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build/components/block-list/block-crash-warning.native.js +24 -0
- package/build/components/block-list/block-crash-warning.native.js.map +1 -0
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +1 -1
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +23 -7
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block-selection-button.native.js.map +1 -1
- package/build/components/block-list/block.native.js +7 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +8 -1
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -3
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-popover/cover.js +68 -0
- package/build/components/block-popover/cover.js.map +1 -0
- package/build/components/block-popover/drop-zone.js +2 -3
- package/build/components/block-popover/drop-zone.js.map +1 -1
- package/build/components/block-popover/index.js +1 -19
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +2 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -4
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-settings/container.native.js +2 -1
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +41 -39
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -3
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/block-toolbar/index.js +24 -11
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +89 -0
- package/build/components/block-toolbar/shuffle.js.map +1 -0
- package/build/components/block-toolbar/use-has-block-toolbar.js +43 -0
- package/build/components/block-toolbar/use-has-block-toolbar.js.map +1 -0
- package/build/components/block-tools/block-selection-button.js +5 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/empty-block-inserter.js +2 -5
- package/build/components/block-tools/empty-block-inserter.js.map +1 -1
- package/build/components/block-tools/index.js +9 -26
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +60 -0
- package/build/components/block-tools/use-show-block-tools.js.map +1 -0
- package/build/components/caption/index.native.js.map +1 -1
- package/build/components/child-layout-control/index.js +108 -11
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/color-palette/control.js.map +1 -1
- package/build/components/colors-gradients/control.js +1 -1
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +11 -0
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/global-styles/border-panel.js +21 -8
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +1 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +8 -33
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/index.js +6 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +80 -23
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +7 -5
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +16 -16
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -4
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid-visualizer/grid-item-resizer.js +77 -0
- package/build/components/grid-visualizer/grid-item-resizer.js.map +1 -0
- package/build/components/grid-visualizer/grid-visualizer.js +81 -0
- package/build/components/grid-visualizer/grid-visualizer.js.map +1 -0
- package/build/components/grid-visualizer/index.js +20 -0
- package/build/components/grid-visualizer/index.js.map +1 -0
- package/build/components/grid-visualizer/utils.js +10 -0
- package/build/components/grid-visualizer/utils.js.map +1 -0
- package/build/components/iframe/index.js +66 -17
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.native.js +7 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +8 -2
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/index.js +3 -6
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +2 -2
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js +36 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- package/build/components/inspector-controls-tabs/index.js +1 -1
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/link-control/link-preview.js +4 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-select-button.js +0 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +4 -11
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-clipboard-handler.js +2 -1
- package/build/components/list-view/use-clipboard-handler.js.map +1 -1
- package/build/components/list-view/utils.js +5 -3
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/panel-color-settings/index.js.map +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +3 -5
- package/build/components/resizable-box-popover/index.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -1
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/index.js +46 -26
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-enter.js +3 -0
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
- package/build/components/url-popover/index.js +3 -3
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +4 -0
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/warning/index.native.js +9 -4
- package/build/components/warning/index.native.js.map +1 -1
- package/build/components/writing-flow/use-clipboard-handler.js +2 -1
- package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build/components/writing-flow/utils.js +23 -6
- package/build/components/writing-flow/utils.js.map +1 -1
- package/build/hooks/anchor.js +7 -8
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +39 -2
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +34 -8
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/border.js +6 -4
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +3 -4
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-size.js +6 -7
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +3 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +67 -6
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/layout.js +32 -14
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/position.js +1 -1
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/spacing-visualizer.js +115 -0
- package/build/hooks/spacing-visualizer.js.map +1 -0
- package/build/hooks/use-bindings-attributes.js +171 -48
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-typography-props.js +1 -2
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/layouts/grid.js +6 -2
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +7 -3
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +3 -1
- package/build/private-apis.native.js.map +1 -1
- package/build/store/actions.js +42 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +29 -55
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +0 -8
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +34 -46
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +27 -15
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-actions/index.js +47 -36
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-bindings-toolbar-indicator/index.js +18 -0
- package/build-module/components/block-bindings-toolbar-indicator/index.js.map +1 -0
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +9 -4
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +5 -5
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -5
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-crash-boundary.native.js +42 -0
- package/build-module/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build-module/components/block-list/block-crash-warning.native.js +15 -0
- package/build-module/components/block-list/block-crash-warning.native.js.map +1 -0
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +1 -1
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +23 -7
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block-selection-button.native.js.map +1 -1
- package/build-module/components/block-list/block.native.js +7 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +9 -2
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -3
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-popover/cover.js +60 -0
- package/build-module/components/block-popover/cover.js.map +1 -0
- package/build-module/components/block-popover/drop-zone.js +2 -3
- package/build-module/components/block-popover/drop-zone.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -19
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +2 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -5
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +3 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +42 -40
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -3
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +24 -12
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +82 -0
- package/build-module/components/block-toolbar/shuffle.js.map +1 -0
- package/build-module/components/block-toolbar/use-has-block-toolbar.js +36 -0
- package/build-module/components/block-toolbar/use-has-block-toolbar.js.map +1 -0
- package/build-module/components/block-tools/block-selection-button.js +5 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/empty-block-inserter.js +2 -5
- package/build-module/components/block-tools/empty-block-inserter.js.map +1 -1
- package/build-module/components/block-tools/index.js +9 -26
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +54 -0
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -0
- package/build-module/components/caption/index.native.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +109 -12
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/color-palette/control.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +1 -1
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +12 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +22 -10
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +1 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +9 -34
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +82 -24
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +7 -5
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +17 -17
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -4
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid-visualizer/grid-item-resizer.js +69 -0
- package/build-module/components/grid-visualizer/grid-item-resizer.js.map +1 -0
- package/build-module/components/grid-visualizer/grid-visualizer.js +73 -0
- package/build-module/components/grid-visualizer/grid-visualizer.js.map +1 -0
- package/build-module/components/grid-visualizer/index.js +3 -0
- package/build-module/components/grid-visualizer/index.js.map +1 -0
- package/build-module/components/grid-visualizer/utils.js +4 -0
- package/build-module/components/grid-visualizer/utils.js.map +1 -0
- package/build-module/components/iframe/index.js +66 -17
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +8 -2
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/index.js +3 -6
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +2 -2
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js +28 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/index.js +1 -1
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +5 -2
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +0 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +6 -13
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-clipboard-handler.js +3 -2
- package/build-module/components/list-view/use-clipboard-handler.js.map +1 -1
- package/build-module/components/list-view/utils.js +2 -1
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/panel-color-settings/index.js.map +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +3 -5
- package/build-module/components/resizable-box-popover/index.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -1
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +47 -28
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +3 -0
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
- package/build-module/components/url-popover/index.js +3 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +4 -0
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/warning/index.native.js +9 -4
- package/build-module/components/warning/index.native.js.map +1 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js +3 -2
- package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build-module/components/writing-flow/utils.js +22 -7
- package/build-module/components/writing-flow/utils.js.map +1 -1
- package/build-module/hooks/anchor.js +8 -9
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +38 -1
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +34 -8
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/border.js +7 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +1 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-size.js +7 -8
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +3 -2
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +67 -6
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/layout.js +32 -14
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/position.js +1 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/spacing-visualizer.js +106 -0
- package/build-module/hooks/spacing-visualizer.js.map +1 -0
- package/build-module/hooks/use-bindings-attributes.js +172 -49
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +2 -3
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/layouts/grid.js +6 -2
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +7 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +3 -1
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/actions.js +42 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +29 -54
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +0 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +34 -46
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +23 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +22 -2
- package/build-style/content.css +22 -2
- package/build-style/default-editor-styles-rtl.css +1 -0
- package/build-style/default-editor-styles.css +1 -0
- package/build-style/style-rtl.css +106 -27
- package/build-style/style.css +106 -27
- package/package.json +31 -31
- package/src/components/block-actions/index.js +59 -55
- package/src/components/block-bindings-toolbar-indicator/index.js +20 -0
- package/src/components/block-bindings-toolbar-indicator/style.scss +16 -0
- package/src/components/block-draggable/test/index.native.js +2 -2
- package/src/components/block-edit/context.js +1 -0
- package/src/components/block-edit/index.js +5 -1
- package/src/components/block-heading-level-dropdown/README.md +5 -5
- package/src/components/block-heading-level-dropdown/index.js +5 -5
- package/src/components/block-heading-level-dropdown/index.native.js +5 -4
- package/src/components/block-inspector/index.js +7 -5
- package/src/components/block-list/block-crash-boundary.native.js +43 -0
- package/src/components/block-list/block-crash-warning.native.js +19 -0
- package/src/components/block-list/block-invalid-warning.native.js +1 -1
- package/src/components/block-list/block-list-item.native.js +1 -1
- package/src/components/block-list/block-outline.native.js +36 -21
- package/src/components/block-list/block-selection-button.native.js +1 -3
- package/src/components/block-list/block.native.js +14 -10
- package/src/components/block-list/content.scss +21 -1
- package/src/components/block-list/test/block-outline.native.js +255 -0
- package/src/components/block-list/use-block-props/index.js +12 -2
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +3 -7
- package/src/components/block-mover/index.native.js +1 -1
- package/src/components/block-popover/cover.js +63 -0
- package/src/components/block-popover/drop-zone.js +3 -4
- package/src/components/block-popover/index.js +1 -28
- package/src/components/block-preview/index.js +3 -1
- package/src/components/block-removal-warning-modal/index.js +5 -19
- package/src/components/block-rename/modal.js +1 -1
- package/src/components/block-settings/container.native.js +5 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +53 -65
- package/src/components/block-settings-menu-controls/README.md +0 -9
- package/src/components/block-settings-menu-controls/index.js +1 -6
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -1
- package/src/components/block-toolbar/block-toolbar-menu.native.js +2 -2
- package/src/components/block-toolbar/index.js +22 -16
- package/src/components/block-toolbar/shuffle.js +93 -0
- package/src/components/block-toolbar/test/index.native.js +1 -7
- package/src/components/block-toolbar/use-has-block-toolbar.js +49 -0
- package/src/components/block-tools/block-selection-button.js +4 -0
- package/src/components/block-tools/empty-block-inserter.js +3 -6
- package/src/components/block-tools/index.js +13 -36
- package/src/components/block-tools/use-show-block-tools.js +73 -0
- package/src/components/caption/index.native.js +1 -1
- package/src/components/child-layout-control/index.js +148 -36
- package/src/components/color-palette/control.js +1 -1
- package/src/components/colors-gradients/control.js +1 -1
- package/src/components/colors-gradients/test/control.js +2 -2
- package/src/components/contrast-checker/test/index.js +10 -10
- package/src/components/convert-to-group-buttons/toolbar.js +13 -1
- package/src/components/default-block-appender/content.scss +5 -2
- package/src/components/global-styles/border-panel.js +35 -24
- package/src/components/global-styles/color-panel.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +9 -34
- package/src/components/global-styles/image-settings-panel.js +1 -1
- package/src/components/global-styles/index.js +5 -1
- package/src/components/global-styles/shadow-panel-components.js +92 -23
- package/src/components/global-styles/style.scss +33 -10
- package/src/components/global-styles/test/typography-utils.js +231 -81
- package/src/components/global-styles/test/use-global-styles-output.js +31 -0
- package/src/components/global-styles/typography-utils.js +10 -7
- package/src/components/global-styles/use-global-styles-output.js +17 -17
- package/src/components/global-styles/utils.js +2 -26
- package/src/components/grid-visualizer/grid-item-resizer.js +100 -0
- package/src/components/grid-visualizer/grid-visualizer.js +81 -0
- package/src/components/grid-visualizer/index.js +2 -0
- package/src/components/grid-visualizer/style.scss +33 -0
- package/src/components/grid-visualizer/utils.js +5 -0
- package/src/components/iframe/index.js +89 -26
- package/src/components/index.native.js +1 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +12 -2
- package/src/components/inserter/block-patterns-explorer/index.js +2 -9
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -1
- package/src/components/inserter/media-tab/media-preview.js +1 -1
- package/src/components/inserter/menu.native.js +3 -3
- package/src/components/inserter/mobile-tab-navigation.js +2 -2
- package/src/components/inserter/style.scss +10 -0
- package/src/components/inspector-controls/block-support-tools-panel.js +2 -2
- package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +31 -0
- package/src/components/inspector-controls-tabs/index.js +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +2 -2
- package/src/components/line-height-control/test/index.js +1 -1
- package/src/components/link-control/link-preview.js +9 -2
- package/src/components/link-control/search-input.js +1 -1
- package/src/components/link-control/style.scss +9 -5
- package/src/components/list-view/block-select-button.js +0 -2
- package/src/components/list-view/block.js +12 -21
- package/src/components/list-view/branch.js +1 -1
- package/src/components/list-view/drop-indicator.js +1 -1
- package/src/components/list-view/index.js +1 -1
- package/src/components/list-view/style.scss +34 -16
- package/src/components/list-view/use-clipboard-handler.js +3 -2
- package/src/components/list-view/utils.js +4 -1
- package/src/components/panel-color-settings/index.js +1 -1
- package/src/components/panel-color-settings/test/index.js +3 -3
- package/src/components/provider/index.js +1 -4
- package/src/components/resizable-box-popover/index.js +4 -6
- package/src/components/responsive-block-control/README.md +4 -4
- package/src/components/responsive-block-control/index.js +1 -1
- package/src/components/responsive-block-control/test/index.js +5 -5
- package/src/components/rich-text/README.md +6 -0
- package/src/components/rich-text/index.js +76 -53
- package/src/components/rich-text/use-enter.js +4 -0
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +4 -4
- package/src/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/src/components/url-popover/index.js +5 -5
- package/src/components/url-popover/style.scss +1 -0
- package/src/components/use-moving-animation/index.js +1 -0
- package/src/components/warning/index.native.js +19 -15
- package/src/components/writing-flow/use-clipboard-handler.js +3 -2
- package/src/components/writing-flow/utils.js +31 -16
- package/src/hooks/anchor.js +41 -61
- package/src/hooks/background.js +49 -4
- package/src/hooks/block-hooks.js +47 -9
- package/src/hooks/block-hooks.scss +6 -0
- package/src/hooks/border.js +16 -4
- package/src/hooks/dimensions.js +1 -2
- package/src/hooks/font-size.js +7 -12
- package/src/hooks/index.js +3 -0
- package/src/hooks/layout-child.js +82 -8
- package/src/hooks/layout.js +34 -19
- package/src/hooks/line-height.js +1 -1
- package/src/hooks/position.js +1 -1
- package/src/hooks/spacing-visualizer.js +126 -0
- package/src/hooks/{padding.scss → spacing.scss} +1 -1
- package/src/hooks/test/__snapshots__/anchor.native.js.snap +7 -0
- package/src/hooks/test/anchor.native.js +32 -0
- package/src/hooks/use-bindings-attributes.js +215 -65
- package/src/hooks/use-typography-props.js +2 -8
- package/src/layouts/grid.js +8 -3
- package/src/private-apis.js +6 -2
- package/src/private-apis.native.js +2 -0
- package/src/store/actions.js +56 -18
- package/src/store/private-actions.js +34 -79
- package/src/store/private-selectors.js +0 -8
- package/src/store/reducer.js +43 -64
- package/src/store/selectors.js +41 -46
- package/src/store/test/actions.js +0 -4
- package/src/style.scss +3 -1
- package/tsconfig.json +1 -0
- package/build/hooks/margin.js +0 -86
- package/build/hooks/margin.js.map +0 -1
- package/build/hooks/padding.js +0 -78
- package/build/hooks/padding.js.map +0 -1
- package/build/utils/use-can-block-toolbar-be-focused.js +0 -46
- package/build/utils/use-can-block-toolbar-be-focused.js.map +0 -1
- package/build-module/hooks/margin.js +0 -78
- package/build-module/hooks/margin.js.map +0 -1
- package/build-module/hooks/padding.js +0 -70
- package/build-module/hooks/padding.js.map +0 -1
- package/build-module/utils/use-can-block-toolbar-be-focused.js +0 -40
- package/build-module/utils/use-can-block-toolbar-be-focused.js.map +0 -1
- package/src/hooks/margin.js +0 -91
- package/src/hooks/padding.js +0 -82
- package/src/utils/use-can-block-toolbar-be-focused.js +0 -48
|
@@ -16,20 +16,25 @@ import { normalizeIconObject } from '@wordpress/blocks';
|
|
|
16
16
|
*/
|
|
17
17
|
import styles from './style.scss';
|
|
18
18
|
function Warning({
|
|
19
|
+
actions,
|
|
19
20
|
title,
|
|
20
21
|
message,
|
|
21
22
|
icon,
|
|
22
23
|
iconClass,
|
|
23
24
|
preferredColorScheme,
|
|
24
25
|
getStylesFromColorScheme,
|
|
26
|
+
containerStyle: extraContainerStyle,
|
|
27
|
+
titleStyle: extraTitleStyle,
|
|
28
|
+
messageStyle: extraMessageStyle,
|
|
25
29
|
...viewProps
|
|
26
30
|
}) {
|
|
27
31
|
icon = icon && normalizeIconObject(icon);
|
|
28
32
|
const internalIconClass = 'warning-icon' + '-' + preferredColorScheme;
|
|
29
|
-
const
|
|
30
|
-
const
|
|
33
|
+
const containerStyle = [getStylesFromColorScheme(styles.container, styles.containerDark), extraContainerStyle];
|
|
34
|
+
const titleStyle = [getStylesFromColorScheme(styles.title, styles.titleDark), extraTitleStyle];
|
|
35
|
+
const messageStyle = [getStylesFromColorScheme(styles.message, styles.messageDark), extraMessageStyle];
|
|
31
36
|
return createElement(View, {
|
|
32
|
-
style:
|
|
37
|
+
style: containerStyle,
|
|
33
38
|
...viewProps
|
|
34
39
|
}, icon && createElement(View, {
|
|
35
40
|
style: styles.icon
|
|
@@ -40,7 +45,7 @@ function Warning({
|
|
|
40
45
|
style: titleStyle
|
|
41
46
|
}, title), message && createElement(Text, {
|
|
42
47
|
style: messageStyle
|
|
43
|
-
}, message));
|
|
48
|
+
}, message), actions);
|
|
44
49
|
}
|
|
45
50
|
export default withPreferredColorScheme(Warning);
|
|
46
51
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","Text","Icon","withPreferredColorScheme","normalizeIconObject","styles","Warning","title","message","icon","iconClass","preferredColorScheme","getStylesFromColorScheme","
|
|
1
|
+
{"version":3,"names":["View","Text","Icon","withPreferredColorScheme","normalizeIconObject","styles","Warning","actions","title","message","icon","iconClass","preferredColorScheme","getStylesFromColorScheme","containerStyle","extraContainerStyle","titleStyle","extraTitleStyle","messageStyle","extraMessageStyle","viewProps","internalIconClass","container","containerDark","titleDark","messageDark","createElement","style","className","src"],"sources":["@wordpress/block-editor/src/components/warning/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, Text } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { Icon } from '@wordpress/components';\nimport { withPreferredColorScheme } from '@wordpress/compose';\nimport { normalizeIconObject } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nfunction Warning( {\n\tactions,\n\ttitle,\n\tmessage,\n\ticon,\n\ticonClass,\n\tpreferredColorScheme,\n\tgetStylesFromColorScheme,\n\tcontainerStyle: extraContainerStyle,\n\ttitleStyle: extraTitleStyle,\n\tmessageStyle: extraMessageStyle,\n\t...viewProps\n} ) {\n\ticon = icon && normalizeIconObject( icon );\n\tconst internalIconClass = 'warning-icon' + '-' + preferredColorScheme;\n\n\tconst containerStyle = [\n\t\tgetStylesFromColorScheme( styles.container, styles.containerDark ),\n\t\textraContainerStyle,\n\t];\n\tconst titleStyle = [\n\t\tgetStylesFromColorScheme( styles.title, styles.titleDark ),\n\t\textraTitleStyle,\n\t];\n\tconst messageStyle = [\n\t\tgetStylesFromColorScheme( styles.message, styles.messageDark ),\n\t\textraMessageStyle,\n\t];\n\n\treturn (\n\t\t<View style={ containerStyle } { ...viewProps }>\n\t\t\t{ icon && (\n\t\t\t\t<View style={ styles.icon }>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName={ iconClass || internalIconClass }\n\t\t\t\t\t\ticon={ icon && icon.src ? icon.src : icon }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t) }\n\t\t\t{ title && <Text style={ titleStyle }>{ title }</Text> }\n\t\t\t{ message && <Text style={ messageStyle }>{ message }</Text> }\n\t\t\t{ actions }\n\t\t</View>\n\t);\n}\n\nexport default withPreferredColorScheme( Warning );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,IAAI,QAAQ,cAAc;;AAEzC;AACA;AACA;AACA,SAASC,IAAI,QAAQ,uBAAuB;AAC5C,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,mBAAmB,QAAQ,mBAAmB;;AAEvD;AACA;AACA;AACA,OAAOC,MAAM,MAAM,cAAc;AAEjC,SAASC,OAAOA,CAAE;EACjBC,OAAO;EACPC,KAAK;EACLC,OAAO;EACPC,IAAI;EACJC,SAAS;EACTC,oBAAoB;EACpBC,wBAAwB;EACxBC,cAAc,EAAEC,mBAAmB;EACnCC,UAAU,EAAEC,eAAe;EAC3BC,YAAY,EAAEC,iBAAiB;EAC/B,GAAGC;AACJ,CAAC,EAAG;EACHV,IAAI,GAAGA,IAAI,IAAIN,mBAAmB,CAAEM,IAAK,CAAC;EAC1C,MAAMW,iBAAiB,GAAG,cAAc,GAAG,GAAG,GAAGT,oBAAoB;EAErE,MAAME,cAAc,GAAG,CACtBD,wBAAwB,CAAER,MAAM,CAACiB,SAAS,EAAEjB,MAAM,CAACkB,aAAc,CAAC,EAClER,mBAAmB,CACnB;EACD,MAAMC,UAAU,GAAG,CAClBH,wBAAwB,CAAER,MAAM,CAACG,KAAK,EAAEH,MAAM,CAACmB,SAAU,CAAC,EAC1DP,eAAe,CACf;EACD,MAAMC,YAAY,GAAG,CACpBL,wBAAwB,CAAER,MAAM,CAACI,OAAO,EAAEJ,MAAM,CAACoB,WAAY,CAAC,EAC9DN,iBAAiB,CACjB;EAED,OACCO,aAAA,CAAC1B,IAAI;IAAC2B,KAAK,EAAGb,cAAgB;IAAA,GAAMM;EAAS,GAC1CV,IAAI,IACLgB,aAAA,CAAC1B,IAAI;IAAC2B,KAAK,EAAGtB,MAAM,CAACK;EAAM,GAC1BgB,aAAA,CAACxB,IAAI;IACJ0B,SAAS,EAAGjB,SAAS,IAAIU,iBAAmB;IAC5CX,IAAI,EAAGA,IAAI,IAAIA,IAAI,CAACmB,GAAG,GAAGnB,IAAI,CAACmB,GAAG,GAAGnB;EAAM,CAC3C,CACI,CACN,EACCF,KAAK,IAAIkB,aAAA,CAACzB,IAAI;IAAC0B,KAAK,EAAGX;EAAY,GAAGR,KAAa,CAAC,EACpDC,OAAO,IAAIiB,aAAA,CAACzB,IAAI;IAAC0B,KAAK,EAAGT;EAAc,GAAGT,OAAe,CAAC,EAC1DF,OACG,CAAC;AAET;AAEA,eAAeJ,wBAAwB,CAAEG,OAAQ,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { documentHasSelection, documentHasUncollapsedSelection } from '@wordpress/dom';
|
|
5
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
+
import { useDispatch, useRegistry, useSelect } from '@wordpress/data';
|
|
6
6
|
import { useRefEffect } from '@wordpress/compose';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -12,6 +12,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
12
12
|
import { useNotifyCopy } from '../../utils/use-notify-copy';
|
|
13
13
|
import { getPasteBlocks, setClipboardBlocks } from './utils';
|
|
14
14
|
export default function useClipboardHandler() {
|
|
15
|
+
const registry = useRegistry();
|
|
15
16
|
const {
|
|
16
17
|
getBlocksByClientId,
|
|
17
18
|
getSelectedBlockClientIds,
|
|
@@ -86,7 +87,7 @@ export default function useClipboardHandler() {
|
|
|
86
87
|
const inBetweenBlocks = getBlocksByClientId(selectedBlockClientIds.slice(1, selectedBlockClientIds.length - 1));
|
|
87
88
|
blocks = [head, ...inBetweenBlocks, tail];
|
|
88
89
|
}
|
|
89
|
-
setClipboardBlocks(event, blocks);
|
|
90
|
+
setClipboardBlocks(event, blocks, registry);
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
if (event.type === 'cut') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["documentHasSelection","documentHasUncollapsedSelection","useDispatch","useSelect","useRefEffect","store","blockEditorStore","useNotifyCopy","getPasteBlocks","setClipboardBlocks","useClipboardHandler","getBlocksByClientId","getSelectedBlockClientIds","hasMultiSelection","getSettings","__unstableIsFullySelected","__unstableIsSelectionCollapsed","__unstableIsSelectionMergeable","__unstableGetSelectedBlocksWithPartialSelection","canInsertBlockType","flashBlock","removeBlocks","replaceBlocks","__unstableDeleteSelection","__unstableExpandSelection","insertBlocks","notifyCopy","node","handler","event","defaultPrevented","selectedBlockClientIds","length","target","ownerDocument","hasSelection","type","contains","activeElement","preventDefault","isSelectionMergeable","shouldHandleWholeBlocks","expandSelectionIsNeeded","blocks","head","tail","inBetweenBlocks","slice","contentEditable","__experimentalCanUserUseUnfilteredHTML","canUserUseUnfilteredHTML","selectedBlockClientId","every","block","name","undefined","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-clipboard-handler.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tdocumentHasSelection,\n\tdocumentHasUncollapsedSelection,\n} from '@wordpress/dom';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useNotifyCopy } from '../../utils/use-notify-copy';\nimport { getPasteBlocks, setClipboardBlocks } from './utils';\n\nexport default function useClipboardHandler() {\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSettings,\n\t\t__unstableIsFullySelected,\n\t\t__unstableIsSelectionCollapsed,\n\t\t__unstableIsSelectionMergeable,\n\t\t__unstableGetSelectedBlocksWithPartialSelection,\n\t\tcanInsertBlockType,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tflashBlock,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\tinsertBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst notifyCopy = useNotifyCopy();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction handler( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t// This was likely already handled in rich-text/use-paste-handler.js.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\tif ( selectedBlockClientIds.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Always handle multiple selected blocks.\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { target } = event;\n\t\t\t\tconst { ownerDocument } = target;\n\t\t\t\t// If copying, only consider actual text selection as selection.\n\t\t\t\t// Otherwise, any focus on an input field is considered.\n\t\t\t\tconst hasSelection =\n\t\t\t\t\tevent.type === 'copy' || event.type === 'cut'\n\t\t\t\t\t\t? documentHasUncollapsedSelection( ownerDocument )\n\t\t\t\t\t\t: documentHasSelection( ownerDocument );\n\n\t\t\t\t// Let native copy behaviour take over in input fields.\n\t\t\t\tif ( hasSelection ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! node.contains( event.target.ownerDocument.activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst isSelectionMergeable = __unstableIsSelectionMergeable();\n\t\t\tconst shouldHandleWholeBlocks =\n\t\t\t\t__unstableIsSelectionCollapsed() || __unstableIsFullySelected();\n\t\t\tconst expandSelectionIsNeeded =\n\t\t\t\t! shouldHandleWholeBlocks && ! isSelectionMergeable;\n\t\t\tif ( event.type === 'copy' || event.type === 'cut' ) {\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tflashBlock( selectedBlockClientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t\t// If we have a partial selection that is not mergeable, just\n\t\t\t\t// expand the selection to the whole blocks.\n\t\t\t\tif ( expandSelectionIsNeeded ) {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t} else {\n\t\t\t\t\tnotifyCopy( event.type, selectedBlockClientIds );\n\t\t\t\t\tlet blocks;\n\t\t\t\t\t// Check if we have partial selection.\n\t\t\t\t\tif ( shouldHandleWholeBlocks ) {\n\t\t\t\t\t\tblocks = getBlocksByClientId( selectedBlockClientIds );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst [ head, tail ] =\n\t\t\t\t\t\t\t__unstableGetSelectedBlocksWithPartialSelection();\n\t\t\t\t\t\tconst inBetweenBlocks = getBlocksByClientId(\n\t\t\t\t\t\t\tselectedBlockClientIds.slice(\n\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length - 1\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tblocks = [ head, ...inBetweenBlocks, tail ];\n\t\t\t\t\t}\n\n\t\t\t\t\tsetClipboardBlocks( event, blocks );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( event.type === 'cut' ) {\n\t\t\t\t// We need to also check if at the start we needed to\n\t\t\t\t// expand the selection, as in this point we might have\n\t\t\t\t// programmatically fully selected the blocks above.\n\t\t\t\tif ( shouldHandleWholeBlocks && ! expandSelectionIsNeeded ) {\n\t\t\t\t\tremoveBlocks( selectedBlockClientIds );\n\t\t\t\t} else {\n\t\t\t\t\tevent.target.ownerDocument.activeElement.contentEditable = false;\n\t\t\t\t\t__unstableDeleteSelection();\n\t\t\t\t}\n\t\t\t} else if ( event.type === 'paste' ) {\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalCanUserUseUnfilteredHTML:\n\t\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t} = getSettings();\n\t\t\t\tconst blocks = getPasteBlocks(\n\t\t\t\t\tevent,\n\t\t\t\t\tcanUserUseUnfilteredHTML\n\t\t\t\t);\n\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tconst [ selectedBlockClientId ] = selectedBlockClientIds;\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tblocks.every( ( block ) =>\n\t\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\t\t\tselectedBlockClientId\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\t\tinsertBlocks(\n\t\t\t\t\t\t\tblocks,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tselectedBlockClientId\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tselectedBlockClientIds,\n\t\t\t\t\tblocks,\n\t\t\t\t\tblocks.length - 1,\n\t\t\t\t\t-1\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.addEventListener( 'copy', handler );\n\t\tnode.ownerDocument.addEventListener( 'cut', handler );\n\t\tnode.ownerDocument.addEventListener( 'paste', handler );\n\n\t\treturn () => {\n\t\t\tnode.ownerDocument.removeEventListener( 'copy', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'cut', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'paste', handler );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,oBAAoB,EACpBC,+BAA+B,QACzB,gBAAgB;AACvB,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC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"}
|
|
1
|
+
{"version":3,"names":["documentHasSelection","documentHasUncollapsedSelection","useDispatch","useRegistry","useSelect","useRefEffect","store","blockEditorStore","useNotifyCopy","getPasteBlocks","setClipboardBlocks","useClipboardHandler","registry","getBlocksByClientId","getSelectedBlockClientIds","hasMultiSelection","getSettings","__unstableIsFullySelected","__unstableIsSelectionCollapsed","__unstableIsSelectionMergeable","__unstableGetSelectedBlocksWithPartialSelection","canInsertBlockType","flashBlock","removeBlocks","replaceBlocks","__unstableDeleteSelection","__unstableExpandSelection","insertBlocks","notifyCopy","node","handler","event","defaultPrevented","selectedBlockClientIds","length","target","ownerDocument","hasSelection","type","contains","activeElement","preventDefault","isSelectionMergeable","shouldHandleWholeBlocks","expandSelectionIsNeeded","blocks","head","tail","inBetweenBlocks","slice","contentEditable","__experimentalCanUserUseUnfilteredHTML","canUserUseUnfilteredHTML","selectedBlockClientId","every","block","name","undefined","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-clipboard-handler.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tdocumentHasSelection,\n\tdocumentHasUncollapsedSelection,\n} from '@wordpress/dom';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useNotifyCopy } from '../../utils/use-notify-copy';\nimport { getPasteBlocks, setClipboardBlocks } from './utils';\n\nexport default function useClipboardHandler() {\n\tconst registry = useRegistry();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\thasMultiSelection,\n\t\tgetSettings,\n\t\t__unstableIsFullySelected,\n\t\t__unstableIsSelectionCollapsed,\n\t\t__unstableIsSelectionMergeable,\n\t\t__unstableGetSelectedBlocksWithPartialSelection,\n\t\tcanInsertBlockType,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\tflashBlock,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\tinsertBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst notifyCopy = useNotifyCopy();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction handler( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t// This was likely already handled in rich-text/use-paste-handler.js.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\n\t\t\tif ( selectedBlockClientIds.length === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Always handle multiple selected blocks.\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { target } = event;\n\t\t\t\tconst { ownerDocument } = target;\n\t\t\t\t// If copying, only consider actual text selection as selection.\n\t\t\t\t// Otherwise, any focus on an input field is considered.\n\t\t\t\tconst hasSelection =\n\t\t\t\t\tevent.type === 'copy' || event.type === 'cut'\n\t\t\t\t\t\t? documentHasUncollapsedSelection( ownerDocument )\n\t\t\t\t\t\t: documentHasSelection( ownerDocument );\n\n\t\t\t\t// Let native copy behaviour take over in input fields.\n\t\t\t\tif ( hasSelection ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( ! node.contains( event.target.ownerDocument.activeElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst isSelectionMergeable = __unstableIsSelectionMergeable();\n\t\t\tconst shouldHandleWholeBlocks =\n\t\t\t\t__unstableIsSelectionCollapsed() || __unstableIsFullySelected();\n\t\t\tconst expandSelectionIsNeeded =\n\t\t\t\t! shouldHandleWholeBlocks && ! isSelectionMergeable;\n\t\t\tif ( event.type === 'copy' || event.type === 'cut' ) {\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tflashBlock( selectedBlockClientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t\t// If we have a partial selection that is not mergeable, just\n\t\t\t\t// expand the selection to the whole blocks.\n\t\t\t\tif ( expandSelectionIsNeeded ) {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t} else {\n\t\t\t\t\tnotifyCopy( event.type, selectedBlockClientIds );\n\t\t\t\t\tlet blocks;\n\t\t\t\t\t// Check if we have partial selection.\n\t\t\t\t\tif ( shouldHandleWholeBlocks ) {\n\t\t\t\t\t\tblocks = getBlocksByClientId( selectedBlockClientIds );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst [ head, tail ] =\n\t\t\t\t\t\t\t__unstableGetSelectedBlocksWithPartialSelection();\n\t\t\t\t\t\tconst inBetweenBlocks = getBlocksByClientId(\n\t\t\t\t\t\t\tselectedBlockClientIds.slice(\n\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\tselectedBlockClientIds.length - 1\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tblocks = [ head, ...inBetweenBlocks, tail ];\n\t\t\t\t\t}\n\n\t\t\t\t\tsetClipboardBlocks( event, blocks, registry );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( event.type === 'cut' ) {\n\t\t\t\t// We need to also check if at the start we needed to\n\t\t\t\t// expand the selection, as in this point we might have\n\t\t\t\t// programmatically fully selected the blocks above.\n\t\t\t\tif ( shouldHandleWholeBlocks && ! expandSelectionIsNeeded ) {\n\t\t\t\t\tremoveBlocks( selectedBlockClientIds );\n\t\t\t\t} else {\n\t\t\t\t\tevent.target.ownerDocument.activeElement.contentEditable = false;\n\t\t\t\t\t__unstableDeleteSelection();\n\t\t\t\t}\n\t\t\t} else if ( event.type === 'paste' ) {\n\t\t\t\tconst {\n\t\t\t\t\t__experimentalCanUserUseUnfilteredHTML:\n\t\t\t\t\t\tcanUserUseUnfilteredHTML,\n\t\t\t\t} = getSettings();\n\t\t\t\tconst blocks = getPasteBlocks(\n\t\t\t\t\tevent,\n\t\t\t\t\tcanUserUseUnfilteredHTML\n\t\t\t\t);\n\n\t\t\t\tif ( selectedBlockClientIds.length === 1 ) {\n\t\t\t\t\tconst [ selectedBlockClientId ] = selectedBlockClientIds;\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tblocks.every( ( block ) =>\n\t\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\t\t\tselectedBlockClientId\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\t\tinsertBlocks(\n\t\t\t\t\t\t\tblocks,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tselectedBlockClientId\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tselectedBlockClientIds,\n\t\t\t\t\tblocks,\n\t\t\t\t\tblocks.length - 1,\n\t\t\t\t\t-1\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.addEventListener( 'copy', handler );\n\t\tnode.ownerDocument.addEventListener( 'cut', handler );\n\t\tnode.ownerDocument.addEventListener( 'paste', handler );\n\n\t\treturn () => {\n\t\t\tnode.ownerDocument.removeEventListener( 'copy', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'cut', handler );\n\t\t\tnode.ownerDocument.removeEventListener( 'paste', handler );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,oBAAoB,EACpBC,+BAA+B,QACzB,gBAAgB;AACvB,SAASC,WAAW,EAAEC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACrE,SAASC,YAAY,QAAQ,oBAAoB;;AAEjD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,aAAa,QAAQ,6BAA6B;AAC3D,SAASC,cAAc,EAAEC,kBAAkB,QAAQ,SAAS;AAE5D,eAAe,SAASC,mBAAmBA,CAAA,EAA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TML as stripHTML } from '@wordpress/dom';
|
|
5
|
-
import { serialize, createBlock, pasteHandler, findTransform, getBlockTransforms } from '@wordpress/blocks';
|
|
5
|
+
import { serialize, createBlock, pasteHandler, findTransform, getBlockTransforms, store as blocksStore } from '@wordpress/blocks';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { getPasteEventData } from '../../utils/pasting';
|
|
11
|
+
import { store as blockEditorStore } from '../../store';
|
|
12
|
+
export const requiresWrapperOnCopy = Symbol('requiresWrapperOnCopy');
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Sets the clipboard data for the provided blocks, with both HTML and plain
|
|
14
16
|
* text representations.
|
|
15
17
|
*
|
|
16
|
-
* @param {ClipboardEvent} event
|
|
17
|
-
* @param {WPBlock[]} blocks
|
|
18
|
+
* @param {ClipboardEvent} event Clipboard event.
|
|
19
|
+
* @param {WPBlock[]} blocks Blocks to set as clipboard data.
|
|
20
|
+
* @param {Object} registry The registry to select from.
|
|
18
21
|
*/
|
|
19
|
-
export function setClipboardBlocks(event, blocks) {
|
|
22
|
+
export function setClipboardBlocks(event, blocks, registry) {
|
|
20
23
|
let _blocks = blocks;
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
+
const [firstBlock] = blocks;
|
|
25
|
+
if (firstBlock) {
|
|
26
|
+
const firstBlockType = registry.select(blocksStore).getBlockType(firstBlock.name);
|
|
27
|
+
if (firstBlockType[requiresWrapperOnCopy]) {
|
|
28
|
+
const {
|
|
29
|
+
getBlockRootClientId,
|
|
30
|
+
getBlockName,
|
|
31
|
+
getBlockAttributes
|
|
32
|
+
} = registry.select(blockEditorStore);
|
|
33
|
+
const wrapperBlockClientId = getBlockRootClientId(firstBlock.clientId);
|
|
34
|
+
const wrapperBlockName = getBlockName(wrapperBlockClientId);
|
|
35
|
+
if (wrapperBlockName) {
|
|
36
|
+
_blocks = createBlock(wrapperBlockName, getBlockAttributes(wrapperBlockClientId), _blocks);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
24
39
|
}
|
|
25
40
|
const serialized = serialize(_blocks);
|
|
26
41
|
event.clipboardData.setData('text/plain', toPlainText(serialized));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__unstableStripHTML","stripHTML","serialize","createBlock","pasteHandler","findTransform","getBlockTransforms","getPasteEventData","setClipboardBlocks","event","blocks","_blocks","
|
|
1
|
+
{"version":3,"names":["__unstableStripHTML","stripHTML","serialize","createBlock","pasteHandler","findTransform","getBlockTransforms","store","blocksStore","getPasteEventData","blockEditorStore","requiresWrapperOnCopy","Symbol","setClipboardBlocks","event","blocks","registry","_blocks","firstBlock","firstBlockType","select","getBlockType","name","getBlockRootClientId","getBlockName","getBlockAttributes","wrapperBlockClientId","clientId","wrapperBlockName","serialized","clipboardData","setData","toPlainText","getPasteBlocks","canUserUseUnfilteredHTML","plainText","html","files","length","fromTransforms","reduce","accumulator","file","transformation","transform","type","isMatch","push","flat","HTML","mode","replace","trim"],"sources":["@wordpress/block-editor/src/components/writing-flow/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tserialize,\n\tcreateBlock,\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport const requiresWrapperOnCopy = Symbol( 'requiresWrapperOnCopy' );\n\n/**\n * Sets the clipboard data for the provided blocks, with both HTML and plain\n * text representations.\n *\n * @param {ClipboardEvent} event Clipboard event.\n * @param {WPBlock[]} blocks Blocks to set as clipboard data.\n * @param {Object} registry The registry to select from.\n */\nexport function setClipboardBlocks( event, blocks, registry ) {\n\tlet _blocks = blocks;\n\n\tconst [ firstBlock ] = blocks;\n\n\tif ( firstBlock ) {\n\t\tconst firstBlockType = registry\n\t\t\t.select( blocksStore )\n\t\t\t.getBlockType( firstBlock.name );\n\n\t\tif ( firstBlockType[ requiresWrapperOnCopy ] ) {\n\t\t\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\t\t\tregistry.select( blockEditorStore );\n\t\t\tconst wrapperBlockClientId = getBlockRootClientId(\n\t\t\t\tfirstBlock.clientId\n\t\t\t);\n\t\t\tconst wrapperBlockName = getBlockName( wrapperBlockClientId );\n\n\t\t\tif ( wrapperBlockName ) {\n\t\t\t\t_blocks = createBlock(\n\t\t\t\t\twrapperBlockName,\n\t\t\t\t\tgetBlockAttributes( wrapperBlockClientId ),\n\t\t\t\t\t_blocks\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst serialized = serialize( _blocks );\n\n\tevent.clipboardData.setData( 'text/plain', toPlainText( serialized ) );\n\tevent.clipboardData.setData( 'text/html', serialized );\n}\n\n/**\n * Returns the blocks to be pasted from the clipboard event.\n *\n * @param {ClipboardEvent} event The clipboard event.\n * @param {boolean} canUserUseUnfilteredHTML Whether the user can or can't post unfiltered HTML.\n * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.\n */\nexport function getPasteBlocks( event, canUserUseUnfilteredHTML ) {\n\tconst { plainText, html, files } = getPasteEventData( event );\n\tlet blocks = [];\n\n\tif ( files.length ) {\n\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\tblocks = files\n\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\tfromTransforms,\n\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t);\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\taccumulator.push( transformation.transform( [ file ] ) );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, [] )\n\t\t\t.flat();\n\t} else {\n\t\tblocks = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode: 'BLOCKS',\n\t\t\tcanUserUseUnfilteredHTML,\n\t\t} );\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Given a string of HTML representing serialized blocks, returns the plain\n * text extracted after stripping the HTML of any tags and fixing line breaks.\n *\n * @param {string} html Serialized blocks.\n * @return {string} The plain-text content with any html removed.\n */\nfunction toPlainText( html ) {\n\t// Manually handle BR tags as line breaks prior to `stripHTML` call\n\thtml = html.replace( /<br>/g, '\\n' );\n\n\tconst plainText = stripHTML( html ).trim();\n\n\t// Merge any consecutive line breaks\n\treturn plainText.replace( /\\n\\n+/g, '\\n\\n' );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SACCC,SAAS,EACTC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,kBAAkB,EAClBC,KAAK,IAAIC,WAAW,QACd,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASF,KAAK,IAAIG,gBAAgB,QAAQ,aAAa;AAEvD,OAAO,MAAMC,qBAAqB,GAAGC,MAAM,CAAE,uBAAwB,CAAC;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAG;EAC7D,IAAIC,OAAO,GAAGF,MAAM;EAEpB,MAAM,CAAEG,UAAU,CAAE,GAAGH,MAAM;EAE7B,IAAKG,UAAU,EAAG;IACjB,MAAMC,cAAc,GAAGH,QAAQ,CAC7BI,MAAM,CAAEZ,WAAY,CAAC,CACrBa,YAAY,CAAEH,UAAU,CAACI,IAAK,CAAC;IAEjC,IAAKH,cAAc,CAAER,qBAAqB,CAAE,EAAG;MAC9C,MAAM;QAAEY,oBAAoB;QAAEC,YAAY;QAAEC;MAAmB,CAAC,GAC/DT,QAAQ,CAACI,MAAM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AC,CACNO,IAAI,CAAC,CAAC;EACT,CAAC,MAAM;IACNjC,MAAM,GAAGX,YAAY,CAAE;MACtB6C,IAAI,EAAEb,IAAI;MACVD,SAAS;MACTe,IAAI,EAAE,QAAQ;MACdhB;IACD,CAAE,CAAC;EACJ;EAEA,OAAOnB,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASiB,WAAWA,CAAEI,IAAI,EAAG;EAC5B;EACAA,IAAI,GAAGA,IAAI,CAACe,OAAO,CAAE,OAAO,EAAE,IAAK,CAAC;EAEpC,MAAMhB,SAAS,GAAGlC,SAAS,CAAEmC,IAAK,CAAC,CAACgB,IAAI,CAAC,CAAC;;EAE1C;EACA,OAAOjB,SAAS,CAACgB,OAAO,CAAE,QAAQ,EAAE,MAAO,CAAC;AAC7C"}
|
|
@@ -3,7 +3,7 @@ import { createElement, Fragment } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { addFilter } from '@wordpress/hooks';
|
|
6
|
-
import {
|
|
6
|
+
import { TextControl, ExternalLink } from '@wordpress/components';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { hasBlockSupport } from '@wordpress/blocks';
|
|
9
9
|
import { Platform } from '@wordpress/element';
|
|
@@ -51,13 +51,17 @@ export function addAttribute(settings) {
|
|
|
51
51
|
return settings;
|
|
52
52
|
}
|
|
53
53
|
function BlockEditAnchorControlPure({
|
|
54
|
-
name: blockName,
|
|
55
54
|
anchor,
|
|
56
55
|
setAttributes
|
|
57
56
|
}) {
|
|
58
57
|
const blockEditingMode = useBlockEditingMode();
|
|
58
|
+
if (blockEditingMode !== 'default') {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
59
61
|
const isWeb = Platform.OS === 'web';
|
|
60
|
-
|
|
62
|
+
return createElement(InspectorControls, {
|
|
63
|
+
group: "advanced"
|
|
64
|
+
}, createElement(TextControl, {
|
|
61
65
|
__nextHasNoMarginBottom: true,
|
|
62
66
|
__next40pxDefaultSize: true,
|
|
63
67
|
className: "html-anchor-control",
|
|
@@ -75,12 +79,7 @@ function BlockEditAnchorControlPure({
|
|
|
75
79
|
},
|
|
76
80
|
autoCapitalize: "none",
|
|
77
81
|
autoComplete: "off"
|
|
78
|
-
});
|
|
79
|
-
return createElement(Fragment, null, isWeb && blockEditingMode === 'default' && createElement(InspectorControls, {
|
|
80
|
-
group: "advanced"
|
|
81
|
-
}, textControl), !isWeb && blockName === 'core/heading' && createElement(InspectorControls, null, createElement(PanelBody, {
|
|
82
|
-
title: __('Heading settings')
|
|
83
|
-
}, textControl)));
|
|
82
|
+
}));
|
|
84
83
|
}
|
|
85
84
|
export default {
|
|
86
85
|
addSaveProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["addFilter","
|
|
1
|
+
{"version":3,"names":["addFilter","TextControl","ExternalLink","__","hasBlockSupport","Platform","InspectorControls","useBlockEditingMode","ANCHOR_REGEX","ANCHOR_SCHEMA","type","source","attribute","selector","addAttribute","settings","_settings$attributes$","attributes","anchor","BlockEditAnchorControlPure","setAttributes","blockEditingMode","isWeb","OS","createElement","group","__nextHasNoMarginBottom","__next40pxDefaultSize","className","label","help","Fragment","href","value","placeholder","onChange","nextValue","replace","autoCapitalize","autoComplete","addSaveProps","edit","attributeKeys","hasSupport","name","extraProps","blockType","id"],"sources":["@wordpress/block-editor/src/hooks/anchor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { 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( { anchor, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\tconst isWeb = Platform.OS === 'web';\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tclassName=\"html-anchor-control\"\n\t\t\t\tlabel={ __( 'HTML anchor' ) }\n\t\t\t\thelp={\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ __(\n\t\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\t) }\n\n\t\t\t\t\t\t{ isWeb && (\n\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-jumps/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Learn more about anchors' ) }\n\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t}\n\t\t\t\tvalue={ anchor || '' }\n\t\t\t\tplaceholder={ ! isWeb ? __( 'Add an anchor' ) : null }\n\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\tnextValue = nextValue.replace( ANCHOR_REGEX, '-' );\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tanchor: nextValue,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tautoCapitalize=\"none\"\n\t\t\t\tautoComplete=\"off\"\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nexport default {\n\taddSaveProps,\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 );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,EAAEC,YAAY,QAAQ,uBAAuB;AACjE,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,M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,GAAGnB,EAAE,CAAE,eAAgB,CAAC,GAAG,IAAM;IACtDgC,QAAQ,EAAKC,SAAS,IAAM;MAC3BA,SAAS,GAAGA,SAAS,CAACC,OAAO,CAAE7B,YAAY,EAAE,GAAI,CAAC;MAClDY,aAAa,CAAE;QACdF,MAAM,EAAEkB;MACT,CAAE,CAAC;IACJ,CAAG;IACHE,cAAc,EAAC,MAAM;IACrBC,YAAY,EAAC;EAAK,CAClB,CACiB,CAAC;AAEtB;AAEA,eAAe;EACdC,YAAY;EACZC,IAAI,EAAEtB,0BAA0B;EAChCuB,aAAa,EAAE,CAAE,QAAQ,CAAE;EAC3BC,UAAUA,CAAEC,IAAI,EAAG;IAClB,OAAOxC,eAAe,CAAEwC,IAAI,EAAE,QAAS,CAAC;EACzC;AACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASJ,YAAYA,CAAEK,UAAU,EAAEC,SAAS,EAAE7B,UAAU,EAAG;EACjE,IAAKb,eAAe,CAAE0C,SAAS,EAAE,QAAS,CAAC,EAAG;IAC7CD,UAAU,CAACE,EAAE,GAAG9B,UAAU,CAACC,MAAM,KAAK,EAAE,GAAG,IAAI,GAAGD,UAAU,CAACC,MAAM;EACpE;EAEA,OAAO2B,UAAU;AAClB;AAEA7C,SAAS,CAAE,0BAA0B,EAAE,uBAAuB,EAAEc,YAAa,CAAC"}
|
|
@@ -73,6 +73,38 @@ export function hasBackgroundSupport(blockName, feature = 'any') {
|
|
|
73
73
|
}
|
|
74
74
|
return !!support?.[feature];
|
|
75
75
|
}
|
|
76
|
+
function useBlockProps({
|
|
77
|
+
name,
|
|
78
|
+
style
|
|
79
|
+
}) {
|
|
80
|
+
if (!hasBackgroundSupport(name) || !style?.background?.backgroundImage) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const backgroundImage = style?.background?.backgroundImage;
|
|
84
|
+
let props;
|
|
85
|
+
|
|
86
|
+
// Set block background defaults.
|
|
87
|
+
if (backgroundImage?.source === 'file' && !!backgroundImage?.url) {
|
|
88
|
+
if (!style?.background?.backgroundSize) {
|
|
89
|
+
props = {
|
|
90
|
+
style: {
|
|
91
|
+
backgroundSize: 'cover'
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if ('contain' === style?.background?.backgroundSize && !style?.background?.backgroundPosition) {
|
|
96
|
+
props = {
|
|
97
|
+
style: {
|
|
98
|
+
backgroundPosition: 'center'
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!props) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
return props;
|
|
107
|
+
}
|
|
76
108
|
|
|
77
109
|
/**
|
|
78
110
|
* Resets the background image block support attributes. This can be used when disabling
|
|
@@ -339,7 +371,7 @@ function BackgroundSizePanelItem({
|
|
|
339
371
|
// If the current value is `cover` and the repeat value is `undefined`, then
|
|
340
372
|
// the toggle should be unchecked as the default state. Otherwise, the toggle
|
|
341
373
|
// should reflect the current repeat value.
|
|
342
|
-
const repeatCheckedValue = repeatValue === 'no-repeat' || currentValueForToggle === 'cover' && repeatValue === undefined
|
|
374
|
+
const repeatCheckedValue = !(repeatValue === 'no-repeat' || currentValueForToggle === 'cover' && repeatValue === undefined);
|
|
343
375
|
const hasValue = hasBackgroundSizeValue(style);
|
|
344
376
|
const resetAllFilter = useCallback(previousValue => {
|
|
345
377
|
return {
|
|
@@ -458,4 +490,9 @@ export function BackgroundImagePanel(props) {
|
|
|
458
490
|
...props
|
|
459
491
|
}));
|
|
460
492
|
}
|
|
493
|
+
export default {
|
|
494
|
+
useBlockProps,
|
|
495
|
+
attributeKeys: ['style'],
|
|
496
|
+
hasSupport: hasBackgroundSupport
|
|
497
|
+
};
|
|
461
498
|
//# sourceMappingURL=background.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","isBlobURL","getBlockSupport","focus","ToggleControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUnitControl","UnitControl","__experimentalVStack","VStack","DropZone","FlexItem","FocalPointPicker","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","style","hasValue","background","backgroundImage","id","url","hasBackgroundSizeValue","backgroundPosition","undefined","backgroundSize","hasBackgroundSupport","blockName","feature","OS","support","backgroundRepeat","resetBackgroundImage","setAttributes","resetBackgroundSize","getBackgroundImageClasses","InspectorImagePreview","label","filename","imgUrl","imgLabel","createElement","as","justify","className","numberOfLines","BackgroundImagePanelItem","clientId","isShownByDefault","mediaUpload","select","getBlockAttributes","getSettings","title","replaceContainerRef","createErrorNotice","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","media_type","source","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","previousValue","onDeselect","panelId","ref","mediaId","mediaURL","accept","onSelect","name","variant","onClick","toggleButton","tabbable","find","current","click","backgroundSizeHelpText","value","coordsToBackgroundPosition","isNaN","x","y","backgroundPositionToCoords","split","map","v","parseFloat","BackgroundSizePanelItem","sizeValue","repeatValue","currentValueForToggle","repeatCheckedValue","updateBackgroundSize","next","nextRepeat","updateBackgroundPosition","toggleIsRepeated","spacing","__next40pxDefaultSize","onChange","size","isBlock","help","key","checked","BackgroundImagePanel","props","showBackgroundSize","defaultControls","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\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalVStack as VStack,\n\tDropZone,\n\tFlexItem,\n\tFocalPointPicker,\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} 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 * Checks if there is a current value in the background size block support\n * attributes. Background size values include background size as well\n * as background position.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether or not the block has a background size value set.\n */\nexport function hasBackgroundSizeValue( style ) {\n\treturn (\n\t\tstyle?.background?.backgroundPosition !== undefined ||\n\t\tstyle?.background?.backgroundSize !== undefined\n\t);\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 (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat\n\t\t);\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\n/**\n * Resets the background size block support attributes. This can be used when disabling\n * the background size 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 */\nfunction resetBackgroundSize( 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\tbackgroundPosition: undefined,\n\t\t\t\tbackgroundRepeat: undefined,\n\t\t\t\tbackgroundSize: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ? 'has-background' : '';\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( {\n\tclientId,\n\tisShownByDefault,\n\tsetAttributes,\n} ) {\n\tconst { style, mediaUpload } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style,\n\t\t\t\tmediaUpload: getSettings().mediaUpload,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { id, title, url } = style?.background?.backgroundImage || {};\n\n\tconst replaceContainerRef = useRef();\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={ isShownByDefault }\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 backgroundSizeHelpText( value ) {\n\tif ( value === 'cover' || value === undefined ) {\n\t\treturn __( 'Image covers the space evenly.' );\n\t}\n\tif ( value === 'contain' ) {\n\t\treturn __( 'Image is contained without distortion.' );\n\t}\n\treturn __( 'Specify a fixed width.' );\n}\n\nexport const coordsToBackgroundPosition = ( value ) => {\n\tif ( ! value || ( isNaN( value.x ) && isNaN( value.y ) ) ) {\n\t\treturn undefined;\n\t}\n\n\tconst x = isNaN( value.x ) ? 0.5 : value.x;\n\tconst y = isNaN( value.y ) ? 0.5 : value.y;\n\n\treturn `${ x * 100 }% ${ y * 100 }%`;\n};\n\nexport const backgroundPositionToCoords = ( value ) => {\n\tif ( ! value ) {\n\t\treturn { x: undefined, y: undefined };\n\t}\n\n\tlet [ x, y ] = value.split( ' ' ).map( ( v ) => parseFloat( v ) / 100 );\n\tx = isNaN( x ) ? undefined : x;\n\ty = isNaN( y ) ? x : y;\n\n\treturn { x, y };\n};\n\nfunction BackgroundSizePanelItem( {\n\tclientId,\n\tisShownByDefault,\n\tsetAttributes,\n} ) {\n\tconst style = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId )?.style,\n\t\t[ clientId ]\n\t);\n\n\tconst sizeValue = style?.background?.backgroundSize;\n\tconst repeatValue = style?.background?.backgroundRepeat;\n\n\t// An `undefined` value is treated as `cover` by the toggle group control.\n\t// An empty string is treated as `auto` by the toggle group control. This\n\t// allows a user to select \"Size\" and then enter a custom value, with an\n\t// empty value being treated as `auto`.\n\tconst currentValueForToggle =\n\t\t( sizeValue !== undefined &&\n\t\t\tsizeValue !== 'cover' &&\n\t\t\tsizeValue !== 'contain' ) ||\n\t\tsizeValue === ''\n\t\t\t? 'auto'\n\t\t\t: sizeValue || 'cover';\n\n\t// If the current value is `cover` and the repeat value is `undefined`, then\n\t// the toggle should be unchecked as the default state. Otherwise, the toggle\n\t// should reflect the current repeat value.\n\tconst repeatCheckedValue =\n\t\trepeatValue === 'no-repeat' ||\n\t\t( currentValueForToggle === 'cover' && repeatValue === undefined )\n\t\t\t? false\n\t\t\t: true;\n\n\tconst hasValue = hasBackgroundSizeValue( style );\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: {\n\t\t\t\t\t...previousValue.style?.background,\n\t\t\t\t\tbackgroundRepeat: undefined,\n\t\t\t\t\tbackgroundSize: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\tconst updateBackgroundSize = ( next ) => {\n\t\t// When switching to 'contain' toggle the repeat off.\n\t\tlet nextRepeat = repeatValue;\n\n\t\tif ( next === 'contain' ) {\n\t\t\tnextRepeat = 'no-repeat';\n\t\t}\n\n\t\tif (\n\t\t\t( currentValueForToggle === 'cover' ||\n\t\t\t\tcurrentValueForToggle === 'contain' ) &&\n\t\t\tnext === 'auto'\n\t\t) {\n\t\t\tnextRepeat = undefined;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundRepeat: nextRepeat,\n\t\t\t\t\tbackgroundSize: next,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst updateBackgroundPosition = ( next ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundPosition: coordsToBackgroundPosition( next ),\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst toggleIsRepeated = () => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundRepeat:\n\t\t\t\t\t\trepeatCheckedValue === true ? 'no-repeat' : undefined,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\treturn (\n\t\t<VStack\n\t\t\tas={ ToolsPanelItem }\n\t\t\tspacing={ 2 }\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasValue }\n\t\t\tlabel={ __( 'Size' ) }\n\t\t\tonDeselect={ () => resetBackgroundSize( style, setAttributes ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<FocalPointPicker\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\turl={ style?.background?.backgroundImage?.url }\n\t\t\t\tvalue={ backgroundPositionToCoords(\n\t\t\t\t\tstyle?.background?.backgroundPosition\n\t\t\t\t) }\n\t\t\t\tonChange={ updateBackgroundPosition }\n\t\t\t/>\n\t\t\t<ToggleGroupControl\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\tvalue={ currentValueForToggle }\n\t\t\t\tonChange={ updateBackgroundSize }\n\t\t\t\tisBlock={ true }\n\t\t\t\thelp={ backgroundSizeHelpText( sizeValue ) }\n\t\t\t>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'cover' }\n\t\t\t\t\tvalue={ 'cover' }\n\t\t\t\t\tlabel={ __( 'Cover' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'contain' }\n\t\t\t\t\tvalue={ 'contain' }\n\t\t\t\t\tlabel={ __( 'Contain' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fixed' }\n\t\t\t\t\tvalue={ 'auto' }\n\t\t\t\t\tlabel={ __( 'Fixed' ) }\n\t\t\t\t/>\n\t\t\t</ToggleGroupControl>\n\t\t\t{ sizeValue !== undefined &&\n\t\t\tsizeValue !== 'cover' &&\n\t\t\tsizeValue !== 'contain' ? (\n\t\t\t\t<UnitControl\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonChange={ updateBackgroundSize }\n\t\t\t\t\tvalue={ sizeValue }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t\t{ currentValueForToggle !== 'cover' && (\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Repeat' ) }\n\t\t\t\t\tchecked={ repeatCheckedValue }\n\t\t\t\t\tonChange={ toggleIsRepeated }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport function BackgroundImagePanel( props ) {\n\tconst [ backgroundImage, backgroundSize ] = useSettings(\n\t\t'background.backgroundImage',\n\t\t'background.backgroundSize'\n\t);\n\n\tif (\n\t\t! backgroundImage ||\n\t\t! hasBackgroundSupport( props.name, 'backgroundImage' )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst showBackgroundSize = !! (\n\t\tbackgroundSize && hasBackgroundSupport( props.name, 'backgroundSize' )\n\t);\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t<BackgroundImagePanelItem\n\t\t\t\tisShownByDefault={ defaultControls?.backgroundImage }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t\t{ showBackgroundSize && (\n\t\t\t\t<BackgroundSizePanelItem\n\t\t\t\t\tisShownByDefault={ defaultControls?.backgroundSize }\n\t\t\t\t\t{ ...props }\n\t\t\t\t/>\n\t\t\t) }\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,eAAe,QAAQ,mBAAmB;AACnD,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SACCC,aAAa,EACbC,gCAAgC,IAAIC,kBAAkB,EACtDC,sCAAsC,IAAIC,wBAAwB,EAClEC,4BAA4B,IAAIC,cAAc,EAC9CC,yBAAyB,IAAIC,WAAW,EACxCC,oBAAoB,IAAIC,MAAM,EAC9BC,QAAQ,EACRC,QAAQ,EACRC,gBAAgB,EAChBC,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;;AAE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sB,EACtB,+BAA+B,CAC9B,CAAC;EAEH,OACC4B,aAAA,CAACjC,iBAAiB;IAACiH,KAAK,EAAC;EAAY,GACpChF,aAAA,CAACK,wBAAwB;IACxBE,gBAAgB,EAAGwE,eAAe,EAAErG,eAAiB;IAAA,GAChDmG;EAAK,CACV,CAAC,EACAC,kBAAkB,IACnB9E,aAAA,CAAC0D,uBAAuB;IACvBnD,gBAAgB,EAAGwE,eAAe,EAAE/F,cAAgB;IAAA,GAC/C6F;EAAK,CACV,CAEgB,CAAC;AAEtB"}
|
|
1
|
+
{"version":3,"names":["classnames","isBlobURL","getBlockSupport","focus","ToggleControl","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalUnitControl","UnitControl","__experimentalVStack","VStack","DropZone","FlexItem","FocalPointPicker","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","style","hasValue","background","backgroundImage","id","url","hasBackgroundSizeValue","backgroundPosition","undefined","backgroundSize","hasBackgroundSupport","blockName","feature","OS","support","backgroundRepeat","useBlockProps","name","props","source","resetBackgroundImage","setAttributes","resetBackgroundSize","getBackgroundImageClasses","InspectorImagePreview","label","filename","imgUrl","imgLabel","createElement","as","justify","className","numberOfLines","BackgroundImagePanelItem","clientId","isShownByDefault","mediaUpload","select","getBlockAttributes","getSettings","title","replaceContainerRef","createErrorNotice","onUploadError","message","type","onSelectMedia","media","newStyle","newAttributes","media_type","onFilesDrop","filesList","allowedTypes","onFileChange","image","onError","resetAllFilter","previousValue","onDeselect","panelId","ref","mediaId","mediaURL","accept","onSelect","variant","onClick","toggleButton","tabbable","find","current","click","backgroundSizeHelpText","value","coordsToBackgroundPosition","isNaN","x","y","backgroundPositionToCoords","split","map","v","parseFloat","BackgroundSizePanelItem","sizeValue","repeatValue","currentValueForToggle","repeatCheckedValue","updateBackgroundSize","next","nextRepeat","updateBackgroundPosition","toggleIsRepeated","spacing","__next40pxDefaultSize","onChange","size","isBlock","help","key","checked","BackgroundImagePanel","showBackgroundSize","defaultControls","group","attributeKeys","hasSupport"],"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\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalVStack as VStack,\n\tDropZone,\n\tFlexItem,\n\tFocalPointPicker,\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} 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 * Checks if there is a current value in the background size block support\n * attributes. Background size values include background size as well\n * as background position.\n *\n * @param {Object} style Style attribute.\n * @return {boolean} Whether or not the block has a background size value set.\n */\nexport function hasBackgroundSizeValue( style ) {\n\treturn (\n\t\tstyle?.background?.backgroundPosition !== undefined ||\n\t\tstyle?.background?.backgroundSize !== undefined\n\t);\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 (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundImage = style?.background?.backgroundImage;\n\tlet props;\n\n\t// Set block background defaults.\n\tif ( backgroundImage?.source === 'file' && !! backgroundImage?.url ) {\n\t\tif ( ! style?.background?.backgroundSize ) {\n\t\t\tprops = {\n\t\t\t\tstyle: {\n\t\t\t\t\tbackgroundSize: 'cover',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (\n\t\t\t'contain' === style?.background?.backgroundSize &&\n\t\t\t! style?.background?.backgroundPosition\n\t\t) {\n\t\t\tprops = {\n\t\t\t\tstyle: {\n\t\t\t\t\tbackgroundPosition: 'center',\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\n\tif ( ! props ) {\n\t\treturn;\n\t}\n\n\treturn props;\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\n/**\n * Resets the background size block support attributes. This can be used when disabling\n * the background size 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 */\nfunction resetBackgroundSize( 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\tbackgroundPosition: undefined,\n\t\t\t\tbackgroundRepeat: undefined,\n\t\t\t\tbackgroundSize: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ? 'has-background' : '';\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( {\n\tclientId,\n\tisShownByDefault,\n\tsetAttributes,\n} ) {\n\tconst { style, mediaUpload } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style,\n\t\t\t\tmediaUpload: getSettings().mediaUpload,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { id, title, url } = style?.background?.backgroundImage || {};\n\n\tconst replaceContainerRef = useRef();\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={ isShownByDefault }\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 backgroundSizeHelpText( value ) {\n\tif ( value === 'cover' || value === undefined ) {\n\t\treturn __( 'Image covers the space evenly.' );\n\t}\n\tif ( value === 'contain' ) {\n\t\treturn __( 'Image is contained without distortion.' );\n\t}\n\treturn __( 'Specify a fixed width.' );\n}\n\nexport const coordsToBackgroundPosition = ( value ) => {\n\tif ( ! value || ( isNaN( value.x ) && isNaN( value.y ) ) ) {\n\t\treturn undefined;\n\t}\n\n\tconst x = isNaN( value.x ) ? 0.5 : value.x;\n\tconst y = isNaN( value.y ) ? 0.5 : value.y;\n\n\treturn `${ x * 100 }% ${ y * 100 }%`;\n};\n\nexport const backgroundPositionToCoords = ( value ) => {\n\tif ( ! value ) {\n\t\treturn { x: undefined, y: undefined };\n\t}\n\n\tlet [ x, y ] = value.split( ' ' ).map( ( v ) => parseFloat( v ) / 100 );\n\tx = isNaN( x ) ? undefined : x;\n\ty = isNaN( y ) ? x : y;\n\n\treturn { x, y };\n};\n\nfunction BackgroundSizePanelItem( {\n\tclientId,\n\tisShownByDefault,\n\tsetAttributes,\n} ) {\n\tconst style = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId )?.style,\n\t\t[ clientId ]\n\t);\n\n\tconst sizeValue = style?.background?.backgroundSize;\n\tconst repeatValue = style?.background?.backgroundRepeat;\n\n\t// An `undefined` value is treated as `cover` by the toggle group control.\n\t// An empty string is treated as `auto` by the toggle group control. This\n\t// allows a user to select \"Size\" and then enter a custom value, with an\n\t// empty value being treated as `auto`.\n\tconst currentValueForToggle =\n\t\t( sizeValue !== undefined &&\n\t\t\tsizeValue !== 'cover' &&\n\t\t\tsizeValue !== 'contain' ) ||\n\t\tsizeValue === ''\n\t\t\t? 'auto'\n\t\t\t: sizeValue || 'cover';\n\n\t// If the current value is `cover` and the repeat value is `undefined`, then\n\t// the toggle should be unchecked as the default state. Otherwise, the toggle\n\t// should reflect the current repeat value.\n\tconst repeatCheckedValue = ! (\n\t\trepeatValue === 'no-repeat' ||\n\t\t( currentValueForToggle === 'cover' && repeatValue === undefined )\n\t);\n\n\tconst hasValue = hasBackgroundSizeValue( style );\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: {\n\t\t\t\t\t...previousValue.style?.background,\n\t\t\t\t\tbackgroundRepeat: undefined,\n\t\t\t\t\tbackgroundSize: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\tconst updateBackgroundSize = ( next ) => {\n\t\t// When switching to 'contain' toggle the repeat off.\n\t\tlet nextRepeat = repeatValue;\n\n\t\tif ( next === 'contain' ) {\n\t\t\tnextRepeat = 'no-repeat';\n\t\t}\n\n\t\tif (\n\t\t\t( currentValueForToggle === 'cover' ||\n\t\t\t\tcurrentValueForToggle === 'contain' ) &&\n\t\t\tnext === 'auto'\n\t\t) {\n\t\t\tnextRepeat = undefined;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundRepeat: nextRepeat,\n\t\t\t\t\tbackgroundSize: next,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst updateBackgroundPosition = ( next ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundPosition: coordsToBackgroundPosition( next ),\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst toggleIsRepeated = () => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\tbackground: {\n\t\t\t\t\t...style?.background,\n\t\t\t\t\tbackgroundRepeat:\n\t\t\t\t\t\trepeatCheckedValue === true ? 'no-repeat' : undefined,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\treturn (\n\t\t<VStack\n\t\t\tas={ ToolsPanelItem }\n\t\t\tspacing={ 2 }\n\t\t\tclassName=\"single-column\"\n\t\t\thasValue={ () => hasValue }\n\t\t\tlabel={ __( 'Size' ) }\n\t\t\tonDeselect={ () => resetBackgroundSize( style, setAttributes ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<FocalPointPicker\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\turl={ style?.background?.backgroundImage?.url }\n\t\t\t\tvalue={ backgroundPositionToCoords(\n\t\t\t\t\tstyle?.background?.backgroundPosition\n\t\t\t\t) }\n\t\t\t\tonChange={ updateBackgroundPosition }\n\t\t\t/>\n\t\t\t<ToggleGroupControl\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\tvalue={ currentValueForToggle }\n\t\t\t\tonChange={ updateBackgroundSize }\n\t\t\t\tisBlock\n\t\t\t\thelp={ backgroundSizeHelpText( sizeValue ) }\n\t\t\t>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'cover' }\n\t\t\t\t\tvalue={ 'cover' }\n\t\t\t\t\tlabel={ __( 'Cover' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'contain' }\n\t\t\t\t\tvalue={ 'contain' }\n\t\t\t\t\tlabel={ __( 'Contain' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fixed' }\n\t\t\t\t\tvalue={ 'auto' }\n\t\t\t\t\tlabel={ __( 'Fixed' ) }\n\t\t\t\t/>\n\t\t\t</ToggleGroupControl>\n\t\t\t{ sizeValue !== undefined &&\n\t\t\tsizeValue !== 'cover' &&\n\t\t\tsizeValue !== 'contain' ? (\n\t\t\t\t<UnitControl\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonChange={ updateBackgroundSize }\n\t\t\t\t\tvalue={ sizeValue }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t\t{ currentValueForToggle !== 'cover' && (\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Repeat' ) }\n\t\t\t\t\tchecked={ repeatCheckedValue }\n\t\t\t\t\tonChange={ toggleIsRepeated }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nexport function BackgroundImagePanel( props ) {\n\tconst [ backgroundImage, backgroundSize ] = useSettings(\n\t\t'background.backgroundImage',\n\t\t'background.backgroundSize'\n\t);\n\n\tif (\n\t\t! backgroundImage ||\n\t\t! hasBackgroundSupport( props.name, 'backgroundImage' )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst showBackgroundSize = !! (\n\t\tbackgroundSize && hasBackgroundSupport( props.name, 'backgroundSize' )\n\t);\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<InspectorControls group=\"background\">\n\t\t\t<BackgroundImagePanelItem\n\t\t\t\tisShownByDefault={ defaultControls?.backgroundImage }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t\t{ showBackgroundSize && (\n\t\t\t\t<BackgroundSizePanelItem\n\t\t\t\t\tisShownByDefault={ defaultControls?.backgroundSize }\n\t\t\t\t\t{ ...props }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\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,aAAa,EACbC,gCAAgC,IAAIC,kBAAkB,EACtDC,sCAAsC,IAAIC,wBAAwB,EAClEC,4BAA4B,IAAIC,cAAc,EAC9CC,yBAAyB,IAAIC,WAAW,EACxCC,oBAAoB,IAAIC,MAAM,EAC9BC,QAAQ,EACRC,QAAQ,EACRC,gBAAgB,EAChBC,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;;AAE5C;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,kCAAkC;AAChE,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASN,KAAK,IAAIO,gBAAgB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