@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
|
@@ -71,7 +71,8 @@ function selector(select) {
|
|
|
71
71
|
isTyping: isTyping(),
|
|
72
72
|
isZoomOutMode: isZoomOut(),
|
|
73
73
|
isDragging: isDragging(),
|
|
74
|
-
viewportModalClientIds: getViewportModalClientIds()
|
|
74
|
+
viewportModalClientIds: getViewportModalClientIds(),
|
|
75
|
+
blockVisibilitySetting: select(import_store.store).getSettings().__experimentalFeatures?.blockVisibility?.allowEditing
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
function BlockTools({
|
|
@@ -85,7 +86,8 @@ function BlockTools({
|
|
|
85
86
|
isTyping,
|
|
86
87
|
isZoomOutMode,
|
|
87
88
|
isDragging,
|
|
88
|
-
viewportModalClientIds
|
|
89
|
+
viewportModalClientIds,
|
|
90
|
+
blockVisibilitySetting
|
|
89
91
|
} = (0, import_data.useSelect)(selector, []);
|
|
90
92
|
const isMatch = (0, import_keyboard_shortcuts.__unstableUseShortcutEventMatch)();
|
|
91
93
|
const {
|
|
@@ -218,6 +220,9 @@ function BlockTools({
|
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
222
|
} else if (isMatch("core/block-editor/toggle-block-visibility", event)) {
|
|
223
|
+
if (blockVisibilitySetting === false) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
221
226
|
const clientIds = getSelectedBlockClientIds();
|
|
222
227
|
if (clientIds.length) {
|
|
223
228
|
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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAuC;AACvC,iBAA4B;AAC5B,wBAAwB;AACxB,gCAAyE;AACzE,qBAAiC;AACjC,oBAIO;AACP,kBAAsB;AACtB,kBAAgC;AAKhC,kCAA+B;AAC/B,6BAGO;AACP,mCAAgC;AAChC,mBAA0C;AAC1C,gCAA6B;AAC7B,qCAAiC;AACjC,kCAAkC;AAClC,yBAAuB;AACvB,8BAA2B;AAC3B,0BAAiD;AACjD,8BAAqC;
|
|
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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAuC;AACvC,iBAA4B;AAC5B,wBAAwB;AACxB,gCAAyE;AACzE,qBAAiC;AACjC,oBAIO;AACP,kBAAsB;AACtB,kBAAgC;AAKhC,kCAA+B;AAC/B,6BAGO;AACP,mCAAgC;AAChC,mBAA0C;AAC1C,gCAA6B;AAC7B,qCAAiC;AACjC,kCAAkC;AAClC,yBAAuB;AACvB,8BAA2B;AAC3B,0BAAiD;AACjD,8BAAqC;AA+QlC;AA7QH,SAAS,SAAU,QAAS;AAC3B,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI,2BAAQ,OAAQ,aAAAA,KAAiB,CAAE;AAEvC,QAAM,WACL,yBAAyB,KAAK,mCAAmC;AAElE,SAAO;AAAA,IACN;AAAA,IACA,iBAAiB,YAAY,EAAE;AAAA,IAC/B,UAAU,SAAS;AAAA,IACnB,eAAe,UAAU;AAAA,IACzB,YAAY,WAAW;AAAA,IACvB,wBAAwB,0BAA0B;AAAA,IAClD,wBACC,OAAQ,aAAAA,KAAiB,EA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AA,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": ["blockEditorStore", "useShortcutEventMatch", "blocksStore", "usePasteStyles", "usePopoverScroll", "clsx", "InsertionPoint", "EmptyBlockInserter", "BlockToolbarPopover", "ZoomOutModeInserters"]
|
|
7
7
|
}
|
|
@@ -121,7 +121,6 @@ function VariationsToggleGroupControl({
|
|
|
121
121
|
value: selectedValue,
|
|
122
122
|
hideLabelFromVision: true,
|
|
123
123
|
onChange: onSelectVariation,
|
|
124
|
-
__next40pxDefaultSize: true,
|
|
125
124
|
children: variations.map((variation) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
126
125
|
import_components.__experimentalToggleGroupControlOptionIcon,
|
|
127
126
|
{
|
|
@@ -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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAqC;AACrC,kBAA4B;AAC5B,wBAKO;AACP,gBAA+B;AAC/B,kBAAuC;AACvC,qBAAwB;AAKxB,wBAAsB;AACtB,mBAA0C;AAC1C,yBAAuB;AAWrB;AATF,IAAM,EAAE,KAAK,QAAI,2BAAQ,kBAAAA,WAAsB;AAE/C,SAAS,kBAAmB;AAAA,EAC3B;AAAA,EACA;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AAAA;AAAA;AAAA,MAbK,UAAU;AAAA,IAejB,CACC,GACH,GACD;AAAA,KACD,GACD;AAEF;AAEA,SAAS,6BAA8B;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,4CAAC,SAAI,WACJ;AAAA,IAAC,kBAAAC;AAAA,IAAA;AAAA,MACA,WAAQ,gBAAI,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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAqC;AACrC,kBAA4B;AAC5B,wBAKO;AACP,gBAA+B;AAC/B,kBAAuC;AACvC,qBAAwB;AAKxB,wBAAsB;AACtB,mBAA0C;AAC1C,yBAAuB;AAWrB;AATF,IAAM,EAAE,KAAK,QAAI,2BAAQ,kBAAAA,WAAsB;AAE/C,SAAS,kBAAmB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,6CAAC,cAAS,WACT;AAAA,gDAAC,4BAAe,QAAS,4CAAC,YAAO,GAC9B,8BAAI,wBAAyB,GAChC;AAAA,IACE,WAAW,IAAK,CAAE,cACnB;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,MAAK;AAAA,QAEL,MAAO,4CAAC,kBAAAC,SAAA,EAAU,MAAO,UAAU,MAAO,YAAU,MAAC;AAAA,QACrD,WAAY,kBAAkB,UAAU;AAAA,QACxC,OACC,kBAAkB,UAAU,OACzB,UAAU,YACV;AAAA;AAAA,cAEA,gBAAI,iBAAkB;AAAA,UACtB,UAAU;AAAA,QACV;AAAA,QAEJ,SAAU,MAAM,kBAAmB,UAAU,IAAK;AAAA,QAClD,cAAa,UAAU;AAAA,QACvB,aAAW;AAAA;AAAA,MAdL,UAAU;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3D;AAAA,IACD,CAAE;AACF,WAAO,eAAe,SAAS,WAAW;AAAA,EAC3C,GAAG,CAAE,UAAW,CAAE;AAElB,QAAM,oBAAoB,CAAE,kBAAmB;AAC9C,0BAAuB,eAAe;AAAA,MACrC,GAAG,WAAW,KAAM,CAAE,EAAE,KAAK,MAAO,SAAS,aAAc,EACzD;AAAA,IACH,CAAE;AAAA,EACH;AAEA,MAAK,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": ["componentsPrivateApis", "BlockIcon", "ToggleGroupControl", "ToggleGroupControlOptionIcon", "blockEditorStore", "blocksStore"]
|
|
7
7
|
}
|
|
@@ -63,6 +63,14 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
63
63
|
"core/editor/toggle-list-view"
|
|
64
64
|
);
|
|
65
65
|
}, []);
|
|
66
|
+
const viewportSettings = (0, import_data.useSelect)(
|
|
67
|
+
(select) => select(import_store.store).getSettings().__experimentalFeatures?.viewport,
|
|
68
|
+
[]
|
|
69
|
+
);
|
|
70
|
+
const viewportEntries = (0, import_element.useMemo)(
|
|
71
|
+
() => (0, import_utils2.getBlockVisibilityViewportEntries)(viewportSettings),
|
|
72
|
+
[viewportSettings]
|
|
73
|
+
);
|
|
66
74
|
const initialViewportValues = (0, import_element.useMemo)(() => {
|
|
67
75
|
if (blocks?.length === 0) {
|
|
68
76
|
return {
|
|
@@ -71,14 +79,14 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
71
79
|
};
|
|
72
80
|
}
|
|
73
81
|
const viewportValues = {};
|
|
74
|
-
|
|
82
|
+
viewportEntries.forEach(([, { key }]) => {
|
|
75
83
|
viewportValues[key] = (0, import_utils2.getViewportCheckboxState)(blocks, key);
|
|
76
84
|
});
|
|
77
85
|
return {
|
|
78
86
|
hideEverywhere: (0, import_utils2.getHideEverywhereCheckboxState)(blocks),
|
|
79
87
|
viewportChecked: viewportValues
|
|
80
88
|
};
|
|
81
|
-
}, [blocks]);
|
|
89
|
+
}, [blocks, viewportEntries]);
|
|
82
90
|
const [viewportChecked, setViewportChecked] = (0, import_element.useState)(
|
|
83
91
|
initialViewportValues?.viewportChecked ?? {}
|
|
84
92
|
);
|
|
@@ -127,10 +135,15 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
127
135
|
if (hideEverywhere !== initialViewportValues.hideEverywhere) {
|
|
128
136
|
return true;
|
|
129
137
|
}
|
|
130
|
-
return
|
|
138
|
+
return viewportEntries.some(
|
|
131
139
|
([, { key }]) => viewportChecked[key] !== initialViewportValues.viewportChecked[key]
|
|
132
140
|
);
|
|
133
|
-
}, [
|
|
141
|
+
}, [
|
|
142
|
+
hideEverywhere,
|
|
143
|
+
viewportChecked,
|
|
144
|
+
initialViewportValues,
|
|
145
|
+
viewportEntries
|
|
146
|
+
]);
|
|
134
147
|
const hasIndeterminateValues = (0, import_element.useMemo)(() => {
|
|
135
148
|
if (hideEverywhere === null) {
|
|
136
149
|
return true;
|
|
@@ -143,7 +156,7 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
143
156
|
(event) => {
|
|
144
157
|
event.preventDefault();
|
|
145
158
|
const newVisibility = hideEverywhere ? false : {
|
|
146
|
-
viewport:
|
|
159
|
+
viewport: viewportEntries.reduce(
|
|
147
160
|
(acc, [, { key }]) => {
|
|
148
161
|
if (viewportChecked[key]) {
|
|
149
162
|
acc[key] = false;
|
|
@@ -181,6 +194,7 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
181
194
|
noticeMessage,
|
|
182
195
|
onClose,
|
|
183
196
|
updateBlockAttributes,
|
|
197
|
+
viewportEntries,
|
|
184
198
|
viewportChecked
|
|
185
199
|
]
|
|
186
200
|
);
|
|
@@ -215,7 +229,7 @@ function BlockVisibilityModal({ clientIds, onClose }) {
|
|
|
215
229
|
}
|
|
216
230
|
}
|
|
217
231
|
),
|
|
218
|
-
hideEverywhere !== true && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "block-editor-block-visibility-modal__sub-options", children:
|
|
232
|
+
hideEverywhere !== true && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "block-editor-block-visibility-modal__sub-options", children: viewportEntries.map(
|
|
219
233
|
([, { label, icon, key }]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
220
234
|
"li",
|
|
221
235
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-visibility/modal.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseState,\n\tuseMemo,\n\tuseCallback,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon as WCIcon,\n\tModal,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBLOCK_VISIBILITY_VIEWPORT_ENTRIES,\n\tBLOCK_VISIBILITY_VIEWPORTS,\n} from './constants';\nimport { store as blockEditorStore } from '../../store';\nimport { cleanEmptyObject } from '../../hooks/utils';\nimport {\n\tgetViewportCheckboxState,\n\tgetHideEverywhereCheckboxState,\n} from './utils';\n\nconst DEFAULT_VIEWPORT_CHECKBOX_VALUES = {\n\t[ BLOCK_VISIBILITY_VIEWPORTS.mobile.key ]: false,\n\t[ BLOCK_VISIBILITY_VIEWPORTS.tablet.key ]: false,\n\t[ BLOCK_VISIBILITY_VIEWPORTS.desktop.key ]: false,\n};\n\nconst EMPTY_BLOCKS = [];\n\n/**\n * Modal component for configuring block visibility across viewports.\n *\n * Allows users to hide blocks on specific viewport sizes (mobile, tablet, desktop)\n * or hide them everywhere. When editing multiple blocks, checkboxes only show as\n * checked if ALL selected blocks share the same setting to avoid ambiguity.\n *\n * @param {Object} props Component props.\n * @param {Array} props.clientIds The client IDs of the blocks to hide.\n * @param {Function} props.onClose Callback function invoked when the modal is closed.\n * @return {React.JSX.Element} The modal component.\n */\nexport default function BlockVisibilityModal( { clientIds, onClose } ) {\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst blocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds ) ??\n\t\t\tEMPTY_BLOCKS,\n\t\t[ clientIds ]\n\t);\n\tconst listViewShortcut = useSelect( ( select ) => {\n\t\treturn select( keyboardShortcutsStore ).getShortcutRepresentation(\n\t\t\t'core/editor/toggle-list-view'\n\t\t);\n\t}, [] );\n\n\tconst initialViewportValues = useMemo( () => {\n\t\tif ( blocks?.length === 0 ) {\n\t\t\treturn {\n\t\t\t\thideEverywhere: false,\n\t\t\t\tviewportChecked: {},\n\t\t\t};\n\t\t}\n\n\t\tconst viewportValues = {};\n\n\t\tBLOCK_VISIBILITY_VIEWPORT_ENTRIES.forEach( ( [ , { key } ] ) => {\n\t\t\tviewportValues[ key ] = getViewportCheckboxState( blocks, key );\n\t\t} );\n\n\t\treturn {\n\t\t\thideEverywhere: getHideEverywhereCheckboxState( blocks ),\n\t\t\tviewportChecked: viewportValues,\n\t\t};\n\t}, [ blocks ] );\n\n\tconst [ viewportChecked, setViewportChecked ] = useState(\n\t\tinitialViewportValues?.viewportChecked ?? {}\n\t);\n\tconst [ hideEverywhere, setHideEverywhere ] = useState(\n\t\tinitialViewportValues?.hideEverywhere ?? false\n\t);\n\n\tconst handleViewportCheckboxChange = useCallback(\n\t\t( viewport, isChecked ) => {\n\t\t\tsetViewportChecked( {\n\t\t\t\t...viewportChecked,\n\t\t\t\t[ viewport ]: isChecked,\n\t\t\t} );\n\t\t},\n\t\t[ viewportChecked ]\n\t);\n\n\tconst noticeMessage = useMemo( () => {\n\t\tif ( ! hideEverywhere ) {\n\t\t\treturn sprintf(\n\t\t\t\t// translators: %s: The shortcut key to access the List View.\n\t\t\t\t__(\n\t\t\t\t\t'Block visibility settings updated. You can access them via the List View (%s).'\n\t\t\t\t),\n\t\t\t\tlistViewShortcut\n\t\t\t);\n\t\t}\n\n\t\tconst message =\n\t\t\tblocks?.length > 1\n\t\t\t\t? // translators: %s: The shortcut key to access the List View.\n\t\t\t\t __(\n\t\t\t\t\t\t'Blocks hidden. You can access them via the List View (%s).'\n\t\t\t\t )\n\t\t\t\t: // translators: %s: The shortcut key to access the List View.\n\t\t\t\t __(\n\t\t\t\t\t\t'Block hidden. You can access it via the List View (%s).'\n\t\t\t\t );\n\n\t\treturn sprintf( message, listViewShortcut );\n\t}, [ hideEverywhere, blocks?.length, listViewShortcut ] );\n\n\tconst isAnyViewportChecked = useMemo(\n\t\t() =>\n\t\t\tObject.values( viewportChecked ).some(\n\t\t\t\t( checked ) => checked === true || checked === null\n\t\t\t),\n\t\t[ viewportChecked ]\n\t);\n\n\tconst isDirty = useMemo( () => {\n\t\tif ( hideEverywhere !== initialViewportValues.hideEverywhere ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn BLOCK_VISIBILITY_VIEWPORT_ENTRIES.some(\n\t\t\t( [ , { key } ] ) =>\n\t\t\t\tviewportChecked[ key ] !==\n\t\t\t\tinitialViewportValues.viewportChecked[ key ]\n\t\t);\n\t}, [ hideEverywhere, viewportChecked, initialViewportValues ] );\n\n\tconst hasIndeterminateValues = useMemo( () => {\n\t\tif ( hideEverywhere === null ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn Object.values( viewportChecked ).some(\n\t\t\t( checked ) => checked === null\n\t\t);\n\t}, [ hideEverywhere, viewportChecked ] );\n\n\tconst handleSubmit = useCallback(\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\tconst newVisibility = hideEverywhere\n\t\t\t\t? false\n\t\t\t\t: {\n\t\t\t\t\t\tviewport: BLOCK_VISIBILITY_VIEWPORT_ENTRIES.reduce(\n\t\t\t\t\t\t\t( acc, [ , { key } ] ) => {\n\t\t\t\t\t\t\t\tif ( viewportChecked[ key ] ) {\n\t\t\t\t\t\t\t\t\t// Values are inverted to hide the block on the selected viewport.\n\t\t\t\t\t\t\t\t\t// In the UI, the checkbox is checked (true) when the block is hidden on the selected viewport,\n\t\t\t\t\t\t\t\t\t// so 'false' means hide the block on the selected viewport.\n\t\t\t\t\t\t\t\t\tacc[ key ] = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn acc;\n\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 };\n\t\t\tconst attributesByClientId = Object.fromEntries(\n\t\t\t\tblocks.map( ( { clientId, attributes } ) => [\n\t\t\t\t\tclientId,\n\t\t\t\t\t{\n\t\t\t\t\t\tmetadata: cleanEmptyObject( {\n\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\tblockVisibility: newVisibility,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t},\n\t\t\t\t] )\n\t\t\t);\n\t\t\tupdateBlockAttributes( clientIds, attributesByClientId, {\n\t\t\t\tuniqueByBlock: true,\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice( noticeMessage, {\n\t\t\t\tid: hideEverywhere\n\t\t\t\t\t? 'block-visibility-hidden'\n\t\t\t\t\t: 'block-visibility-viewports-updated',\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\tonClose();\n\t\t},\n\t\t[\n\t\t\tblocks,\n\t\t\tclientIds,\n\t\t\tcreateSuccessNotice,\n\t\t\thideEverywhere,\n\t\t\tnoticeMessage,\n\t\t\tonClose,\n\t\t\tupdateBlockAttributes,\n\t\t\tviewportChecked,\n\t\t]\n\t);\n\n\tconst hasMultipleBlocks = blocks?.length > 1;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\tclientIds?.length > 1 ? __( 'Hide blocks' ) : __( 'Hide block' )\n\t\t\t}\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-visibility-modal\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form onSubmit={ handleSubmit }>\n\t\t\t\t<fieldset>\n\t\t\t\t\t<legend>\n\t\t\t\t\t\t{ hasMultipleBlocks\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'Select the viewport sizes for which you want to hide the blocks. Changes will apply to all selected blocks.'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Select the viewport size for which you want to hide the block.'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</legend>\n\t\t\t\t\t<ul className=\"block-editor-block-visibility-modal__options\">\n\t\t\t\t\t\t<li className=\"block-editor-block-visibility-modal__options-item block-editor-block-visibility-modal__options-item--everywhere\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-visibility-modal__options-checkbox--everywhere\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Omit from published content' ) }\n\t\t\t\t\t\t\t\tchecked={ hideEverywhere === true }\n\t\t\t\t\t\t\t\tindeterminate={ hideEverywhere === null }\n\t\t\t\t\t\t\t\tonChange={ ( checked ) => {\n\t\t\t\t\t\t\t\t\tsetHideEverywhere( checked );\n\t\t\t\t\t\t\t\t\t// Reset viewport checkboxes when hide everywhere is checked.\n\t\t\t\t\t\t\t\t\tsetViewportChecked(\n\t\t\t\t\t\t\t\t\t\tDEFAULT_VIEWPORT_CHECKBOX_VALUES\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{ hideEverywhere !== true && (\n\t\t\t\t\t\t\t\t<ul className=\"block-editor-block-visibility-modal__sub-options\">\n\t\t\t\t\t\t\t\t\t{ BLOCK_VISIBILITY_VIEWPORT_ENTRIES.map(\n\t\t\t\t\t\t\t\t\t\t( [ , { label, icon, key } ] ) => (\n\t\t\t\t\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-visibility-modal__options-item\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t// translators: %s: The viewport name.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__( 'Hide on %s' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tviewportChecked[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t] ?? false\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\tindeterminate={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tviewportChecked[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t] === null\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={ ( checked ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thandleViewportCheckboxChange(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tchecked\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t<WCIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName={ clsx( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'block-editor-block-visibility-modal__options-icon--checked':\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tviewportChecked[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</li>\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</ul>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ hasMultipleBlocks && hasIndeterminateValues && (\n\t\t\t\t\t\t<p className=\"block-editor-block-visibility-modal__description\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Selected blocks have different visibility settings. The checkboxes show an indeterminate state when settings differ.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! hasMultipleBlocks && hideEverywhere === true && (\n\t\t\t\t\t\t<p className=\"block-editor-block-visibility-modal__description\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The shortcut key to access the List View.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Block will be hidden in the editor, and omitted from the published markup on the frontend. You can configure it again by selecting it in the List View (%s).'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tlistViewShortcut\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! hasMultipleBlocks &&\n\t\t\t\t\t\t! hideEverywhere &&\n\t\t\t\t\t\tisAnyViewportChecked && (\n\t\t\t\t\t\t\t<p className=\"block-editor-block-visibility-modal__description\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The shortcut key to access the List View\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'Block will be hidden according to the selected viewports. It will be <strong>included in the published markup on the frontend</strong>. You can configure it again by selecting it in the List View (%s).'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tlistViewShortcut\n\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\tstrong: <strong />,\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</p>\n\t\t\t\t\t\t) }\n\t\t\t\t</fieldset>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-visibility-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tdisabled={ ! isDirty }\n\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAA4B;AAC5B,qBAKO;AACP,wBAOO;AACP,kBAAuC;AACvC,gCAAgD;AAChD,qBAAsC;AAKtC,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseState,\n\tuseMemo,\n\tuseCallback,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon as WCIcon,\n\tModal,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { BLOCK_VISIBILITY_VIEWPORTS } from './constants';\nimport { store as blockEditorStore } from '../../store';\nimport { cleanEmptyObject } from '../../hooks/utils';\nimport {\n\tgetBlockVisibilityViewportEntries,\n\tgetViewportCheckboxState,\n\tgetHideEverywhereCheckboxState,\n} from './utils';\n\nconst DEFAULT_VIEWPORT_CHECKBOX_VALUES = {\n\t[ BLOCK_VISIBILITY_VIEWPORTS.mobile.key ]: false,\n\t[ BLOCK_VISIBILITY_VIEWPORTS.tablet.key ]: false,\n\t[ BLOCK_VISIBILITY_VIEWPORTS.desktop.key ]: false,\n};\n\nconst EMPTY_BLOCKS = [];\n\n/**\n * Modal component for configuring block visibility across viewports.\n *\n * Allows users to hide blocks on specific viewport sizes (mobile, tablet, desktop)\n * or hide them everywhere. When editing multiple blocks, checkboxes only show as\n * checked if ALL selected blocks share the same setting to avoid ambiguity.\n *\n * @param {Object} props Component props.\n * @param {Array} props.clientIds The client IDs of the blocks to hide.\n * @param {Function} props.onClose Callback function invoked when the modal is closed.\n * @return {React.JSX.Element} The modal component.\n */\nexport default function BlockVisibilityModal( { clientIds, onClose } ) {\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\tconst blocks = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds ) ??\n\t\t\tEMPTY_BLOCKS,\n\t\t[ clientIds ]\n\t);\n\tconst listViewShortcut = useSelect( ( select ) => {\n\t\treturn select( keyboardShortcutsStore ).getShortcutRepresentation(\n\t\t\t'core/editor/toggle-list-view'\n\t\t);\n\t}, [] );\n\tconst viewportSettings = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__experimentalFeatures\n\t\t\t\t?.viewport,\n\t\t[]\n\t);\n\tconst viewportEntries = useMemo(\n\t\t() => getBlockVisibilityViewportEntries( viewportSettings ),\n\t\t[ viewportSettings ]\n\t);\n\n\tconst initialViewportValues = useMemo( () => {\n\t\tif ( blocks?.length === 0 ) {\n\t\t\treturn {\n\t\t\t\thideEverywhere: false,\n\t\t\t\tviewportChecked: {},\n\t\t\t};\n\t\t}\n\n\t\tconst viewportValues = {};\n\n\t\tviewportEntries.forEach( ( [ , { key } ] ) => {\n\t\t\tviewportValues[ key ] = getViewportCheckboxState( blocks, key );\n\t\t} );\n\n\t\treturn {\n\t\t\thideEverywhere: getHideEverywhereCheckboxState( blocks ),\n\t\t\tviewportChecked: viewportValues,\n\t\t};\n\t}, [ blocks, viewportEntries ] );\n\n\tconst [ viewportChecked, setViewportChecked ] = useState(\n\t\tinitialViewportValues?.viewportChecked ?? {}\n\t);\n\tconst [ hideEverywhere, setHideEverywhere ] = useState(\n\t\tinitialViewportValues?.hideEverywhere ?? false\n\t);\n\n\tconst handleViewportCheckboxChange = useCallback(\n\t\t( viewport, isChecked ) => {\n\t\t\tsetViewportChecked( {\n\t\t\t\t...viewportChecked,\n\t\t\t\t[ viewport ]: isChecked,\n\t\t\t} );\n\t\t},\n\t\t[ viewportChecked ]\n\t);\n\n\tconst noticeMessage = useMemo( () => {\n\t\tif ( ! hideEverywhere ) {\n\t\t\treturn sprintf(\n\t\t\t\t// translators: %s: The shortcut key to access the List View.\n\t\t\t\t__(\n\t\t\t\t\t'Block visibility settings updated. You can access them via the List View (%s).'\n\t\t\t\t),\n\t\t\t\tlistViewShortcut\n\t\t\t);\n\t\t}\n\n\t\tconst message =\n\t\t\tblocks?.length > 1\n\t\t\t\t? // translators: %s: The shortcut key to access the List View.\n\t\t\t\t __(\n\t\t\t\t\t\t'Blocks hidden. You can access them via the List View (%s).'\n\t\t\t\t )\n\t\t\t\t: // translators: %s: The shortcut key to access the List View.\n\t\t\t\t __(\n\t\t\t\t\t\t'Block hidden. You can access it via the List View (%s).'\n\t\t\t\t );\n\n\t\treturn sprintf( message, listViewShortcut );\n\t}, [ hideEverywhere, blocks?.length, listViewShortcut ] );\n\n\tconst isAnyViewportChecked = useMemo(\n\t\t() =>\n\t\t\tObject.values( viewportChecked ).some(\n\t\t\t\t( checked ) => checked === true || checked === null\n\t\t\t),\n\t\t[ viewportChecked ]\n\t);\n\n\tconst isDirty = useMemo( () => {\n\t\tif ( hideEverywhere !== initialViewportValues.hideEverywhere ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn viewportEntries.some(\n\t\t\t( [ , { key } ] ) =>\n\t\t\t\tviewportChecked[ key ] !==\n\t\t\t\tinitialViewportValues.viewportChecked[ key ]\n\t\t);\n\t}, [\n\t\thideEverywhere,\n\t\tviewportChecked,\n\t\tinitialViewportValues,\n\t\tviewportEntries,\n\t] );\n\n\tconst hasIndeterminateValues = useMemo( () => {\n\t\tif ( hideEverywhere === null ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn Object.values( viewportChecked ).some(\n\t\t\t( checked ) => checked === null\n\t\t);\n\t}, [ hideEverywhere, viewportChecked ] );\n\n\tconst handleSubmit = useCallback(\n\t\t( event ) => {\n\t\t\tevent.preventDefault();\n\t\t\tconst newVisibility = hideEverywhere\n\t\t\t\t? false\n\t\t\t\t: {\n\t\t\t\t\t\tviewport: viewportEntries.reduce(\n\t\t\t\t\t\t\t( acc, [ , { key } ] ) => {\n\t\t\t\t\t\t\t\tif ( viewportChecked[ key ] ) {\n\t\t\t\t\t\t\t\t\t// Values are inverted to hide the block on the selected viewport.\n\t\t\t\t\t\t\t\t\t// In the UI, the checkbox is checked (true) when the block is hidden on the selected viewport,\n\t\t\t\t\t\t\t\t\t// so 'false' means hide the block on the selected viewport.\n\t\t\t\t\t\t\t\t\tacc[ key ] = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn acc;\n\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 };\n\t\t\tconst attributesByClientId = Object.fromEntries(\n\t\t\t\tblocks.map( ( { clientId, attributes } ) => [\n\t\t\t\t\tclientId,\n\t\t\t\t\t{\n\t\t\t\t\t\tmetadata: cleanEmptyObject( {\n\t\t\t\t\t\t\t...attributes?.metadata,\n\t\t\t\t\t\t\tblockVisibility: newVisibility,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t},\n\t\t\t\t] )\n\t\t\t);\n\t\t\tupdateBlockAttributes( clientIds, attributesByClientId, {\n\t\t\t\tuniqueByBlock: true,\n\t\t\t} );\n\n\t\t\tcreateSuccessNotice( noticeMessage, {\n\t\t\t\tid: hideEverywhere\n\t\t\t\t\t? 'block-visibility-hidden'\n\t\t\t\t\t: 'block-visibility-viewports-updated',\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t\tonClose();\n\t\t},\n\t\t[\n\t\t\tblocks,\n\t\t\tclientIds,\n\t\t\tcreateSuccessNotice,\n\t\t\thideEverywhere,\n\t\t\tnoticeMessage,\n\t\t\tonClose,\n\t\t\tupdateBlockAttributes,\n\t\t\tviewportEntries,\n\t\t\tviewportChecked,\n\t\t]\n\t);\n\n\tconst hasMultipleBlocks = blocks?.length > 1;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={\n\t\t\t\tclientIds?.length > 1 ? __( 'Hide blocks' ) : __( 'Hide block' )\n\t\t\t}\n\t\t\tonRequestClose={ onClose }\n\t\t\toverlayClassName=\"block-editor-block-visibility-modal\"\n\t\t\tsize=\"small\"\n\t\t>\n\t\t\t<form onSubmit={ handleSubmit }>\n\t\t\t\t<fieldset>\n\t\t\t\t\t<legend>\n\t\t\t\t\t\t{ hasMultipleBlocks\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'Select the viewport sizes for which you want to hide the blocks. Changes will apply to all selected blocks.'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Select the viewport size for which you want to hide the block.'\n\t\t\t\t\t\t\t ) }\n\t\t\t\t\t</legend>\n\t\t\t\t\t<ul className=\"block-editor-block-visibility-modal__options\">\n\t\t\t\t\t\t<li className=\"block-editor-block-visibility-modal__options-item block-editor-block-visibility-modal__options-item--everywhere\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-visibility-modal__options-checkbox--everywhere\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Omit from published content' ) }\n\t\t\t\t\t\t\t\tchecked={ hideEverywhere === true }\n\t\t\t\t\t\t\t\tindeterminate={ hideEverywhere === null }\n\t\t\t\t\t\t\t\tonChange={ ( checked ) => {\n\t\t\t\t\t\t\t\t\tsetHideEverywhere( checked );\n\t\t\t\t\t\t\t\t\t// Reset viewport checkboxes when hide everywhere is checked.\n\t\t\t\t\t\t\t\t\tsetViewportChecked(\n\t\t\t\t\t\t\t\t\t\tDEFAULT_VIEWPORT_CHECKBOX_VALUES\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{ hideEverywhere !== true && (\n\t\t\t\t\t\t\t\t<ul className=\"block-editor-block-visibility-modal__sub-options\">\n\t\t\t\t\t\t\t\t\t{ viewportEntries.map(\n\t\t\t\t\t\t\t\t\t\t( [ , { label, icon, key } ] ) => (\n\t\t\t\t\t\t\t\t\t\t\t<li\n\t\t\t\t\t\t\t\t\t\t\t\tkey={ key }\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-block-visibility-modal__options-item\"\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t// translators: %s: The viewport name.\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t__( 'Hide on %s' ),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tviewportChecked[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t] ?? false\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\tindeterminate={\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tviewportChecked[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t] === null\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChange={ ( checked ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\thandleViewportCheckboxChange(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tchecked\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t\t<WCIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\t\t\t\tclassName={ clsx( {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'block-editor-block-visibility-modal__options-icon--checked':\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tviewportChecked[\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t</li>\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</ul>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t{ hasMultipleBlocks && hasIndeterminateValues && (\n\t\t\t\t\t\t<p className=\"block-editor-block-visibility-modal__description\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Selected blocks have different visibility settings. The checkboxes show an indeterminate state when settings differ.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! hasMultipleBlocks && hideEverywhere === true && (\n\t\t\t\t\t\t<p className=\"block-editor-block-visibility-modal__description\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The shortcut key to access the List View.\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Block will be hidden in the editor, and omitted from the published markup on the frontend. You can configure it again by selecting it in the List View (%s).'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tlistViewShortcut\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! hasMultipleBlocks &&\n\t\t\t\t\t\t! hideEverywhere &&\n\t\t\t\t\t\tisAnyViewportChecked && (\n\t\t\t\t\t\t\t<p className=\"block-editor-block-visibility-modal__description\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: The shortcut key to access the List View\n\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t'Block will be hidden according to the selected viewports. It will be <strong>included in the published markup on the frontend</strong>. You can configure it again by selecting it in the List View (%s).'\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tlistViewShortcut\n\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\tstrong: <strong />,\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</p>\n\t\t\t\t\t\t) }\n\t\t\t\t</fieldset>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-visibility-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\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AA,kBACL,UAAW,CAAE;AAAA,kBACb,wBAAsB;AAAA,kBACtB,uBAAqB;AAAA,kBAEnB,8BAAI,OAAQ;AAAA;AAAA,cACf,GACD;AAAA;AAAA;AAAA,QACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
6
|
"names": ["import_utils", "noticesStore", "blockEditorStore", "keyboardShortcutsStore", "WCIcon", "clsx"]
|
|
7
7
|
}
|
|
@@ -24,23 +24,33 @@ __export(use_block_visibility_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(use_block_visibility_exports);
|
|
26
26
|
var import_compose = require("@wordpress/compose");
|
|
27
|
+
var import_global_styles_engine = require("@wordpress/global-styles-engine");
|
|
27
28
|
var import_constants = require("./constants.cjs");
|
|
29
|
+
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
30
|
+
var { getViewportBreakpoints } = (0, import_lock_unlock.unlock)(import_global_styles_engine.privateApis);
|
|
28
31
|
function useBlockVisibility(options = {}) {
|
|
29
32
|
const {
|
|
30
33
|
blockVisibility = void 0,
|
|
31
34
|
deviceType = import_constants.BLOCK_VISIBILITY_VIEWPORTS.desktop.key,
|
|
35
|
+
viewportSettings,
|
|
32
36
|
view = window
|
|
33
37
|
} = options;
|
|
34
|
-
const
|
|
35
|
-
const
|
|
38
|
+
const viewportBreakpoints = getViewportBreakpoints(viewportSettings);
|
|
39
|
+
const mobileMediaQuery = viewportBreakpoints.mobile ? `(width <= ${viewportBreakpoints.mobile})` : void 0;
|
|
40
|
+
const isMobileViewport = (0, import_compose.useMediaQuery)(mobileMediaQuery, view);
|
|
41
|
+
let tabletMediaQuery;
|
|
42
|
+
if (viewportBreakpoints.tablet) {
|
|
43
|
+
tabletMediaQuery = viewportBreakpoints.mobile ? `(${viewportBreakpoints.mobile} < width <= ${viewportBreakpoints.tablet})` : `(width <= ${viewportBreakpoints.tablet})`;
|
|
44
|
+
}
|
|
45
|
+
const isTabletViewport = (0, import_compose.useMediaQuery)(tabletMediaQuery, view);
|
|
36
46
|
let currentViewport;
|
|
37
|
-
if (deviceType === import_constants.BLOCK_VISIBILITY_VIEWPORTS.mobile.key) {
|
|
47
|
+
if (deviceType === import_constants.BLOCK_VISIBILITY_VIEWPORTS.mobile.key && viewportBreakpoints.mobile) {
|
|
38
48
|
currentViewport = import_constants.BLOCK_VISIBILITY_VIEWPORTS.mobile.key;
|
|
39
|
-
} else if (deviceType === import_constants.BLOCK_VISIBILITY_VIEWPORTS.tablet.key) {
|
|
49
|
+
} else if (deviceType === import_constants.BLOCK_VISIBILITY_VIEWPORTS.tablet.key && viewportBreakpoints.tablet) {
|
|
40
50
|
currentViewport = import_constants.BLOCK_VISIBILITY_VIEWPORTS.tablet.key;
|
|
41
|
-
} else if (
|
|
51
|
+
} else if (isMobileViewport) {
|
|
42
52
|
currentViewport = import_constants.BLOCK_VISIBILITY_VIEWPORTS.mobile.key;
|
|
43
|
-
} else if (
|
|
53
|
+
} else if (isTabletViewport && viewportBreakpoints.tablet) {
|
|
44
54
|
currentViewport = import_constants.BLOCK_VISIBILITY_VIEWPORTS.tablet.key;
|
|
45
55
|
} else {
|
|
46
56
|
currentViewport = import_constants.BLOCK_VISIBILITY_VIEWPORTS.desktop.key;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-visibility/use-block-visibility.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMediaQuery } from '@wordpress/compose';\nimport { privateApis as globalStylesEnginePrivateApis } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport { BLOCK_VISIBILITY_VIEWPORTS } from './constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { getViewportBreakpoints } = unlock( globalStylesEnginePrivateApis );\n\n/**\n * Returns information about the current block visibility state.\n *\n * @param {Object} options Parameters to avoid extra store subscriptions.\n * @param {Object|boolean} options.blockVisibility Block visibility metadata.\n * @param {string} options.deviceType Current device type ('desktop', 'tablet', 'mobile').\n * @param {Object} options.viewportSettings Viewport breakpoint settings.\n * @param {Window?} options.view Window instance in which to perform viewport matching\n * @return {Object} Object with `isBlockCurrentlyHidden` (boolean) and `currentViewport` (string) properties.\n */\nexport default function useBlockVisibility( options = {} ) {\n\tconst {\n\t\tblockVisibility = undefined,\n\t\tdeviceType = BLOCK_VISIBILITY_VIEWPORTS.desktop.key,\n\t\tviewportSettings,\n\t\tview = window,\n\t} = options;\n\n\tconst viewportBreakpoints = getViewportBreakpoints( viewportSettings );\n\tconst mobileMediaQuery = viewportBreakpoints.mobile\n\t\t? `(width <= ${ viewportBreakpoints.mobile })`\n\t\t: undefined;\n\tconst isMobileViewport = useMediaQuery( mobileMediaQuery, view );\n\tlet tabletMediaQuery;\n\tif ( viewportBreakpoints.tablet ) {\n\t\ttabletMediaQuery = viewportBreakpoints.mobile\n\t\t\t? `(${ viewportBreakpoints.mobile } < width <= ${ viewportBreakpoints.tablet })`\n\t\t\t: `(width <= ${ viewportBreakpoints.tablet })`;\n\t}\n\tconst isTabletViewport = useMediaQuery( tabletMediaQuery, view );\n\n\t/*\n\t * Priority:\n\t * 1. Device type override (Mobile/Tablet) - uses device type to determine viewport\n\t * 2. Actual window size (Desktop mode) - uses viewport detection\n\t */\n\tlet currentViewport;\n\tif (\n\t\tdeviceType === BLOCK_VISIBILITY_VIEWPORTS.mobile.key &&\n\t\tviewportBreakpoints.mobile\n\t) {\n\t\tcurrentViewport = BLOCK_VISIBILITY_VIEWPORTS.mobile.key;\n\t} else if (\n\t\tdeviceType === BLOCK_VISIBILITY_VIEWPORTS.tablet.key &&\n\t\tviewportBreakpoints.tablet\n\t) {\n\t\tcurrentViewport = BLOCK_VISIBILITY_VIEWPORTS.tablet.key;\n\t} else if ( isMobileViewport ) {\n\t\tcurrentViewport = BLOCK_VISIBILITY_VIEWPORTS.mobile.key;\n\t} else if ( isTabletViewport && viewportBreakpoints.tablet ) {\n\t\tcurrentViewport = BLOCK_VISIBILITY_VIEWPORTS.tablet.key;\n\t} else {\n\t\tcurrentViewport = BLOCK_VISIBILITY_VIEWPORTS.desktop.key;\n\t}\n\n\t// Determine if block is currently hidden.\n\tconst isBlockCurrentlyHidden =\n\t\tblockVisibility === false ||\n\t\tblockVisibility?.viewport?.[ currentViewport ] === false;\n\n\treturn { isBlockCurrentlyHidden, currentViewport };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAC9B,kCAA6D;AAK7D,uBAA2C;AAC3C,yBAAuB;AAEvB,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,4BAAAA,WAA8B;AAY1D,SAAR,mBAAqC,UAAU,CAAC,GAAI;AAC1D,QAAM;AAAA,IACL,kBAAkB;AAAA,IAClB,aAAa,4CAA2B,QAAQ;AAAA,IAChD;AAAA,IACA,OAAO;AAAA,EACR,IAAI;AAEJ,QAAM,sBAAsB,uBAAwB,gBAAiB;AACrE,QAAM,mBAAmB,oBAAoB,SAC1C,aAAc,oBAAoB,MAAO,MACzC;AACH,QAAM,uBAAmB,8BAAe,kBAAkB,IAAK;AAC/D,MAAI;AACJ,MAAK,oBAAoB,QAAS;AACjC,uBAAmB,oBAAoB,SACpC,IAAK,oBAAoB,MAAO,eAAgB,oBAAoB,MAAO,MAC3E,aAAc,oBAAoB,MAAO;AAAA,EAC7C;AACA,QAAM,uBAAmB,8BAAe,kBAAkB,IAAK;AAO/D,MAAI;AACJ,MACC,eAAe,4CAA2B,OAAO,OACjD,oBAAoB,QACnB;AACD,sBAAkB,4CAA2B,OAAO;AAAA,EACrD,WACC,eAAe,4CAA2B,OAAO,OACjD,oBAAoB,QACnB;AACD,sBAAkB,4CAA2B,OAAO;AAAA,EACrD,WAAY,kBAAmB;AAC9B,sBAAkB,4CAA2B,OAAO;AAAA,EACrD,WAAY,oBAAoB,oBAAoB,QAAS;AAC5D,sBAAkB,4CAA2B,OAAO;AAAA,EACrD,OAAO;AACN,sBAAkB,4CAA2B,QAAQ;AAAA,EACtD;AAGA,QAAM,yBACL,oBAAoB,SACpB,iBAAiB,WAAY,eAAgB,MAAM;AAEpD,SAAO,EAAE,wBAAwB,gBAAgB;AAClD;",
|
|
6
|
+
"names": ["globalStylesEnginePrivateApis"]
|
|
7
7
|
}
|
|
@@ -21,12 +21,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var utils_exports = {};
|
|
22
22
|
__export(utils_exports, {
|
|
23
23
|
getBlockVisibilityLabel: () => getBlockVisibilityLabel,
|
|
24
|
+
getBlockVisibilityViewportEntries: () => getBlockVisibilityViewportEntries,
|
|
24
25
|
getHideEverywhereCheckboxState: () => getHideEverywhereCheckboxState,
|
|
25
26
|
getViewportCheckboxState: () => getViewportCheckboxState
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(utils_exports);
|
|
29
|
+
var import_global_styles_engine = require("@wordpress/global-styles-engine");
|
|
28
30
|
var import_i18n = require("@wordpress/i18n");
|
|
29
31
|
var import_constants = require("./constants.cjs");
|
|
32
|
+
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
33
|
+
var { getViewportBreakpoints } = (0, import_lock_unlock.unlock)(import_global_styles_engine.privateApis);
|
|
34
|
+
function getBlockVisibilityViewportEntries(viewportSettings) {
|
|
35
|
+
const breakpoints = getViewportBreakpoints(viewportSettings);
|
|
36
|
+
return import_constants.BLOCK_VISIBILITY_VIEWPORT_ENTRIES.filter(
|
|
37
|
+
([viewport]) => (viewport !== import_constants.BLOCK_VISIBILITY_VIEWPORTS.tablet.key || breakpoints.tablet !== void 0) && (viewport !== import_constants.BLOCK_VISIBILITY_VIEWPORTS.mobile.key || breakpoints.mobile !== void 0)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
30
40
|
function isBlockHiddenForViewport(block, viewport) {
|
|
31
41
|
if (!block) {
|
|
32
42
|
return false;
|
|
@@ -79,7 +89,7 @@ function getHideEverywhereCheckboxState(blocks) {
|
|
|
79
89
|
}
|
|
80
90
|
return null;
|
|
81
91
|
}
|
|
82
|
-
function getBlockVisibilityLabel(blockVisibility) {
|
|
92
|
+
function getBlockVisibilityLabel(blockVisibility, viewportSettings) {
|
|
83
93
|
if (!blockVisibility && blockVisibility !== false) {
|
|
84
94
|
return null;
|
|
85
95
|
}
|
|
@@ -87,7 +97,9 @@ function getBlockVisibilityLabel(blockVisibility) {
|
|
|
87
97
|
return (0, import_i18n.__)("Block is hidden");
|
|
88
98
|
}
|
|
89
99
|
if (blockVisibility?.viewport) {
|
|
90
|
-
const hiddenViewports =
|
|
100
|
+
const hiddenViewports = getBlockVisibilityViewportEntries(
|
|
101
|
+
viewportSettings
|
|
102
|
+
).filter(
|
|
91
103
|
([key]) => blockVisibility.viewport?.[key] === false
|
|
92
104
|
).map(([, viewport]) => viewport.label);
|
|
93
105
|
if (hiddenViewports.length > 0) {
|
|
@@ -103,6 +115,7 @@ function getBlockVisibilityLabel(blockVisibility) {
|
|
|
103
115
|
// Annotate the CommonJS export names for ESM import in node:
|
|
104
116
|
0 && (module.exports = {
|
|
105
117
|
getBlockVisibilityLabel,
|
|
118
|
+
getBlockVisibilityViewportEntries,
|
|
106
119
|
getHideEverywhereCheckboxState,
|
|
107
120
|
getViewportCheckboxState
|
|
108
121
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-visibility/utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAK5B,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as globalStylesEnginePrivateApis } from '@wordpress/global-styles-engine';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBLOCK_VISIBILITY_VIEWPORT_ENTRIES,\n\tBLOCK_VISIBILITY_VIEWPORTS,\n} from './constants';\nimport { unlock } from '../../lock-unlock';\n\nconst { getViewportBreakpoints } = unlock( globalStylesEnginePrivateApis );\n\nexport function getBlockVisibilityViewportEntries( viewportSettings ) {\n\tconst breakpoints = getViewportBreakpoints( viewportSettings );\n\n\t// Desktop has no breakpoint, so only filter mobile/tablet by configured viewport support.\n\treturn BLOCK_VISIBILITY_VIEWPORT_ENTRIES.filter(\n\t\t( [ viewport ] ) =>\n\t\t\t( viewport !== BLOCK_VISIBILITY_VIEWPORTS.tablet.key ||\n\t\t\t\tbreakpoints.tablet !== undefined ) &&\n\t\t\t( viewport !== BLOCK_VISIBILITY_VIEWPORTS.mobile.key ||\n\t\t\t\tbreakpoints.mobile !== undefined )\n\t);\n}\n\n/**\n * Checks if a block is hidden for a specific viewport.\n *\n * @param {Object} block The block to check.\n * @param {string} viewport The viewport to check (e.g., 'mobile', 'tablet', 'desktop').\n * @return {boolean} Whether the block is hidden for the viewport.\n */\nfunction isBlockHiddenForViewport( block, viewport ) {\n\tif ( ! block ) {\n\t\treturn false;\n\t}\n\n\tconst blockVisibility = block.attributes?.metadata?.blockVisibility;\n\n\t// If explicitly visible everywhere (true), return false for all viewports.\n\tif ( blockVisibility === true ) {\n\t\treturn false;\n\t}\n\n\t// If null or not an object, block is not hidden for any specific viewport.\n\tif ( 'object' !== typeof blockVisibility ) {\n\t\treturn false;\n\t}\n\n\t// Get viewport configuration from nested structure.\n\tconst viewportConfig = blockVisibility.viewport;\n\n\t// If no viewport config, block is not hidden for any specific viewport.\n\tif ( ! viewportConfig || 'object' !== typeof viewportConfig ) {\n\t\treturn false;\n\t}\n\n\t// Check if the viewport is valid.\n\tif (\n\t\t! BLOCK_VISIBILITY_VIEWPORT_ENTRIES.some(\n\t\t\t( [ , { key } ] ) => key === viewport\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\t// Check if the specific viewport is hidden.\n\treturn viewportConfig[ viewport ] === false;\n}\n\n/**\n * Gets the checkbox state for a viewport across multiple blocks.\n * Returns `true` if all blocks are hidden, `null` if some are hidden, `false` if none are hidden.\n *\n * @param {Array} blocks Array of blocks to check.\n * @param {string} viewport The viewport to check (e.g., 'mobile', 'tablet', 'desktop').\n * @return {boolean|null} `true` if all hidden, `null` if some hidden, `false` if none hidden.\n */\nexport function getViewportCheckboxState( blocks, viewport ) {\n\tif ( ! blocks?.length ) {\n\t\treturn false;\n\t}\n\n\tconst hiddenCount = blocks.filter( ( block ) =>\n\t\tisBlockHiddenForViewport( block, viewport )\n\t).length;\n\n\tif ( hiddenCount === 0 ) {\n\t\treturn false;\n\t}\n\tif ( hiddenCount === blocks.length ) {\n\t\treturn true;\n\t}\n\n\treturn null; // Indeterminate: some hidden, some visible (normal mixed state)\n}\n\n/**\n * Gets the checkbox state for \"hide everywhere\" across multiple blocks.\n * Returns `true` if all blocks are hidden everywhere, `null` if some are hidden everywhere, `false` if none are.\n *\n * @param {Array} blocks Array of blocks to check.\n * @return {boolean|null} `true` if all hidden everywhere, `null` if some hidden everywhere, `false` if none.\n */\nexport function getHideEverywhereCheckboxState( blocks ) {\n\tif ( ! blocks?.length ) {\n\t\treturn false;\n\t}\n\n\tconst hiddenEverywhereCount = blocks.filter(\n\t\t( block ) =>\n\t\t\tblock && block.attributes?.metadata?.blockVisibility === false\n\t).length;\n\n\tif ( hiddenEverywhereCount === 0 ) {\n\t\treturn false;\n\t}\n\tif ( hiddenEverywhereCount === blocks.length ) {\n\t\treturn true;\n\t}\n\n\treturn null; // Indeterminate: some but not all\n}\n\n/**\n * Get a human-readable label describing which viewports a block is hidden on.\n *\n * @param {boolean|Object} blockVisibility The block's visibility metadata.\n * @param {Object} viewportSettings Viewport breakpoint settings.\n * @return {string|null} A descriptive label, or null if the block is not hidden.\n */\nexport function getBlockVisibilityLabel( blockVisibility, viewportSettings ) {\n\t// Not hidden at all\n\tif ( ! blockVisibility && blockVisibility !== false ) {\n\t\treturn null;\n\t}\n\n\tif ( blockVisibility === false ) {\n\t\t// Hidden on all viewports\n\t\treturn __( 'Block is hidden' );\n\t}\n\n\tif ( blockVisibility?.viewport ) {\n\t\t// Hidden on specific viewports - list them\n\t\tconst hiddenViewports = getBlockVisibilityViewportEntries(\n\t\t\tviewportSettings\n\t\t)\n\t\t\t.filter(\n\t\t\t\t( [ key ] ) => blockVisibility.viewport?.[ key ] === false\n\t\t\t)\n\t\t\t.map( ( [ , viewport ] ) => viewport.label );\n\n\t\tif ( hiddenViewports.length > 0 ) {\n\t\t\treturn sprintf(\n\t\t\t\t/* translators: %s: comma-separated list of viewport names (Desktop, Tablet, Mobile) */\n\t\t\t\t__( 'Block is hidden on %s' ),\n\t\t\t\thiddenViewports.join( ', ' )\n\t\t\t);\n\t\t}\n\t}\n\n\treturn null;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kCAA6D;AAC7D,kBAA4B;AAK5B,uBAGO;AACP,yBAAuB;AAEvB,IAAM,EAAE,uBAAuB,QAAI,2BAAQ,4BAAAA,WAA8B;AAElE,SAAS,kCAAmC,kBAAmB;AACrE,QAAM,cAAc,uBAAwB,gBAAiB;AAG7D,SAAO,mDAAkC;AAAA,IACxC,CAAE,CAAE,QAAS,OACV,aAAa,4CAA2B,OAAO,OAChD,YAAY,WAAW,YACtB,aAAa,4CAA2B,OAAO,OAChD,YAAY,WAAW;AAAA,EAC1B;AACD;AASA,SAAS,yBAA0B,OAAO,UAAW;AACpD,MA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K,iBAAiB,UAAW;AAEhC,UAAM,kBAAkB;AAAA,MACvB;AAAA,IACD,EACE;AAAA,MACA,CAAE,CAAE,GAAI,MAAO,gBAAgB,WAAY,GAAI,MAAM;AAAA,IACtD,EACC,IAAK,CAAE,CAAE,EAAE,QAAS,MAAO,SAAS,KAAM;AAE5C,QAAK,gBAAgB,SAAS,GAAI;AACjC,iBAAO;AAAA;AAAA,YAEN,gBAAI,uBAAwB;AAAA,QAC5B,gBAAgB,KAAM,IAAK;AAAA,MAC5B;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": ["globalStylesEnginePrivateApis"]
|
|
7
7
|
}
|
|
@@ -29,8 +29,10 @@ var import_data = require("@wordpress/data");
|
|
|
29
29
|
var import_keyboard_shortcuts = require("@wordpress/keyboard-shortcuts");
|
|
30
30
|
var import_store = require("../../store/index.cjs");
|
|
31
31
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
32
|
+
var import_use_settings = require("../use-settings/index.cjs");
|
|
32
33
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
34
|
function BlockVisibilityViewportMenuItem({ clientIds }) {
|
|
35
|
+
const [blockVisibility] = (0, import_use_settings.useSettings)("blockVisibility.allowEditing");
|
|
34
36
|
const { areBlocksHiddenAnywhere, shortcut } = (0, import_data.useSelect)(
|
|
35
37
|
(select) => {
|
|
36
38
|
const { isBlockHiddenAnywhere } = (0, import_lock_unlock.unlock)(
|
|
@@ -49,7 +51,11 @@ function BlockVisibilityViewportMenuItem({ clientIds }) {
|
|
|
49
51
|
},
|
|
50
52
|
[clientIds]
|
|
51
53
|
);
|
|
52
|
-
const
|
|
54
|
+
const dispatch = (0, import_data.useDispatch)(import_store.store);
|
|
55
|
+
if (blockVisibility === false) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const { showViewportModal } = (0, import_lock_unlock.unlock)(dispatch);
|
|
53
59
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
54
60
|
import_components.MenuItem,
|
|
55
61
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/block-visibility/viewport-menu-item.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nexport default function BlockVisibilityViewportMenuItem( { clientIds } ) {\n\tconst { areBlocksHiddenAnywhere, shortcut } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isBlockHiddenAnywhere } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tareBlocksHiddenAnywhere: clientIds?.every( ( clientId ) =>\n\t\t\t\t\tisBlockHiddenAnywhere( clientId )\n\t\t\t\t),\n\t\t\t\tshortcut: select(\n\t\t\t\t\tkeyboardShortcutsStore\n\t\t\t\t).getShortcutRepresentation(\n\t\t\t\t\t'core/block-editor/toggle-block-visibility'\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\tconst { showViewportModal } = unlock(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,wBAAyB;AACzB,kBAAuC;AACvC,gCAAgD;AAKhD,mBAA0C;AAC1C,yBAAuB;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useSettings } from '../use-settings';\n\nexport default function BlockVisibilityViewportMenuItem( { clientIds } ) {\n\tconst [ blockVisibility ] = useSettings( 'blockVisibility.allowEditing' );\n\tconst { areBlocksHiddenAnywhere, shortcut } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isBlockHiddenAnywhere } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tareBlocksHiddenAnywhere: clientIds?.every( ( clientId ) =>\n\t\t\t\t\tisBlockHiddenAnywhere( clientId )\n\t\t\t\t),\n\t\t\t\tshortcut: select(\n\t\t\t\t\tkeyboardShortcutsStore\n\t\t\t\t).getShortcutRepresentation(\n\t\t\t\t\t'core/block-editor/toggle-block-visibility'\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\tconst dispatch = useDispatch( blockEditorStore );\n\n\tif ( blockVisibility === false ) {\n\t\treturn null;\n\t}\n\n\tconst { showViewportModal } = unlock( dispatch );\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => showViewportModal( clientIds ) }\n\t\t\tshortcut={ shortcut }\n\t\t>\n\t\t\t{ areBlocksHiddenAnywhere ? __( 'Show' ) : __( 'Hide' ) }\n\t\t</MenuItem>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AACnB,wBAAyB;AACzB,kBAAuC;AACvC,gCAAgD;AAKhD,mBAA0C;AAC1C,yBAAuB;AACvB,0BAA4B;AA+B1B;AA7Ba,SAAR,gCAAkD,EAAE,UAAU,GAAI;AACxE,QAAM,CAAE,eAAgB,QAAI,iCAAa,8BAA+B;AACxE,QAAM,EAAE,yBAAyB,SAAS,QAAI;AAAA,IAC7C,CAAE,WAAY;AACb,YAAM,EAAE,sBAAsB,QAAI;AAAA,QACjC,OAAQ,aAAAA,KAAiB;AAAA,MAC1B;AACA,aAAO;AAAA,QACN,yBAAyB,WAAW;AAAA,UAAO,CAAE,aAC5C,sBAAuB,QAAS;AAAA,QACjC;AAAA,QACA,UAAU;AAAA,UACT,0BAAAC;AAAA,QACD,EAAE;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,SAAU;AAAA,EACb;AACA,QAAM,eAAW,yBAAa,aAAAD,KAAiB;AAE/C,MAAK,oBAAoB,OAAQ;AAChC,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,kBAAkB,QAAI,2BAAQ,QAAS;AAE/C,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,MAAM,kBAAmB,SAAU;AAAA,MAC7C;AAAA,MAEE,wCAA0B,gBAAI,MAAO,QAAI,gBAAI,MAAO;AAAA;AAAA,EACvD;AAEF;",
|
|
6
6
|
"names": ["blockEditorStore", "keyboardShortcutsStore"]
|
|
7
7
|
}
|
|
@@ -31,9 +31,11 @@ var import_blocks = require("@wordpress/blocks");
|
|
|
31
31
|
var import_data = require("@wordpress/data");
|
|
32
32
|
var import_store = require("../../store/index.cjs");
|
|
33
33
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
34
|
+
var import_use_settings = require("../use-settings/index.cjs");
|
|
34
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
36
|
function BlockVisibilityViewportToolbar({ clientIds }) {
|
|
36
37
|
const hasBlockVisibilityButtonShownRef = (0, import_element.useRef)(false);
|
|
38
|
+
const [blockVisibility] = (0, import_use_settings.useSettings)("blockVisibility.allowEditing");
|
|
37
39
|
const { canToggleBlockVisibility, areBlocksHiddenAnywhere } = (0, import_data.useSelect)(
|
|
38
40
|
(select) => {
|
|
39
41
|
const { getBlocksByClientId, getBlockName, isBlockHiddenAnywhere } = (0, import_lock_unlock.unlock)(select(import_store.store));
|
|
@@ -59,6 +61,9 @@ function BlockVisibilityViewportToolbar({ clientIds }) {
|
|
|
59
61
|
hasBlockVisibilityButtonShownRef.current = true;
|
|
60
62
|
}
|
|
61
63
|
}, [areBlocksHiddenAnywhere]);
|
|
64
|
+
if (blockVisibility === false) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
62
67
|
if (!areBlocksHiddenAnywhere && !hasBlockVisibilityButtonShownRef.current) {
|
|
63
68
|
return null;
|
|
64
69
|
}
|