@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
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
useMemo,
|
|
14
14
|
useReducer,
|
|
15
15
|
renderToString,
|
|
16
|
+
useEffect,
|
|
16
17
|
} from '@wordpress/element';
|
|
17
18
|
import { __ } from '@wordpress/i18n';
|
|
18
19
|
import {
|
|
@@ -243,10 +244,16 @@ function Iframe( {
|
|
|
243
244
|
// Correct doctype is required to enable rendering in standards
|
|
244
245
|
// mode. Also preload the styles to avoid a flash of unstyled
|
|
245
246
|
// content.
|
|
246
|
-
const
|
|
247
|
-
|
|
247
|
+
const src = useMemo( () => {
|
|
248
|
+
const html = '<!doctype html>' + renderToString( styleAssets );
|
|
249
|
+
const blob = new window.Blob( [ html ], { type: 'text/html' } );
|
|
250
|
+
return URL.createObjectURL( blob );
|
|
248
251
|
}, [] );
|
|
249
252
|
|
|
253
|
+
useEffect( () => () => {
|
|
254
|
+
URL.revokeObjectURL( src );
|
|
255
|
+
} );
|
|
256
|
+
|
|
250
257
|
// We need to counter the margin created by scaling the iframe. If the scale
|
|
251
258
|
// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the
|
|
252
259
|
// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).
|
|
@@ -260,15 +267,18 @@ function Iframe( {
|
|
|
260
267
|
style={ {
|
|
261
268
|
...props.style,
|
|
262
269
|
height: expand ? contentHeight : props.style?.height,
|
|
263
|
-
marginTop:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
marginTop:
|
|
271
|
+
scale !== 1
|
|
272
|
+
? -marginFromScaling + frameSize
|
|
273
|
+
: props.style?.marginTop,
|
|
274
|
+
marginBottom:
|
|
275
|
+
scale !== 1
|
|
276
|
+
? -marginFromScaling + frameSize
|
|
277
|
+
: props.style?.marginBottom,
|
|
278
|
+
transform:
|
|
279
|
+
scale !== 1
|
|
280
|
+
? `scale( ${ scale } )`
|
|
281
|
+
: props.style?.transform,
|
|
272
282
|
transition: 'all .3s',
|
|
273
283
|
} }
|
|
274
284
|
ref={ useMergeRefs( [ ref, setRef ] ) }
|
|
@@ -276,7 +286,7 @@ function Iframe( {
|
|
|
276
286
|
// Correct doctype is required to enable rendering in standards
|
|
277
287
|
// mode. Also preload the styles to avoid a flash of unstyled
|
|
278
288
|
// content.
|
|
279
|
-
|
|
289
|
+
src={ src }
|
|
280
290
|
title={ __( 'Editor canvas' ) }
|
|
281
291
|
>
|
|
282
292
|
{ iframeDocument &&
|
|
@@ -180,3 +180,8 @@ For example, a button block, deeply nested in several levels of block `X` that u
|
|
|
180
180
|
|
|
181
181
|
- **Type:** `Function`
|
|
182
182
|
- **Default:** - `undefined`. The placeholder is an optional function that can be passed in to be a rendered component placed in front of the appender. This can be used to represent an example state prior to any blocks being placed. See the Social Links for an implementation example.
|
|
183
|
+
|
|
184
|
+
### `prioritizedInserterBlocks`
|
|
185
|
+
|
|
186
|
+
- **Type:** `Array`
|
|
187
|
+
- **Default:** - `undefined`. Determines which block types should be shown in the block inserter. For example, when inserting a block within the Navigation block we specify `core/navigation-link` and `core/navigation-link/page` as these are the most commonly used inner blocks. `prioritizedInserterBlocks` takes an array of the form {blockName}/{variationName}, where {variationName} is optional.
|
|
@@ -45,6 +45,7 @@ function UncontrolledInnerBlocks( props ) {
|
|
|
45
45
|
const {
|
|
46
46
|
clientId,
|
|
47
47
|
allowedBlocks,
|
|
48
|
+
prioritizedInserterBlocks,
|
|
48
49
|
__experimentalDefaultBlock,
|
|
49
50
|
__experimentalDirectInsert,
|
|
50
51
|
template,
|
|
@@ -62,6 +63,7 @@ function UncontrolledInnerBlocks( props ) {
|
|
|
62
63
|
useNestedSettingsUpdate(
|
|
63
64
|
clientId,
|
|
64
65
|
allowedBlocks,
|
|
66
|
+
prioritizedInserterBlocks,
|
|
65
67
|
__experimentalDefaultBlock,
|
|
66
68
|
__experimentalDirectInsert,
|
|
67
69
|
templateLock,
|
|
@@ -17,7 +17,6 @@ import useBlockContext from './use-block-context';
|
|
|
17
17
|
* Internal dependencies
|
|
18
18
|
*/
|
|
19
19
|
import BlockList from '../block-list';
|
|
20
|
-
import BlockListCompact from '../block-list/block-list-compact';
|
|
21
20
|
import { useBlockEditContext } from '../block-edit/context';
|
|
22
21
|
import useBlockSync from '../provider/use-block-sync';
|
|
23
22
|
import { BlockContextProvider } from '../block-context';
|
|
@@ -73,9 +72,13 @@ function UncontrolledInnerBlocks( props ) {
|
|
|
73
72
|
const {
|
|
74
73
|
clientId,
|
|
75
74
|
allowedBlocks,
|
|
75
|
+
prioritizedInserterBlocks,
|
|
76
|
+
__experimentalDefaultBlock,
|
|
77
|
+
__experimentalDirectInsert,
|
|
76
78
|
template,
|
|
77
79
|
templateLock,
|
|
78
80
|
templateInsertUpdatesSelection,
|
|
81
|
+
__experimentalCaptureToolbars: captureToolbars,
|
|
79
82
|
orientation,
|
|
80
83
|
renderAppender,
|
|
81
84
|
renderFooterAppender,
|
|
@@ -92,12 +95,21 @@ function UncontrolledInnerBlocks( props ) {
|
|
|
92
95
|
blockWidth,
|
|
93
96
|
__experimentalLayout: layout = defaultLayout,
|
|
94
97
|
gridProperties,
|
|
95
|
-
useCompactList,
|
|
96
98
|
} = props;
|
|
97
99
|
|
|
98
100
|
const context = useBlockContext( clientId );
|
|
99
101
|
|
|
100
|
-
useNestedSettingsUpdate(
|
|
102
|
+
useNestedSettingsUpdate(
|
|
103
|
+
clientId,
|
|
104
|
+
allowedBlocks,
|
|
105
|
+
prioritizedInserterBlocks,
|
|
106
|
+
__experimentalDefaultBlock,
|
|
107
|
+
__experimentalDirectInsert,
|
|
108
|
+
templateLock,
|
|
109
|
+
captureToolbars,
|
|
110
|
+
orientation,
|
|
111
|
+
layout
|
|
112
|
+
);
|
|
101
113
|
|
|
102
114
|
useInnerBlockTemplateSync(
|
|
103
115
|
clientId,
|
|
@@ -106,12 +118,10 @@ function UncontrolledInnerBlocks( props ) {
|
|
|
106
118
|
templateInsertUpdatesSelection
|
|
107
119
|
);
|
|
108
120
|
|
|
109
|
-
const BlockListComponent = useCompactList ? BlockListCompact : BlockList;
|
|
110
|
-
|
|
111
121
|
return (
|
|
112
122
|
<LayoutProvider value={ layout }>
|
|
113
123
|
<BlockContextProvider value={ context }>
|
|
114
|
-
<
|
|
124
|
+
<BlockList
|
|
115
125
|
marginVertical={ marginVertical }
|
|
116
126
|
marginHorizontal={ marginHorizontal }
|
|
117
127
|
rootClientId={ clientId }
|
|
@@ -25,6 +25,7 @@ const pendingSettingsUpdates = new WeakMap();
|
|
|
25
25
|
* @param {string} clientId The client ID of the block to update.
|
|
26
26
|
* @param {string[]} allowedBlocks An array of block names which are permitted
|
|
27
27
|
* in inner blocks.
|
|
28
|
+
* @param {string[]} prioritizedInserterBlocks Block names and/or block variations to be prioritized in the inserter, in the format {blockName}/{variationName}.
|
|
28
29
|
* @param {?WPDirectInsertBlock} __experimentalDefaultBlock The default block to insert: [ blockName, { blockAttributes } ].
|
|
29
30
|
* @param {?Function|boolean} __experimentalDirectInsert If a default block should be inserted directly by the
|
|
30
31
|
* appender.
|
|
@@ -40,6 +41,7 @@ const pendingSettingsUpdates = new WeakMap();
|
|
|
40
41
|
export default function useNestedSettingsUpdate(
|
|
41
42
|
clientId,
|
|
42
43
|
allowedBlocks,
|
|
44
|
+
prioritizedInserterBlocks,
|
|
43
45
|
__experimentalDefaultBlock,
|
|
44
46
|
__experimentalDirectInsert,
|
|
45
47
|
templateLock,
|
|
@@ -64,13 +66,27 @@ export default function useNestedSettingsUpdate(
|
|
|
64
66
|
[ clientId ]
|
|
65
67
|
);
|
|
66
68
|
|
|
67
|
-
// Memoize
|
|
68
|
-
// render
|
|
69
|
-
|
|
69
|
+
// Memoize allowedBlocks and prioritisedInnerBlocks based on the contents
|
|
70
|
+
// of the arrays. Implementors often pass a new array on every render,
|
|
71
|
+
// and the contents of the arrays are just strings, so the entire array
|
|
72
|
+
// can be passed as dependencies.
|
|
73
|
+
|
|
74
|
+
const _allowedBlocks = useMemo(
|
|
75
|
+
() => allowedBlocks,
|
|
76
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
+
allowedBlocks
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const _prioritizedInserterBlocks = useMemo(
|
|
81
|
+
() => prioritizedInserterBlocks,
|
|
82
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
|
+
prioritizedInserterBlocks
|
|
84
|
+
);
|
|
70
85
|
|
|
71
86
|
useLayoutEffect( () => {
|
|
72
87
|
const newSettings = {
|
|
73
88
|
allowedBlocks: _allowedBlocks,
|
|
89
|
+
prioritizedInserterBlocks: _prioritizedInserterBlocks,
|
|
74
90
|
templateLock:
|
|
75
91
|
templateLock === undefined || parentLock === 'contentOnly'
|
|
76
92
|
? parentLock
|
|
@@ -130,6 +146,7 @@ export default function useNestedSettingsUpdate(
|
|
|
130
146
|
clientId,
|
|
131
147
|
blockListSettings,
|
|
132
148
|
_allowedBlocks,
|
|
149
|
+
_prioritizedInserterBlocks,
|
|
133
150
|
__experimentalDefaultBlock,
|
|
134
151
|
__experimentalDirectInsert,
|
|
135
152
|
templateLock,
|
|
@@ -150,7 +150,6 @@ class PrivateInserter extends Component {
|
|
|
150
150
|
prioritizePatterns,
|
|
151
151
|
onSelectOrClose,
|
|
152
152
|
selectBlockOnInsert,
|
|
153
|
-
orderInitialBlockItems,
|
|
154
153
|
} = this.props;
|
|
155
154
|
|
|
156
155
|
if ( isQuick ) {
|
|
@@ -174,7 +173,6 @@ class PrivateInserter extends Component {
|
|
|
174
173
|
isAppender={ isAppender }
|
|
175
174
|
prioritizePatterns={ prioritizePatterns }
|
|
176
175
|
selectBlockOnInsert={ selectBlockOnInsert }
|
|
177
|
-
orderInitialBlockItems={ orderInitialBlockItems }
|
|
178
176
|
/>
|
|
179
177
|
);
|
|
180
178
|
}
|
|
@@ -426,13 +424,7 @@ export const ComposedPrivateInserter = compose( [
|
|
|
426
424
|
] )( PrivateInserter );
|
|
427
425
|
|
|
428
426
|
const Inserter = forwardRef( ( props, ref ) => {
|
|
429
|
-
return
|
|
430
|
-
<ComposedPrivateInserter
|
|
431
|
-
ref={ ref }
|
|
432
|
-
{ ...props }
|
|
433
|
-
orderInitialBlockItems={ undefined }
|
|
434
|
-
/>
|
|
435
|
-
);
|
|
427
|
+
return <ComposedPrivateInserter ref={ ref } { ...props } />;
|
|
436
428
|
} );
|
|
437
429
|
|
|
438
430
|
export default Inserter;
|
|
@@ -32,7 +32,6 @@ export default function QuickInserter( {
|
|
|
32
32
|
isAppender,
|
|
33
33
|
prioritizePatterns,
|
|
34
34
|
selectBlockOnInsert,
|
|
35
|
-
orderInitialBlockItems,
|
|
36
35
|
} ) {
|
|
37
36
|
const [ filterValue, setFilterValue ] = useState( '' );
|
|
38
37
|
const [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {
|
|
@@ -125,7 +124,6 @@ export default function QuickInserter( {
|
|
|
125
124
|
isDraggable={ false }
|
|
126
125
|
prioritizePatterns={ prioritizePatterns }
|
|
127
126
|
selectBlockOnInsert={ selectBlockOnInsert }
|
|
128
|
-
orderInitialBlockItems={ orderInitialBlockItems }
|
|
129
127
|
/>
|
|
130
128
|
</div>
|
|
131
129
|
|
|
@@ -6,6 +6,7 @@ import { __, _n, sprintf } from '@wordpress/i18n';
|
|
|
6
6
|
import { VisuallyHidden } from '@wordpress/components';
|
|
7
7
|
import { useDebounce, useAsyncList } from '@wordpress/compose';
|
|
8
8
|
import { speak } from '@wordpress/a11y';
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
@@ -21,6 +22,8 @@ import useBlockTypesState from './hooks/use-block-types-state';
|
|
|
21
22
|
import { searchBlockItems, searchItems } from './search-items';
|
|
22
23
|
import InserterListbox from '../inserter-listbox';
|
|
23
24
|
import { orderBy } from '../../utils/sorting';
|
|
25
|
+
import { orderInserterBlockItems } from '../../utils/order-inserter-block-items';
|
|
26
|
+
import { store as blockEditorStore } from '../../store';
|
|
24
27
|
|
|
25
28
|
const INITIAL_INSERTER_RESULTS = 9;
|
|
26
29
|
/**
|
|
@@ -46,10 +49,22 @@ function InserterSearchResults( {
|
|
|
46
49
|
shouldFocusBlock = true,
|
|
47
50
|
prioritizePatterns,
|
|
48
51
|
selectBlockOnInsert,
|
|
49
|
-
orderInitialBlockItems,
|
|
50
52
|
} ) {
|
|
51
53
|
const debouncedSpeak = useDebounce( speak, 500 );
|
|
52
54
|
|
|
55
|
+
const { prioritizedBlocks } = useSelect(
|
|
56
|
+
( select ) => {
|
|
57
|
+
const blockListSettings =
|
|
58
|
+
select( blockEditorStore ).getBlockListSettings( rootClientId );
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
prioritizedBlocks:
|
|
62
|
+
blockListSettings?.prioritizedInserterBlocks || EMPTY_ARRAY,
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
[ rootClientId ]
|
|
66
|
+
);
|
|
67
|
+
|
|
53
68
|
const [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {
|
|
54
69
|
onSelect,
|
|
55
70
|
rootClientId,
|
|
@@ -89,10 +104,16 @@ function InserterSearchResults( {
|
|
|
89
104
|
if ( maxBlockTypesToShow === 0 ) {
|
|
90
105
|
return [];
|
|
91
106
|
}
|
|
107
|
+
|
|
92
108
|
let orderedItems = orderBy( blockTypes, 'frecency', 'desc' );
|
|
93
|
-
|
|
94
|
-
|
|
109
|
+
|
|
110
|
+
if ( ! filterValue && prioritizedBlocks.length ) {
|
|
111
|
+
orderedItems = orderInserterBlockItems(
|
|
112
|
+
orderedItems,
|
|
113
|
+
prioritizedBlocks
|
|
114
|
+
);
|
|
95
115
|
}
|
|
116
|
+
|
|
96
117
|
const results = searchBlockItems(
|
|
97
118
|
orderedItems,
|
|
98
119
|
blockTypeCategories,
|
|
@@ -108,8 +129,8 @@ function InserterSearchResults( {
|
|
|
108
129
|
blockTypes,
|
|
109
130
|
blockTypeCategories,
|
|
110
131
|
blockTypeCollections,
|
|
111
|
-
|
|
112
|
-
|
|
132
|
+
maxBlockTypesToShow,
|
|
133
|
+
prioritizedBlocks,
|
|
113
134
|
] );
|
|
114
135
|
|
|
115
136
|
// Announce search results on change.
|
|
@@ -124,7 +145,12 @@ function InserterSearchResults( {
|
|
|
124
145
|
count
|
|
125
146
|
);
|
|
126
147
|
debouncedSpeak( resultsFoundMessage );
|
|
127
|
-
}, [
|
|
148
|
+
}, [
|
|
149
|
+
filterValue,
|
|
150
|
+
debouncedSpeak,
|
|
151
|
+
filteredBlockTypes,
|
|
152
|
+
filteredBlockPatterns,
|
|
153
|
+
] );
|
|
128
154
|
|
|
129
155
|
const currentShownBlockTypes = useAsyncList( filteredBlockTypes, {
|
|
130
156
|
step: INITIAL_INSERTER_RESULTS,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { useInstanceId } from '@wordpress/compose';
|
|
5
5
|
import { speak } from '@wordpress/a11y';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
|
-
import { forwardRef,
|
|
7
|
+
import { forwardRef, useEffect } from '@wordpress/element';
|
|
8
8
|
import { __, sprintf } from '@wordpress/i18n';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -12,11 +12,12 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
12
12
|
*/
|
|
13
13
|
import { store as blockEditorStore } from '../../store';
|
|
14
14
|
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
15
|
+
import { useListViewContext } from './context';
|
|
15
16
|
import Inserter from '../inserter';
|
|
16
17
|
|
|
17
18
|
export const Appender = forwardRef(
|
|
18
19
|
( { nestingLevel, blockCount, clientId, ...props }, ref ) => {
|
|
19
|
-
const
|
|
20
|
+
const { insertedBlock, setInsertedBlock } = useListViewContext();
|
|
20
21
|
|
|
21
22
|
const instanceId = useInstanceId( Appender );
|
|
22
23
|
const { hideInserter } = useSelect(
|
|
@@ -47,7 +47,8 @@ const ListViewBlockContents = forwardRef(
|
|
|
47
47
|
[ clientId ]
|
|
48
48
|
);
|
|
49
49
|
|
|
50
|
-
const { renderAdditionalBlockUI } =
|
|
50
|
+
const { renderAdditionalBlockUI, insertedBlock, setInsertedBlock } =
|
|
51
|
+
useListViewContext();
|
|
51
52
|
|
|
52
53
|
const isBlockMoveTarget =
|
|
53
54
|
blockMovingClientId && selectedBlockInBlockEditor === clientId;
|
|
@@ -66,7 +67,12 @@ const ListViewBlockContents = forwardRef(
|
|
|
66
67
|
|
|
67
68
|
return (
|
|
68
69
|
<>
|
|
69
|
-
{ renderAdditionalBlockUI &&
|
|
70
|
+
{ renderAdditionalBlockUI &&
|
|
71
|
+
renderAdditionalBlockUI(
|
|
72
|
+
block,
|
|
73
|
+
insertedBlock,
|
|
74
|
+
setInsertedBlock
|
|
75
|
+
) }
|
|
70
76
|
<BlockDraggable clientIds={ draggableClientIds }>
|
|
71
77
|
{ ( { draggable, onDragStart, onDragEnd } ) => (
|
|
72
78
|
<ListViewBlockSelectButton
|
|
@@ -38,6 +38,7 @@ import { getBlockPositionDescription } from './utils';
|
|
|
38
38
|
import { store as blockEditorStore } from '../../store';
|
|
39
39
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
40
40
|
import { useBlockLock } from '../block-lock';
|
|
41
|
+
import { unlock } from '../../lock-unlock';
|
|
41
42
|
|
|
42
43
|
function ListViewBlock( {
|
|
43
44
|
block: { clientId },
|
|
@@ -59,31 +60,13 @@ function ListViewBlock( {
|
|
|
59
60
|
const rowRef = useRef( null );
|
|
60
61
|
const [ isHovered, setIsHovered ] = useState( false );
|
|
61
62
|
|
|
62
|
-
const { isLocked,
|
|
63
|
-
const forceSelectionContentLock = useSelect(
|
|
64
|
-
( select ) => {
|
|
65
|
-
if ( isSelected ) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
if ( ! isContentLocked ) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
return select( blockEditorStore ).hasSelectedInnerBlock(
|
|
72
|
-
clientId,
|
|
73
|
-
true
|
|
74
|
-
);
|
|
75
|
-
},
|
|
76
|
-
[ isContentLocked, clientId, isSelected ]
|
|
77
|
-
);
|
|
63
|
+
const { isLocked, canEdit } = useBlockLock( clientId );
|
|
78
64
|
|
|
79
|
-
const canExpand = isContentLocked ? false : canEdit;
|
|
80
65
|
const isFirstSelectedBlock =
|
|
81
|
-
|
|
82
|
-
( isSelected && selectedClientIds[ 0 ] === clientId );
|
|
66
|
+
isSelected && selectedClientIds[ 0 ] === clientId;
|
|
83
67
|
const isLastSelectedBlock =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
selectedClientIds[ selectedClientIds.length - 1 ] === clientId );
|
|
68
|
+
isSelected &&
|
|
69
|
+
selectedClientIds[ selectedClientIds.length - 1 ] === clientId;
|
|
87
70
|
|
|
88
71
|
const { toggleBlockHighlight } = useDispatch( blockEditorStore );
|
|
89
72
|
|
|
@@ -97,15 +80,21 @@ function ListViewBlock( {
|
|
|
97
80
|
( select ) => select( blockEditorStore ).getBlockName( clientId ),
|
|
98
81
|
[ clientId ]
|
|
99
82
|
);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
'__experimentalToolbar',
|
|
107
|
-
true
|
|
83
|
+
const blockEditingMode = useSelect(
|
|
84
|
+
( select ) =>
|
|
85
|
+
unlock( select( blockEditorStore ) ).getBlockEditingMode(
|
|
86
|
+
clientId
|
|
87
|
+
),
|
|
88
|
+
[ clientId ]
|
|
108
89
|
);
|
|
90
|
+
|
|
91
|
+
const showBlockActions =
|
|
92
|
+
// When a block hides its toolbar it also hides the block settings menu,
|
|
93
|
+
// since that menu is part of the toolbar in the editor canvas.
|
|
94
|
+
// List View respects this by also hiding the block settings menu.
|
|
95
|
+
hasBlockSupport( blockName, '__experimentalToolbar', true ) &&
|
|
96
|
+
// Don't show the settings menu if block is disabled or content only.
|
|
97
|
+
blockEditingMode === 'default';
|
|
109
98
|
const instanceId = useInstanceId( ListViewBlock );
|
|
110
99
|
const descriptionId = `list-view-block-select-button__${ instanceId }`;
|
|
111
100
|
const blockPositionDescription = getBlockPositionDescription(
|
|
@@ -134,6 +123,8 @@ function ListViewBlock( {
|
|
|
134
123
|
collapse,
|
|
135
124
|
BlockSettingsMenu,
|
|
136
125
|
listViewInstanceId,
|
|
126
|
+
expandedState,
|
|
127
|
+
setInsertedBlock,
|
|
137
128
|
} = useListViewContext();
|
|
138
129
|
|
|
139
130
|
const hasSiblings = siblingBlockCount > 0;
|
|
@@ -203,7 +194,7 @@ function ListViewBlock( {
|
|
|
203
194
|
}
|
|
204
195
|
|
|
205
196
|
const classes = classnames( {
|
|
206
|
-
'is-selected': isSelected
|
|
197
|
+
'is-selected': isSelected,
|
|
207
198
|
'is-first-selected': isFirstSelectedBlock,
|
|
208
199
|
'is-last-selected': isLastSelectedBlock,
|
|
209
200
|
'is-branch-selected': isBranchSelected,
|
|
@@ -247,14 +238,14 @@ function ListViewBlock( {
|
|
|
247
238
|
path={ path }
|
|
248
239
|
id={ `list-view-${ listViewInstanceId }-block-${ clientId }` }
|
|
249
240
|
data-block={ clientId }
|
|
250
|
-
data-expanded={
|
|
241
|
+
data-expanded={ canEdit ? isExpanded : undefined }
|
|
251
242
|
ref={ rowRef }
|
|
252
243
|
>
|
|
253
244
|
<TreeGridCell
|
|
254
245
|
className="block-editor-list-view-block__contents-cell"
|
|
255
246
|
colSpan={ colSpan }
|
|
256
247
|
ref={ cellRef }
|
|
257
|
-
aria-selected={ !! isSelected
|
|
248
|
+
aria-selected={ !! isSelected }
|
|
258
249
|
>
|
|
259
250
|
{ ( { ref, tabIndex, onFocus } ) => (
|
|
260
251
|
<div className="block-editor-list-view-block__contents-container">
|
|
@@ -271,7 +262,7 @@ function ListViewBlock( {
|
|
|
271
262
|
currentlyEditingBlockInCanvas ? 0 : tabIndex
|
|
272
263
|
}
|
|
273
264
|
onFocus={ onFocus }
|
|
274
|
-
isExpanded={
|
|
265
|
+
isExpanded={ canEdit ? isExpanded : undefined }
|
|
275
266
|
selectedClientIds={ selectedClientIds }
|
|
276
267
|
ariaLabel={ blockAriaLabel }
|
|
277
268
|
ariaDescribedBy={ descriptionId }
|
|
@@ -320,7 +311,7 @@ function ListViewBlock( {
|
|
|
320
311
|
{ showBlockActions && BlockSettingsMenu && (
|
|
321
312
|
<TreeGridCell
|
|
322
313
|
className={ listViewBlockSettingsClassName }
|
|
323
|
-
aria-selected={ !! isSelected
|
|
314
|
+
aria-selected={ !! isSelected }
|
|
324
315
|
>
|
|
325
316
|
{ ( { ref, tabIndex, onFocus } ) => (
|
|
326
317
|
<BlockSettingsMenu
|
|
@@ -336,6 +327,9 @@ function ListViewBlock( {
|
|
|
336
327
|
} }
|
|
337
328
|
disableOpenOnArrowDown
|
|
338
329
|
__experimentalSelectBlock={ updateSelection }
|
|
330
|
+
expand={ expand }
|
|
331
|
+
expandedState={ expandedState }
|
|
332
|
+
setInsertedBlock={ setInsertedBlock }
|
|
339
333
|
/>
|
|
340
334
|
) }
|
|
341
335
|
</TreeGridCell>
|
|
@@ -109,13 +109,7 @@ function ListViewBranch( props ) {
|
|
|
109
109
|
if ( ! parentId ) {
|
|
110
110
|
return true;
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
const isContentLocked =
|
|
114
|
-
select( blockEditorStore ).getTemplateLock( parentId ) ===
|
|
115
|
-
'contentOnly';
|
|
116
|
-
const canEdit = select( blockEditorStore ).canEditBlock( parentId );
|
|
117
|
-
|
|
118
|
-
return isContentLocked ? false : canEdit;
|
|
112
|
+
return select( blockEditorStore ).canEditBlock( parentId );
|
|
119
113
|
},
|
|
120
114
|
[ parentId ]
|
|
121
115
|
);
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
useRef,
|
|
17
17
|
useReducer,
|
|
18
18
|
forwardRef,
|
|
19
|
+
useState,
|
|
19
20
|
} from '@wordpress/element';
|
|
20
21
|
import { __ } from '@wordpress/i18n';
|
|
21
22
|
|
|
@@ -128,6 +129,9 @@ function ListViewComponent(
|
|
|
128
129
|
const treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );
|
|
129
130
|
|
|
130
131
|
const isMounted = useRef( false );
|
|
132
|
+
|
|
133
|
+
const [ insertedBlock, setInsertedBlock ] = useState( null );
|
|
134
|
+
|
|
131
135
|
const { setSelectedTreeId } = useListViewExpandSelectedItem( {
|
|
132
136
|
firstSelectedBlockClientId: selectedClientIds[ 0 ],
|
|
133
137
|
setExpandedState,
|
|
@@ -212,6 +216,8 @@ function ListViewComponent(
|
|
|
212
216
|
BlockSettingsMenu,
|
|
213
217
|
listViewInstanceId: instanceId,
|
|
214
218
|
renderAdditionalBlockUI,
|
|
219
|
+
insertedBlock,
|
|
220
|
+
setInsertedBlock,
|
|
215
221
|
} ),
|
|
216
222
|
[
|
|
217
223
|
draggedClientIds,
|
|
@@ -221,11 +227,13 @@ function ListViewComponent(
|
|
|
221
227
|
BlockSettingsMenu,
|
|
222
228
|
instanceId,
|
|
223
229
|
renderAdditionalBlockUI,
|
|
230
|
+
insertedBlock,
|
|
231
|
+
setInsertedBlock,
|
|
224
232
|
]
|
|
225
233
|
);
|
|
226
234
|
|
|
227
|
-
// If there are no blocks to show, do not render the list view.
|
|
228
|
-
if ( ! clientIdsTree.length ) {
|
|
235
|
+
// If there are no blocks to show and we're not showing the appender, do not render the list view.
|
|
236
|
+
if ( ! clientIdsTree.length && ! showAppender ) {
|
|
229
237
|
return null;
|
|
230
238
|
}
|
|
231
239
|
|
|
@@ -264,18 +272,23 @@ function ListViewComponent(
|
|
|
264
272
|
</AsyncModeProvider>
|
|
265
273
|
);
|
|
266
274
|
}
|
|
275
|
+
|
|
276
|
+
// This is the private API for the ListView component.
|
|
277
|
+
// It allows access to all props, not just the public ones.
|
|
267
278
|
export const PrivateListView = forwardRef( ListViewComponent );
|
|
268
279
|
|
|
280
|
+
// This is the public API for the ListView component.
|
|
281
|
+
// We wrap the PrivateListView component to hide some props from the public API.
|
|
269
282
|
export default forwardRef( ( props, ref ) => {
|
|
270
283
|
return (
|
|
271
284
|
<PrivateListView
|
|
272
285
|
ref={ ref }
|
|
273
286
|
{ ...props }
|
|
274
287
|
showAppender={ false }
|
|
275
|
-
blockSettingsMenu={ BlockSettingsDropdown }
|
|
276
288
|
rootClientId={ null }
|
|
277
289
|
onSelect={ null }
|
|
278
|
-
|
|
290
|
+
renderAdditionalBlockUI={ null }
|
|
291
|
+
blockSettingsMenu={ undefined }
|
|
279
292
|
/>
|
|
280
293
|
);
|
|
281
294
|
} );
|
|
@@ -123,7 +123,6 @@
|
|
|
123
123
|
border-radius: 0;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
127
126
|
// List View renders a fixed number of items and relies on each item having a fixed height of 36px.
|
|
128
127
|
// If this value changes, we should also change the itemHeight value set in useFixedWindowList.
|
|
129
128
|
// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
|
|
@@ -214,19 +213,17 @@
|
|
|
214
213
|
line-height: 0;
|
|
215
214
|
width: $button-size;
|
|
216
215
|
vertical-align: middle;
|
|
217
|
-
@include reduce-motion("transition");
|
|
218
216
|
|
|
219
217
|
> * {
|
|
220
|
-
will-change: opacity;
|
|
221
218
|
opacity: 0;
|
|
222
219
|
}
|
|
223
220
|
|
|
224
|
-
// Show on hover, visible, and show above to keep the hit area size.
|
|
221
|
+
// Show on hover, visible, when focused, and show above to keep the hit area size.
|
|
225
222
|
&:hover,
|
|
223
|
+
&:focus-within,
|
|
226
224
|
&.is-visible {
|
|
227
225
|
> * {
|
|
228
226
|
opacity: 1;
|
|
229
|
-
@include edit-post__fade-in-animation;
|
|
230
227
|
}
|
|
231
228
|
}
|
|
232
229
|
|
|
@@ -8,6 +8,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { store as blockEditorStore } from '../../store';
|
|
11
|
+
import { unlock } from '../../lock-unlock';
|
|
11
12
|
|
|
12
13
|
export default function useListViewClientIds( { blocks, rootClientId } ) {
|
|
13
14
|
return useSelect(
|
|
@@ -16,14 +17,30 @@ export default function useListViewClientIds( { blocks, rootClientId } ) {
|
|
|
16
17
|
getDraggedBlockClientIds,
|
|
17
18
|
getSelectedBlockClientIds,
|
|
18
19
|
__unstableGetClientIdsTree,
|
|
19
|
-
|
|
20
|
+
getBlockEditingMode,
|
|
21
|
+
} = unlock( select( blockEditorStore ) );
|
|
22
|
+
|
|
23
|
+
const removeDisabledBlocks = ( tree ) => {
|
|
24
|
+
return tree.flatMap( ( { clientId, innerBlocks, ...rest } ) => {
|
|
25
|
+
if ( getBlockEditingMode( clientId ) === 'disabled' ) {
|
|
26
|
+
return removeDisabledBlocks( innerBlocks );
|
|
27
|
+
}
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
clientId,
|
|
31
|
+
innerBlocks: removeDisabledBlocks( innerBlocks ),
|
|
32
|
+
...rest,
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
} );
|
|
36
|
+
};
|
|
20
37
|
|
|
21
38
|
return {
|
|
22
39
|
selectedClientIds: getSelectedBlockClientIds(),
|
|
23
40
|
draggedClientIds: getDraggedBlockClientIds(),
|
|
24
|
-
clientIdsTree:
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
clientIdsTree: removeDisabledBlocks(
|
|
42
|
+
blocks ?? __unstableGetClientIdsTree( rootClientId )
|
|
43
|
+
),
|
|
27
44
|
};
|
|
28
45
|
},
|
|
29
46
|
[ blocks, rootClientId ]
|