@wordpress/block-editor 12.1.0 → 12.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/autocompleters/block.js +13 -5
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +6 -3
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-editing-mode/index.js +84 -0
- package/build/components/block-editing-mode/index.js.map +1 -0
- package/build/components/block-list/block-list-block-context.js +15 -0
- package/build/components/block-list/block-list-block-context.js.map +1 -0
- package/build/components/block-list/block.js +29 -37
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +14 -22
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +107 -108
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +2 -2
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +7 -5
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js +15 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +19 -4
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-styles/preview-panel.js +1 -2
- package/build/components/block-styles/preview-panel.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +8 -0
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/block-variation-transformations.js +125 -0
- package/build/components/block-switcher/block-variation-transformations.js.map +1 -0
- package/build/components/block-switcher/index.js +34 -12
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +3 -3
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/index.js +9 -7
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +5 -3
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +11 -5
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +7 -2
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.native.js +87 -3
- package/build/components/convert-to-group-buttons/index.native.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +23 -37
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +3 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/iframe/index.js +14 -7
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +2 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +7 -7
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +13 -5
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/index.js +3 -7
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -4
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +19 -6
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/list-view/appender.js +6 -1
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/list-view/block-contents.js +4 -2
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +21 -25
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +1 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +14 -7
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +27 -3
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +0 -2
- package/build/components/publish-date-time-picker/index.js.map +1 -1
- package/build/components/url-input/index.js +3 -0
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +25 -15
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +8 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +13 -7
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/align.js +3 -7
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/behaviors.js +115 -0
- package/build/hooks/behaviors.js.map +1 -0
- package/build/hooks/dimensions.js +0 -30
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +4 -8
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +8 -9
- package/build/hooks/layout.js.map +1 -1
- package/build/private-apis.js +4 -7
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +46 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +88 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +36 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +28 -18
- package/build/store/selectors.js.map +1 -1
- package/build/utils/order-inserter-block-items.js +41 -0
- package/build/utils/order-inserter-block-items.js.map +1 -0
- package/build-module/autocompleters/block.js +12 -5
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +5 -3
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +72 -0
- package/build-module/components/block-editing-mode/index.js.map +1 -0
- package/build-module/components/block-list/block-list-block-context.js +6 -0
- package/build-module/components/block-list/block-list-block-context.js.map +1 -0
- package/build-module/components/block-list/block.js +26 -34
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +14 -22
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +108 -110
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -1
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +6 -5
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +15 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -4
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-styles/preview-panel.js +1 -2
- package/build-module/components/block-styles/preview-panel.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +7 -0
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/block-variation-transformations.js +108 -0
- package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -0
- package/build-module/components/block-switcher/index.js +33 -12
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -3
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +8 -7
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +4 -3
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +11 -5
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +7 -2
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.native.js +76 -1
- package/build-module/components/convert-to-group-buttons/index.native.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +22 -36
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/iframe/index.js +15 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +2 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +7 -6
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +13 -5
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -7
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -4
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +16 -6
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/list-view/appender.js +6 -2
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +4 -2
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +20 -25
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +15 -8
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +26 -3
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +0 -2
- package/build-module/components/publish-date-time-picker/index.js.map +1 -1
- package/build-module/components/url-input/index.js +3 -0
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +25 -16
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +8 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +13 -7
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/align.js +3 -6
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/behaviors.js +97 -0
- package/build-module/hooks/behaviors.js.map +1 -0
- package/build-module/hooks/dimensions.js +0 -28
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +3 -6
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +7 -9
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/private-apis.js +3 -5
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +42 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +79 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +34 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +26 -17
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/order-inserter-block-items.js +32 -0
- package/build-module/utils/order-inserter-block-items.js.map +1 -0
- package/build-style/content-rtl.css +32 -13
- package/build-style/content.css +32 -13
- 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 +19 -64
- package/build-style/style.css +20 -64
- package/package.json +32 -31
- package/src/autocompleters/block.js +15 -7
- package/src/components/block-breadcrumb/index.js +11 -3
- package/src/components/block-editing-mode/index.js +71 -0
- package/src/components/block-list/block-list-block-context.js +6 -0
- package/src/components/block-list/block.js +38 -56
- package/src/components/block-list/block.native.js +30 -41
- package/src/components/block-list/content.scss +5 -5
- package/src/components/block-list/index.native.js +164 -153
- package/src/components/block-list/test/index.native.js +2 -2
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-list/use-in-between-inserter.js +7 -3
- package/src/components/block-list-appender/index.js +22 -4
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +23 -0
- package/src/components/block-mover/style.scss +1 -0
- package/src/components/block-styles/preview-panel.js +1 -3
- package/src/components/block-switcher/block-transformations-menu.js +12 -0
- package/src/components/block-switcher/block-variation-transformations.js +115 -0
- package/src/components/block-switcher/index.js +38 -5
- package/src/components/block-switcher/pattern-transformations-menu.js +5 -5
- package/src/components/block-switcher/style.scss +6 -5
- package/src/components/block-toolbar/index.js +10 -11
- package/src/components/block-tools/block-contextual-toolbar.js +4 -5
- package/src/components/block-tools/insertion-point.js +23 -9
- package/src/components/button-block-appender/content.scss +22 -0
- package/src/components/convert-to-group-buttons/index.js +9 -2
- package/src/components/convert-to-group-buttons/index.native.js +79 -1
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +32 -38
- package/src/components/global-styles/dimensions-panel.js +3 -2
- package/src/components/global-styles/style.scss +3 -0
- package/src/components/iframe/index.js +22 -12
- package/src/components/inner-blocks/README.md +5 -0
- package/src/components/inner-blocks/index.js +2 -0
- package/src/components/inner-blocks/index.native.js +16 -6
- package/src/components/inner-blocks/use-nested-settings-update.js +20 -3
- package/src/components/inserter/index.js +1 -9
- package/src/components/inserter/quick-inserter.js +0 -2
- package/src/components/inserter/search-results.js +32 -6
- package/src/components/list-view/appender.js +3 -2
- package/src/components/list-view/block-contents.js +8 -2
- package/src/components/list-view/block.js +29 -35
- package/src/components/list-view/branch.js +1 -7
- package/src/components/list-view/index.js +17 -4
- package/src/components/list-view/style.scss +2 -5
- package/src/components/list-view/use-list-view-client-ids.js +21 -4
- package/src/components/publish-date-time-picker/index.js +0 -2
- package/src/components/url-input/README.md +6 -0
- package/src/components/url-input/index.js +1 -0
- package/src/components/use-block-drop-zone/index.js +31 -17
- package/src/components/use-resize-canvas/index.js +9 -1
- package/src/components/writing-flow/test/index.js +15 -0
- package/src/components/writing-flow/use-arrow-nav.js +17 -4
- package/src/hooks/align.js +3 -11
- package/src/hooks/behaviors.js +104 -0
- package/src/hooks/dimensions.js +0 -40
- package/src/hooks/duotone.js +3 -11
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +10 -18
- package/src/private-apis.js +2 -4
- package/src/store/private-actions.js +39 -0
- package/src/store/private-selectors.js +95 -0
- package/src/store/reducer.js +27 -0
- package/src/store/selectors.js +25 -15
- package/src/store/test/private-actions.js +32 -1
- package/src/store/test/private-selectors.js +158 -0
- package/src/store/test/reducer.js +48 -0
- package/src/style.scss +0 -3
- package/src/utils/order-inserter-block-items.js +26 -0
- package/build/components/block-list/block-list-compact.native.js +0 -75
- package/build/components/block-list/block-list-compact.native.js.map +0 -1
- package/build/components/off-canvas-editor/appender.js +0 -125
- package/build/components/off-canvas-editor/appender.js.map +0 -1
- package/build/components/off-canvas-editor/block-contents.js +0 -141
- package/build/components/off-canvas-editor/block-contents.js.map +0 -1
- package/build/components/off-canvas-editor/block-select-button.js +0 -126
- package/build/components/off-canvas-editor/block-select-button.js.map +0 -1
- package/build/components/off-canvas-editor/block.js +0 -297
- package/build/components/off-canvas-editor/block.js.map +0 -1
- package/build/components/off-canvas-editor/branch.js +0 -197
- package/build/components/off-canvas-editor/branch.js.map +0 -1
- package/build/components/off-canvas-editor/context.js +0 -19
- package/build/components/off-canvas-editor/context.js.map +0 -1
- package/build/components/off-canvas-editor/drop-indicator.js +0 -118
- package/build/components/off-canvas-editor/drop-indicator.js.map +0 -1
- package/build/components/off-canvas-editor/expander.js +0 -41
- package/build/components/off-canvas-editor/expander.js.map +0 -1
- package/build/components/off-canvas-editor/index.js +0 -236
- package/build/components/off-canvas-editor/index.js.map +0 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +0 -148
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
- package/build/components/off-canvas-editor/leaf.js +0 -60
- package/build/components/off-canvas-editor/leaf.js.map +0 -1
- package/build/components/off-canvas-editor/link-ui.js +0 -186
- package/build/components/off-canvas-editor/link-ui.js.map +0 -1
- package/build/components/off-canvas-editor/update-attributes.js +0 -108
- package/build/components/off-canvas-editor/update-attributes.js.map +0 -1
- package/build/components/off-canvas-editor/use-block-selection.js +0 -139
- package/build/components/off-canvas-editor/use-block-selection.js.map +0 -1
- package/build/components/off-canvas-editor/use-inserted-block.js +0 -58
- package/build/components/off-canvas-editor/use-inserted-block.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +0 -33
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +0 -235
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -60
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
- package/build/components/off-canvas-editor/utils.js +0 -60
- package/build/components/off-canvas-editor/utils.js.map +0 -1
- package/build-module/components/block-list/block-list-compact.native.js +0 -60
- package/build-module/components/block-list/block-list-compact.native.js.map +0 -1
- package/build-module/components/off-canvas-editor/appender.js +0 -108
- package/build-module/components/off-canvas-editor/appender.js.map +0 -1
- package/build-module/components/off-canvas-editor/block-contents.js +0 -121
- package/build-module/components/off-canvas-editor/block-contents.js.map +0 -1
- package/build-module/components/off-canvas-editor/block-select-button.js +0 -107
- package/build-module/components/off-canvas-editor/block-select-button.js.map +0 -1
- package/build-module/components/off-canvas-editor/block.js +0 -273
- package/build-module/components/off-canvas-editor/block.js.map +0 -1
- package/build-module/components/off-canvas-editor/branch.js +0 -179
- package/build-module/components/off-canvas-editor/branch.js.map +0 -1
- package/build-module/components/off-canvas-editor/context.js +0 -7
- package/build-module/components/off-canvas-editor/context.js.map +0 -1
- package/build-module/components/off-canvas-editor/drop-indicator.js +0 -111
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +0 -1
- package/build-module/components/off-canvas-editor/expander.js +0 -32
- package/build-module/components/off-canvas-editor/expander.js.map +0 -1
- package/build-module/components/off-canvas-editor/index.js +0 -213
- package/build-module/components/off-canvas-editor/index.js.map +0 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +0 -130
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
- package/build-module/components/off-canvas-editor/leaf.js +0 -45
- package/build-module/components/off-canvas-editor/leaf.js.map +0 -1
- package/build-module/components/off-canvas-editor/link-ui.js +0 -166
- package/build-module/components/off-canvas-editor/link-ui.js.map +0 -1
- package/build-module/components/off-canvas-editor/update-attributes.js +0 -97
- package/build-module/components/off-canvas-editor/update-attributes.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-block-selection.js +0 -124
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-inserted-block.js +0 -47
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +0 -24
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +0 -220
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -50
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
- package/build-module/components/off-canvas-editor/utils.js +0 -44
- package/build-module/components/off-canvas-editor/utils.js.map +0 -1
- package/src/components/block-list/block-list-compact.native.js +0 -63
- package/src/components/off-canvas-editor/README.md +0 -5
- package/src/components/off-canvas-editor/appender.js +0 -124
- package/src/components/off-canvas-editor/block-contents.js +0 -156
- package/src/components/off-canvas-editor/block-select-button.js +0 -128
- package/src/components/off-canvas-editor/block.js +0 -347
- package/src/components/off-canvas-editor/branch.js +0 -238
- package/src/components/off-canvas-editor/context.js +0 -8
- package/src/components/off-canvas-editor/drop-indicator.js +0 -126
- package/src/components/off-canvas-editor/expander.js +0 -26
- package/src/components/off-canvas-editor/index.js +0 -271
- package/src/components/off-canvas-editor/leaf-more-menu.js +0 -158
- package/src/components/off-canvas-editor/leaf.js +0 -52
- package/src/components/off-canvas-editor/link-ui.js +0 -167
- package/src/components/off-canvas-editor/style.scss +0 -34
- package/src/components/off-canvas-editor/test/use-inserted-block.js +0 -108
- package/src/components/off-canvas-editor/test/utils.js +0 -50
- package/src/components/off-canvas-editor/update-attributes.js +0 -99
- package/src/components/off-canvas-editor/use-block-selection.js +0 -169
- package/src/components/off-canvas-editor/use-inserted-block.js +0 -47
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +0 -29
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +0 -260
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -58
- package/src/components/off-canvas-editor/utils.js +0 -58
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { MenuItem } from '@wordpress/components';
|
|
5
|
+
import {
|
|
6
|
+
getBlockMenuDefaultClassName,
|
|
7
|
+
cloneBlock,
|
|
8
|
+
store as blocksStore,
|
|
9
|
+
} from '@wordpress/blocks';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { useState, useMemo } from '@wordpress/element';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { store as blockEditorStore } from '../../store';
|
|
17
|
+
import BlockIcon from '../block-icon';
|
|
18
|
+
import PreviewBlockPopover from './preview-block-popover';
|
|
19
|
+
|
|
20
|
+
const EMPTY_OBJECT = {};
|
|
21
|
+
|
|
22
|
+
export function useBlockVariationTransforms( { clientIds, blocks } ) {
|
|
23
|
+
const { activeBlockVariation, blockVariationTransformations } = useSelect(
|
|
24
|
+
( select ) => {
|
|
25
|
+
const {
|
|
26
|
+
getBlockRootClientId,
|
|
27
|
+
getBlockAttributes,
|
|
28
|
+
canRemoveBlocks,
|
|
29
|
+
} = select( blockEditorStore );
|
|
30
|
+
const { getActiveBlockVariation, getBlockVariations } =
|
|
31
|
+
select( blocksStore );
|
|
32
|
+
const rootClientId = getBlockRootClientId(
|
|
33
|
+
Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds
|
|
34
|
+
);
|
|
35
|
+
const canRemove = canRemoveBlocks( clientIds, rootClientId );
|
|
36
|
+
// Only handle single selected blocks for now.
|
|
37
|
+
if ( blocks.length !== 1 || ! canRemove ) {
|
|
38
|
+
return EMPTY_OBJECT;
|
|
39
|
+
}
|
|
40
|
+
const [ firstBlock ] = blocks;
|
|
41
|
+
return {
|
|
42
|
+
blockVariationTransformations: getBlockVariations(
|
|
43
|
+
firstBlock.name,
|
|
44
|
+
'transform'
|
|
45
|
+
),
|
|
46
|
+
activeBlockVariation: getActiveBlockVariation(
|
|
47
|
+
firstBlock.name,
|
|
48
|
+
getBlockAttributes( firstBlock.clientId )
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
[ clientIds, blocks ]
|
|
53
|
+
);
|
|
54
|
+
const transformations = useMemo( () => {
|
|
55
|
+
return blockVariationTransformations?.filter(
|
|
56
|
+
( { name } ) => name !== activeBlockVariation?.name
|
|
57
|
+
);
|
|
58
|
+
}, [ blockVariationTransformations, activeBlockVariation ] );
|
|
59
|
+
return transformations;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const BlockVariationTransformations = ( {
|
|
63
|
+
transformations,
|
|
64
|
+
onSelect,
|
|
65
|
+
blocks,
|
|
66
|
+
} ) => {
|
|
67
|
+
const [ hoveredTransformItemName, setHoveredTransformItemName ] =
|
|
68
|
+
useState();
|
|
69
|
+
return (
|
|
70
|
+
<>
|
|
71
|
+
{ hoveredTransformItemName && (
|
|
72
|
+
<PreviewBlockPopover
|
|
73
|
+
blocks={ cloneBlock(
|
|
74
|
+
blocks[ 0 ],
|
|
75
|
+
transformations.find(
|
|
76
|
+
( { name } ) => name === hoveredTransformItemName
|
|
77
|
+
).attributes
|
|
78
|
+
) }
|
|
79
|
+
/>
|
|
80
|
+
) }
|
|
81
|
+
{ transformations?.map( ( item ) => (
|
|
82
|
+
<BlockVariationTranformationItem
|
|
83
|
+
key={ item.name }
|
|
84
|
+
item={ item }
|
|
85
|
+
onSelect={ onSelect }
|
|
86
|
+
setHoveredTransformItemName={ setHoveredTransformItemName }
|
|
87
|
+
/>
|
|
88
|
+
) ) }
|
|
89
|
+
</>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
function BlockVariationTranformationItem( {
|
|
94
|
+
item,
|
|
95
|
+
onSelect,
|
|
96
|
+
setHoveredTransformItemName,
|
|
97
|
+
} ) {
|
|
98
|
+
const { name, icon, title } = item;
|
|
99
|
+
return (
|
|
100
|
+
<MenuItem
|
|
101
|
+
className={ getBlockMenuDefaultClassName( name ) }
|
|
102
|
+
onClick={ ( event ) => {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
onSelect( name );
|
|
105
|
+
} }
|
|
106
|
+
onMouseLeave={ () => setHoveredTransformItemName( null ) }
|
|
107
|
+
onMouseEnter={ () => setHoveredTransformItemName( name ) }
|
|
108
|
+
>
|
|
109
|
+
<BlockIcon icon={ icon } showColors />
|
|
110
|
+
{ title }
|
|
111
|
+
</MenuItem>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export default BlockVariationTransformations;
|
|
@@ -24,12 +24,14 @@ import { store as blockEditorStore } from '../../store';
|
|
|
24
24
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
25
25
|
import BlockIcon from '../block-icon';
|
|
26
26
|
import BlockTransformationsMenu from './block-transformations-menu';
|
|
27
|
+
import { useBlockVariationTransforms } from './block-variation-transformations';
|
|
27
28
|
import BlockStylesMenu from './block-styles-menu';
|
|
28
29
|
import PatternTransformationsMenu from './pattern-transformations-menu';
|
|
29
30
|
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
30
31
|
|
|
31
32
|
export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
32
|
-
const { replaceBlocks, multiSelect } =
|
|
33
|
+
const { replaceBlocks, multiSelect, updateBlockAttributes } =
|
|
34
|
+
useDispatch( blockEditorStore );
|
|
33
35
|
const blockInformation = useBlockDisplayInformation( blocks[ 0 ].clientId );
|
|
34
36
|
const {
|
|
35
37
|
possibleBlockTransformations,
|
|
@@ -43,9 +45,9 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
43
45
|
getBlockRootClientId,
|
|
44
46
|
getBlockTransformItems,
|
|
45
47
|
__experimentalGetPatternTransformItems,
|
|
48
|
+
canRemoveBlocks,
|
|
46
49
|
} = select( blockEditorStore );
|
|
47
50
|
const { getBlockStyles, getBlockType } = select( blocksStore );
|
|
48
|
-
const { canRemoveBlocks } = select( blockEditorStore );
|
|
49
51
|
const rootClientId = getBlockRootClientId(
|
|
50
52
|
Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds
|
|
51
53
|
);
|
|
@@ -82,6 +84,11 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
82
84
|
[ clientIds, blocks, blockInformation?.icon ]
|
|
83
85
|
);
|
|
84
86
|
|
|
87
|
+
const blockVariationTransformations = useBlockVariationTransforms( {
|
|
88
|
+
clientIds,
|
|
89
|
+
blocks,
|
|
90
|
+
} );
|
|
91
|
+
|
|
85
92
|
const blockTitle = useBlockDisplayTitle( {
|
|
86
93
|
clientId: Array.isArray( clientIds ) ? clientIds[ 0 ] : clientIds,
|
|
87
94
|
maximumLength: 35,
|
|
@@ -105,6 +112,14 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
105
112
|
selectForMultipleBlocks( newBlocks );
|
|
106
113
|
}
|
|
107
114
|
|
|
115
|
+
function onBlockVariationTransform( name ) {
|
|
116
|
+
updateBlockAttributes( blocks[ 0 ].clientId, {
|
|
117
|
+
...blockVariationTransformations.find(
|
|
118
|
+
( { name: variationName } ) => variationName === name
|
|
119
|
+
).attributes,
|
|
120
|
+
} );
|
|
121
|
+
}
|
|
122
|
+
|
|
108
123
|
// Pattern transformation through the `Patterns` API.
|
|
109
124
|
function onPatternTransform( transformedBlocks ) {
|
|
110
125
|
replaceBlocks( clientIds, transformedBlocks );
|
|
@@ -118,8 +133,14 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
118
133
|
*/
|
|
119
134
|
const hasPossibleBlockTransformations =
|
|
120
135
|
!! possibleBlockTransformations.length && canRemove && ! isTemplate;
|
|
136
|
+
const hasPossibleBlockVariationTransformations =
|
|
137
|
+
!! blockVariationTransformations?.length;
|
|
121
138
|
const hasPatternTransformation = !! patterns?.length && canRemove;
|
|
122
|
-
if (
|
|
139
|
+
if (
|
|
140
|
+
! hasBlockStyles &&
|
|
141
|
+
! hasPossibleBlockTransformations &&
|
|
142
|
+
! hasPossibleBlockVariationTransformations
|
|
143
|
+
) {
|
|
123
144
|
return (
|
|
124
145
|
<ToolbarGroup>
|
|
125
146
|
<ToolbarButton
|
|
@@ -160,9 +181,12 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
160
181
|
blocks.length
|
|
161
182
|
);
|
|
162
183
|
|
|
184
|
+
const hasBlockOrBlockVariationTransforms =
|
|
185
|
+
hasPossibleBlockTransformations ||
|
|
186
|
+
hasPossibleBlockVariationTransformations;
|
|
163
187
|
const showDropDown =
|
|
164
188
|
hasBlockStyles ||
|
|
165
|
-
|
|
189
|
+
hasBlockOrBlockVariationTransforms ||
|
|
166
190
|
hasPatternTransformation;
|
|
167
191
|
return (
|
|
168
192
|
<ToolbarGroup>
|
|
@@ -213,17 +237,26 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => {
|
|
|
213
237
|
} }
|
|
214
238
|
/>
|
|
215
239
|
) }
|
|
216
|
-
{
|
|
240
|
+
{ hasBlockOrBlockVariationTransforms && (
|
|
217
241
|
<BlockTransformationsMenu
|
|
218
242
|
className="block-editor-block-switcher__transforms__menugroup"
|
|
219
243
|
possibleBlockTransformations={
|
|
220
244
|
possibleBlockTransformations
|
|
221
245
|
}
|
|
246
|
+
possibleBlockVariationTransformations={
|
|
247
|
+
blockVariationTransformations
|
|
248
|
+
}
|
|
222
249
|
blocks={ blocks }
|
|
223
250
|
onSelect={ ( name ) => {
|
|
224
251
|
onBlockTransform( name );
|
|
225
252
|
onClose();
|
|
226
253
|
} }
|
|
254
|
+
onSelectVariation={ ( name ) => {
|
|
255
|
+
onBlockVariationTransform(
|
|
256
|
+
name
|
|
257
|
+
);
|
|
258
|
+
onClose();
|
|
259
|
+
} }
|
|
227
260
|
/>
|
|
228
261
|
) }
|
|
229
262
|
{ hasBlockStyles && (
|
|
@@ -105,15 +105,15 @@ function BlockPattern( { pattern, onSelect, composite } ) {
|
|
|
105
105
|
`${ baseClassName }-list__item-description`
|
|
106
106
|
);
|
|
107
107
|
return (
|
|
108
|
-
<div
|
|
109
|
-
className={ `${ baseClassName }-list__list-item` }
|
|
110
|
-
aria-label={ pattern.title }
|
|
111
|
-
aria-describedby={ pattern.description ? descriptionId : undefined }
|
|
112
|
-
>
|
|
108
|
+
<div className={ `${ baseClassName }-list__list-item` }>
|
|
113
109
|
<CompositeItem
|
|
114
110
|
role="option"
|
|
115
111
|
as="div"
|
|
116
112
|
{ ...composite }
|
|
113
|
+
aria-label={ pattern.title }
|
|
114
|
+
aria-describedby={
|
|
115
|
+
pattern.description ? descriptionId : undefined
|
|
116
|
+
}
|
|
117
117
|
className={ `${ baseClassName }-list__item` }
|
|
118
118
|
onClick={ () => onSelect( pattern.transformedBlocks ) }
|
|
119
119
|
>
|
|
@@ -109,19 +109,20 @@
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
.components-popover__content {
|
|
112
|
-
|
|
112
|
+
width: 300px;
|
|
113
113
|
border: $border-width solid $gray-900;
|
|
114
114
|
background: $white;
|
|
115
115
|
border-radius: $radius-block-ui;
|
|
116
116
|
outline: none;
|
|
117
|
+
box-shadow: none;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
.block-editor-block-switcher__preview {
|
|
120
|
-
|
|
121
|
-
height: auto;
|
|
122
|
-
// Subtract margin from max-height.
|
|
121
|
+
// Subtract vertical margin from max-height.
|
|
123
122
|
max-height: calc(500px - #{$grid-unit-40});
|
|
124
|
-
margin: $grid-unit-20;
|
|
123
|
+
margin: $grid-unit-20 0;
|
|
124
|
+
// Use padding to prevent the pattern previews focus style from being cut-off.
|
|
125
|
+
padding: 0 $grid-unit-20;
|
|
125
126
|
overflow: hidden;
|
|
126
127
|
}
|
|
127
128
|
}
|
|
@@ -32,6 +32,7 @@ import BlockEditVisuallyButton from '../block-edit-visually-button';
|
|
|
32
32
|
import { useShowMoversGestures } from './utils';
|
|
33
33
|
import { store as blockEditorStore } from '../../store';
|
|
34
34
|
import __unstableBlockNameContext from './block-name-context';
|
|
35
|
+
import { unlock } from '../../lock-unlock';
|
|
35
36
|
|
|
36
37
|
const BlockToolbar = ( { hideDragHandle } ) => {
|
|
37
38
|
const {
|
|
@@ -42,7 +43,7 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
42
43
|
isDistractionFree,
|
|
43
44
|
isValid,
|
|
44
45
|
isVisual,
|
|
45
|
-
|
|
46
|
+
blockEditingMode,
|
|
46
47
|
} = useSelect( ( select ) => {
|
|
47
48
|
const {
|
|
48
49
|
getBlockName,
|
|
@@ -51,8 +52,8 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
51
52
|
isBlockValid,
|
|
52
53
|
getBlockRootClientId,
|
|
53
54
|
getSettings,
|
|
54
|
-
|
|
55
|
-
} = select( blockEditorStore );
|
|
55
|
+
getBlockEditingMode,
|
|
56
|
+
} = unlock( select( blockEditorStore ) );
|
|
56
57
|
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
57
58
|
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
58
59
|
const blockRootClientId = getBlockRootClientId( selectedBlockClientId );
|
|
@@ -73,9 +74,7 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
73
74
|
isVisual: selectedBlockClientIds.every(
|
|
74
75
|
( id ) => getBlockMode( id ) === 'visual'
|
|
75
76
|
),
|
|
76
|
-
|
|
77
|
-
selectedBlockClientId
|
|
78
|
-
),
|
|
77
|
+
blockEditingMode: getBlockEditingMode( selectedBlockClientId ),
|
|
79
78
|
};
|
|
80
79
|
}, [] );
|
|
81
80
|
|
|
@@ -125,12 +124,12 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
125
124
|
|
|
126
125
|
return (
|
|
127
126
|
<div className={ classes }>
|
|
128
|
-
{ ! isMultiToolbar &&
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
{ ! isMultiToolbar &&
|
|
128
|
+
isLargeViewport &&
|
|
129
|
+
blockEditingMode === 'default' && <BlockParentSelector /> }
|
|
131
130
|
<div ref={ nodeRef } { ...showMoversGestures }>
|
|
132
131
|
{ ( shouldShowVisualToolbar || isMultiToolbar ) &&
|
|
133
|
-
|
|
132
|
+
blockEditingMode === 'default' && (
|
|
134
133
|
<ToolbarGroup className="block-editor-block-toolbar__block-controls">
|
|
135
134
|
<BlockSwitcher clientIds={ blockClientIds } />
|
|
136
135
|
{ ! isMultiToolbar && (
|
|
@@ -175,7 +174,7 @@ const BlockToolbar = ( { hideDragHandle } ) => {
|
|
|
175
174
|
</>
|
|
176
175
|
) }
|
|
177
176
|
<BlockEditVisuallyButton clientIds={ blockClientIds } />
|
|
178
|
-
{
|
|
177
|
+
{ blockEditingMode === 'default' && (
|
|
179
178
|
<BlockSettingsMenu clientIds={ blockClientIds } />
|
|
180
179
|
) }
|
|
181
180
|
</div>
|
|
@@ -25,6 +25,7 @@ import NavigableToolbar from '../navigable-toolbar';
|
|
|
25
25
|
import BlockToolbar from '../block-toolbar';
|
|
26
26
|
import { store as blockEditorStore } from '../../store';
|
|
27
27
|
import BlockIcon from '../block-icon';
|
|
28
|
+
import { unlock } from '../../lock-unlock';
|
|
28
29
|
|
|
29
30
|
function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
30
31
|
// When the toolbar is fixed it can be collapsed
|
|
@@ -38,8 +39,8 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
|
38
39
|
getBlockName,
|
|
39
40
|
getBlockParents,
|
|
40
41
|
getSelectedBlockClientIds,
|
|
41
|
-
|
|
42
|
-
} = select( blockEditorStore );
|
|
42
|
+
getBlockEditingMode,
|
|
43
|
+
} = unlock( select( blockEditorStore ) );
|
|
43
44
|
const { getBlockType } = select( blocksStore );
|
|
44
45
|
const selectedBlockClientIds = getSelectedBlockClientIds();
|
|
45
46
|
const _selectedBlockClientId = selectedBlockClientIds[ 0 ];
|
|
@@ -62,9 +63,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
|
|
|
62
63
|
true
|
|
63
64
|
) &&
|
|
64
65
|
selectedBlockClientIds.length <= 1 &&
|
|
65
|
-
|
|
66
|
-
_selectedBlockClientId
|
|
67
|
-
),
|
|
66
|
+
getBlockEditingMode( _selectedBlockClientId ) === 'default',
|
|
68
67
|
};
|
|
69
68
|
}, [] );
|
|
70
69
|
|
|
@@ -198,16 +198,30 @@ function InbetweenInsertionPointPopover( {
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
export default function InsertionPoint( props ) {
|
|
201
|
-
const { insertionPoint, isVisible } = useSelect(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
201
|
+
const { insertionPoint, isVisible, isBlockListEmpty } = useSelect(
|
|
202
|
+
( select ) => {
|
|
203
|
+
const {
|
|
204
|
+
getBlockInsertionPoint,
|
|
205
|
+
isBlockInsertionPointVisible,
|
|
206
|
+
getBlockCount,
|
|
207
|
+
} = select( blockEditorStore );
|
|
208
|
+
const blockInsertionPoint = getBlockInsertionPoint();
|
|
209
|
+
return {
|
|
210
|
+
insertionPoint: blockInsertionPoint,
|
|
211
|
+
isVisible: isBlockInsertionPointVisible(),
|
|
212
|
+
isBlockListEmpty:
|
|
213
|
+
getBlockCount( blockInsertionPoint?.rootClientId ) === 0,
|
|
214
|
+
};
|
|
215
|
+
},
|
|
216
|
+
[]
|
|
217
|
+
);
|
|
209
218
|
|
|
210
|
-
if (
|
|
219
|
+
if (
|
|
220
|
+
! isVisible ||
|
|
221
|
+
// Don't render the insertion point if the block list is empty.
|
|
222
|
+
// The insertion point will be represented by the appender instead.
|
|
223
|
+
isBlockListEmpty
|
|
224
|
+
) {
|
|
211
225
|
return null;
|
|
212
226
|
}
|
|
213
227
|
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
|
|
35
36
|
// When the appender shows up in empty container blocks, such as Group and Columns, add an extra click state.
|
|
36
37
|
.block-list-appender:only-child {
|
|
37
38
|
.is-layout-constrained.block-editor-block-list__block:not(.is-selected) > &,
|
|
@@ -56,5 +57,26 @@
|
|
|
56
57
|
.block-editor-inserter {
|
|
57
58
|
visibility: hidden;
|
|
58
59
|
}
|
|
60
|
+
|
|
61
|
+
&.is-drag-over {
|
|
62
|
+
&::after {
|
|
63
|
+
border: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.block-editor-inserter {
|
|
67
|
+
visibility: visible;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
&.is-drag-over .block-editor-button-block-appender {
|
|
73
|
+
background-color: var(--wp-admin-theme-color);
|
|
74
|
+
box-shadow: inset 0 0 0 $border-width $light-gray-placeholder;
|
|
75
|
+
color: $light-gray-placeholder;
|
|
76
|
+
transition: background-color 0.2s ease-in-out;
|
|
77
|
+
|
|
78
|
+
@media ( prefers-reduced-motion: reduce ) {
|
|
79
|
+
transition: none;
|
|
80
|
+
}
|
|
59
81
|
}
|
|
60
82
|
}
|
|
@@ -17,6 +17,7 @@ function ConvertToGroupButton( {
|
|
|
17
17
|
clientIds,
|
|
18
18
|
isGroupable,
|
|
19
19
|
isUngroupable,
|
|
20
|
+
onUngroup,
|
|
20
21
|
blocksSelection,
|
|
21
22
|
groupingBlockName,
|
|
22
23
|
onClose = () => {},
|
|
@@ -34,10 +35,16 @@ function ConvertToGroupButton( {
|
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
const onConvertFromGroup = () => {
|
|
37
|
-
|
|
38
|
+
let innerBlocks = blocksSelection[ 0 ].innerBlocks;
|
|
38
39
|
if ( ! innerBlocks.length ) {
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
42
|
+
if ( onUngroup ) {
|
|
43
|
+
innerBlocks = onUngroup(
|
|
44
|
+
blocksSelection[ 0 ].attributes,
|
|
45
|
+
blocksSelection[ 0 ].innerBlocks
|
|
46
|
+
);
|
|
47
|
+
}
|
|
41
48
|
replaceBlocks( clientIds, innerBlocks );
|
|
42
49
|
};
|
|
43
50
|
|
|
@@ -66,7 +73,7 @@ function ConvertToGroupButton( {
|
|
|
66
73
|
>
|
|
67
74
|
{ _x(
|
|
68
75
|
'Ungroup',
|
|
69
|
-
'Ungrouping blocks from within a
|
|
76
|
+
'Ungrouping blocks from within a grouping block back into individual blocks within the Editor '
|
|
70
77
|
) }
|
|
71
78
|
</MenuItem>
|
|
72
79
|
) }
|
|
@@ -1 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __, _x } from '@wordpress/i18n';
|
|
5
|
+
import { switchToBlockType } from '@wordpress/blocks';
|
|
6
|
+
import { useDispatch } from '@wordpress/data';
|
|
7
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { store as blockEditorStore } from '../../store';
|
|
13
|
+
import useConvertToGroupButtonProps from './use-convert-to-group-button-props';
|
|
14
|
+
|
|
15
|
+
function useConvertToGroupButtons( {
|
|
16
|
+
clientIds,
|
|
17
|
+
onUngroup,
|
|
18
|
+
blocksSelection,
|
|
19
|
+
groupingBlockName,
|
|
20
|
+
} ) {
|
|
21
|
+
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
22
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
23
|
+
const onConvertToGroup = () => {
|
|
24
|
+
// Activate the `transform` on the Grouping Block which does the conversion.
|
|
25
|
+
const newBlocks = switchToBlockType(
|
|
26
|
+
blocksSelection,
|
|
27
|
+
groupingBlockName
|
|
28
|
+
);
|
|
29
|
+
if ( newBlocks ) {
|
|
30
|
+
replaceBlocks( clientIds, newBlocks );
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const onConvertFromGroup = () => {
|
|
35
|
+
let innerBlocks = blocksSelection[ 0 ].innerBlocks;
|
|
36
|
+
if ( ! innerBlocks.length ) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if ( onUngroup ) {
|
|
40
|
+
innerBlocks = onUngroup(
|
|
41
|
+
blocksSelection[ 0 ].attributes,
|
|
42
|
+
blocksSelection[ 0 ].innerBlocks
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
replaceBlocks( clientIds, innerBlocks );
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
group: {
|
|
50
|
+
id: 'groupButtonOption',
|
|
51
|
+
label: _x( 'Group', 'verb' ),
|
|
52
|
+
value: 'groupButtonOption',
|
|
53
|
+
onSelect: () => {
|
|
54
|
+
onConvertToGroup();
|
|
55
|
+
createSuccessNotice(
|
|
56
|
+
// translators: displayed right after the block is grouped
|
|
57
|
+
__( 'Block grouped' )
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
ungroup: {
|
|
62
|
+
id: 'ungroupButtonOption',
|
|
63
|
+
label: _x(
|
|
64
|
+
'Ungroup',
|
|
65
|
+
'Ungrouping blocks from within a grouping block back into individual blocks within the Editor'
|
|
66
|
+
),
|
|
67
|
+
value: 'ungroupButtonOption',
|
|
68
|
+
onSelect: () => {
|
|
69
|
+
onConvertFromGroup();
|
|
70
|
+
createSuccessNotice(
|
|
71
|
+
// translators: displayed right after the block is ungrouped.
|
|
72
|
+
__( 'Block ungrouped' )
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { useConvertToGroupButtons, useConvertToGroupButtonProps };
|
|
@@ -31,13 +31,7 @@ import { store as blockEditorStore } from '../../store';
|
|
|
31
31
|
* @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.
|
|
32
32
|
*/
|
|
33
33
|
export default function useConvertToGroupButtonProps( selectedClientIds ) {
|
|
34
|
-
|
|
35
|
-
clientIds,
|
|
36
|
-
isGroupable,
|
|
37
|
-
isUngroupable,
|
|
38
|
-
blocksSelection,
|
|
39
|
-
groupingBlockName,
|
|
40
|
-
} = useSelect(
|
|
34
|
+
return useSelect(
|
|
41
35
|
( select ) => {
|
|
42
36
|
const {
|
|
43
37
|
getBlockRootClientId,
|
|
@@ -45,54 +39,54 @@ export default function useConvertToGroupButtonProps( selectedClientIds ) {
|
|
|
45
39
|
canInsertBlockType,
|
|
46
40
|
getSelectedBlockClientIds,
|
|
47
41
|
} = select( blockEditorStore );
|
|
48
|
-
const { getGroupingBlockName } =
|
|
49
|
-
|
|
50
|
-
const
|
|
42
|
+
const { getGroupingBlockName, getBlockType } =
|
|
43
|
+
select( blocksStore );
|
|
44
|
+
const clientIds = selectedClientIds?.length
|
|
51
45
|
? selectedClientIds
|
|
52
46
|
: getSelectedBlockClientIds();
|
|
53
|
-
const
|
|
47
|
+
const groupingBlockName = getGroupingBlockName();
|
|
54
48
|
|
|
55
|
-
const rootClientId =
|
|
56
|
-
? getBlockRootClientId(
|
|
49
|
+
const rootClientId = clientIds?.length
|
|
50
|
+
? getBlockRootClientId( clientIds[ 0 ] )
|
|
57
51
|
: undefined;
|
|
58
52
|
|
|
59
53
|
const groupingBlockAvailable = canInsertBlockType(
|
|
60
|
-
|
|
54
|
+
groupingBlockName,
|
|
61
55
|
rootClientId
|
|
62
56
|
);
|
|
63
57
|
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
const blocksSelection = getBlocksByClientId( clientIds );
|
|
59
|
+
const isSingleBlockSelected = blocksSelection.length === 1;
|
|
60
|
+
const [ firstSelectedBlock ] = blocksSelection;
|
|
61
|
+
// A block is ungroupable if it is a single grouping block with inner blocks.
|
|
62
|
+
// If a block has an `ungroup` transform, it is also ungroupable, without the
|
|
63
|
+
// requirement of being the default grouping block.
|
|
64
|
+
// Do we have a single grouping Block selected and does that group have inner blocks?
|
|
65
|
+
const isUngroupable =
|
|
66
|
+
isSingleBlockSelected &&
|
|
67
|
+
( firstSelectedBlock.name === groupingBlockName ||
|
|
68
|
+
getBlockType( firstSelectedBlock.name )?.transforms
|
|
69
|
+
?.ungroup ) &&
|
|
70
|
+
!! firstSelectedBlock.innerBlocks.length;
|
|
69
71
|
|
|
70
72
|
// Do we have
|
|
71
73
|
// 1. Grouping block available to be inserted?
|
|
72
74
|
// 2. One or more blocks selected
|
|
73
|
-
const
|
|
74
|
-
groupingBlockAvailable &&
|
|
75
|
+
const isGroupable =
|
|
76
|
+
groupingBlockAvailable && blocksSelection.length;
|
|
75
77
|
|
|
76
|
-
// Do we have a single Group Block selected and does that group have inner blocks?
|
|
77
|
-
const _isUngroupable =
|
|
78
|
-
isSingleGroupingBlock &&
|
|
79
|
-
!! _blocksSelection[ 0 ].innerBlocks.length;
|
|
80
78
|
return {
|
|
81
|
-
clientIds
|
|
82
|
-
isGroupable
|
|
83
|
-
isUngroupable
|
|
84
|
-
blocksSelection
|
|
85
|
-
groupingBlockName
|
|
79
|
+
clientIds,
|
|
80
|
+
isGroupable,
|
|
81
|
+
isUngroupable,
|
|
82
|
+
blocksSelection,
|
|
83
|
+
groupingBlockName,
|
|
84
|
+
onUngroup:
|
|
85
|
+
isUngroupable &&
|
|
86
|
+
getBlockType( firstSelectedBlock.name )?.transforms
|
|
87
|
+
?.ungroup,
|
|
86
88
|
};
|
|
87
89
|
},
|
|
88
90
|
[ selectedClientIds ]
|
|
89
91
|
);
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
clientIds,
|
|
93
|
-
isGroupable,
|
|
94
|
-
isUngroupable,
|
|
95
|
-
blocksSelection,
|
|
96
|
-
groupingBlockName,
|
|
97
|
-
};
|
|
98
92
|
}
|
|
@@ -103,8 +103,9 @@ function useHasSpacingPresets( settings ) {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function filterValuesBySides( values, sides ) {
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
// If no custom side configuration, all sides are opted into by default.
|
|
107
|
+
// Without any values, we have nothing to filter either.
|
|
108
|
+
if ( ! sides || ! values ) {
|
|
108
109
|
return values;
|
|
109
110
|
}
|
|
110
111
|
|
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
|
|
45
45
|
.block-editor-global-styles-advanced-panel__custom-css-input textarea {
|
|
46
46
|
font-family: $editor_html_font;
|
|
47
|
+
// CSS input is always LTR regardless of language.
|
|
48
|
+
/*rtl:ignore*/
|
|
49
|
+
direction: ltr;
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
.block-editor-global-styles-advanced-panel__custom-css-validation-wrapper {
|