@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
|
@@ -139,6 +139,12 @@ _Required._ Called when the value changes. The second parameter is `null` unless
|
|
|
139
139
|
}
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
+
### `onKeydown`: `( event: KeyboardEvent ) => void`
|
|
143
|
+
|
|
144
|
+
A callback invoked on the keydown event.
|
|
145
|
+
|
|
146
|
+
- Required: No
|
|
147
|
+
|
|
142
148
|
### `label: String`
|
|
143
149
|
|
|
144
150
|
_Optional._ If this property is added, a label will be generated using label property as the content.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
4
|
+
import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
|
|
5
5
|
import { useCallback, useState } from '@wordpress/element';
|
|
6
6
|
import {
|
|
7
7
|
useThrottle,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
isPointContainedByRect,
|
|
20
20
|
} from '../../utils/math';
|
|
21
21
|
import { store as blockEditorStore } from '../../store';
|
|
22
|
+
import { unlock } from '../../lock-unlock';
|
|
22
23
|
|
|
23
24
|
/** @typedef {import('../../utils/math').WPPoint} WPPoint */
|
|
24
25
|
/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */
|
|
@@ -142,6 +143,7 @@ export default function useBlockDropZone( {
|
|
|
142
143
|
// an empty string to represent top-level blocks.
|
|
143
144
|
rootClientId: targetRootClientId = '',
|
|
144
145
|
} = {} ) {
|
|
146
|
+
const registry = useRegistry();
|
|
145
147
|
const [ dropTarget, setDropTarget ] = useState( {
|
|
146
148
|
index: null,
|
|
147
149
|
operation: 'insert',
|
|
@@ -150,15 +152,13 @@ export default function useBlockDropZone( {
|
|
|
150
152
|
const isDisabled = useSelect(
|
|
151
153
|
( select ) => {
|
|
152
154
|
const {
|
|
153
|
-
getTemplateLock,
|
|
154
155
|
__unstableIsWithinBlockOverlay,
|
|
155
156
|
__unstableHasActiveBlockOverlayActive,
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
getBlockEditingMode,
|
|
158
|
+
} = unlock( select( blockEditorStore ) );
|
|
159
|
+
const blockEditingMode = getBlockEditingMode( targetRootClientId );
|
|
158
160
|
return (
|
|
159
|
-
|
|
160
|
-
( lock ) => lock === templateLock
|
|
161
|
-
) ||
|
|
161
|
+
blockEditingMode !== 'default' ||
|
|
162
162
|
__unstableHasActiveBlockOverlayActive( targetRootClientId ) ||
|
|
163
163
|
__unstableIsWithinBlockOverlay( targetRootClientId )
|
|
164
164
|
);
|
|
@@ -181,9 +181,14 @@ export default function useBlockDropZone( {
|
|
|
181
181
|
|
|
182
182
|
// The block list is empty, don't show the insertion point but still allow dropping.
|
|
183
183
|
if ( blocks.length === 0 ) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
registry.batch( () => {
|
|
185
|
+
setDropTarget( {
|
|
186
|
+
index: 0,
|
|
187
|
+
operation: 'insert',
|
|
188
|
+
} );
|
|
189
|
+
showInsertionPoint( targetRootClientId, 0, {
|
|
190
|
+
operation: 'insert',
|
|
191
|
+
} );
|
|
187
192
|
} );
|
|
188
193
|
return;
|
|
189
194
|
}
|
|
@@ -208,15 +213,24 @@ export default function useBlockDropZone( {
|
|
|
208
213
|
getBlockListSettings( targetRootClientId )?.orientation
|
|
209
214
|
);
|
|
210
215
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
registry.batch( () => {
|
|
217
|
+
setDropTarget( {
|
|
218
|
+
index: targetIndex,
|
|
219
|
+
operation,
|
|
220
|
+
} );
|
|
221
|
+
showInsertionPoint( targetRootClientId, targetIndex, {
|
|
222
|
+
operation,
|
|
223
|
+
} );
|
|
217
224
|
} );
|
|
218
225
|
},
|
|
219
|
-
[
|
|
226
|
+
[
|
|
227
|
+
getBlocks,
|
|
228
|
+
targetRootClientId,
|
|
229
|
+
getBlockListSettings,
|
|
230
|
+
registry,
|
|
231
|
+
showInsertionPoint,
|
|
232
|
+
getBlockIndex,
|
|
233
|
+
]
|
|
220
234
|
),
|
|
221
235
|
200
|
|
222
236
|
);
|
|
@@ -47,12 +47,20 @@ export default function useResizeCanvas( deviceType ) {
|
|
|
47
47
|
|
|
48
48
|
const contentInlineStyles = ( device ) => {
|
|
49
49
|
const height = device === 'Mobile' ? '768px' : '1024px';
|
|
50
|
+
const marginVertical = marginValue() + 'px';
|
|
51
|
+
const marginHorizontal = 'auto';
|
|
52
|
+
|
|
50
53
|
switch ( device ) {
|
|
51
54
|
case 'Tablet':
|
|
52
55
|
case 'Mobile':
|
|
53
56
|
return {
|
|
54
57
|
width: getCanvasWidth( device ),
|
|
55
|
-
margin
|
|
58
|
+
// Keeping margin styles separate to avoid warnings
|
|
59
|
+
// when those props get overridden in the iframe component
|
|
60
|
+
marginTop: marginVertical,
|
|
61
|
+
marginBottom: marginVertical,
|
|
62
|
+
marginLeft: marginHorizontal,
|
|
63
|
+
marginRight: marginHorizontal,
|
|
56
64
|
height,
|
|
57
65
|
borderRadius: '2px 2px 2px 2px',
|
|
58
66
|
border: '1px solid #ddd',
|
|
@@ -19,6 +19,9 @@ describe( 'isNavigationCandidate', () => {
|
|
|
19
19
|
elements.inputCheckbox = document.createElement( 'input' );
|
|
20
20
|
elements.inputCheckbox.setAttribute( 'type', 'checkbox' );
|
|
21
21
|
|
|
22
|
+
elements.inputNumber = document.createElement( 'input' );
|
|
23
|
+
elements.inputNumber.setAttribute( 'type', 'number' );
|
|
24
|
+
|
|
22
25
|
elements.contentEditable = document.createElement( 'p' );
|
|
23
26
|
elements.contentEditable.contentEditable = true;
|
|
24
27
|
} );
|
|
@@ -47,6 +50,18 @@ describe( 'isNavigationCandidate', () => {
|
|
|
47
50
|
} );
|
|
48
51
|
} );
|
|
49
52
|
|
|
53
|
+
it( 'should return false if vertically navigating inputs with vertial support like number', () => {
|
|
54
|
+
[ UP, DOWN ].forEach( ( keyCode ) => {
|
|
55
|
+
const result = isNavigationCandidate(
|
|
56
|
+
elements.inputNumber,
|
|
57
|
+
keyCode,
|
|
58
|
+
false
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect( result ).toBe( false );
|
|
62
|
+
} );
|
|
63
|
+
} );
|
|
64
|
+
|
|
50
65
|
it( 'should return false if horizontally navigating input', () => {
|
|
51
66
|
[ LEFT, RIGHT ].forEach( ( keyCode ) => {
|
|
52
67
|
const result = isNavigationCandidate(
|
|
@@ -32,19 +32,32 @@ import { store as blockEditorStore } from '../../store';
|
|
|
32
32
|
*/
|
|
33
33
|
export function isNavigationCandidate( element, keyCode, hasModifier ) {
|
|
34
34
|
const isVertical = keyCode === UP || keyCode === DOWN;
|
|
35
|
+
const { tagName } = element;
|
|
36
|
+
const elementType = element.getAttribute( 'type' );
|
|
35
37
|
|
|
36
|
-
//
|
|
38
|
+
// Native inputs should not navigate vertically, unless they are simple types that don't need up/down arrow keys.
|
|
37
39
|
if ( isVertical && ! hasModifier ) {
|
|
40
|
+
if ( tagName === 'INPUT' ) {
|
|
41
|
+
const verticalInputTypes = [
|
|
42
|
+
'date',
|
|
43
|
+
'datetime-local',
|
|
44
|
+
'month',
|
|
45
|
+
'number',
|
|
46
|
+
'range',
|
|
47
|
+
'time',
|
|
48
|
+
'week',
|
|
49
|
+
];
|
|
50
|
+
return ! verticalInputTypes.includes( elementType );
|
|
51
|
+
}
|
|
38
52
|
return true;
|
|
39
53
|
}
|
|
40
54
|
|
|
41
|
-
const { tagName } = element;
|
|
42
|
-
|
|
43
55
|
// Native inputs should not navigate horizontally, unless they are simple types that don't need left/right arrow keys.
|
|
44
56
|
if ( tagName === 'INPUT' ) {
|
|
45
57
|
const simpleInputTypes = [
|
|
46
58
|
'button',
|
|
47
59
|
'checkbox',
|
|
60
|
+
'number',
|
|
48
61
|
'color',
|
|
49
62
|
'file',
|
|
50
63
|
'image',
|
|
@@ -52,7 +65,7 @@ export function isNavigationCandidate( element, keyCode, hasModifier ) {
|
|
|
52
65
|
'reset',
|
|
53
66
|
'submit',
|
|
54
67
|
];
|
|
55
|
-
return simpleInputTypes.includes(
|
|
68
|
+
return simpleInputTypes.includes( elementType );
|
|
56
69
|
}
|
|
57
70
|
|
|
58
71
|
// Native textareas should not navigate horizontally.
|
package/src/hooks/align.js
CHANGED
|
@@ -13,14 +13,13 @@ import {
|
|
|
13
13
|
getBlockType,
|
|
14
14
|
hasBlockSupport,
|
|
15
15
|
} from '@wordpress/blocks';
|
|
16
|
-
import { useSelect } from '@wordpress/data';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* Internal dependencies
|
|
20
19
|
*/
|
|
21
20
|
import { BlockControls, BlockAlignmentControl } from '../components';
|
|
22
21
|
import useAvailableAlignments from '../components/block-alignment-control/use-available-alignments';
|
|
23
|
-
import {
|
|
22
|
+
import { useBlockEditingMode } from '../components/block-editing-mode';
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* An array which includes all possible valid alignments,
|
|
@@ -133,15 +132,8 @@ export const withToolbarControls = createHigherOrderComponent(
|
|
|
133
132
|
const validAlignments = useAvailableAlignments(
|
|
134
133
|
blockAllowedAlignments
|
|
135
134
|
).map( ( { name } ) => name );
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
return select(
|
|
139
|
-
blockEditorStore
|
|
140
|
-
).__unstableGetContentLockingParent( props.clientId );
|
|
141
|
-
},
|
|
142
|
-
[ props.clientId ]
|
|
143
|
-
);
|
|
144
|
-
if ( ! validAlignments.length || isContentLocked ) {
|
|
135
|
+
const blockEditingMode = useBlockEditingMode();
|
|
136
|
+
if ( ! validAlignments.length || blockEditingMode !== 'default' ) {
|
|
145
137
|
return blockEdit;
|
|
146
138
|
}
|
|
147
139
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { addFilter } from '@wordpress/hooks';
|
|
5
|
+
import { SelectControl } from '@wordpress/components';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
8
|
+
import { select } from '@wordpress/data';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { InspectorControls } from '../components';
|
|
14
|
+
import { store as blockEditorStore } from '../store';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* External dependencies
|
|
18
|
+
*/
|
|
19
|
+
import merge from 'deepmerge';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Override the default edit UI to include a new block inspector control for
|
|
23
|
+
* assigning behaviors to blocks if behaviors are enabled in the theme.json.
|
|
24
|
+
*
|
|
25
|
+
* Currently, only the `core/image` block is supported.
|
|
26
|
+
*
|
|
27
|
+
* @param {WPComponent} BlockEdit Original component.
|
|
28
|
+
*
|
|
29
|
+
* @return {WPComponent} Wrapped component.
|
|
30
|
+
*/
|
|
31
|
+
export const withBehaviors = createHigherOrderComponent( ( BlockEdit ) => {
|
|
32
|
+
return ( props ) => {
|
|
33
|
+
// Only add behaviors to the core/image block.
|
|
34
|
+
if ( props.name !== 'core/image' ) {
|
|
35
|
+
return <BlockEdit { ...props } />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const settings =
|
|
39
|
+
select( blockEditorStore ).getSettings()?.__experimentalFeatures
|
|
40
|
+
?.blocks?.[ props.name ]?.behaviors;
|
|
41
|
+
|
|
42
|
+
if (
|
|
43
|
+
! settings ||
|
|
44
|
+
// If every behavior is disabled, do not show the behaviors inspector control.
|
|
45
|
+
Object.entries( settings ).every( ( [ , value ] ) => ! value )
|
|
46
|
+
) {
|
|
47
|
+
return <BlockEdit { ...props } />;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const { behaviors: blockBehaviors } = props.attributes;
|
|
51
|
+
|
|
52
|
+
// Get the theme behaviors for the block from the theme.json.
|
|
53
|
+
const themeBehaviors =
|
|
54
|
+
select( blockEditorStore ).getBehaviors()?.blocks?.[ props.name ];
|
|
55
|
+
|
|
56
|
+
// Block behaviors take precedence over theme behaviors.
|
|
57
|
+
const behaviors = merge( themeBehaviors, blockBehaviors || {} );
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
<BlockEdit { ...props } />
|
|
62
|
+
<InspectorControls group="advanced">
|
|
63
|
+
<SelectControl
|
|
64
|
+
__nextHasNoMarginBottom
|
|
65
|
+
label={ __( 'Behaviors' ) }
|
|
66
|
+
// At the moment we are only supporting one behavior (Lightbox)
|
|
67
|
+
value={ behaviors?.lightbox ? 'lightbox' : '' }
|
|
68
|
+
options={ Object.entries( settings )
|
|
69
|
+
.filter( ( [ , behaviorValue ] ) => behaviorValue ) // Filter out behaviors that are disabled.
|
|
70
|
+
.map( ( [ behaviorName ] ) => ( {
|
|
71
|
+
value: behaviorName,
|
|
72
|
+
label:
|
|
73
|
+
// Capitalize the first letter of the behavior name.
|
|
74
|
+
behaviorName[ 0 ].toUpperCase() +
|
|
75
|
+
behaviorName.slice( 1 ).toLowerCase(),
|
|
76
|
+
} ) )
|
|
77
|
+
.concat( {
|
|
78
|
+
value: '',
|
|
79
|
+
label: __( 'No behaviors' ),
|
|
80
|
+
} ) }
|
|
81
|
+
onChange={ ( nextValue ) => {
|
|
82
|
+
// If the user selects something, it means that they want to
|
|
83
|
+
// change the default value (true) so we save it in the attributes.
|
|
84
|
+
props.setAttributes( {
|
|
85
|
+
behaviors: {
|
|
86
|
+
lightbox: nextValue === 'lightbox',
|
|
87
|
+
},
|
|
88
|
+
} );
|
|
89
|
+
} }
|
|
90
|
+
hideCancelButton={ true }
|
|
91
|
+
help={ __( 'Add behaviors.' ) }
|
|
92
|
+
size="__unstable-large"
|
|
93
|
+
/>
|
|
94
|
+
</InspectorControls>
|
|
95
|
+
</>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
}, 'withBehaviors' );
|
|
99
|
+
|
|
100
|
+
addFilter(
|
|
101
|
+
'editor.BlockEdit',
|
|
102
|
+
'core/behaviors/with-inspector-control',
|
|
103
|
+
withBehaviors
|
|
104
|
+
);
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -136,43 +136,3 @@ export function useCustomSides() {
|
|
|
136
136
|
version: '6.4',
|
|
137
137
|
} );
|
|
138
138
|
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Custom hook to determine whether the sides configured in the
|
|
142
|
-
* block support are valid. A dimension property cannot declare
|
|
143
|
-
* support for a mix of axial and individual sides.
|
|
144
|
-
*
|
|
145
|
-
* @param {string} blockName Block name.
|
|
146
|
-
* @param {string} feature The feature custom sides relate to e.g. padding or margins.
|
|
147
|
-
*
|
|
148
|
-
* @return {boolean} If the feature has a valid configuration of sides.
|
|
149
|
-
*/
|
|
150
|
-
export function useIsDimensionsSupportValid( blockName, feature ) {
|
|
151
|
-
const sides = useCustomSides( blockName, feature );
|
|
152
|
-
|
|
153
|
-
if (
|
|
154
|
-
sides &&
|
|
155
|
-
sides.some( ( side ) => ALL_SIDES.includes( side ) ) &&
|
|
156
|
-
sides.some( ( side ) => AXIAL_SIDES.includes( side ) )
|
|
157
|
-
) {
|
|
158
|
-
// eslint-disable-next-line no-console
|
|
159
|
-
console.warn(
|
|
160
|
-
`The ${ feature } support for the "${ blockName }" block can not be configured to support both axial and arbitrary sides.`
|
|
161
|
-
);
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
sides?.length &&
|
|
167
|
-
feature === 'blockGap' &&
|
|
168
|
-
! AXIAL_SIDES.every( ( side ) => sides.includes( side ) )
|
|
169
|
-
) {
|
|
170
|
-
// eslint-disable-next-line no-console
|
|
171
|
-
console.warn(
|
|
172
|
-
`The ${ feature } support for the "${ blockName }" block can not be configured to support arbitrary sides.`
|
|
173
|
-
);
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return true;
|
|
178
|
-
}
|
package/src/hooks/duotone.js
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
17
17
|
import { addFilter } from '@wordpress/hooks';
|
|
18
18
|
import { useMemo, useContext, createPortal } from '@wordpress/element';
|
|
19
|
-
import { useSelect } from '@wordpress/data';
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Internal dependencies
|
|
@@ -36,8 +35,8 @@ import {
|
|
|
36
35
|
import { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';
|
|
37
36
|
import { scopeSelector } from '../components/global-styles/utils';
|
|
38
37
|
import { useBlockSettings } from './utils';
|
|
39
|
-
import { store as blockEditorStore } from '../store';
|
|
40
38
|
import { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';
|
|
39
|
+
import { useBlockEditingMode } from '../components/block-editing-mode';
|
|
41
40
|
|
|
42
41
|
const EMPTY_ARRAY = [];
|
|
43
42
|
|
|
@@ -226,14 +225,7 @@ const withDuotoneControls = createHigherOrderComponent(
|
|
|
226
225
|
'filter.duotone'
|
|
227
226
|
);
|
|
228
227
|
|
|
229
|
-
const
|
|
230
|
-
( select ) => {
|
|
231
|
-
return select(
|
|
232
|
-
blockEditorStore
|
|
233
|
-
).__unstableGetContentLockingParent( props.clientId );
|
|
234
|
-
},
|
|
235
|
-
[ props.clientId ]
|
|
236
|
-
);
|
|
228
|
+
const blockEditingMode = useBlockEditingMode();
|
|
237
229
|
|
|
238
230
|
// CAUTION: code added before this line will be executed
|
|
239
231
|
// for all blocks, not just those that support duotone. Code added
|
|
@@ -241,7 +233,7 @@ const withDuotoneControls = createHigherOrderComponent(
|
|
|
241
233
|
// performance.
|
|
242
234
|
return (
|
|
243
235
|
<>
|
|
244
|
-
{ hasDuotoneSupport &&
|
|
236
|
+
{ hasDuotoneSupport && blockEditingMode === 'default' && (
|
|
245
237
|
<DuotonePanel { ...props } />
|
|
246
238
|
) }
|
|
247
239
|
<BlockEdit { ...props } />
|
package/src/hooks/index.js
CHANGED
package/src/hooks/layout.js
CHANGED
|
@@ -29,6 +29,7 @@ import useSetting from '../components/use-setting';
|
|
|
29
29
|
import { LayoutStyle } from '../components/block-list/layout';
|
|
30
30
|
import BlockList from '../components/block-list';
|
|
31
31
|
import { getLayoutType, getLayoutTypes } from '../layouts';
|
|
32
|
+
import { useBlockEditingMode } from '../components/block-editing-mode';
|
|
32
33
|
|
|
33
34
|
const layoutBlockSupportKey = '__experimentalLayout';
|
|
34
35
|
|
|
@@ -131,25 +132,16 @@ export function useLayoutStyles( blockAttributes = {}, blockName, selector ) {
|
|
|
131
132
|
return css;
|
|
132
133
|
}
|
|
133
134
|
|
|
134
|
-
function LayoutPanel( {
|
|
135
|
-
clientId,
|
|
136
|
-
setAttributes,
|
|
137
|
-
attributes,
|
|
138
|
-
name: blockName,
|
|
139
|
-
} ) {
|
|
135
|
+
function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
140
136
|
const { layout } = attributes;
|
|
141
137
|
const defaultThemeLayout = useSetting( 'layout' );
|
|
142
|
-
const { themeSupportsLayout
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
};
|
|
150
|
-
},
|
|
151
|
-
[ clientId ]
|
|
152
|
-
);
|
|
138
|
+
const { themeSupportsLayout } = useSelect( ( select ) => {
|
|
139
|
+
const { getSettings } = select( blockEditorStore );
|
|
140
|
+
return {
|
|
141
|
+
themeSupportsLayout: getSettings().supportsLayout,
|
|
142
|
+
};
|
|
143
|
+
}, [] );
|
|
144
|
+
const blockEditingMode = useBlockEditingMode();
|
|
153
145
|
|
|
154
146
|
const layoutBlockSupport = getBlockSupport(
|
|
155
147
|
blockName,
|
|
@@ -270,7 +262,7 @@ function LayoutPanel( {
|
|
|
270
262
|
) }
|
|
271
263
|
</PanelBody>
|
|
272
264
|
</InspectorControls>
|
|
273
|
-
{ ! inherit &&
|
|
265
|
+
{ ! inherit && blockEditingMode === 'default' && layoutType && (
|
|
274
266
|
<layoutType.toolBarControls
|
|
275
267
|
layout={ usedLayout }
|
|
276
268
|
onChange={ onChangeLayout }
|
package/src/private-apis.js
CHANGED
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
import * as globalStyles from './components/global-styles';
|
|
5
5
|
import { ExperimentalBlockEditorProvider } from './components/provider';
|
|
6
6
|
import { lock } from './lock-unlock';
|
|
7
|
-
import OffCanvasEditor from './components/off-canvas-editor';
|
|
8
|
-
import LeafMoreMenu from './components/off-canvas-editor/leaf-more-menu';
|
|
9
7
|
import ResizableBoxPopover from './components/resizable-box-popover';
|
|
10
8
|
import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
|
|
11
9
|
import { PrivateListView } from './components/list-view';
|
|
12
10
|
import BlockInfo from './components/block-info-slot-fill';
|
|
13
11
|
import { useShouldContextualToolbarShow } from './utils/use-should-contextual-toolbar-show';
|
|
14
12
|
import { cleanEmptyObject } from './hooks/utils';
|
|
13
|
+
import { useBlockEditingMode } from './components/block-editing-mode';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Private @wordpress/block-editor APIs.
|
|
@@ -20,12 +19,11 @@ export const privateApis = {};
|
|
|
20
19
|
lock( privateApis, {
|
|
21
20
|
...globalStyles,
|
|
22
21
|
ExperimentalBlockEditorProvider,
|
|
23
|
-
LeafMoreMenu,
|
|
24
|
-
OffCanvasEditor,
|
|
25
22
|
PrivateInserter,
|
|
26
23
|
PrivateListView,
|
|
27
24
|
ResizableBoxPopover,
|
|
28
25
|
BlockInfo,
|
|
29
26
|
useShouldContextualToolbarShow,
|
|
30
27
|
cleanEmptyObject,
|
|
28
|
+
useBlockEditingMode,
|
|
31
29
|
} );
|
|
@@ -66,3 +66,42 @@ export function showBlockInterface() {
|
|
|
66
66
|
type: 'SHOW_BLOCK_INTERFACE',
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Sets the block editing mode for a given block.
|
|
76
|
+
*
|
|
77
|
+
* @see useBlockEditingMode
|
|
78
|
+
*
|
|
79
|
+
* @param {string} clientId The block client ID, or `''` for the root container.
|
|
80
|
+
* @param {BlockEditingMode} mode The block editing mode. One of `'disabled'`,
|
|
81
|
+
* `'contentOnly'`, or `'default'`.
|
|
82
|
+
*
|
|
83
|
+
* @return {Object} Action object.
|
|
84
|
+
*/
|
|
85
|
+
export function setBlockEditingMode( clientId = '', mode ) {
|
|
86
|
+
return {
|
|
87
|
+
type: 'SET_BLOCK_EDITING_MODE',
|
|
88
|
+
clientId,
|
|
89
|
+
mode,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Clears the block editing mode for a given block.
|
|
95
|
+
*
|
|
96
|
+
* @see useBlockEditingMode
|
|
97
|
+
*
|
|
98
|
+
* @param {string} clientId The block client ID, or `''` for the root container.
|
|
99
|
+
*
|
|
100
|
+
* @return {Object} Action object.
|
|
101
|
+
*/
|
|
102
|
+
export function unsetBlockEditingMode( clientId = '' ) {
|
|
103
|
+
return {
|
|
104
|
+
type: 'UNSET_BLOCK_EDITING_MODE',
|
|
105
|
+
clientId,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import createSelector from 'rememo';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { createRegistrySelector } from '@wordpress/data';
|
|
10
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import {
|
|
16
|
+
getBlockRootClientId,
|
|
17
|
+
getTemplateLock,
|
|
18
|
+
getBlockName,
|
|
19
|
+
} from './selectors';
|
|
20
|
+
|
|
1
21
|
/**
|
|
2
22
|
* Returns true if the block interface is hidden, or false otherwise.
|
|
3
23
|
*
|
|
@@ -18,3 +38,78 @@ export function isBlockInterfaceHidden( state ) {
|
|
|
18
38
|
export function getLastInsertedBlocksClientIds( state ) {
|
|
19
39
|
return state?.lastBlockInserted?.clientIds;
|
|
20
40
|
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Returns the block editing mode for a given block.
|
|
48
|
+
*
|
|
49
|
+
* The mode can be one of three options:
|
|
50
|
+
*
|
|
51
|
+
* - `'disabled'`: Prevents editing the block entirely, i.e. it cannot be
|
|
52
|
+
* selected.
|
|
53
|
+
* - `'contentOnly'`: Hides all non-content UI, e.g. auxiliary controls in the
|
|
54
|
+
* toolbar, the block movers, block settings.
|
|
55
|
+
* - `'default'`: Allows editing the block as normal.
|
|
56
|
+
*
|
|
57
|
+
* Blocks can set a mode using the `useBlockEditingMode` hook.
|
|
58
|
+
*
|
|
59
|
+
* The mode is inherited by all of the block's inner blocks, unless they have
|
|
60
|
+
* their own mode.
|
|
61
|
+
*
|
|
62
|
+
* A template lock can also set a mode. If the template lock is `'contentOnly'`,
|
|
63
|
+
* the block's mode is overridden to `'contentOnly'` if the block has a content
|
|
64
|
+
* role attribute, or `'disabled'` otherwise.
|
|
65
|
+
*
|
|
66
|
+
* @see useBlockEditingMode
|
|
67
|
+
*
|
|
68
|
+
* @param {Object} state Global application state.
|
|
69
|
+
* @param {string} clientId The block client ID, or `''` for the root container.
|
|
70
|
+
*
|
|
71
|
+
* @return {BlockEditingMode} The block editing mode. One of `'disabled'`,
|
|
72
|
+
* `'contentOnly'`, or `'default'`.
|
|
73
|
+
*/
|
|
74
|
+
export const getBlockEditingMode = createRegistrySelector(
|
|
75
|
+
( select ) =>
|
|
76
|
+
( state, clientId = '' ) => {
|
|
77
|
+
const explicitEditingMode = getExplcitBlockEditingMode(
|
|
78
|
+
state,
|
|
79
|
+
clientId
|
|
80
|
+
);
|
|
81
|
+
const rootClientId = getBlockRootClientId( state, clientId );
|
|
82
|
+
const templateLock = getTemplateLock( state, rootClientId );
|
|
83
|
+
const name = getBlockName( state, clientId );
|
|
84
|
+
const isContent =
|
|
85
|
+
select( blocksStore ).__experimentalHasContentRoleAttribute(
|
|
86
|
+
name
|
|
87
|
+
);
|
|
88
|
+
if (
|
|
89
|
+
explicitEditingMode === 'disabled' ||
|
|
90
|
+
( templateLock === 'contentOnly' && ! isContent )
|
|
91
|
+
) {
|
|
92
|
+
return 'disabled';
|
|
93
|
+
}
|
|
94
|
+
if (
|
|
95
|
+
explicitEditingMode === 'contentOnly' ||
|
|
96
|
+
( templateLock === 'contentOnly' && isContent )
|
|
97
|
+
) {
|
|
98
|
+
return 'contentOnly';
|
|
99
|
+
}
|
|
100
|
+
return 'default';
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const getExplcitBlockEditingMode = createSelector(
|
|
105
|
+
( state, clientId = '' ) => {
|
|
106
|
+
while (
|
|
107
|
+
! state.blockEditingModes.has( clientId ) &&
|
|
108
|
+
state.blocks.parents.has( clientId )
|
|
109
|
+
) {
|
|
110
|
+
clientId = state.blocks.parents.get( clientId );
|
|
111
|
+
}
|
|
112
|
+
return state.blockEditingModes.get( clientId ) ?? 'default';
|
|
113
|
+
},
|
|
114
|
+
( state ) => [ state.blockEditingModes, state.blocks.parents ]
|
|
115
|
+
);
|