@wordpress/block-editor 15.23.0 → 16.0.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 +33 -0
- package/build/autocompleters/block.cjs +10 -2
- package/build/autocompleters/block.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +0 -2
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-canvas/index.cjs +6 -1
- package/build/components/block-canvas/index.cjs.map +2 -2
- package/build/components/block-controls/groups.cjs +3 -1
- package/build/components/block-controls/groups.cjs.map +2 -2
- package/build/components/block-edit/edit.cjs +10 -18
- package/build/components/block-edit/edit.cjs.map +2 -2
- package/build/components/block-inspector/edit-contents.cjs +3 -0
- package/build/components/block-inspector/edit-contents.cjs.map +3 -3
- package/build/components/block-inspector/index.cjs +2 -3
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-invalid-warning.cjs +8 -19
- package/build/components/block-list/block-invalid-warning.cjs.map +2 -2
- package/build/components/block-list/block.cjs +9 -3
- package/build/components/block-list/block.cjs.map +3 -3
- package/build/components/block-list/index.cjs +1 -3
- package/build/components/block-list/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs +3 -1
- package/build/components/block-list/use-block-props/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs +9 -4
- package/build/components/block-list/use-block-props/use-focus-first-element.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-focus-handler.cjs +12 -4
- package/build/components/block-list/use-block-props/use-focus-handler.cjs.map +2 -2
- package/build/components/block-styles/use-styles-for-block.cjs +2 -1
- package/build/components/block-styles/use-styles-for-block.cjs.map +2 -2
- package/build/components/block-title/use-block-display-title.cjs +7 -2
- package/build/components/block-title/use-block-display-title.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +10 -14
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +43 -24
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-tools/index.cjs +7 -2
- package/build/components/block-tools/index.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +0 -1
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/block-visibility/modal.cjs +20 -6
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/block-visibility/use-block-visibility.cjs +16 -6
- package/build/components/block-visibility/use-block-visibility.cjs.map +3 -3
- package/build/components/block-visibility/utils.cjs +15 -2
- package/build/components/block-visibility/utils.cjs.map +3 -3
- package/build/components/block-visibility/viewport-menu-item.cjs +7 -1
- package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
- package/build/components/block-visibility/viewport-toolbar.cjs +5 -0
- package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs +5 -1
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +0 -6
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +5 -5
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +1 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +0 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/width-height-tool.cjs +2 -4
- package/build/components/dimensions-tool/width-height-tool.cjs.map +2 -2
- package/build/components/font-appearance-control/index.cjs +6 -25
- package/build/components/font-appearance-control/index.cjs.map +3 -3
- package/build/components/font-family/index.cjs +6 -15
- package/build/components/font-family/index.cjs.map +3 -3
- package/build/components/font-sizes/font-size-picker.cjs +1 -2
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +0 -1
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +0 -3
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/state-control-badges.cjs +39 -3
- package/build/components/global-styles/state-control-badges.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +4 -11
- package/build/components/global-styles/typography-panel.cjs.map +2 -2
- package/build/components/height-control/index.cjs +0 -2
- package/build/components/height-control/index.cjs.map +2 -2
- package/build/components/html-element-control/index.cjs +0 -1
- package/build/components/html-element-control/index.cjs.map +2 -2
- package/build/components/image-editor/index.cjs +5 -0
- package/build/components/image-editor/index.cjs.map +3 -3
- package/build/components/image-editor/zoom-dropdown.cjs +0 -1
- package/build/components/image-editor/zoom-dropdown.cjs.map +2 -2
- package/build/components/image-size-control/index.cjs +3 -7
- package/build/components/image-size-control/index.cjs.map +2 -2
- package/build/components/inner-content/index.cjs +107 -0
- package/build/components/inner-content/index.cjs.map +7 -0
- package/build/components/inserter/hooks/use-block-types-state.cjs +10 -2
- package/build/components/inserter/hooks/use-block-types-state.cjs.map +2 -2
- package/build/components/inserter/media-tab/hooks.cjs +67 -12
- package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-list.cjs +3 -1
- package/build/components/inserter/media-tab/media-list.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-panel.cjs +287 -28
- package/build/components/inserter/media-tab/media-panel.cjs.map +3 -3
- package/build/components/inserter/media-tab/media-preview.cjs +32 -17
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-tab.cjs +26 -6
- package/build/components/inserter/media-tab/media-tab.cjs.map +2 -2
- package/build/components/inserter/mobile-tab-navigation.cjs +6 -1
- package/build/components/inserter/mobile-tab-navigation.cjs.map +2 -2
- package/build/components/inserter/no-results.cjs +2 -2
- package/build/components/inserter/no-results.cjs.map +2 -2
- package/build/components/inserter/preview-panel.cjs +2 -1
- package/build/components/inserter/preview-panel.cjs.map +2 -2
- package/build/components/inserter-list-item/index.cjs +8 -2
- package/build/components/inserter-list-item/index.cjs.map +2 -2
- package/build/components/keyboard-shortcuts/index.cjs +19 -11
- package/build/components/keyboard-shortcuts/index.cjs.map +2 -2
- package/build/components/letter-spacing-control/index.cjs +0 -24
- package/build/components/letter-spacing-control/index.cjs.map +3 -3
- package/build/components/line-height-control/index.cjs +6 -22
- package/build/components/line-height-control/index.cjs.map +3 -3
- package/build/components/list-view/block-select-button.cjs +90 -84
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +61 -21
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/list-view/expander.cjs +1 -1
- package/build/components/list-view/expander.cjs.map +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs.map +2 -2
- package/build/components/media-placeholder/index.cjs +0 -1
- package/build/components/media-placeholder/index.cjs.map +2 -2
- package/build/components/observe-typing/index.cjs +4 -3
- package/build/components/observe-typing/index.cjs.map +2 -2
- package/build/components/preset-input-control/custom-value-controls.cjs +1 -3
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs +1 -3
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/resolution-tool/index.cjs +1 -2
- package/build/components/resolution-tool/index.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/before-input-rules.cjs +3 -4
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/delete.cjs +2 -3
- package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/enter.cjs +3 -2
- package/build/components/rich-text/event-listeners/enter.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-events.cjs +3 -3
- package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-rules.cjs +3 -4
- package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +3 -3
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/paste-handler.cjs +2 -1
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +3 -3
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/shortcuts.cjs +3 -3
- package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +3 -3
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
- package/build/components/rich-text/index.cjs +66 -17
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/text-alignment-control/index.cjs +0 -1
- package/build/components/text-alignment-control/index.cjs.map +2 -2
- package/build/components/text-decoration-control/index.cjs +0 -1
- package/build/components/text-decoration-control/index.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +0 -8
- package/build/components/text-indent-control/index.cjs.map +2 -2
- package/build/components/text-transform-control/index.cjs +0 -1
- package/build/components/text-transform-control/index.cjs.map +2 -2
- package/build/components/typewriter/index.cjs +129 -136
- package/build/components/typewriter/index.cjs.map +3 -3
- package/build/components/use-block-commands/index.cjs +21 -17
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -8
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/use-on-block-drop/index.cjs +3 -7
- package/build/components/use-on-block-drop/index.cjs.map +2 -2
- package/build/components/writing-flow/index.cjs +12 -1
- package/build/components/writing-flow/index.cjs.map +3 -3
- package/build/components/writing-flow/use-arrow-nav.cjs +18 -5
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-click-selection.cjs +2 -2
- package/build/components/writing-flow/use-click-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-clipboard-handler.cjs +4 -1
- package/build/components/writing-flow/use-clipboard-handler.cjs.map +2 -2
- package/build/components/writing-flow/use-drag-selection.cjs +3 -8
- package/build/components/writing-flow/use-drag-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-editable-root.cjs +112 -0
- package/build/components/writing-flow/use-editable-root.cjs.map +7 -0
- package/build/components/writing-flow/use-home-end.cjs +64 -0
- package/build/components/writing-flow/use-home-end.cjs.map +7 -0
- package/build/components/writing-flow/use-input.cjs +15 -5
- package/build/components/writing-flow/use-input.cjs.map +2 -2
- package/build/components/writing-flow/use-multi-selection.cjs +2 -2
- package/build/components/writing-flow/use-multi-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-select-all.cjs +14 -2
- package/build/components/writing-flow/use-select-all.cjs.map +2 -2
- package/build/components/writing-flow/use-selection-observer.cjs +126 -20
- package/build/components/writing-flow/use-selection-observer.cjs.map +3 -3
- package/build/components/writing-flow/utils.cjs +39 -2
- package/build/components/writing-flow/utils.cjs.map +2 -2
- package/build/components/writing-mode-control/index.cjs +0 -1
- package/build/components/writing-mode-control/index.cjs.map +2 -2
- package/build/hooks/background.cjs +3 -2
- package/build/hooks/background.cjs.map +2 -2
- package/build/hooks/block-fields/rich-text/index.cjs +2 -3
- package/build/hooks/block-fields/rich-text/index.cjs.map +3 -3
- package/build/hooks/elements.cjs +1 -1
- package/build/hooks/elements.cjs.map +2 -2
- package/build/hooks/font-size.cjs +1 -2
- package/build/hooks/font-size.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +5 -3
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +22 -12
- package/build/hooks/layout-child.cjs.map +3 -3
- package/build/hooks/layout.cjs +33 -16
- package/build/hooks/layout.cjs.map +3 -3
- package/build/hooks/position.cjs +36 -16
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/states.cjs +29 -12
- package/build/hooks/states.cjs.map +3 -3
- package/build/hooks/style.cjs +31 -9
- package/build/hooks/style.cjs.map +3 -3
- package/build/hooks/text-align.cjs +36 -6
- package/build/hooks/text-align.cjs.map +3 -3
- package/build/hooks/typography.cjs +1 -1
- package/build/hooks/typography.cjs.map +2 -2
- package/build/layouts/constrained.cjs +35 -27
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +27 -22
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/grid.cjs +51 -11
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +4 -1
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs +2 -2
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +3 -0
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +85 -6
- package/build/store/private-selectors.cjs.map +3 -3
- package/build/store/selectors.cjs +13 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/block-bindings.cjs +29 -0
- package/build/utils/block-bindings.cjs.map +2 -2
- package/build/utils/dom.cjs +14 -0
- package/build/utils/dom.cjs.map +2 -2
- package/build-module/autocompleters/block.mjs +10 -2
- package/build-module/autocompleters/block.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +0 -2
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-canvas/index.mjs +7 -2
- package/build-module/components/block-canvas/index.mjs.map +2 -2
- package/build-module/components/block-controls/groups.mjs +3 -1
- package/build-module/components/block-controls/groups.mjs.map +2 -2
- package/build-module/components/block-edit/edit.mjs +11 -18
- package/build-module/components/block-edit/edit.mjs.map +2 -2
- package/build-module/components/block-inspector/edit-contents.mjs +4 -1
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +2 -3
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-invalid-warning.mjs +8 -19
- package/build-module/components/block-list/block-invalid-warning.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +9 -3
- package/build-module/components/block-list/block.mjs.map +3 -3
- package/build-module/components/block-list/index.mjs +1 -3
- package/build-module/components/block-list/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/index.mjs +3 -1
- package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs +9 -4
- package/build-module/components/block-list/use-block-props/use-focus-first-element.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs +12 -4
- package/build-module/components/block-list/use-block-props/use-focus-handler.mjs.map +2 -2
- package/build-module/components/block-styles/use-styles-for-block.mjs +2 -1
- package/build-module/components/block-styles/use-styles-for-block.mjs.map +2 -2
- package/build-module/components/block-title/use-block-display-title.mjs +7 -2
- package/build-module/components/block-title/use-block-display-title.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +10 -14
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +43 -24
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-tools/index.mjs +7 -2
- package/build-module/components/block-tools/index.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +0 -1
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +22 -10
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/use-block-visibility.mjs +17 -7
- package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
- package/build-module/components/block-visibility/utils.mjs +18 -3
- package/build-module/components/block-visibility/utils.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-menu-item.mjs +7 -1
- package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-toolbar.mjs +5 -0
- package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +5 -1
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +0 -6
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +5 -5
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +1 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +0 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.mjs +2 -4
- package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
- package/build-module/components/font-appearance-control/index.mjs +6 -15
- package/build-module/components/font-appearance-control/index.mjs.map +2 -2
- package/build-module/components/font-family/index.mjs +6 -15
- package/build-module/components/font-family/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +1 -2
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +0 -1
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/state-control-badges.mjs +41 -5
- package/build-module/components/global-styles/state-control-badges.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +4 -11
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/height-control/index.mjs +0 -2
- package/build-module/components/height-control/index.mjs.map +2 -2
- package/build-module/components/html-element-control/index.mjs +0 -1
- package/build-module/components/html-element-control/index.mjs.map +2 -2
- package/build-module/components/image-editor/index.mjs +5 -0
- package/build-module/components/image-editor/index.mjs.map +2 -2
- package/build-module/components/image-editor/zoom-dropdown.mjs +0 -1
- package/build-module/components/image-editor/zoom-dropdown.mjs.map +2 -2
- package/build-module/components/image-size-control/index.mjs +3 -7
- package/build-module/components/image-size-control/index.mjs.map +2 -2
- package/build-module/components/inner-content/index.mjs +82 -0
- package/build-module/components/inner-content/index.mjs.map +7 -0
- package/build-module/components/inserter/hooks/use-block-types-state.mjs +10 -2
- package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/hooks.mjs +66 -12
- package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-list.mjs +3 -1
- package/build-module/components/inserter/media-tab/media-list.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-panel.mjs +297 -32
- package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs +33 -18
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.mjs +27 -7
- package/build-module/components/inserter/media-tab/media-tab.mjs.map +2 -2
- package/build-module/components/inserter/mobile-tab-navigation.mjs +6 -1
- package/build-module/components/inserter/mobile-tab-navigation.mjs.map +2 -2
- package/build-module/components/inserter/no-results.mjs +2 -2
- package/build-module/components/inserter/no-results.mjs.map +2 -2
- package/build-module/components/inserter/preview-panel.mjs +2 -1
- package/build-module/components/inserter/preview-panel.mjs.map +2 -2
- package/build-module/components/inserter-list-item/index.mjs +8 -2
- package/build-module/components/inserter-list-item/index.mjs.map +2 -2
- package/build-module/components/keyboard-shortcuts/index.mjs +19 -11
- package/build-module/components/keyboard-shortcuts/index.mjs.map +2 -2
- package/build-module/components/letter-spacing-control/index.mjs +0 -14
- package/build-module/components/letter-spacing-control/index.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +6 -12
- package/build-module/components/line-height-control/index.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +90 -84
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +61 -21
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/expander.mjs +1 -1
- package/build-module/components/list-view/expander.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs.map +2 -2
- package/build-module/components/media-placeholder/index.mjs +0 -1
- package/build-module/components/media-placeholder/index.mjs.map +2 -2
- package/build-module/components/observe-typing/index.mjs +4 -3
- package/build-module/components/observe-typing/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs +1 -3
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +1 -3
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/resolution-tool/index.mjs +1 -2
- package/build-module/components/resolution-tool/index.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +8 -5
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/delete.mjs +7 -4
- package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +8 -3
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-events.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs +8 -5
- package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs +8 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +3 -3
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +64 -13
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/text-alignment-control/index.mjs +0 -1
- package/build-module/components/text-alignment-control/index.mjs.map +2 -2
- package/build-module/components/text-decoration-control/index.mjs +0 -1
- package/build-module/components/text-decoration-control/index.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +0 -8
- package/build-module/components/text-indent-control/index.mjs.map +2 -2
- package/build-module/components/text-transform-control/index.mjs +0 -1
- package/build-module/components/text-transform-control/index.mjs.map +2 -2
- package/build-module/components/typewriter/index.mjs +129 -136
- package/build-module/components/typewriter/index.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +21 -17
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -8
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/use-on-block-drop/index.mjs +4 -7
- package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +12 -1
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +19 -6
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-click-selection.mjs +2 -2
- package/build-module/components/writing-flow/use-click-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-clipboard-handler.mjs +5 -2
- package/build-module/components/writing-flow/use-clipboard-handler.mjs.map +2 -2
- package/build-module/components/writing-flow/use-drag-selection.mjs +1 -6
- package/build-module/components/writing-flow/use-drag-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-editable-root.mjs +86 -0
- package/build-module/components/writing-flow/use-editable-root.mjs.map +7 -0
- package/build-module/components/writing-flow/use-home-end.mjs +43 -0
- package/build-module/components/writing-flow/use-home-end.mjs.map +7 -0
- package/build-module/components/writing-flow/use-input.mjs +15 -5
- package/build-module/components/writing-flow/use-input.mjs.map +2 -2
- package/build-module/components/writing-flow/use-multi-selection.mjs +2 -2
- package/build-module/components/writing-flow/use-multi-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-select-all.mjs +19 -3
- package/build-module/components/writing-flow/use-select-all.mjs.map +2 -2
- package/build-module/components/writing-flow/use-selection-observer.mjs +128 -19
- package/build-module/components/writing-flow/use-selection-observer.mjs.map +2 -2
- package/build-module/components/writing-flow/utils.mjs +35 -1
- package/build-module/components/writing-flow/utils.mjs.map +2 -2
- package/build-module/components/writing-mode-control/index.mjs +0 -1
- package/build-module/components/writing-mode-control/index.mjs.map +2 -2
- package/build-module/hooks/background.mjs +3 -2
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/rich-text/index.mjs +2 -6
- package/build-module/hooks/block-fields/rich-text/index.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +1 -1
- package/build-module/hooks/elements.mjs.map +2 -2
- package/build-module/hooks/font-size.mjs +1 -2
- package/build-module/hooks/font-size.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +5 -3
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +22 -12
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +32 -16
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/position.mjs +38 -18
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/states.mjs +29 -12
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +40 -11
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/text-align.mjs +39 -10
- package/build-module/hooks/text-align.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +1 -1
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +35 -27
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +27 -22
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +52 -11
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +5 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs +3 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +2 -0
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +84 -6
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +13 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/block-bindings.mjs +28 -0
- package/build-module/utils/block-bindings.mjs.map +2 -2
- package/build-module/utils/dom.mjs +13 -0
- package/build-module/utils/dom.mjs.map +2 -2
- package/build-style/content-rtl.css +15 -14
- package/build-style/content.css +15 -14
- package/build-style/default-editor-styles-rtl.css +1 -1
- package/build-style/default-editor-styles.css +1 -1
- package/build-style/style-rtl.css +144 -47
- package/build-style/style.css +144 -47
- package/build-types/components/block-context/index.d.ts +7 -0
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/build-types/utils/block-bindings.d.ts +19 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -1
- package/build-types/utils/dom.d.ts +11 -0
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/get-px-from-css-unit.d.ts +2 -2
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -1
- package/build-types/utils/pasting.d.ts +1 -1
- package/build-types/utils/pasting.d.ts.map +1 -1
- package/package.json +46 -44
- package/src/autocompleters/block.js +10 -3
- package/src/autocompleters/test/block.js +53 -0
- package/src/components/background-image-control/index.js +0 -2
- package/src/components/block-canvas/index.js +9 -2
- package/src/components/block-card/style.scss +1 -1
- package/src/components/block-controls/groups.js +2 -0
- package/src/components/block-edit/edit.js +13 -31
- package/src/components/block-inspector/edit-contents.js +5 -1
- package/src/components/block-inspector/index.js +3 -2
- package/src/components/block-list/block-invalid-warning.js +8 -19
- package/src/components/block-list/block.js +6 -0
- package/src/components/block-list/index.js +0 -2
- package/src/components/block-list/use-block-props/index.js +2 -0
- package/src/components/block-list/use-block-props/use-focus-first-element.js +23 -4
- package/src/components/block-list/use-block-props/use-focus-handler.js +34 -9
- package/src/components/block-lock/style.scss +1 -1
- package/src/components/block-manager/style.scss +1 -1
- package/src/components/block-navigation/style.scss +1 -1
- package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/block-quick-navigation/style.scss +1 -3
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-styles/use-styles-for-block.js +1 -0
- package/src/components/block-title/use-block-display-title.js +7 -2
- package/src/components/block-toolbar/block-toolbar-icon.js +11 -16
- package/src/components/block-toolbar/index.js +41 -18
- package/src/components/block-toolbar/test/block-toolbar-icon.js +32 -9
- package/src/components/block-tools/index.js +7 -0
- package/src/components/block-types-list/style.scss +0 -1
- package/src/components/block-variation-transforms/index.js +0 -1
- package/src/components/block-visibility/modal.js +24 -10
- package/src/components/block-visibility/style.scss +1 -1
- package/src/components/block-visibility/test/use-block-visibility.js +128 -35
- package/src/components/block-visibility/test/utils.js +11 -0
- package/src/components/block-visibility/use-block-visibility.js +33 -11
- package/src/components/block-visibility/utils.js +31 -6
- package/src/components/block-visibility/viewport-menu-item.js +10 -1
- package/src/components/block-visibility/viewport-toolbar.js +6 -0
- package/src/components/block-visibility/viewport-visibility-info.js +5 -1
- package/src/components/button-block-appender/content.scss +1 -7
- package/src/components/child-layout-control/index.js +0 -6
- package/src/components/color-palette/test/__snapshots__/control.js.snap +13 -108
- package/src/components/colors-gradients/control.js +4 -4
- package/src/components/colors-gradients/style.scss +2 -2
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/dimensions-tool/aspect-ratio-tool.js +0 -1
- package/src/components/dimensions-tool/scale-tool.js +0 -1
- package/src/components/dimensions-tool/width-height-tool.js +0 -2
- package/src/components/font-appearance-control/index.js +6 -19
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +6 -19
- package/src/components/font-family/stories/index.story.jsx +1 -2
- package/src/components/font-sizes/font-size-picker.js +0 -1
- package/src/components/global-styles/border-panel.js +0 -1
- package/src/components/global-styles/dimensions-panel.js +0 -3
- package/src/components/global-styles/state-control-badges.js +45 -6
- package/src/components/global-styles/style.scss +5 -0
- package/src/components/global-styles/test/state-control-badges.js +65 -0
- package/src/components/global-styles/typography-panel.js +0 -7
- package/src/components/height-control/index.js +0 -2
- package/src/components/html-element-control/index.js +0 -1
- package/src/components/iframe/content.scss +3 -3
- package/src/components/image-editor/index.js +22 -0
- package/src/components/image-editor/zoom-dropdown.js +0 -1
- package/src/components/image-size-control/index.js +0 -4
- package/src/components/inner-content/index.js +119 -0
- package/src/components/inner-content/test/index.js +81 -0
- package/src/components/inserter/hooks/use-block-types-state.js +10 -2
- package/src/components/inserter/media-tab/hooks.js +114 -16
- package/src/components/inserter/media-tab/media-list.js +2 -0
- package/src/components/inserter/media-tab/media-panel.js +354 -19
- package/src/components/inserter/media-tab/media-preview.js +34 -17
- package/src/components/inserter/media-tab/media-tab.js +20 -2
- package/src/components/inserter/media-tab/test/hooks.js +267 -0
- package/src/components/inserter/media-tab/test/media-panel.js +127 -0
- package/src/components/inserter/mobile-tab-navigation.js +6 -1
- package/src/components/inserter/no-results.js +2 -2
- package/src/components/inserter/preview-panel.js +1 -0
- package/src/components/inserter/style.scss +115 -3
- package/src/components/inserter-list-item/index.js +8 -2
- package/src/components/inserter-list-item/style.scss +0 -15
- package/src/components/keyboard-shortcuts/index.js +28 -11
- package/src/components/letter-spacing-control/README.md +0 -8
- package/src/components/letter-spacing-control/index.js +5 -23
- package/src/components/letter-spacing-control/stories/index.story.jsx +0 -12
- package/src/components/line-height-control/README.md +0 -8
- package/src/components/line-height-control/index.js +6 -16
- package/src/components/line-height-control/stories/index.story.jsx +0 -1
- package/src/components/line-height-control/test/index.js +1 -7
- package/src/components/link-control/style.scss +2 -2
- package/src/components/link-control/test/index.js +6 -6
- package/src/components/link-picker/style.scss +1 -2
- package/src/components/link-picker/test/index.js +3 -1
- package/src/components/list-view/block-select-button.js +5 -1
- package/src/components/list-view/block.js +69 -23
- package/src/components/list-view/expander.js +5 -1
- package/src/components/list-view/style.scss +23 -5
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/media-placeholder/index.js +0 -1
- package/src/components/multi-selection-inspector/style.scss +1 -1
- package/src/components/observe-typing/index.js +9 -4
- package/src/components/preset-input-control/custom-value-controls.js +0 -2
- package/src/components/preset-input-control/index.js +0 -2
- package/src/components/resolution-tool/index.js +0 -1
- package/src/components/responsive-block-control/style.scss +1 -1
- package/src/components/responsive-block-control/test/index.js +1 -5
- package/src/components/rich-text/event-listeners/before-input-rules.js +8 -5
- package/src/components/rich-text/event-listeners/delete.js +7 -4
- package/src/components/rich-text/event-listeners/enter.js +10 -4
- package/src/components/rich-text/event-listeners/input-events.js +4 -3
- package/src/components/rich-text/event-listeners/input-rules.js +8 -5
- package/src/components/rich-text/event-listeners/insert-replacement-text.js +4 -3
- package/src/components/rich-text/event-listeners/paste-handler.js +15 -3
- package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +4 -3
- package/src/components/rich-text/event-listeners/shortcuts.js +4 -3
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +4 -3
- package/src/components/rich-text/index.js +94 -25
- package/src/components/skip-to-selected-block/style.scss +1 -1
- package/src/components/text-alignment-control/index.js +0 -1
- package/src/components/text-decoration-control/index.js +0 -1
- package/src/components/text-indent-control/index.js +7 -16
- package/src/components/text-transform-control/index.js +0 -1
- package/src/components/typewriter/index.js +228 -224
- package/src/components/use-block-commands/index.js +27 -17
- package/src/components/use-block-display-information/index.js +9 -13
- package/src/components/use-block-display-information/test/index.js +47 -9
- package/src/components/use-on-block-drop/index.js +4 -7
- package/src/components/writing-flow/index.js +15 -1
- package/src/components/writing-flow/use-arrow-nav.js +39 -12
- package/src/components/writing-flow/use-click-selection.js +2 -3
- package/src/components/writing-flow/use-clipboard-handler.js +5 -2
- package/src/components/writing-flow/use-drag-selection.js +1 -14
- package/src/components/writing-flow/use-editable-root.js +182 -0
- package/src/components/writing-flow/use-home-end.js +63 -0
- package/src/components/writing-flow/use-input.js +25 -8
- package/src/components/writing-flow/use-multi-selection.js +2 -3
- package/src/components/writing-flow/use-select-all.js +33 -3
- package/src/components/writing-flow/use-selection-observer.js +197 -38
- package/src/components/writing-flow/utils.js +83 -0
- package/src/components/writing-mode-control/index.js +0 -1
- package/src/hooks/background.js +7 -9
- package/src/hooks/block-fields/link/styles.scss +1 -6
- package/src/hooks/block-fields/media/styles.scss +1 -6
- package/src/hooks/block-fields/rich-text/index.js +6 -9
- package/src/hooks/block-hooks.scss +15 -0
- package/src/hooks/elements.js +0 -1
- package/src/hooks/font-size.js +0 -1
- package/src/hooks/grid-visualizer.js +40 -36
- package/src/hooks/layout-child.js +19 -9
- package/src/hooks/layout.js +53 -35
- package/src/hooks/position.js +44 -23
- package/src/hooks/states.js +36 -13
- package/src/hooks/style.js +67 -17
- package/src/hooks/test/cross-origin-isolation.js +0 -4
- package/src/hooks/test/layout.js +75 -1
- package/src/hooks/test/style.js +29 -0
- package/src/hooks/test/text-align.js +34 -1
- package/src/hooks/text-align.js +41 -10
- package/src/hooks/typography.js +0 -1
- package/src/layouts/constrained.js +56 -29
- package/src/layouts/flex.js +5 -4
- package/src/layouts/grid.js +59 -9
- package/src/layouts/test/constrained.js +91 -0
- package/src/layouts/test/grid.js +71 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +43 -14
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +166 -9
- package/src/store/selectors.js +41 -0
- package/src/store/test/actions.js +1 -1
- package/src/store/test/private-selectors.js +533 -0
- package/src/store/test/reducer.js +11 -11
- package/src/store/test/selectors.js +133 -0
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +50 -0
- package/src/utils/dom.ts +33 -0
- package/src/utils/test/block-bindings.js +181 -0
- package/build/components/rich-text/input-event.cjs +0 -50
- package/build/components/rich-text/input-event.cjs.map +0 -7
- package/build/components/rich-text/shortcut.cjs +0 -51
- package/build/components/rich-text/shortcut.cjs.map +0 -7
- package/build-module/components/rich-text/input-event.mjs +0 -25
- package/build-module/components/rich-text/input-event.mjs.map +0 -7
- package/build-module/components/rich-text/shortcut.mjs +0 -26
- package/build-module/components/rich-text/shortcut.mjs.map +0 -7
- package/src/components/rich-text/input-event.js +0 -31
- package/src/components/rich-text/shortcut.js +0 -32
|
@@ -13,7 +13,6 @@ import useBlockDisplayTitle from "../block-title/use-block-display-title.mjs";
|
|
|
13
13
|
import { store as blockEditorStore } from "../../store/index.mjs";
|
|
14
14
|
import { hasPatternOverridesDefaultBinding } from "../../utils/block-bindings.mjs";
|
|
15
15
|
import { unlock } from "../../lock-unlock.mjs";
|
|
16
|
-
import { isIsolatedEditorKey } from "../../store/private-keys.mjs";
|
|
17
16
|
import { jsx } from "react/jsx-runtime";
|
|
18
17
|
function getBlockIconVariant({ select, clientIds }) {
|
|
19
18
|
const {
|
|
@@ -24,11 +23,9 @@ function getBlockIconVariant({ select, clientIds }) {
|
|
|
24
23
|
getTemplateLock,
|
|
25
24
|
getBlockEditingMode,
|
|
26
25
|
canEditBlock,
|
|
27
|
-
|
|
28
|
-
getSettings
|
|
26
|
+
isSectionBlock
|
|
29
27
|
} = unlock(select(blockEditorStore));
|
|
30
28
|
const { getBlockStyles } = select(blocksStore);
|
|
31
|
-
const isIsolatedEditor = !!getSettings()?.[isIsolatedEditorKey];
|
|
32
29
|
const hasTemplateLock = clientIds.some(
|
|
33
30
|
(id) => getTemplateLock(id) === "contentOnly"
|
|
34
31
|
);
|
|
@@ -36,7 +33,7 @@ function getBlockIconVariant({ select, clientIds }) {
|
|
|
36
33
|
const blockName = isSingleBlock && getBlockName(clientIds[0]);
|
|
37
34
|
const hasBlockStyles = isSingleBlock && !!getBlockStyles(blockName)?.length;
|
|
38
35
|
const hasPatternNameInSelection = clientIds.some(
|
|
39
|
-
(id) => !!getBlockAttributes(id)?.metadata?.patternName &&
|
|
36
|
+
(id) => !!getBlockAttributes(id)?.metadata?.patternName && isSectionBlock(id)
|
|
40
37
|
);
|
|
41
38
|
const hasPatternOverrides = clientIds.every(
|
|
42
39
|
(clientId) => hasPatternOverridesDefaultBinding(
|
|
@@ -64,24 +61,23 @@ function getBlockIconVariant({ select, clientIds }) {
|
|
|
64
61
|
return "default";
|
|
65
62
|
}
|
|
66
63
|
function getBlockIcon({ select, clientIds }) {
|
|
67
|
-
const {
|
|
68
|
-
getBlockName,
|
|
69
|
-
getBlockAttributes,
|
|
70
|
-
isWithinEditedContentOnlySection,
|
|
71
|
-
getSettings
|
|
72
|
-
} = unlock(select(blockEditorStore));
|
|
73
|
-
const isIsolatedEditor = !!getSettings()?.[isIsolatedEditorKey];
|
|
64
|
+
const { getBlockName, getBlockAttributes, getBlock, isSectionBlock } = unlock(select(blockEditorStore));
|
|
74
65
|
const _isSingleBlock = clientIds.length === 1;
|
|
75
66
|
const firstClientId = clientIds[0];
|
|
76
67
|
const blockAttributes = getBlockAttributes(firstClientId);
|
|
77
|
-
if (_isSingleBlock && blockAttributes?.metadata?.patternName &&
|
|
68
|
+
if (_isSingleBlock && blockAttributes?.metadata?.patternName && isSectionBlock(firstClientId)) {
|
|
78
69
|
return symbol;
|
|
79
70
|
}
|
|
80
71
|
const blockName = getBlockName(firstClientId);
|
|
81
72
|
const blockType = getBlockType(blockName);
|
|
82
73
|
if (_isSingleBlock) {
|
|
83
74
|
const { getActiveBlockVariation } = select(blocksStore);
|
|
84
|
-
const match = getActiveBlockVariation(
|
|
75
|
+
const match = getActiveBlockVariation(
|
|
76
|
+
blockName,
|
|
77
|
+
blockAttributes,
|
|
78
|
+
void 0,
|
|
79
|
+
getBlock?.(firstClientId)?.innerContent
|
|
80
|
+
);
|
|
85
81
|
return match?.icon || blockType?.icon;
|
|
86
82
|
}
|
|
87
83
|
const blockNames = clientIds.map((id) => getBlockName(id));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-toolbar/block-toolbar-icon.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ToolbarButton } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { copy, symbol } from '@wordpress/icons';\nimport { getBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport BlockSwitcher from '../block-switcher';\nimport BlockIcon from '../block-icon';\nimport BlockStylesDropdown from './block-styles-dropdown';\nimport PatternOverridesDropdown from './pattern-overrides-dropdown';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport { store as blockEditorStore } from '../../store';\nimport { hasPatternOverridesDefaultBinding } from '../../utils/block-bindings';\nimport { unlock } from '../../lock-unlock';\
|
|
5
|
-
"mappings": ";AAGA,SAAS,qBAAqB;AAC9B,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,cAAc;AAC7B,SAAS,cAAc,SAAS,mBAAmB;AACnD,SAAS,SAAS,wBAAwB;AAK1C,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,OAAO,yBAAyB;AAChC,OAAO,8BAA8B;AACrC,OAAO,0BAA0B;AACjC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,yCAAyC;AAClD,SAAS,cAAc;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { ToolbarButton } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { copy, symbol } from '@wordpress/icons';\nimport { getBlockType, store as blocksStore } from '@wordpress/blocks';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport BlockSwitcher from '../block-switcher';\nimport BlockIcon from '../block-icon';\nimport BlockStylesDropdown from './block-styles-dropdown';\nimport PatternOverridesDropdown from './pattern-overrides-dropdown';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport { store as blockEditorStore } from '../../store';\nimport { hasPatternOverridesDefaultBinding } from '../../utils/block-bindings';\nimport { unlock } from '../../lock-unlock';\n\nfunction getBlockIconVariant( { select, clientIds } ) {\n\tconst {\n\t\tgetBlockName,\n\t\tgetBlockAttributes,\n\t\tgetBlockParentsByBlockName,\n\t\tcanRemoveBlocks,\n\t\tgetTemplateLock,\n\t\tgetBlockEditingMode,\n\t\tcanEditBlock,\n\t\tisSectionBlock,\n\t} = unlock( select( blockEditorStore ) );\n\tconst { getBlockStyles } = select( blocksStore );\n\n\tconst hasTemplateLock = clientIds.some(\n\t\t( id ) => getTemplateLock( id ) === 'contentOnly'\n\t);\n\n\t// Calculate props only used in this function\n\tconst isSingleBlock = clientIds.length === 1;\n\tconst blockName = isSingleBlock && getBlockName( clientIds[ 0 ] );\n\tconst hasBlockStyles =\n\t\tisSingleBlock && !! getBlockStyles( blockName )?.length;\n\tconst hasPatternNameInSelection = clientIds.some(\n\t\t( id ) =>\n\t\t\t!! getBlockAttributes( id )?.metadata?.patternName &&\n\t\t\tisSectionBlock( id )\n\t);\n\tconst hasPatternOverrides = clientIds.every( ( clientId ) =>\n\t\thasPatternOverridesDefaultBinding(\n\t\t\tgetBlockAttributes( clientId )?.metadata?.bindings\n\t\t)\n\t);\n\tconst hasParentPattern = clientIds.every(\n\t\t( clientId ) =>\n\t\t\tgetBlockParentsByBlockName( clientId, 'core/block', true ).length >\n\t\t\t0\n\t);\n\tconst canRemove = canRemoveBlocks( clientIds );\n\tconst canEdit = clientIds.every( ( clientId ) => canEditBlock( clientId ) );\n\tconst editingMode = getBlockEditingMode( clientIds[ 0 ] );\n\tconst isDefaultEditingMode = editingMode === 'default';\n\tconst isContentOnlyMode = editingMode === 'contentOnly';\n\tconst _hideTransformsForSections = hasPatternNameInSelection;\n\tconst _showBlockSwitcher =\n\t\t! _hideTransformsForSections &&\n\t\tisDefaultEditingMode &&\n\t\t( hasBlockStyles || canRemove ) &&\n\t\t! hasTemplateLock &&\n\t\tcanEdit;\n\n\tconst _showPatternOverrides = hasPatternOverrides && hasParentPattern;\n\n\tif ( _showBlockSwitcher ) {\n\t\treturn 'switcher';\n\t} else if (\n\t\tisContentOnlyMode &&\n\t\thasBlockStyles &&\n\t\t! hasPatternOverrides &&\n\t\tcanEdit\n\t) {\n\t\treturn 'styles-only';\n\t} else if ( _showPatternOverrides ) {\n\t\treturn 'pattern-overrides';\n\t}\n\n\treturn 'default';\n}\n\nfunction getBlockIcon( { select, clientIds } ) {\n\tconst { getBlockName, getBlockAttributes, getBlock, isSectionBlock } =\n\t\tunlock( select( blockEditorStore ) );\n\n\tconst _isSingleBlock = clientIds.length === 1;\n\tconst firstClientId = clientIds[ 0 ];\n\n\tconst blockAttributes = getBlockAttributes( firstClientId );\n\tif (\n\t\t_isSingleBlock &&\n\t\tblockAttributes?.metadata?.patternName &&\n\t\tisSectionBlock( firstClientId )\n\t) {\n\t\treturn symbol;\n\t}\n\n\tconst blockName = getBlockName( firstClientId );\n\tconst blockType = getBlockType( blockName );\n\tif ( _isSingleBlock ) {\n\t\tconst { getActiveBlockVariation } = select( blocksStore );\n\t\tconst match = getActiveBlockVariation(\n\t\t\tblockName,\n\t\t\tblockAttributes,\n\t\t\tundefined,\n\t\t\tgetBlock?.( firstClientId )?.innerContent\n\t\t);\n\t\treturn match?.icon || blockType?.icon;\n\t}\n\n\tconst blockNames = clientIds.map( ( id ) => getBlockName( id ) );\n\tconst isSelectionOfSameType = new Set( blockNames ).size === 1;\n\treturn isSelectionOfSameType ? blockType?.icon : copy;\n}\n\nexport default function BlockToolbarIcon( { clientIds, isSynced } ) {\n\tconst { icon, showIconLabels, variant } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\ticon: getBlockIcon( { select, clientIds } ),\n\t\t\t\tshowIconLabels: select( preferencesStore ).get(\n\t\t\t\t\t'core',\n\t\t\t\t\t'showIconLabels'\n\t\t\t\t),\n\t\t\t\tvariant: getBlockIconVariant( {\n\t\t\t\t\tselect,\n\t\t\t\t\tclientIds,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId: clientIds?.[ 0 ],\n\t\tmaximumLength: 35,\n\t} );\n\n\tconst isSingleBlock = clientIds.length === 1;\n\tconst showBlockTitle = isSingleBlock && isSynced && ! showIconLabels;\n\tconst label = isSingleBlock ? blockTitle : __( 'Multiple blocks selected' );\n\t// Used to hide the block icon when the showIconLabels preference is enabled, or to display the template title when it's a template.\n\tconst text = showBlockTitle && blockTitle ? blockTitle : undefined;\n\n\tconst BlockIconElement = (\n\t\t<BlockIcon\n\t\t\tclassName=\"block-editor-block-toolbar__block-icon\"\n\t\t\ticon={ icon }\n\t\t/>\n\t);\n\n\tif ( variant === 'switcher' ) {\n\t\treturn (\n\t\t\t<BlockSwitcher\n\t\t\t\tclientIds={ clientIds }\n\t\t\t\tlabel={ label }\n\t\t\t\ttext={ text }\n\t\t\t>\n\t\t\t\t{ BlockIconElement }\n\t\t\t</BlockSwitcher>\n\t\t);\n\t}\n\n\tif ( variant === 'styles-only' ) {\n\t\treturn (\n\t\t\t<BlockStylesDropdown\n\t\t\t\tclientIds={ clientIds }\n\t\t\t\tlabel={ label }\n\t\t\t\ttext={ text }\n\t\t\t>\n\t\t\t\t{ BlockIconElement }\n\t\t\t</BlockStylesDropdown>\n\t\t);\n\t}\n\n\tif ( variant === 'pattern-overrides' ) {\n\t\treturn (\n\t\t\t<PatternOverridesDropdown\n\t\t\t\ticon={ BlockIconElement }\n\t\t\t\tclientIds={ clientIds }\n\t\t\t\tblockTitle={ blockTitle }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<ToolbarButton\n\t\t\tdisabled\n\t\t\tclassName=\"block-editor-block-toolbar__block-icon-button\"\n\t\t\ttitle={ label }\n\t\t\ticon={ BlockIconElement }\n\t\t\ttext={ text }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,qBAAqB;AAC9B,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,MAAM,cAAc;AAC7B,SAAS,cAAc,SAAS,mBAAmB;AACnD,SAAS,SAAS,wBAAwB;AAK1C,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,OAAO,yBAAyB;AAChC,OAAO,8BAA8B;AACrC,OAAO,0BAA0B;AACjC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,yCAAyC;AAClD,SAAS,cAAc;AAsIrB;AApIF,SAAS,oBAAqB,EAAE,QAAQ,UAAU,GAAI;AACrD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,OAAQ,OAAQ,gBAAiB,CAAE;AACvC,QAAM,EAAE,eAAe,IAAI,OAAQ,WAAY;AAE/C,QAAM,kBAAkB,UAAU;AAAA,IACjC,CAAE,OAAQ,gBAAiB,EAAG,MAAM;AAAA,EACrC;AAGA,QAAM,gBAAgB,UAAU,WAAW;AAC3C,QAAM,YAAY,iBAAiB,aAAc,UAAW,CAAE,CAAE;AAChE,QAAM,iBACL,iBAAiB,CAAC,CAAE,eAAgB,SAAU,GAAG;AAClD,QAAM,4BAA4B,UAAU;AAAA,IAC3C,CAAE,OACD,CAAC,CAAE,mBAAoB,EAAG,GAAG,UAAU,eACvC,eAAgB,EAAG;AAAA,EACrB;AACA,QAAM,sBAAsB,UAAU;AAAA,IAAO,CAAE,aAC9C;AAAA,MACC,mBAAoB,QAAS,GAAG,UAAU;AAAA,IAC3C;AAAA,EACD;AACA,QAAM,mBA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MAAO;AAAA,MACP;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -30,6 +30,7 @@ import EditSectionButton from "./edit-section-button.mjs";
|
|
|
30
30
|
import { unlock } from "../../lock-unlock.mjs";
|
|
31
31
|
import { deviceTypeKey } from "../../store/private-keys.mjs";
|
|
32
32
|
import BlockToolbarIcon from "./block-toolbar-icon.mjs";
|
|
33
|
+
import { hasViewportBlockStyleState } from "../../hooks/block-style-state.mjs";
|
|
33
34
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
34
35
|
function PrivateBlockToolbar({
|
|
35
36
|
hideDragHandle,
|
|
@@ -56,6 +57,7 @@ function PrivateBlockToolbar({
|
|
|
56
57
|
showBlockVisibilityButton,
|
|
57
58
|
showSwitchSectionStyleButton,
|
|
58
59
|
areSelectedBlocksHiddenOnViewport,
|
|
60
|
+
showStyleStateSlot,
|
|
59
61
|
canEdit
|
|
60
62
|
} = useSelect((select) => {
|
|
61
63
|
const { canEditBlock } = select(blockEditorStore);
|
|
@@ -72,7 +74,9 @@ function PrivateBlockToolbar({
|
|
|
72
74
|
getParentSectionBlock,
|
|
73
75
|
isZoomOut,
|
|
74
76
|
isSectionBlock,
|
|
75
|
-
isBlockHiddenAtViewport
|
|
77
|
+
isBlockHiddenAtViewport,
|
|
78
|
+
getSelectedBlockStyleState,
|
|
79
|
+
isResponsiveEditing
|
|
76
80
|
} = unlock(select(blockEditorStore));
|
|
77
81
|
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
78
82
|
const selectedBlockClientId = selectedBlockClientIds[0];
|
|
@@ -104,6 +108,9 @@ function PrivateBlockToolbar({
|
|
|
104
108
|
const _areSelectedBlocksHiddenOnViewport = selectedBlockClientIds.length > 0 && selectedBlockClientIds.every(
|
|
105
109
|
(id) => isBlockHiddenAtViewport(id, _currentDeviceType)
|
|
106
110
|
);
|
|
111
|
+
const _isEditingResponsiveStyleState = isResponsiveEditing() && hasViewportBlockStyleState(
|
|
112
|
+
getSelectedBlockStyleState(selectedBlockClientId)
|
|
113
|
+
);
|
|
107
114
|
return {
|
|
108
115
|
blockClientId: selectedBlockClientId,
|
|
109
116
|
blockClientIds: selectedBlockClientIds,
|
|
@@ -120,7 +127,8 @@ function PrivateBlockToolbar({
|
|
|
120
127
|
isSectionContainer: _isSectionBlock,
|
|
121
128
|
hasContentOnlyLocking: _hasTemplateLock,
|
|
122
129
|
showShuffleButton: _isZoomOut,
|
|
123
|
-
showSlots: !_isZoomOut,
|
|
130
|
+
showSlots: !_isZoomOut && !_isEditingResponsiveStyleState,
|
|
131
|
+
showStyleStateSlot: !_isZoomOut && _isEditingResponsiveStyleState,
|
|
124
132
|
showGroupButtons: !_isZoomOut,
|
|
125
133
|
showLockButtons: !_isZoomOut,
|
|
126
134
|
showBlockVisibilityButton: !_isZoomOut,
|
|
@@ -192,39 +200,50 @@ function PrivateBlockToolbar({
|
|
|
192
200
|
!isMultiToolbar && canEdit && /* @__PURE__ */ jsx(EditSectionButton, { clientId: blockClientIds[0] }),
|
|
193
201
|
!areSelectedBlocksHiddenOnViewport && showShuffleButton && /* @__PURE__ */ jsx(ChangeDesign, { clientId: blockClientIds[0] }),
|
|
194
202
|
!areSelectedBlocksHiddenOnViewport && showSwitchSectionStyleButton && /* @__PURE__ */ jsx(SwitchSectionStyle, { clientId: blockClientIds[0] }),
|
|
195
|
-
!areSelectedBlocksHiddenOnViewport && shouldShowVisualToolbar &&
|
|
203
|
+
!areSelectedBlocksHiddenOnViewport && shouldShowVisualToolbar && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
196
204
|
!isSectionContainer && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
197
|
-
/* @__PURE__ */
|
|
205
|
+
showSlots && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
206
|
+
/* @__PURE__ */ jsx(
|
|
207
|
+
BlockControls.Slot,
|
|
208
|
+
{
|
|
209
|
+
group: "parent",
|
|
210
|
+
className: "block-editor-block-toolbar__slot"
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
/* @__PURE__ */ jsx(
|
|
214
|
+
BlockControls.Slot,
|
|
215
|
+
{
|
|
216
|
+
group: "block",
|
|
217
|
+
className: "block-editor-block-toolbar__slot"
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
/* @__PURE__ */ jsx(BlockControls.Slot, { className: "block-editor-block-toolbar__slot" }),
|
|
221
|
+
/* @__PURE__ */ jsx(
|
|
222
|
+
BlockControls.Slot,
|
|
223
|
+
{
|
|
224
|
+
group: "inline",
|
|
225
|
+
className: "block-editor-block-toolbar__slot"
|
|
226
|
+
}
|
|
227
|
+
)
|
|
228
|
+
] }),
|
|
229
|
+
showStyleStateSlot && /* @__PURE__ */ jsx(
|
|
198
230
|
BlockControls.Slot,
|
|
199
231
|
{
|
|
200
|
-
group: "
|
|
232
|
+
group: "style-state",
|
|
201
233
|
className: "block-editor-block-toolbar__slot"
|
|
202
234
|
}
|
|
203
|
-
)
|
|
235
|
+
)
|
|
236
|
+
] }),
|
|
237
|
+
showSlots && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
204
238
|
/* @__PURE__ */ jsx(
|
|
205
239
|
BlockControls.Slot,
|
|
206
240
|
{
|
|
207
|
-
group: "
|
|
241
|
+
group: "other",
|
|
208
242
|
className: "block-editor-block-toolbar__slot"
|
|
209
243
|
}
|
|
210
244
|
),
|
|
211
|
-
/* @__PURE__ */ jsx(
|
|
212
|
-
|
|
213
|
-
BlockControls.Slot,
|
|
214
|
-
{
|
|
215
|
-
group: "inline",
|
|
216
|
-
className: "block-editor-block-toolbar__slot"
|
|
217
|
-
}
|
|
218
|
-
)
|
|
219
|
-
] }),
|
|
220
|
-
/* @__PURE__ */ jsx(
|
|
221
|
-
BlockControls.Slot,
|
|
222
|
-
{
|
|
223
|
-
group: "other",
|
|
224
|
-
className: "block-editor-block-toolbar__slot"
|
|
225
|
-
}
|
|
226
|
-
),
|
|
227
|
-
/* @__PURE__ */ jsx(__unstableBlockToolbarLastItem.Slot, {})
|
|
245
|
+
/* @__PURE__ */ jsx(__unstableBlockToolbarLastItem.Slot, {})
|
|
246
|
+
] })
|
|
228
247
|
] }),
|
|
229
248
|
/* @__PURE__ */ jsx(BlockEditVisuallyButton, { clientIds: blockClientIds }),
|
|
230
249
|
/* @__PURE__ */ jsx(BlockSettingsMenu, { clientIds: blockClientIds })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-toolbar/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tgetBlockType,\n\thasBlockSupport,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { ToolbarGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\nimport BlockParentSelector from '../block-parent-selector';\nimport BlockControls from '../block-controls';\nimport __unstableBlockToolbarLastItem from './block-toolbar-last-item';\nimport BlockSettingsMenu from '../block-settings-menu';\nimport { BlockLockToolbar } from '../block-lock';\nimport { ViewportVisibilityToolbar } from '../block-visibility';\nimport { BlockGroupToolbar } from '../convert-to-group-buttons';\nimport BlockEditVisuallyButton from '../block-edit-visually-button';\nimport { useShowHoveredOrFocusedGestures } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport NavigableToolbar from '../navigable-toolbar';\nimport { useHasBlockToolbar } from './use-has-block-toolbar';\nimport ChangeDesign from './change-design';\nimport SwitchSectionStyle from './switch-section-style';\nimport EditSectionButton from './edit-section-button';\nimport { unlock } from '../../lock-unlock';\nimport { deviceTypeKey } from '../../store/private-keys';\nimport BlockToolbarIcon from './block-toolbar-icon';\n\n/**\n * Renders the block toolbar.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n *\n * @param {Object} props Components props.\n * @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.\n * @param {boolean} props.focusOnMount Focus the toolbar when mounted.\n * @param {number} props.__experimentalInitialIndex The initial index of the toolbar item to focus.\n * @param {Function} props.__experimentalOnIndexChange Callback function to be called when the index of the focused toolbar item changes.\n * @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.\n */\nexport function PrivateBlockToolbar( {\n\thideDragHandle,\n\tfocusOnMount,\n\t__experimentalInitialIndex,\n\t__experimentalOnIndexChange,\n\tvariant = 'unstyled',\n} ) {\n\tconst {\n\t\tblockClientId,\n\t\tblockClientIds,\n\t\tisDefaultEditingMode,\n\t\tblockType,\n\t\ttoolbarKey,\n\t\tshouldShowVisualToolbar,\n\t\tshowParentSelector,\n\t\tisUsingBindings,\n\t\tisSectionContainer,\n\t\thasContentOnlyLocking,\n\t\tshowShuffleButton,\n\t\tshowSlots,\n\t\tshowGroupButtons,\n\t\tshowLockButtons,\n\t\tshowBlockVisibilityButton,\n\t\tshowSwitchSectionStyleButton,\n\t\tareSelectedBlocksHiddenOnViewport,\n\t\tcanEdit,\n\t} = useSelect( ( select ) => {\n\t\tconst { canEditBlock } = select( blockEditorStore );\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockMode,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisBlockValid,\n\t\t\tgetBlockEditingMode,\n\t\t\tgetBlockAttributes,\n\t\t\tgetSettings,\n\t\t\tgetTemplateLock,\n\t\t\tgetParentSectionBlock,\n\t\t\tisZoomOut,\n\t\t\tisSectionBlock,\n\t\t\tisBlockHiddenAtViewport,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst parents = getBlockParents( selectedBlockClientId );\n\t\tconst parentSection = getParentSectionBlock( selectedBlockClientId );\n\t\tconst parentClientId = parentSection ?? parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\t\tconst editingMode = getBlockEditingMode( selectedBlockClientId );\n\t\tconst _isDefaultEditingMode = editingMode === 'default';\n\t\tconst _blockName = getBlockName( selectedBlockClientId );\n\t\tconst isValid = selectedBlockClientIds.every( ( id ) =>\n\t\t\tisBlockValid( id )\n\t\t);\n\t\tconst isVisual = selectedBlockClientIds.every(\n\t\t\t( id ) => getBlockMode( id ) === 'visual'\n\t\t);\n\t\tconst _isUsingBindings = selectedBlockClientIds.every(\n\t\t\t( clientId ) =>\n\t\t\t\t!! getBlockAttributes( clientId )?.metadata?.bindings\n\t\t);\n\n\t\t// If one or more selected blocks are locked, do not show the BlockGroupToolbar.\n\t\tconst _hasTemplateLock = selectedBlockClientIds.some(\n\t\t\t( id ) => getTemplateLock( id ) === 'contentOnly'\n\t\t);\n\n\t\tconst _isZoomOut = isZoomOut();\n\t\tconst _isSectionBlock = isSectionBlock( selectedBlockClientId );\n\t\tconst _canEditBlock = canEditBlock( selectedBlockClientId );\n\t\tconst _showSwitchSectionStyleButton =\n\t\t\t_canEditBlock && ( _isZoomOut || _isSectionBlock );\n\n\t\tconst _currentDeviceType =\n\t\t\tgetSettings()?.[ deviceTypeKey ]?.toLowerCase() || 'desktop';\n\t\tconst _areSelectedBlocksHiddenOnViewport =\n\t\t\tselectedBlockClientIds.length > 0 &&\n\t\t\tselectedBlockClientIds.every( ( id ) =>\n\t\t\t\tisBlockHiddenAtViewport( id, _currentDeviceType )\n\t\t\t);\n\n\t\treturn {\n\t\t\tblockClientId: selectedBlockClientId,\n\t\t\tblockClientIds: selectedBlockClientIds,\n\t\t\tisDefaultEditingMode: _isDefaultEditingMode,\n\t\t\tblockType: selectedBlockClientId && getBlockType( _blockName ),\n\t\t\tshouldShowVisualToolbar: isValid && isVisual,\n\t\t\ttoolbarKey: `${ selectedBlockClientId }${ parentClientId }`,\n\t\t\tshowParentSelector:\n\t\t\t\t! _isZoomOut &&\n\t\t\t\tparentBlockType &&\n\t\t\t\teditingMode !== 'contentOnly' &&\n\t\t\t\tgetBlockEditingMode( parentClientId ) !== 'disabled' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length === 1,\n\t\t\tisUsingBindings: _isUsingBindings,\n\t\t\tisSectionContainer: _isSectionBlock,\n\t\t\thasContentOnlyLocking: _hasTemplateLock,\n\t\t\tshowShuffleButton: _isZoomOut,\n\t\t\tshowSlots: ! _isZoomOut,\n\t\t\tshowGroupButtons: ! _isZoomOut,\n\t\t\tshowLockButtons: ! _isZoomOut,\n\t\t\tshowBlockVisibilityButton: ! _isZoomOut,\n\t\t\tshowSwitchSectionStyleButton: _showSwitchSectionStyleButton,\n\t\t\tareSelectedBlocksHiddenOnViewport:\n\t\t\t\t_areSelectedBlocksHiddenOnViewport,\n\t\t\tcanEdit: _canEditBlock,\n\t\t};\n\t}, [] );\n\n\tconst toolbarWrapperRef = useRef( null );\n\n\t// Handles highlighting the current block outline on hover or focus of the\n\t// block type toolbar area.\n\tconst nodeRef = useRef();\n\tconst showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures( {\n\t\tref: nodeRef,\n\t} );\n\n\tconst isLargeViewport = ! useViewportMatch( 'medium', '<' );\n\n\tconst hasBlockToolbar = useHasBlockToolbar();\n\tif ( ! hasBlockToolbar ) {\n\t\treturn null;\n\t}\n\n\tconst isMultiToolbar = blockClientIds.length > 1;\n\tconst isSynced =\n\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = clsx( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': showParentSelector,\n\t} );\n\n\tconst innerClasses = clsx( 'block-editor-block-toolbar', {\n\t\t'is-synced': isSynced,\n\t\t'is-connected': isUsingBindings,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusEditorOnEscape\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t// The variant is applied as \"toolbar\" when undefined, which is the black border style of the dropdown from the toolbar popover.\n\t\t\tvariant={ variant === 'toolbar' ? undefined : variant }\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\t__experimentalInitialIndex={ __experimentalInitialIndex }\n\t\t\t__experimentalOnIndexChange={ __experimentalOnIndexChange }\n\t\t\t// Resets the index whenever the active block changes so\n\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\tkey={ toolbarKey }\n\t\t>\n\t\t\t<div ref={ toolbarWrapperRef } className={ innerClasses }>\n\t\t\t\t{ showParentSelector && ! isMultiToolbar && isLargeViewport && (\n\t\t\t\t\t<BlockParentSelector />\n\t\t\t\t) }\n\t\t\t\t{ ( shouldShowVisualToolbar || isMultiToolbar ) && (\n\t\t\t\t\t<div ref={ nodeRef } { ...showHoveredOrFocusedGestures }>\n\t\t\t\t\t\t<ToolbarGroup className=\"block-editor-block-toolbar__block-controls\">\n\t\t\t\t\t\t\t<BlockToolbarIcon\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\tisSynced={ isSynced }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isDefaultEditingMode &&\n\t\t\t\t\t\t\t\tshowBlockVisibilityButton && (\n\t\t\t\t\t\t\t\t\t<ViewportVisibilityToolbar\n\t\t\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ! isMultiToolbar &&\n\t\t\t\t\t\t\t\tisDefaultEditingMode &&\n\t\t\t\t\t\t\t\tshowLockButtons && (\n\t\t\t\t\t\t\t\t\t<BlockLockToolbar\n\t\t\t\t\t\t\t\t\t\tclientId={ blockClientId }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<BlockMover\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\thideDragHandle={ hideDragHandle }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t{ ! areSelectedBlocksHiddenOnViewport &&\n\t\t\t\t\t! hasContentOnlyLocking &&\n\t\t\t\t\tshouldShowVisualToolbar &&\n\t\t\t\t\tisMultiToolbar &&\n\t\t\t\t\tshowGroupButtons && <BlockGroupToolbar /> }\n\t\t\t\t{ ! isMultiToolbar && canEdit && (\n\t\t\t\t\t<EditSectionButton clientId={ blockClientIds[ 0 ] } />\n\t\t\t\t) }\n\t\t\t\t{ ! areSelectedBlocksHiddenOnViewport && showShuffleButton && (\n\t\t\t\t\t<ChangeDesign clientId={ blockClientIds[ 0 ] } />\n\t\t\t\t) }\n\t\t\t\t{ ! areSelectedBlocksHiddenOnViewport &&\n\t\t\t\t\tshowSwitchSectionStyleButton && (\n\t\t\t\t\t\t<SwitchSectionStyle clientId={ blockClientIds[ 0 ] } />\n\t\t\t\t\t) }\n\t\t\t\t{ ! areSelectedBlocksHiddenOnViewport &&\n\t\t\t\t\tshouldShowVisualToolbar &&\n\t\t\t\t\tshowSlots && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isSectionContainer && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\t\tgroup=\"parent\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<BlockControls.Slot className=\"block-editor-block-toolbar__slot\" />\n\t\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\t\tgroup=\"inline\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\tgroup=\"other\"\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<__unstableBlockToolbarLastItem.Slot />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t<BlockEditVisuallyButton clientIds={ blockClientIds } />\n\t\t\t\t<BlockSettingsMenu clientIds={ blockClientIds } />\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\n/**\n * Renders the block toolbar.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n *\n * @param {Object} props Components props.\n * @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.\n * @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.\n */\nexport default function BlockToolbar( { hideDragHandle, variant } ) {\n\treturn (\n\t\t<PrivateBlockToolbar\n\t\t\thideDragHandle={ hideDragHandle }\n\t\t\tvariant={ variant }\n\t\t\tfocusOnMount={ undefined }\n\t\t\t__experimentalInitialIndex={ undefined }\n\t\t\t__experimentalOnIndexChange={ undefined }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oBAAoB;AAK7B,OAAO,gBAAgB;AACvB,OAAO,yBAAyB;AAChC,OAAO,mBAAmB;AAC1B,OAAO,oCAAoC;AAC3C,OAAO,uBAAuB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,iCAAiC;AAC1C,SAAS,yBAAyB;AAClC,OAAO,6BAA6B;AACpC,SAAS,uCAAuC;AAChD,SAAS,SAAS,wBAAwB;AAC1C,OAAO,sBAAsB;AAC7B,SAAS,0BAA0B;AACnC,OAAO,kBAAkB;AACzB,OAAO,wBAAwB;AAC/B,OAAO,uBAAuB;AAC9B,SAAS,cAAc;AACvB,SAAS,qBAAqB;AAC9B,OAAO,sBAAsB;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { useRef } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tgetBlockType,\n\thasBlockSupport,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { ToolbarGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockMover from '../block-mover';\nimport BlockParentSelector from '../block-parent-selector';\nimport BlockControls from '../block-controls';\nimport __unstableBlockToolbarLastItem from './block-toolbar-last-item';\nimport BlockSettingsMenu from '../block-settings-menu';\nimport { BlockLockToolbar } from '../block-lock';\nimport { ViewportVisibilityToolbar } from '../block-visibility';\nimport { BlockGroupToolbar } from '../convert-to-group-buttons';\nimport BlockEditVisuallyButton from '../block-edit-visually-button';\nimport { useShowHoveredOrFocusedGestures } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport NavigableToolbar from '../navigable-toolbar';\nimport { useHasBlockToolbar } from './use-has-block-toolbar';\nimport ChangeDesign from './change-design';\nimport SwitchSectionStyle from './switch-section-style';\nimport EditSectionButton from './edit-section-button';\nimport { unlock } from '../../lock-unlock';\nimport { deviceTypeKey } from '../../store/private-keys';\nimport BlockToolbarIcon from './block-toolbar-icon';\nimport { hasViewportBlockStyleState } from '../../hooks/block-style-state';\n\n/**\n * Renders the block toolbar.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n *\n * @param {Object} props Components props.\n * @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.\n * @param {boolean} props.focusOnMount Focus the toolbar when mounted.\n * @param {number} props.__experimentalInitialIndex The initial index of the toolbar item to focus.\n * @param {Function} props.__experimentalOnIndexChange Callback function to be called when the index of the focused toolbar item changes.\n * @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.\n */\nexport function PrivateBlockToolbar( {\n\thideDragHandle,\n\tfocusOnMount,\n\t__experimentalInitialIndex,\n\t__experimentalOnIndexChange,\n\tvariant = 'unstyled',\n} ) {\n\tconst {\n\t\tblockClientId,\n\t\tblockClientIds,\n\t\tisDefaultEditingMode,\n\t\tblockType,\n\t\ttoolbarKey,\n\t\tshouldShowVisualToolbar,\n\t\tshowParentSelector,\n\t\tisUsingBindings,\n\t\tisSectionContainer,\n\t\thasContentOnlyLocking,\n\t\tshowShuffleButton,\n\t\tshowSlots,\n\t\tshowGroupButtons,\n\t\tshowLockButtons,\n\t\tshowBlockVisibilityButton,\n\t\tshowSwitchSectionStyleButton,\n\t\tareSelectedBlocksHiddenOnViewport,\n\t\tshowStyleStateSlot,\n\t\tcanEdit,\n\t} = useSelect( ( select ) => {\n\t\tconst { canEditBlock } = select( blockEditorStore );\n\t\tconst {\n\t\t\tgetBlockName,\n\t\t\tgetBlockMode,\n\t\t\tgetBlockParents,\n\t\t\tgetSelectedBlockClientIds,\n\t\t\tisBlockValid,\n\t\t\tgetBlockEditingMode,\n\t\t\tgetBlockAttributes,\n\t\t\tgetSettings,\n\t\t\tgetTemplateLock,\n\t\t\tgetParentSectionBlock,\n\t\t\tisZoomOut,\n\t\t\tisSectionBlock,\n\t\t\tisBlockHiddenAtViewport,\n\t\t\tgetSelectedBlockStyleState,\n\t\t\tisResponsiveEditing,\n\t\t} = unlock( select( blockEditorStore ) );\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst selectedBlockClientId = selectedBlockClientIds[ 0 ];\n\t\tconst parents = getBlockParents( selectedBlockClientId );\n\t\tconst parentSection = getParentSectionBlock( selectedBlockClientId );\n\t\tconst parentClientId = parentSection ?? parents[ parents.length - 1 ];\n\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\tconst parentBlockType = getBlockType( parentBlockName );\n\t\tconst editingMode = getBlockEditingMode( selectedBlockClientId );\n\t\tconst _isDefaultEditingMode = editingMode === 'default';\n\t\tconst _blockName = getBlockName( selectedBlockClientId );\n\t\tconst isValid = selectedBlockClientIds.every( ( id ) =>\n\t\t\tisBlockValid( id )\n\t\t);\n\t\tconst isVisual = selectedBlockClientIds.every(\n\t\t\t( id ) => getBlockMode( id ) === 'visual'\n\t\t);\n\t\tconst _isUsingBindings = selectedBlockClientIds.every(\n\t\t\t( clientId ) =>\n\t\t\t\t!! getBlockAttributes( clientId )?.metadata?.bindings\n\t\t);\n\n\t\t// If one or more selected blocks are locked, do not show the BlockGroupToolbar.\n\t\tconst _hasTemplateLock = selectedBlockClientIds.some(\n\t\t\t( id ) => getTemplateLock( id ) === 'contentOnly'\n\t\t);\n\n\t\tconst _isZoomOut = isZoomOut();\n\t\tconst _isSectionBlock = isSectionBlock( selectedBlockClientId );\n\t\tconst _canEditBlock = canEditBlock( selectedBlockClientId );\n\t\tconst _showSwitchSectionStyleButton =\n\t\t\t_canEditBlock && ( _isZoomOut || _isSectionBlock );\n\n\t\tconst _currentDeviceType =\n\t\t\tgetSettings()?.[ deviceTypeKey ]?.toLowerCase() || 'desktop';\n\t\tconst _areSelectedBlocksHiddenOnViewport =\n\t\t\tselectedBlockClientIds.length > 0 &&\n\t\t\tselectedBlockClientIds.every( ( id ) =>\n\t\t\t\tisBlockHiddenAtViewport( id, _currentDeviceType )\n\t\t\t);\n\t\tconst _isEditingResponsiveStyleState =\n\t\t\tisResponsiveEditing() &&\n\t\t\thasViewportBlockStyleState(\n\t\t\t\tgetSelectedBlockStyleState( selectedBlockClientId )\n\t\t\t);\n\n\t\treturn {\n\t\t\tblockClientId: selectedBlockClientId,\n\t\t\tblockClientIds: selectedBlockClientIds,\n\t\t\tisDefaultEditingMode: _isDefaultEditingMode,\n\t\t\tblockType: selectedBlockClientId && getBlockType( _blockName ),\n\t\t\tshouldShowVisualToolbar: isValid && isVisual,\n\t\t\ttoolbarKey: `${ selectedBlockClientId }${ parentClientId }`,\n\t\t\tshowParentSelector:\n\t\t\t\t! _isZoomOut &&\n\t\t\t\tparentBlockType &&\n\t\t\t\teditingMode !== 'contentOnly' &&\n\t\t\t\tgetBlockEditingMode( parentClientId ) !== 'disabled' &&\n\t\t\t\thasBlockSupport(\n\t\t\t\t\tparentBlockType,\n\t\t\t\t\t'__experimentalParentSelector',\n\t\t\t\t\ttrue\n\t\t\t\t) &&\n\t\t\t\tselectedBlockClientIds.length === 1,\n\t\t\tisUsingBindings: _isUsingBindings,\n\t\t\tisSectionContainer: _isSectionBlock,\n\t\t\thasContentOnlyLocking: _hasTemplateLock,\n\t\t\tshowShuffleButton: _isZoomOut,\n\t\t\tshowSlots: ! _isZoomOut && ! _isEditingResponsiveStyleState,\n\t\t\tshowStyleStateSlot: ! _isZoomOut && _isEditingResponsiveStyleState,\n\t\t\tshowGroupButtons: ! _isZoomOut,\n\t\t\tshowLockButtons: ! _isZoomOut,\n\t\t\tshowBlockVisibilityButton: ! _isZoomOut,\n\t\t\tshowSwitchSectionStyleButton: _showSwitchSectionStyleButton,\n\t\t\tareSelectedBlocksHiddenOnViewport:\n\t\t\t\t_areSelectedBlocksHiddenOnViewport,\n\t\t\tcanEdit: _canEditBlock,\n\t\t};\n\t}, [] );\n\n\tconst toolbarWrapperRef = useRef( null );\n\n\t// Handles highlighting the current block outline on hover or focus of the\n\t// block type toolbar area.\n\tconst nodeRef = useRef();\n\tconst showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures( {\n\t\tref: nodeRef,\n\t} );\n\n\tconst isLargeViewport = ! useViewportMatch( 'medium', '<' );\n\n\tconst hasBlockToolbar = useHasBlockToolbar();\n\tif ( ! hasBlockToolbar ) {\n\t\treturn null;\n\t}\n\n\tconst isMultiToolbar = blockClientIds.length > 1;\n\tconst isSynced =\n\t\tisReusableBlock( blockType ) || isTemplatePart( blockType );\n\n\t// Shifts the toolbar to make room for the parent block selector.\n\tconst classes = clsx( 'block-editor-block-contextual-toolbar', {\n\t\t'has-parent': showParentSelector,\n\t} );\n\n\tconst innerClasses = clsx( 'block-editor-block-toolbar', {\n\t\t'is-synced': isSynced,\n\t\t'is-connected': isUsingBindings,\n\t} );\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tfocusEditorOnEscape\n\t\t\tclassName={ classes }\n\t\t\t/* translators: accessibility text for the block toolbar */\n\t\t\taria-label={ __( 'Block tools' ) }\n\t\t\t// The variant is applied as \"toolbar\" when undefined, which is the black border style of the dropdown from the toolbar popover.\n\t\t\tvariant={ variant === 'toolbar' ? undefined : variant }\n\t\t\tfocusOnMount={ focusOnMount }\n\t\t\t__experimentalInitialIndex={ __experimentalInitialIndex }\n\t\t\t__experimentalOnIndexChange={ __experimentalOnIndexChange }\n\t\t\t// Resets the index whenever the active block changes so\n\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\tkey={ toolbarKey }\n\t\t>\n\t\t\t<div ref={ toolbarWrapperRef } className={ innerClasses }>\n\t\t\t\t{ showParentSelector && ! isMultiToolbar && isLargeViewport && (\n\t\t\t\t\t<BlockParentSelector />\n\t\t\t\t) }\n\t\t\t\t{ ( shouldShowVisualToolbar || isMultiToolbar ) && (\n\t\t\t\t\t<div ref={ nodeRef } { ...showHoveredOrFocusedGestures }>\n\t\t\t\t\t\t<ToolbarGroup className=\"block-editor-block-toolbar__block-controls\">\n\t\t\t\t\t\t\t<BlockToolbarIcon\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\tisSynced={ isSynced }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isDefaultEditingMode &&\n\t\t\t\t\t\t\t\tshowBlockVisibilityButton && (\n\t\t\t\t\t\t\t\t\t<ViewportVisibilityToolbar\n\t\t\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ ! isMultiToolbar &&\n\t\t\t\t\t\t\t\tisDefaultEditingMode &&\n\t\t\t\t\t\t\t\tshowLockButtons && (\n\t\t\t\t\t\t\t\t\t<BlockLockToolbar\n\t\t\t\t\t\t\t\t\t\tclientId={ blockClientId }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t<BlockMover\n\t\t\t\t\t\t\t\tclientIds={ blockClientIds }\n\t\t\t\t\t\t\t\thideDragHandle={ hideDragHandle }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t{ ! areSelectedBlocksHiddenOnViewport &&\n\t\t\t\t\t! hasContentOnlyLocking &&\n\t\t\t\t\tshouldShowVisualToolbar &&\n\t\t\t\t\tisMultiToolbar &&\n\t\t\t\t\tshowGroupButtons && <BlockGroupToolbar /> }\n\t\t\t\t{ ! isMultiToolbar && canEdit && (\n\t\t\t\t\t<EditSectionButton clientId={ blockClientIds[ 0 ] } />\n\t\t\t\t) }\n\t\t\t\t{ ! areSelectedBlocksHiddenOnViewport && showShuffleButton && (\n\t\t\t\t\t<ChangeDesign clientId={ blockClientIds[ 0 ] } />\n\t\t\t\t) }\n\t\t\t\t{ ! areSelectedBlocksHiddenOnViewport &&\n\t\t\t\t\tshowSwitchSectionStyleButton && (\n\t\t\t\t\t\t<SwitchSectionStyle clientId={ blockClientIds[ 0 ] } />\n\t\t\t\t\t) }\n\t\t\t\t{ ! areSelectedBlocksHiddenOnViewport &&\n\t\t\t\t\tshouldShowVisualToolbar && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{ ! isSectionContainer && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ showSlots && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\t\t\t\tgroup=\"parent\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\t\t\t\tgroup=\"block\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<BlockControls.Slot className=\"block-editor-block-toolbar__slot\" />\n\t\t\t\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\t\t\t\tgroup=\"inline\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ showStyleStateSlot && (\n\t\t\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\t\t\tgroup=\"style-state\"\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ showSlots && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<BlockControls.Slot\n\t\t\t\t\t\t\t\t\t\tgroup=\"other\"\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-toolbar__slot\"\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<__unstableBlockToolbarLastItem.Slot />\n\t\t\t\t\t\t\t\t</>\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<BlockEditVisuallyButton clientIds={ blockClientIds } />\n\t\t\t\t<BlockSettingsMenu clientIds={ blockClientIds } />\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\n/**\n * Renders the block toolbar.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-toolbar/README.md\n *\n * @param {Object} props Components props.\n * @param {boolean} props.hideDragHandle Show or hide the Drag Handle for drag and drop functionality.\n * @param {string} props.variant Style variant of the toolbar, also passed to the Dropdowns rendered from Block Toolbar Buttons.\n */\nexport default function BlockToolbar( { hideDragHandle, variant } ) {\n\treturn (\n\t\t<PrivateBlockToolbar\n\t\t\thideDragHandle={ hideDragHandle }\n\t\t\tvariant={ variant }\n\t\t\tfocusOnMount={ undefined }\n\t\t\t__experimentalInitialIndex={ undefined }\n\t\t\t__experimentalOnIndexChange={ undefined }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,oBAAoB;AAK7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,+BAA+B,MAA/B,EAAoC;AAAA,aACtC;AAAA,WAEF;AAAA,QAEF,oBAAC,2BAAwB,WAAY,gBAAiB;AAAA,QACtD,oBAAC,qBAAkB,WAAY,gBAAiB;AAAA,SACjD;AAAA;AAAA,IA3FM;AAAA,EA4FP;AAEF;AAWe,SAAR,aAA+B,EAAE,gBAAgB,QAAQ,GAAI;AACnE,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAe;AAAA,MACf,4BAA6B;AAAA,MAC7B,6BAA8B;AAAA;AAAA,EAC/B;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -44,7 +44,8 @@ function selector(select) {
|
|
|
44
44
|
isTyping: isTyping(),
|
|
45
45
|
isZoomOutMode: isZoomOut(),
|
|
46
46
|
isDragging: isDragging(),
|
|
47
|
-
viewportModalClientIds: getViewportModalClientIds()
|
|
47
|
+
viewportModalClientIds: getViewportModalClientIds(),
|
|
48
|
+
blockVisibilitySetting: select(blockEditorStore).getSettings().__experimentalFeatures?.blockVisibility?.allowEditing
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
function BlockTools({
|
|
@@ -58,7 +59,8 @@ function BlockTools({
|
|
|
58
59
|
isTyping,
|
|
59
60
|
isZoomOutMode,
|
|
60
61
|
isDragging,
|
|
61
|
-
viewportModalClientIds
|
|
62
|
+
viewportModalClientIds,
|
|
63
|
+
blockVisibilitySetting
|
|
62
64
|
} = useSelect(selector, []);
|
|
63
65
|
const isMatch = useShortcutEventMatch();
|
|
64
66
|
const {
|
|
@@ -191,6 +193,9 @@ function BlockTools({
|
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
195
|
} else if (isMatch("core/block-editor/toggle-block-visibility", event)) {
|
|
196
|
+
if (blockVisibilitySetting === false) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
194
199
|
const clientIds = getSelectedBlockClientIds();
|
|
195
200
|
if (clientIds.length) {
|
|
196
201
|
event.preventDefault();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-tools/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef, useState } from '@wordpress/element';\nimport {\n\tswitchToBlockType,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\nimport usePasteStyles from '../use-paste-styles';\nimport { BlockRenameModal, useBlockRename } from '../block-rename';\nimport { BlockVisibilityModal } from '../block-visibility';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t\tgetViewportModalClientIds,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t\tviewportModalClientIds: getViewportModalClientIds(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst {\n\t\tclientId,\n\t\thasFixedToolbar,\n\t\tisTyping,\n\t\tisZoomOutMode,\n\t\tisDragging,\n\t\tviewportModalClientIds,\n\t} = useSelect( selector, [] );\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tgetBlockEditingMode,\n\t\tgetBlockName,\n\t\tisGroupable,\n\t\tgetEditedContentOnlySection,\n\t\tcanEditBlock,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\tconst pasteStyles = usePasteStyles();\n\tconst [ renamingBlockClientId, setRenamingBlockClientId ] =\n\t\tuseState( null );\n\n\tconst { canRename } = useBlockRename(\n\t\tgetBlockName( getSelectedBlockClientIds()[ 0 ] )\n\t);\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t\tstopEditingContentOnlySection,\n\t\tshowViewportModal,\n\t\thideViewportModal,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/move-up', event ) ||\n\t\t\tisMatch( 'core/block-editor/move-down', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tconst direction = isMatch( 'core/block-editor/move-up', event )\n\t\t\t\t\t? 'up'\n\t\t\t\t\t: 'down';\n\t\t\t\tif ( direction === 'up' ) {\n\t\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t\t} else {\n\t\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t\t}\n\t\t\t\tconst blockLength = Array.isArray( clientIds )\n\t\t\t\t\t? clientIds.length\n\t\t\t\t\t: 1;\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %d: the name of the block that has been moved\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d block moved.',\n\t\t\t\t\t\t'%d blocks moved.',\n\t\t\t\t\t\tclientIds.length\n\t\t\t\t\t),\n\t\t\t\t\tblockLength\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tpasteStyles( blocks );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/rename', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length === 1 ) {\n\t\t\t\tconst isContentOnly =\n\t\t\t\t\tgetBlockEditingMode( clientIds[ 0 ] ) === 'contentOnly';\n\t\t\t\tconst canRenameBlock =\n\t\t\t\t\tcanRename &&\n\t\t\t\t\t! isContentOnly &&\n\t\t\t\t\tcanEditBlock( clientIds[ 0 ] );\n\t\t\t\tif ( canRenameBlock ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tsetRenamingBlockClientId( clientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tisMatch( 'core/block-editor/toggle-block-visibility', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst supportsBlockVisibility = blocks.every( ( block ) =>\n\t\t\t\t\thasBlockSupport( block.name, 'visibility', true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! supportsBlockVisibility ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't allow visibility toggle for blocks that are not in the\n\t\t\t\t// default editing mode or when block editing is disabled\n\t\t\t\t// (e.g. Revisions UI with isPreviewMode).\n\t\t\t\tif (\n\t\t\t\t\tclientIds.some(\n\t\t\t\t\t\t( id ) =>\n\t\t\t\t\t\t\tgetBlockEditingMode( id ) !== 'default' ||\n\t\t\t\t\t\t\t! canEditBlock( id )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Open the visibility breakpoints modal.\n\t\t\t\tshowViewportModal( clientIds );\n\t\t\t}\n\t\t}\n\n\t\t// Has the same keyboard shortcut as 'unselect', so can't be within the\n\t\t// if/else chain above.\n\t\tif ( isMatch( 'core/block-editor/stop-editing-as-blocks', event ) ) {\n\t\t\tif ( getEditedContentOnlySection() ) {\n\t\t\t\tstopEditingContentOnlySection();\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\t// Popover slots cannot be unmounted during dragging because the\n\t\t\t// will just be rendered in a fallback popover slot instead.\n\t\t\tclassName={ clsx( props.className, {\n\t\t\t\t'block-editor-block-tools--is-dragging': isDragging,\n\t\t\t} ) }\n\t\t>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t\t{ renamingBlockClientId && (\n\t\t\t\t<BlockRenameModal\n\t\t\t\t\tclientId={ renamingBlockClientId }\n\t\t\t\t\tonClose={ () => setRenamingBlockClientId( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ viewportModalClientIds && (\n\t\t\t\t<BlockVisibilityModal\n\t\t\t\t\tclientIds={ viewportModalClientIds }\n\t\t\t\t\tonClose={ hideViewportModal }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,WAAW,mBAAmB;AACvC,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,mCAAmC,6BAA6B;AACzE,SAAS,QAAQ,gBAAgB;AACjC;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,aAAa;AACtB,SAAS,IAAI,SAAS,UAAU;AAKhC,OAAO,wBAAwB;AAC/B;AAAA,EACC;AAAA,EACA,WAAW;AAAA,OACL;AACP,OAAO,yBAAyB;AAChC,SAAS,SAAS,wBAAwB;AAC1C,OAAO,sBAAsB;AAC7B,OAAO,0BAA0B;AACjC,SAAS,yBAAyB;AAClC,SAAS,cAAc;AACvB,OAAO,oBAAoB;AAC3B,SAAS,kBAAkB,sBAAsB;AACjD,SAAS,4BAA4B;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { isTextField } from '@wordpress/dom';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef, useState } from '@wordpress/element';\nimport {\n\tswitchToBlockType,\n\thasBlockSupport,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { speak } from '@wordpress/a11y';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EmptyBlockInserter from './empty-block-inserter';\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport BlockToolbarPopover from './block-toolbar-popover';\nimport { store as blockEditorStore } from '../../store';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\nimport { useShowBlockTools } from './use-show-block-tools';\nimport { unlock } from '../../lock-unlock';\nimport usePasteStyles from '../use-paste-styles';\nimport { BlockRenameModal, useBlockRename } from '../block-rename';\nimport { BlockVisibilityModal } from '../block-visibility';\n\nfunction selector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetSettings,\n\t\tisTyping,\n\t\tisDragging,\n\t\tisZoomOut,\n\t\tgetViewportModalClientIds,\n\t} = unlock( select( blockEditorStore ) );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\treturn {\n\t\tclientId,\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t\tisZoomOutMode: isZoomOut(),\n\t\tisDragging: isDragging(),\n\t\tviewportModalClientIds: getViewportModalClientIds(),\n\t\tblockVisibilitySetting:\n\t\t\tselect( blockEditorStore ).getSettings().__experimentalFeatures\n\t\t\t\t?.blockVisibility?.allowEditing,\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst {\n\t\tclientId,\n\t\thasFixedToolbar,\n\t\tisTyping,\n\t\tisZoomOutMode,\n\t\tisDragging,\n\t\tviewportModalClientIds,\n\t\tblockVisibilitySetting,\n\t} = useSelect( selector, [] );\n\tconst isMatch = useShortcutEventMatch();\n\tconst {\n\t\tgetBlocksByClientId,\n\t\tgetSelectedBlockClientIds,\n\t\tgetBlockRootClientId,\n\t\tgetBlockEditingMode,\n\t\tgetBlockName,\n\t\tisGroupable,\n\t\tgetEditedContentOnlySection,\n\t\tcanEditBlock,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst { showEmptyBlockSideInserter, showBlockToolbarPopover } =\n\t\tuseShowBlockTools();\n\tconst pasteStyles = usePasteStyles();\n\tconst [ renamingBlockClientId, setRenamingBlockClientId ] =\n\t\tuseState( null );\n\n\tconst { canRename } = useBlockRename(\n\t\tgetBlockName( getSelectedBlockClientIds()[ 0 ] )\n\t);\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\treplaceBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tselectBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t\texpandBlock,\n\t\tstopEditingContentOnlySection,\n\t\tshowViewportModal,\n\t\thideViewportModal,\n\t} = unlock( useDispatch( blockEditorStore ) );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tisMatch( 'core/block-editor/move-up', event ) ||\n\t\t\tisMatch( 'core/block-editor/move-down', event )\n\t\t) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tconst direction = isMatch( 'core/block-editor/move-up', event )\n\t\t\t\t\t? 'up'\n\t\t\t\t\t: 'down';\n\t\t\t\tif ( direction === 'up' ) {\n\t\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t\t} else {\n\t\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t\t}\n\t\t\t\tconst blockLength = Array.isArray( clientIds )\n\t\t\t\t\t? clientIds.length\n\t\t\t\t\t: 1;\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %d: the name of the block that has been moved\n\t\t\t\t\t_n(\n\t\t\t\t\t\t'%d block moved.',\n\t\t\t\t\t\t'%d blocks moved.',\n\t\t\t\t\t\tclientIds.length\n\t\t\t\t\t),\n\t\t\t\t\tblockLength\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/paste-styles', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tpasteStyles( blocks );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tif ( event.target.closest( '[role=toolbar]' ) ) {\n\t\t\t\t// This shouldn't be necessary, but we have a combination of a few things all combining to create a situation where:\n\t\t\t\t// - Because the block toolbar uses createPortal to populate the block toolbar fills, we can't rely on the React event bubbling to hit the onKeyDown listener for the block toolbar\n\t\t\t\t// - Since we can't use the React tree, we use the DOM tree which _should_ handle the event bubbling correctly from a `createPortal` element.\n\t\t\t\t// - This bubbles via the React tree, which hits this `unselect` escape keypress before the block toolbar DOM event listener has access to it.\n\t\t\t\t// An alternative would be to remove the addEventListener on the navigableToolbar and use this event to handle it directly right here. That feels hacky too though.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// If there is more than one block selected, select the first\n\t\t\t\t// block so that focus is directed back to the beginning of the selection.\n\t\t\t\t// In effect, to the user this feels like deselecting the multi-selection.\n\t\t\t\tselectBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {\n\t\t\t// If focus is currently within a text field, such as a rich text block or other editable field,\n\t\t\t// skip collapsing the list view, and allow the keyboard shortcut to be handled by the text field.\n\t\t\t// This condition checks for both the active element and the active element within an iframed editor.\n\t\t\tif (\n\t\t\t\tisTextField( event.target ) ||\n\t\t\t\tisTextField(\n\t\t\t\t\tevent.target?.contentWindow?.document?.activeElement\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\t\t\texpandBlock( clientId );\n\t\t} else if ( isMatch( 'core/block-editor/group', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length > 1 && isGroupable( clientIds ) ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst groupingBlockName = getGroupingBlockName();\n\t\t\t\tconst newBlocks = switchToBlockType(\n\t\t\t\t\tblocks,\n\t\t\t\t\tgroupingBlockName\n\t\t\t\t);\n\t\t\t\treplaceBlocks( clientIds, newBlocks );\n\t\t\t\tspeak( __( 'Selected blocks are grouped.' ) );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/rename', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length === 1 ) {\n\t\t\t\tconst isContentOnly =\n\t\t\t\t\tgetBlockEditingMode( clientIds[ 0 ] ) === 'contentOnly';\n\t\t\t\tconst canRenameBlock =\n\t\t\t\t\tcanRename &&\n\t\t\t\t\t! isContentOnly &&\n\t\t\t\t\tcanEditBlock( clientIds[ 0 ] );\n\t\t\t\tif ( canRenameBlock ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tsetRenamingBlockClientId( clientIds[ 0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (\n\t\t\tisMatch( 'core/block-editor/toggle-block-visibility', event )\n\t\t) {\n\t\t\tif ( blockVisibilitySetting === false ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst blocks = getBlocksByClientId( clientIds );\n\t\t\t\tconst supportsBlockVisibility = blocks.every( ( block ) =>\n\t\t\t\t\thasBlockSupport( block.name, 'visibility', true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! supportsBlockVisibility ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Don't allow visibility toggle for blocks that are not in the\n\t\t\t\t// default editing mode or when block editing is disabled\n\t\t\t\t// (e.g. Revisions UI with isPreviewMode).\n\t\t\t\tif (\n\t\t\t\t\tclientIds.some(\n\t\t\t\t\t\t( id ) =>\n\t\t\t\t\t\t\tgetBlockEditingMode( id ) !== 'default' ||\n\t\t\t\t\t\t\t! canEditBlock( id )\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Open the visibility breakpoints modal.\n\t\t\t\tshowViewportModal( clientIds );\n\t\t\t}\n\t\t}\n\n\t\t// Has the same keyboard shortcut as 'unselect', so can't be within the\n\t\t// if/else chain above.\n\t\tif ( isMatch( 'core/block-editor/stop-editing-as-blocks', event ) ) {\n\t\t\tif ( getEditedContentOnlySection() ) {\n\t\t\t\tstopEditingContentOnlySection();\n\t\t\t}\n\t\t}\n\t}\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\t{ ...props }\n\t\t\tonKeyDown={ onKeyDown }\n\t\t\t// Popover slots cannot be unmounted during dragging because the\n\t\t\t// will just be rendered in a fallback popover slot instead.\n\t\t\tclassName={ clsx( props.className, {\n\t\t\t\t'block-editor-block-tools--is-dragging': isDragging,\n\t\t\t} ) }\n\t\t>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showEmptyBlockSideInserter && (\n\t\t\t\t\t<EmptyBlockInserter\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ showBlockToolbarPopover && (\n\t\t\t\t\t<BlockToolbarPopover\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisTyping={ isTyping }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ /* Used for the inline rich text toolbar. Until this toolbar is combined into BlockToolbar, someone implementing their own BlockToolbar will also need to use this to see the image caption toolbar. */ }\n\t\t\t\t{ ! isZoomOutMode && ! hasFixedToolbar && (\n\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && ! isDragging && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t\t{ renamingBlockClientId && (\n\t\t\t\t<BlockRenameModal\n\t\t\t\t\tclientId={ renamingBlockClientId }\n\t\t\t\t\tonClose={ () => setRenamingBlockClientId( null ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ viewportModalClientIds && (\n\t\t\t\t<BlockVisibilityModal\n\t\t\t\t\tclientIds={ viewportModalClientIds }\n\t\t\t\t\tonClose={ hideViewportModal }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,WAAW,mBAAmB;AACvC,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,mCAAmC,6BAA6B;AACzE,SAAS,QAAQ,gBAAgB;AACjC;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,OACH;AACP,SAAS,aAAa;AACtB,SAAS,IAAI,SAAS,UAAU;AAKhC,OAAO,wBAAwB;AAC/B;AAAA,EACC;AAAA,EACA,WAAW;AAAA,OACL;AACP,OAAO,yBAAyB;AAChC,SAAS,SAAS,wBAAwB;AAC1C,OAAO,sBAAsB;AAC7B,OAAO,0BAA0B;AACjC,SAAS,yBAAyB;AAClC,SAAS,cAAc;AACvB,OAAO,oBAAoB;AAC3B,SAAS,kBAAkB,sBAAsB;AACjD,SAAS,4BAA4B;AA+QlC,SAEE,KAFF;AA7QH,SAAS,SAAU,QAAS;AAC3B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,OAAQ,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AAAA,YACP;AAAA,YACE,iBAAiB,CAAE,cACpB;AAAA,cAAC;AAAA;AAAA,gBACA;AAAA;AAAA,YACD;AAAA,aAEF;AAAA,UACE,yBACD;AAAA,YAAC;AAAA;AAAA,cACA,UAAW;AAAA,cACX,SAAU,MAAM,yBAA0B,IAAK;AAAA;AAAA,UAChD;AAAA,UAEC,0BACD;AAAA,YAAC;AAAA;AAAA,cACA,WAAY;AAAA,cACZ,SAAU;AAAA;AAAA,UACX;AAAA;AAAA;AAAA,IAEF;AAAA;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-variation-transforms/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Menu } = unlock( componentsPrivateApis );\n\nfunction VariationsButtons( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<fieldset className={ className }>\n\t\t\t<VisuallyHidden render={ <legend /> }>\n\t\t\t\t{ __( 'Transform to variation' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tkey={ variation.name }\n\t\t\t\t\ticon={ <BlockIcon icon={ variation.icon } showColors /> }\n\t\t\t\t\tisPressed={ selectedValue === variation.name }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tselectedValue === variation.name\n\t\t\t\t\t\t\t? variation.title\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: Block or block variation name. */\n\t\t\t\t\t\t\t\t\t__( 'Transform to %s' ),\n\t\t\t\t\t\t\t\t\tvariation.title\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => onSelectVariation( variation.name ) }\n\t\t\t\t\taria-label={ variation.title }\n\t\t\t\t\tshowTooltip\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</fieldset>\n\t);\n}\n\nfunction VariationsDropdown( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<Menu>\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"block-editor-block-variation-transforms__button\"\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Transform to variation' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Menu.Popover position=\"bottom\">\n\t\t\t\t\t<Menu.Group>\n\t\t\t\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t\t\t\t<Menu.RadioItem\n\t\t\t\t\t\t\t\tkey={ variation.name }\n\t\t\t\t\t\t\t\tvalue={ variation.name }\n\t\t\t\t\t\t\t\tchecked={ selectedValue === variation.name }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tonSelectVariation( variation.name )\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<Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t{ variation.title }\n\t\t\t\t\t\t\t\t</Menu.ItemLabel>\n\t\t\t\t\t\t\t\t{ variation.description && (\n\t\t\t\t\t\t\t\t\t<Menu.ItemHelpText>\n\t\t\t\t\t\t\t\t\t\t{ variation.description }\n\t\t\t\t\t\t\t\t\t</Menu.ItemHelpText>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Menu.RadioItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Menu.Group>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t</div>\n\t);\n}\n\nfunction VariationsToggleGroupControl( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<ToggleGroupControl\n\t\t\t\tlabel={ __( 'Transform to variation' ) }\n\t\t\t\tvalue={ selectedValue }\n\t\t\t\thideLabelFromVision\n\t\t\t\tonChange={ onSelectVariation }\n\t\t\t
|
|
5
|
-
"mappings": ";AAGA,SAAS,SAAS,mBAAmB;AACrC,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA,oCAAoC;AAAA,EACpC,8CAA8C;AAAA,EAC9C,eAAe;AAAA,OACT;AACP,SAAS,sBAAsB;AAC/B,SAAS,WAAW,mBAAmB;AACvC,SAAS,eAAe;AAKxB,OAAO,eAAe;AACtB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAWrB,SAC0B,KAD1B;AATF,IAAM,EAAE,KAAK,IAAI,OAAQ,qBAAsB;AAE/C,SAAS,kBAAmB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,qBAAC,cAAS,WACT;AAAA,wBAAC,kBAAe,QAAS,oBAAC,YAAO,GAC9B,aAAI,wBAAyB,GAChC;AAAA,IACE,WAAW,IAAK,CAAE,cACnB;AAAA,MAAC;AAAA;AAAA,QACA,u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,OAAQ,GAAI,wBAAyB;AAAA,MACrC,OAAQ;AAAA,MACR,qBAAmB;AAAA,MACnB,UAAW;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { Menu } = unlock( componentsPrivateApis );\n\nfunction VariationsButtons( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<fieldset className={ className }>\n\t\t\t<VisuallyHidden render={ <legend /> }>\n\t\t\t\t{ __( 'Transform to variation' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tkey={ variation.name }\n\t\t\t\t\ticon={ <BlockIcon icon={ variation.icon } showColors /> }\n\t\t\t\t\tisPressed={ selectedValue === variation.name }\n\t\t\t\t\tlabel={\n\t\t\t\t\t\tselectedValue === variation.name\n\t\t\t\t\t\t\t? variation.title\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: Block or block variation name. */\n\t\t\t\t\t\t\t\t\t__( 'Transform to %s' ),\n\t\t\t\t\t\t\t\t\tvariation.title\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t\tonClick={ () => onSelectVariation( variation.name ) }\n\t\t\t\t\taria-label={ variation.title }\n\t\t\t\t\tshowTooltip\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</fieldset>\n\t);\n}\n\nfunction VariationsDropdown( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<Menu>\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName=\"block-editor-block-variation-transforms__button\"\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Transform to variation' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<Menu.Popover position=\"bottom\">\n\t\t\t\t\t<Menu.Group>\n\t\t\t\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t\t\t\t<Menu.RadioItem\n\t\t\t\t\t\t\t\tkey={ variation.name }\n\t\t\t\t\t\t\t\tvalue={ variation.name }\n\t\t\t\t\t\t\t\tchecked={ selectedValue === variation.name }\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tonSelectVariation( variation.name )\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<Menu.ItemLabel>\n\t\t\t\t\t\t\t\t\t{ variation.title }\n\t\t\t\t\t\t\t\t</Menu.ItemLabel>\n\t\t\t\t\t\t\t\t{ variation.description && (\n\t\t\t\t\t\t\t\t\t<Menu.ItemHelpText>\n\t\t\t\t\t\t\t\t\t\t{ variation.description }\n\t\t\t\t\t\t\t\t\t</Menu.ItemHelpText>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Menu.RadioItem>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Menu.Group>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\t\t</div>\n\t);\n}\n\nfunction VariationsToggleGroupControl( {\n\tclassName,\n\tonSelectVariation,\n\tselectedValue,\n\tvariations,\n} ) {\n\treturn (\n\t\t<div className={ className }>\n\t\t\t<ToggleGroupControl\n\t\t\t\tlabel={ __( 'Transform to variation' ) }\n\t\t\t\tvalue={ selectedValue }\n\t\t\t\thideLabelFromVision\n\t\t\t\tonChange={ onSelectVariation }\n\t\t\t>\n\t\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t\t<ToggleGroupControlOptionIcon\n\t\t\t\t\t\tkey={ variation.name }\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<BlockIcon icon={ variation.icon } showColors />\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ variation.name }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tselectedValue === variation.name\n\t\t\t\t\t\t\t\t? variation.title\n\t\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: Block or block variation name. */\n\t\t\t\t\t\t\t\t\t\t__( 'Transform to %s' ),\n\t\t\t\t\t\t\t\t\t\tvariation.title\n\t\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) ) }\n\t\t\t</ToggleGroupControl>\n\t\t</div>\n\t);\n}\n\nfunction BlockVariationTransforms( { blockClientId } ) {\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst {\n\t\tactiveBlockVariation,\n\t\tvariations,\n\t\tcanEdit,\n\t\tisContentOnly,\n\t\tisSection,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getActiveBlockVariation, getBlockVariations } =\n\t\t\t\tselect( blocksStore );\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tisSectionBlock,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\t\t\tconst { canEditBlock } = select( blockEditorStore );\n\n\t\t\tconst name = blockClientId && getBlockName( blockClientId );\n\n\t\t\tconst { hasContentRoleAttribute } = unlock( select( blocksStore ) );\n\t\t\tconst isContentBlock = hasContentRoleAttribute( name );\n\n\t\t\treturn {\n\t\t\t\tactiveBlockVariation: getActiveBlockVariation(\n\t\t\t\t\tname,\n\t\t\t\t\tgetBlockAttributes( blockClientId ),\n\t\t\t\t\t'transform'\n\t\t\t\t),\n\t\t\t\tvariations: name && getBlockVariations( name, 'transform' ),\n\t\t\t\tcanEdit: canEditBlock( blockClientId ),\n\t\t\t\tisContentOnly:\n\t\t\t\t\tgetBlockEditingMode( blockClientId ) === 'contentOnly' &&\n\t\t\t\t\t! isContentBlock,\n\t\t\t\tisSection: isSectionBlock( blockClientId ),\n\t\t\t};\n\t\t},\n\t\t[ blockClientId ]\n\t);\n\n\tconst selectedValue = activeBlockVariation?.name;\n\n\t// Check if each variation has a unique icon.\n\tconst hasUniqueIcons = useMemo( () => {\n\t\tconst variationIcons = new Set();\n\t\tif ( ! variations ) {\n\t\t\treturn false;\n\t\t}\n\t\tvariations.forEach( ( variation ) => {\n\t\t\tif ( variation.icon ) {\n\t\t\t\tvariationIcons.add( variation.icon?.src || variation.icon );\n\t\t\t}\n\t\t} );\n\t\treturn variationIcons.size === variations.length;\n\t}, [ variations ] );\n\n\tconst onSelectVariation = ( variationName ) => {\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\t...variations.find( ( { name } ) => name === variationName )\n\t\t\t\t.attributes,\n\t\t} );\n\t};\n\n\tif ( ! variations?.length || ! canEdit || isContentOnly || isSection ) {\n\t\treturn null;\n\t}\n\n\tconst baseClass = 'block-editor-block-variation-transforms';\n\n\t// Show buttons if there are more than 6 variations because the ToggleGroupControl does not wrap\n\tconst showButtons = variations.length > 6;\n\n\tconst ButtonComponent = showButtons\n\t\t? VariationsButtons\n\t\t: VariationsToggleGroupControl;\n\n\tconst Component = hasUniqueIcons ? ButtonComponent : VariationsDropdown;\n\n\treturn (\n\t\t<Component\n\t\t\tclassName={ baseClass }\n\t\t\tonSelectVariation={ onSelectVariation }\n\t\t\tselectedValue={ selectedValue }\n\t\t\tvariations={ variations }\n\t\t/>\n\t);\n}\n\nexport default BlockVariationTransforms;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,SAAS,mBAAmB;AACrC,SAAS,IAAI,eAAe;AAC5B;AAAA,EACC;AAAA,EACA,oCAAoC;AAAA,EACpC,8CAA8C;AAAA,EAC9C,eAAe;AAAA,OACT;AACP,SAAS,sBAAsB;AAC/B,SAAS,WAAW,mBAAmB;AACvC,SAAS,eAAe;AAKxB,OAAO,eAAe;AACtB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,cAAc;AAWrB,SAC0B,KAD1B;AATF,IAAM,EAAE,KAAK,IAAI,OAAQ,qBAAsB;AAE/C,SAAS,kBAAmB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,qBAAC,cAAS,WACT;AAAA,wBAAC,kBAAe,QAAS,oBAAC,YAAO,GAC9B,aAAI,wBAAyB,GAChC;AAAA,IACE,WAAW,IAAK,CAAE,cACnB;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,MAAK;AAAA,QAEL,MAAO,oBAAC,aAAU,MAAO,UAAU,MAAO,YAAU,MAAC;AAAA,QACrD,WAAY,kBAAkB,UAAU;AAAA,QACxC,OACC,kBAAkB,UAAU,OACzB,UAAU,QACV;AAAA;AAAA,UAEA,GAAI,iBAAkB;AAAA,UACtB,UAAU;AAAA,QACV;AAAA,QAEJ,SAAU,MAAM,kBAAmB,UAAU,IAAK;AAAA,QAClD,cAAa,UAAU;AAAA,QACvB,aAAW;AAAA;AAAA,MAdL,UAAU;AAAA,IAejB,CACC;AAAA,KACH;AAEF;AAEA,SAAS,mBAAoB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,oBAAC,SAAI,WACJ,+BAAC,QACA;AAAA;AAAA,MA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AK,CAAE,YAAY,UAAU,CAAE,WAAW,iBAAiB,WAAY;AACtE,WAAO;AAAA,EACR;AAEA,QAAM,YAAY;AAGlB,QAAM,cAAc,WAAW,SAAS;AAExC,QAAM,kBAAkB,cACrB,oBACA;AAEH,QAAM,YAAY,iBAAiB,kBAAkB;AAErD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD;AAEF;AAEA,IAAO,qCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,13 +18,11 @@ import {
|
|
|
18
18
|
import { useDispatch, useSelect } from "@wordpress/data";
|
|
19
19
|
import { store as keyboardShortcutsStore } from "@wordpress/keyboard-shortcuts";
|
|
20
20
|
import { store as noticesStore } from "@wordpress/notices";
|
|
21
|
-
import {
|
|
22
|
-
BLOCK_VISIBILITY_VIEWPORT_ENTRIES,
|
|
23
|
-
BLOCK_VISIBILITY_VIEWPORTS
|
|
24
|
-
} from "./constants.mjs";
|
|
21
|
+
import { BLOCK_VISIBILITY_VIEWPORTS } from "./constants.mjs";
|
|
25
22
|
import { store as blockEditorStore } from "../../store/index.mjs";
|
|
26
23
|
import { cleanEmptyObject } from "../../hooks/utils.mjs";
|
|
27
24
|
import {
|
|
25
|
+
getBlockVisibilityViewportEntries,
|
|
28
26
|
getViewportCheckboxState,
|
|
29
27
|
getHideEverywhereCheckboxState
|
|
30
28
|
} from "./utils.mjs";
|
|
@@ -47,6 +45,14 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
47
45
|
"core/editor/toggle-list-view"
|
|
48
46
|
);
|
|
49
47
|
}, []);
|
|
48
|
+
const viewportSettings = useSelect(
|
|
49
|
+
(select) => select(blockEditorStore).getSettings().__experimentalFeatures?.viewport,
|
|
50
|
+
[]
|
|
51
|
+
);
|
|
52
|
+
const viewportEntries = useMemo(
|
|
53
|
+
() => getBlockVisibilityViewportEntries(viewportSettings),
|
|
54
|
+
[viewportSettings]
|
|
55
|
+
);
|
|
50
56
|
const initialViewportValues = useMemo(() => {
|
|
51
57
|
if (blocks?.length === 0) {
|
|
52
58
|
return {
|
|
@@ -55,14 +61,14 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
55
61
|
};
|
|
56
62
|
}
|
|
57
63
|
const viewportValues = {};
|
|
58
|
-
|
|
64
|
+
viewportEntries.forEach(([, { key }]) => {
|
|
59
65
|
viewportValues[key] = getViewportCheckboxState(blocks, key);
|
|
60
66
|
});
|
|
61
67
|
return {
|
|
62
68
|
hideEverywhere: getHideEverywhereCheckboxState(blocks),
|
|
63
69
|
viewportChecked: viewportValues
|
|
64
70
|
};
|
|
65
|
-
}, [blocks]);
|
|
71
|
+
}, [blocks, viewportEntries]);
|
|
66
72
|
const [viewportChecked, setViewportChecked] = useState(
|
|
67
73
|
initialViewportValues?.viewportChecked ?? {}
|
|
68
74
|
);
|
|
@@ -111,10 +117,15 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
111
117
|
if (hideEverywhere !== initialViewportValues.hideEverywhere) {
|
|
112
118
|
return true;
|
|
113
119
|
}
|
|
114
|
-
return
|
|
120
|
+
return viewportEntries.some(
|
|
115
121
|
([, { key }]) => viewportChecked[key] !== initialViewportValues.viewportChecked[key]
|
|
116
122
|
);
|
|
117
|
-
}, [
|
|
123
|
+
}, [
|
|
124
|
+
hideEverywhere,
|
|
125
|
+
viewportChecked,
|
|
126
|
+
initialViewportValues,
|
|
127
|
+
viewportEntries
|
|
128
|
+
]);
|
|
118
129
|
const hasIndeterminateValues = useMemo(() => {
|
|
119
130
|
if (hideEverywhere === null) {
|
|
120
131
|
return true;
|
|
@@ -127,7 +138,7 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
127
138
|
(event) => {
|
|
128
139
|
event.preventDefault();
|
|
129
140
|
const newVisibility = hideEverywhere ? false : {
|
|
130
|
-
viewport:
|
|
141
|
+
viewport: viewportEntries.reduce(
|
|
131
142
|
(acc, [, { key }]) => {
|
|
132
143
|
if (viewportChecked[key]) {
|
|
133
144
|
acc[key] = false;
|
|
@@ -165,6 +176,7 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
165
176
|
noticeMessage,
|
|
166
177
|
onClose,
|
|
167
178
|
updateBlockAttributes,
|
|
179
|
+
viewportEntries,
|
|
168
180
|
viewportChecked
|
|
169
181
|
]
|
|
170
182
|
);
|
|
@@ -199,7 +211,7 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
199
211
|
}
|
|
200
212
|
}
|
|
201
213
|
),
|
|
202
|
-
hideEverywhere !== true && /* @__PURE__ */ jsx("ul", { className: "block-editor-block-visibility-modal__sub-options", children:
|
|
214
|
+
hideEverywhere !== true && /* @__PURE__ */ jsx("ul", { className: "block-editor-block-visibility-modal__sub-options", children: viewportEntries.map(
|
|
203
215
|
([, { label, icon, key }]) => /* @__PURE__ */ jsxs(
|
|
204
216
|
"li",
|
|
205
217
|
{
|