@wordpress/block-editor 15.23.0 → 16.0.1-next.v.202607070741.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 +25 -0
- package/build/autocompleters/block.cjs +10 -2
- package/build/autocompleters/block.cjs.map +2 -2
- package/build/components/background-image-control/index.cjs +0 -2
- package/build/components/background-image-control/index.cjs.map +2 -2
- package/build/components/block-inspector/edit-contents.cjs +3 -0
- package/build/components/block-inspector/edit-contents.cjs.map +3 -3
- package/build/components/block-inspector/index.cjs +2 -3
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-list/block-invalid-warning.cjs +8 -19
- package/build/components/block-list/block-invalid-warning.cjs.map +2 -2
- package/build/components/block-styles/use-styles-for-block.cjs +2 -1
- package/build/components/block-styles/use-styles-for-block.cjs.map +2 -2
- package/build/components/block-title/use-block-display-title.cjs +7 -2
- package/build/components/block-title/use-block-display-title.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +10 -14
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +0 -1
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +0 -2
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +5 -5
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs +1 -2
- package/build/components/dimensions-tool/aspect-ratio-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +0 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/dimensions-tool/width-height-tool.cjs +2 -4
- package/build/components/dimensions-tool/width-height-tool.cjs.map +2 -2
- package/build/components/font-appearance-control/index.cjs +6 -25
- package/build/components/font-appearance-control/index.cjs.map +3 -3
- package/build/components/font-family/index.cjs +6 -15
- package/build/components/font-family/index.cjs.map +3 -3
- package/build/components/font-sizes/font-size-picker.cjs +1 -2
- package/build/components/font-sizes/font-size-picker.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +0 -1
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +0 -3
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +4 -10
- package/build/components/global-styles/typography-panel.cjs.map +2 -2
- package/build/components/height-control/index.cjs +0 -2
- package/build/components/height-control/index.cjs.map +2 -2
- package/build/components/html-element-control/index.cjs +0 -1
- package/build/components/html-element-control/index.cjs.map +2 -2
- package/build/components/image-editor/index.cjs +5 -0
- package/build/components/image-editor/index.cjs.map +3 -3
- package/build/components/image-editor/zoom-dropdown.cjs +0 -1
- package/build/components/image-editor/zoom-dropdown.cjs.map +2 -2
- package/build/components/image-size-control/index.cjs +1 -3
- package/build/components/image-size-control/index.cjs.map +2 -2
- package/build/components/inner-content/index.cjs +107 -0
- package/build/components/inner-content/index.cjs.map +7 -0
- package/build/components/inserter/hooks/use-block-types-state.cjs +10 -2
- package/build/components/inserter/hooks/use-block-types-state.cjs.map +2 -2
- package/build/components/inserter/media-tab/hooks.cjs +34 -6
- package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-list.cjs +3 -1
- package/build/components/inserter/media-tab/media-list.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-panel.cjs +224 -27
- package/build/components/inserter/media-tab/media-panel.cjs.map +3 -3
- package/build/components/inserter/media-tab/media-preview.cjs +32 -17
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/media-tab/media-tab.cjs +26 -6
- package/build/components/inserter/media-tab/media-tab.cjs.map +2 -2
- package/build/components/inserter/mobile-tab-navigation.cjs +6 -1
- package/build/components/inserter/mobile-tab-navigation.cjs.map +2 -2
- package/build/components/inserter/no-results.cjs +2 -2
- package/build/components/inserter/no-results.cjs.map +2 -2
- package/build/components/inserter/preview-panel.cjs +2 -1
- package/build/components/inserter/preview-panel.cjs.map +2 -2
- package/build/components/inserter-list-item/index.cjs +8 -2
- package/build/components/inserter-list-item/index.cjs.map +2 -2
- package/build/components/letter-spacing-control/index.cjs +0 -24
- package/build/components/letter-spacing-control/index.cjs.map +3 -3
- package/build/components/line-height-control/index.cjs +7 -22
- package/build/components/line-height-control/index.cjs.map +3 -3
- package/build/components/list-view/block-select-button.cjs +90 -84
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +51 -20
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/list-view/expander.cjs +1 -1
- package/build/components/list-view/expander.cjs.map +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs +2 -2
- package/build/components/list-view/use-list-view-client-ids.cjs.map +2 -2
- package/build/components/observe-typing/index.cjs +4 -3
- package/build/components/observe-typing/index.cjs.map +2 -2
- package/build/components/preset-input-control/custom-value-controls.cjs +1 -3
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/preset-input-control/index.cjs +1 -3
- package/build/components/preset-input-control/index.cjs.map +2 -2
- package/build/components/resolution-tool/index.cjs +1 -2
- package/build/components/resolution-tool/index.cjs.map +2 -2
- package/build/components/text-alignment-control/index.cjs +0 -1
- package/build/components/text-alignment-control/index.cjs.map +2 -2
- package/build/components/text-decoration-control/index.cjs +0 -1
- package/build/components/text-decoration-control/index.cjs.map +2 -2
- package/build/components/text-indent-control/index.cjs +0 -8
- package/build/components/text-indent-control/index.cjs.map +2 -2
- package/build/components/text-transform-control/index.cjs +0 -1
- package/build/components/text-transform-control/index.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -8
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/use-on-block-drop/index.cjs +3 -7
- package/build/components/use-on-block-drop/index.cjs.map +2 -2
- package/build/components/writing-mode-control/index.cjs +0 -1
- package/build/components/writing-mode-control/index.cjs.map +2 -2
- package/build/hooks/font-size.cjs +1 -2
- package/build/hooks/font-size.cjs.map +2 -2
- package/build/hooks/layout.cjs +5 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/position.cjs +36 -16
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/states.cjs +6 -9
- package/build/hooks/states.cjs.map +2 -2
- package/build/layouts/constrained.cjs +21 -21
- package/build/layouts/constrained.cjs.map +2 -2
- package/build/layouts/flex.cjs +0 -3
- package/build/layouts/flex.cjs.map +2 -2
- package/build/layouts/grid.cjs +51 -9
- package/build/layouts/grid.cjs.map +2 -2
- package/build/private-apis.cjs +4 -1
- package/build/private-apis.cjs.map +3 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +3 -0
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +72 -4
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/selectors.cjs +13 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/autocompleters/block.mjs +10 -2
- package/build-module/autocompleters/block.mjs.map +2 -2
- package/build-module/components/background-image-control/index.mjs +0 -2
- package/build-module/components/background-image-control/index.mjs.map +2 -2
- package/build-module/components/block-inspector/edit-contents.mjs +4 -1
- package/build-module/components/block-inspector/edit-contents.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +2 -3
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block-invalid-warning.mjs +8 -19
- package/build-module/components/block-list/block-invalid-warning.mjs.map +2 -2
- package/build-module/components/block-styles/use-styles-for-block.mjs +2 -1
- package/build-module/components/block-styles/use-styles-for-block.mjs.map +2 -2
- package/build-module/components/block-title/use-block-display-title.mjs +7 -2
- package/build-module/components/block-title/use-block-display-title.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +10 -14
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +0 -1
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +0 -2
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +5 -5
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs +1 -2
- package/build-module/components/dimensions-tool/aspect-ratio-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +0 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/dimensions-tool/width-height-tool.mjs +2 -4
- package/build-module/components/dimensions-tool/width-height-tool.mjs.map +2 -2
- package/build-module/components/font-appearance-control/index.mjs +6 -15
- package/build-module/components/font-appearance-control/index.mjs.map +2 -2
- package/build-module/components/font-family/index.mjs +6 -15
- package/build-module/components/font-family/index.mjs.map +2 -2
- package/build-module/components/font-sizes/font-size-picker.mjs +1 -2
- package/build-module/components/font-sizes/font-size-picker.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +0 -1
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +4 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/height-control/index.mjs +0 -2
- package/build-module/components/height-control/index.mjs.map +2 -2
- package/build-module/components/html-element-control/index.mjs +0 -1
- package/build-module/components/html-element-control/index.mjs.map +2 -2
- package/build-module/components/image-editor/index.mjs +5 -0
- package/build-module/components/image-editor/index.mjs.map +2 -2
- package/build-module/components/image-editor/zoom-dropdown.mjs +0 -1
- package/build-module/components/image-editor/zoom-dropdown.mjs.map +2 -2
- package/build-module/components/image-size-control/index.mjs +1 -3
- package/build-module/components/image-size-control/index.mjs.map +2 -2
- package/build-module/components/inner-content/index.mjs +82 -0
- package/build-module/components/inner-content/index.mjs.map +7 -0
- package/build-module/components/inserter/hooks/use-block-types-state.mjs +10 -2
- package/build-module/components/inserter/hooks/use-block-types-state.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/hooks.mjs +33 -6
- package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-list.mjs +3 -1
- package/build-module/components/inserter/media-tab/media-list.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-panel.mjs +227 -30
- package/build-module/components/inserter/media-tab/media-panel.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-preview.mjs +33 -18
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.mjs +27 -7
- package/build-module/components/inserter/media-tab/media-tab.mjs.map +2 -2
- package/build-module/components/inserter/mobile-tab-navigation.mjs +6 -1
- package/build-module/components/inserter/mobile-tab-navigation.mjs.map +2 -2
- package/build-module/components/inserter/no-results.mjs +2 -2
- package/build-module/components/inserter/no-results.mjs.map +2 -2
- package/build-module/components/inserter/preview-panel.mjs +2 -1
- package/build-module/components/inserter/preview-panel.mjs.map +2 -2
- package/build-module/components/inserter-list-item/index.mjs +8 -2
- package/build-module/components/inserter-list-item/index.mjs.map +2 -2
- package/build-module/components/letter-spacing-control/index.mjs +0 -14
- package/build-module/components/letter-spacing-control/index.mjs.map +2 -2
- package/build-module/components/line-height-control/index.mjs +7 -12
- package/build-module/components/line-height-control/index.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +90 -84
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +51 -20
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/expander.mjs +1 -1
- package/build-module/components/list-view/expander.mjs.map +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.mjs.map +2 -2
- package/build-module/components/observe-typing/index.mjs +4 -3
- package/build-module/components/observe-typing/index.mjs.map +2 -2
- package/build-module/components/preset-input-control/custom-value-controls.mjs +1 -3
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/preset-input-control/index.mjs +1 -3
- package/build-module/components/preset-input-control/index.mjs.map +2 -2
- package/build-module/components/resolution-tool/index.mjs +1 -2
- package/build-module/components/resolution-tool/index.mjs.map +2 -2
- package/build-module/components/text-alignment-control/index.mjs +0 -1
- package/build-module/components/text-alignment-control/index.mjs.map +2 -2
- package/build-module/components/text-decoration-control/index.mjs +0 -1
- package/build-module/components/text-decoration-control/index.mjs.map +2 -2
- package/build-module/components/text-indent-control/index.mjs +0 -8
- package/build-module/components/text-indent-control/index.mjs.map +2 -2
- package/build-module/components/text-transform-control/index.mjs +0 -1
- package/build-module/components/text-transform-control/index.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -8
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/use-on-block-drop/index.mjs +4 -7
- package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
- package/build-module/components/writing-mode-control/index.mjs +0 -1
- package/build-module/components/writing-mode-control/index.mjs.map +2 -2
- package/build-module/hooks/font-size.mjs +1 -2
- package/build-module/hooks/font-size.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +4 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/position.mjs +38 -18
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/states.mjs +6 -9
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/layouts/constrained.mjs +21 -21
- package/build-module/layouts/constrained.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +0 -3
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +52 -9
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/private-apis.mjs +5 -1
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +2 -0
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +71 -4
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/selectors.mjs +13 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/content-rtl.css +11 -5
- package/build-style/content.css +11 -5
- package/build-style/style-rtl.css +113 -3
- package/build-style/style.css +113 -3
- package/package.json +43 -41
- package/src/autocompleters/block.js +10 -3
- package/src/autocompleters/test/block.js +53 -0
- package/src/components/background-image-control/index.js +0 -2
- package/src/components/block-inspector/edit-contents.js +5 -1
- package/src/components/block-inspector/index.js +3 -2
- package/src/components/block-list/block-invalid-warning.js +8 -19
- package/src/components/block-patterns-list/stories/index.story.jsx +1 -1
- package/src/components/block-styles/use-styles-for-block.js +1 -0
- package/src/components/block-title/use-block-display-title.js +7 -2
- package/src/components/block-toolbar/block-toolbar-icon.js +11 -16
- package/src/components/block-toolbar/test/block-toolbar-icon.js +32 -9
- package/src/components/block-variation-transforms/index.js +0 -1
- package/src/components/child-layout-control/index.js +0 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +11 -106
- package/src/components/colors-gradients/control.js +4 -4
- package/src/components/colors-gradients/style.scss +2 -2
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/dimensions-tool/aspect-ratio-tool.js +0 -1
- package/src/components/dimensions-tool/scale-tool.js +0 -1
- package/src/components/dimensions-tool/width-height-tool.js +0 -2
- package/src/components/font-appearance-control/index.js +6 -19
- package/src/components/font-family/README.md +0 -9
- package/src/components/font-family/index.js +6 -19
- package/src/components/font-family/stories/index.story.jsx +0 -1
- package/src/components/font-sizes/font-size-picker.js +0 -1
- package/src/components/global-styles/border-panel.js +0 -1
- package/src/components/global-styles/dimensions-panel.js +0 -3
- package/src/components/global-styles/typography-panel.js +0 -6
- package/src/components/height-control/index.js +0 -2
- package/src/components/html-element-control/index.js +0 -1
- package/src/components/iframe/content.scss +3 -3
- package/src/components/image-editor/index.js +22 -0
- package/src/components/image-editor/zoom-dropdown.js +0 -1
- package/src/components/image-size-control/index.js +0 -2
- package/src/components/inner-content/index.js +119 -0
- package/src/components/inner-content/test/index.js +81 -0
- package/src/components/inserter/hooks/use-block-types-state.js +10 -2
- package/src/components/inserter/media-tab/hooks.js +59 -9
- package/src/components/inserter/media-tab/media-list.js +2 -0
- package/src/components/inserter/media-tab/media-panel.js +256 -17
- package/src/components/inserter/media-tab/media-preview.js +34 -17
- package/src/components/inserter/media-tab/media-tab.js +20 -2
- package/src/components/inserter/media-tab/test/hooks.js +204 -0
- package/src/components/inserter/mobile-tab-navigation.js +6 -1
- package/src/components/inserter/no-results.js +2 -2
- package/src/components/inserter/preview-panel.js +1 -0
- package/src/components/inserter/style.scss +110 -1
- package/src/components/inserter-list-item/index.js +8 -2
- package/src/components/letter-spacing-control/README.md +0 -8
- package/src/components/letter-spacing-control/index.js +5 -23
- package/src/components/letter-spacing-control/stories/index.story.jsx +0 -12
- package/src/components/line-height-control/README.md +0 -8
- package/src/components/line-height-control/index.js +7 -16
- package/src/components/line-height-control/stories/index.story.jsx +0 -1
- package/src/components/line-height-control/test/index.js +1 -7
- package/src/components/link-picker/test/index.js +3 -1
- package/src/components/list-view/block-select-button.js +5 -1
- package/src/components/list-view/block.js +57 -20
- package/src/components/list-view/expander.js +5 -1
- package/src/components/list-view/style.scss +19 -0
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/observe-typing/index.js +9 -4
- package/src/components/preset-input-control/custom-value-controls.js +0 -2
- package/src/components/preset-input-control/index.js +0 -2
- package/src/components/resolution-tool/index.js +0 -1
- package/src/components/responsive-block-control/test/index.js +1 -5
- package/src/components/text-alignment-control/index.js +0 -1
- package/src/components/text-decoration-control/index.js +0 -1
- package/src/components/text-indent-control/index.js +7 -16
- package/src/components/text-transform-control/index.js +0 -1
- package/src/components/use-block-display-information/index.js +9 -13
- package/src/components/use-block-display-information/test/index.js +47 -9
- package/src/components/use-on-block-drop/index.js +4 -7
- package/src/components/writing-mode-control/index.js +0 -1
- package/src/hooks/block-hooks.scss +15 -0
- package/src/hooks/font-size.js +0 -1
- package/src/hooks/layout.js +5 -4
- package/src/hooks/position.js +44 -23
- package/src/hooks/states.js +6 -12
- package/src/hooks/test/cross-origin-isolation.js +0 -4
- package/src/hooks/test/layout.js +75 -1
- package/src/layouts/constrained.js +51 -28
- package/src/layouts/flex.js +0 -3
- package/src/layouts/grid.js +59 -7
- package/src/layouts/test/constrained.js +91 -0
- package/src/layouts/test/grid.js +71 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +1 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +141 -4
- package/src/store/selectors.js +41 -0
- package/src/store/test/private-selectors.js +422 -0
- package/src/store/test/reducer.js +11 -11
- package/src/store/test/selectors.js +133 -0
- package/src/style.scss +1 -0
|
@@ -159,16 +159,31 @@ export const getClientIdsTree = createSelector(
|
|
|
159
159
|
( state ) => [ state.blocks.order ]
|
|
160
160
|
);
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Returns a tree of block objects filtered by a block inclusion callback.
|
|
164
|
+
* Excluded blocks are replaced by any included descendants.
|
|
165
|
+
*
|
|
166
|
+
* @param {Object} state Global application state.
|
|
167
|
+
* @param {?string} rootClientId Optional root client ID of block list.
|
|
168
|
+
* @param {Function} includesBlock Callback that returns whether to include a block.
|
|
169
|
+
*
|
|
170
|
+
* @return {Object[]} Tree of block objects with only clientID and innerBlocks set.
|
|
171
|
+
*/
|
|
172
|
+
function getFilteredClientIdsTreeUnmemoized(
|
|
173
|
+
state,
|
|
174
|
+
rootClientId,
|
|
175
|
+
includesBlock
|
|
176
|
+
) {
|
|
163
177
|
const blockOrder = getBlockOrder( state, rootClientId );
|
|
164
178
|
const result = [];
|
|
165
179
|
|
|
166
180
|
for ( const clientId of blockOrder ) {
|
|
167
|
-
const innerBlocks =
|
|
181
|
+
const innerBlocks = getFilteredClientIdsTreeUnmemoized(
|
|
168
182
|
state,
|
|
169
|
-
clientId
|
|
183
|
+
clientId,
|
|
184
|
+
includesBlock
|
|
170
185
|
);
|
|
171
|
-
if (
|
|
186
|
+
if ( includesBlock( state, clientId ) ) {
|
|
172
187
|
result.push( { clientId, innerBlocks } );
|
|
173
188
|
} else {
|
|
174
189
|
result.push( ...innerBlocks );
|
|
@@ -178,6 +193,100 @@ function getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {
|
|
|
178
193
|
return result;
|
|
179
194
|
}
|
|
180
195
|
|
|
196
|
+
function getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {
|
|
197
|
+
return getFilteredClientIdsTreeUnmemoized(
|
|
198
|
+
state,
|
|
199
|
+
rootClientId,
|
|
200
|
+
( _state, clientId ) =>
|
|
201
|
+
getBlockEditingMode( _state, clientId ) !== 'disabled'
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Returns whether the nearest explicit block editing mode in the block's
|
|
207
|
+
* ancestry is disabled.
|
|
208
|
+
*
|
|
209
|
+
* @param {Object} state Global application state.
|
|
210
|
+
* @param {string} clientId The block client ID.
|
|
211
|
+
*
|
|
212
|
+
* @return {boolean} Whether an explicit parent block editing mode disables this
|
|
213
|
+
* block.
|
|
214
|
+
*/
|
|
215
|
+
function hasExplicitDisabledParent( state, clientId ) {
|
|
216
|
+
let parent = state.blocks.parents.get( clientId );
|
|
217
|
+
|
|
218
|
+
while ( parent !== undefined ) {
|
|
219
|
+
const parentBlockEditingMode =
|
|
220
|
+
state.blocks.blockEditingModes.get( parent );
|
|
221
|
+
|
|
222
|
+
if ( parentBlockEditingMode ) {
|
|
223
|
+
return parentBlockEditingMode === 'disabled';
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
parent = state.blocks.parents.get( parent );
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Returns the block tree displayed by List View.
|
|
234
|
+
*
|
|
235
|
+
* @param {Object} state Global application state.
|
|
236
|
+
* @param {?string} rootClientId Optional root client ID of block list.
|
|
237
|
+
*
|
|
238
|
+
* @return {Object[]} Tree of block objects with only clientID and innerBlocks set.
|
|
239
|
+
*/
|
|
240
|
+
function getListViewClientIdsTreeUnmemoized( state, rootClientId ) {
|
|
241
|
+
return getFilteredClientIdsTreeUnmemoized(
|
|
242
|
+
state,
|
|
243
|
+
rootClientId,
|
|
244
|
+
( _state, clientId ) => {
|
|
245
|
+
// Non-disabled blocks are always shown in List view.
|
|
246
|
+
if ( getBlockEditingMode( _state, clientId ) !== 'disabled' ) {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const explicitBlockEditingMode =
|
|
251
|
+
_state.blocks.blockEditingModes.get( clientId );
|
|
252
|
+
if ( explicitBlockEditingMode ) {
|
|
253
|
+
return explicitBlockEditingMode !== 'disabled';
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if ( hasExplicitDisabledParent( _state, clientId ) ) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// When a contentOnly section is being edited, there's some special handling.
|
|
261
|
+
if ( _state.editedContentOnlySection ) {
|
|
262
|
+
// Blocks within the edited content only section generally have their block
|
|
263
|
+
// editing mode flipped from disabled to default for editing, any disabled
|
|
264
|
+
// blocks can still be excluded.
|
|
265
|
+
if ( isWithinEditedContentOnlySection( _state, clientId ) ) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Blocks that are not in another section but are disabled are shown.
|
|
270
|
+
// These are blocks that would usually be visible.
|
|
271
|
+
const parentSectionBlock = getParentSectionBlock(
|
|
272
|
+
_state,
|
|
273
|
+
clientId
|
|
274
|
+
);
|
|
275
|
+
if ( ! parentSectionBlock ) {
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// If a block is in another section, then it is only visible if its a content block.
|
|
280
|
+
if ( isContentBlock( getBlockName( _state, clientId ) ) ) {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
181
290
|
/**
|
|
182
291
|
* Returns a tree of block objects with only clientID and innerBlocks set.
|
|
183
292
|
* Blocks with a 'disabled' editing mode are not included.
|
|
@@ -195,6 +304,34 @@ export const getEnabledClientIdsTree = createRegistrySelector( () =>
|
|
|
195
304
|
] )
|
|
196
305
|
);
|
|
197
306
|
|
|
307
|
+
/**
|
|
308
|
+
* Returns the block tree displayed by List View.
|
|
309
|
+
*
|
|
310
|
+
* Blocks with a 'disabled' editing mode are usually not included. When a
|
|
311
|
+
* content-only section is being edited, List View keeps visible outside-section
|
|
312
|
+
* context blocks in the tree so they can be faded. Blocks that were already
|
|
313
|
+
* hidden because they are non-content blocks inside another content-only section
|
|
314
|
+
* remain hidden.
|
|
315
|
+
*
|
|
316
|
+
* @param {Object} state Global application state.
|
|
317
|
+
* @param {?string} rootClientId Optional root client ID of block list.
|
|
318
|
+
*
|
|
319
|
+
* @return {Object[]} Tree of block objects with only clientID and innerBlocks set.
|
|
320
|
+
*/
|
|
321
|
+
export const getListViewClientIdsTree = createRegistrySelector( () =>
|
|
322
|
+
createSelector( getListViewClientIdsTreeUnmemoized, ( state ) => [
|
|
323
|
+
state.blocks.order,
|
|
324
|
+
state.derivedBlockEditingModes,
|
|
325
|
+
state.blocks.blockEditingModes,
|
|
326
|
+
state.blocks.parents,
|
|
327
|
+
state.blocks.byClientId,
|
|
328
|
+
state.blocks.attributes,
|
|
329
|
+
state.blockListSettings,
|
|
330
|
+
state.editedContentOnlySection,
|
|
331
|
+
state.settings,
|
|
332
|
+
] )
|
|
333
|
+
);
|
|
334
|
+
|
|
198
335
|
/**
|
|
199
336
|
* Returns a list of a given block's ancestors, from top to bottom. Blocks with
|
|
200
337
|
* a 'disabled' editing mode are excluded.
|
package/src/store/selectors.js
CHANGED
|
@@ -1692,6 +1692,12 @@ const canInsertBlockTypeUnmemoized = (
|
|
|
1692
1692
|
return false;
|
|
1693
1693
|
}
|
|
1694
1694
|
|
|
1695
|
+
// No insertion within static inner content: the inner blocks are fixed
|
|
1696
|
+
// at their placeholder positions within the static markup.
|
|
1697
|
+
if ( isInnerContentRoot( state, rootClientId ) ) {
|
|
1698
|
+
return false;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1695
1701
|
const blockEditingMode = getBlockEditingMode( state, rootClientId ?? '' );
|
|
1696
1702
|
|
|
1697
1703
|
// Compute section context early so the disabled check below can use it.
|
|
@@ -1899,6 +1905,24 @@ export function canInsertBlocks( state, clientIds, rootClientId = null ) {
|
|
|
1899
1905
|
);
|
|
1900
1906
|
}
|
|
1901
1907
|
|
|
1908
|
+
/**
|
|
1909
|
+
* Returns whether the given root block keeps its markup as static inner
|
|
1910
|
+
* content (the Custom HTML block). Its inner blocks are fixed at their
|
|
1911
|
+
* positions within the static markup: they can be edited in place, but not
|
|
1912
|
+
* moved or removed, and no blocks can be inserted alongside them. This only
|
|
1913
|
+
* applies to the direct children; deeper descendants are unaffected.
|
|
1914
|
+
*
|
|
1915
|
+
* @param {Object} state Editor state.
|
|
1916
|
+
* @param {?string} rootClientId Root block client ID.
|
|
1917
|
+
*
|
|
1918
|
+
* @return {boolean} Whether the root block uses static inner content.
|
|
1919
|
+
*/
|
|
1920
|
+
function isInnerContentRoot( state, rootClientId ) {
|
|
1921
|
+
return (
|
|
1922
|
+
!! rootClientId && getBlockName( state, rootClientId ) === 'core/html'
|
|
1923
|
+
);
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1902
1926
|
/**
|
|
1903
1927
|
* Determines if the given block is allowed to be deleted.
|
|
1904
1928
|
*
|
|
@@ -1913,6 +1937,14 @@ export function canRemoveBlock( state, clientId ) {
|
|
|
1913
1937
|
return false;
|
|
1914
1938
|
}
|
|
1915
1939
|
|
|
1940
|
+
// Blocks within static inner content are fixed in place; a `lock`
|
|
1941
|
+
// attribute can't override the structural constraint.
|
|
1942
|
+
if (
|
|
1943
|
+
isInnerContentRoot( state, getBlockRootClientId( state, clientId ) )
|
|
1944
|
+
) {
|
|
1945
|
+
return false;
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1916
1948
|
const attributes = getBlockAttributes( state, clientId );
|
|
1917
1949
|
if ( attributes === null ) {
|
|
1918
1950
|
return true;
|
|
@@ -2014,6 +2046,14 @@ export function canMoveBlock( state, clientId ) {
|
|
|
2014
2046
|
return false;
|
|
2015
2047
|
}
|
|
2016
2048
|
|
|
2049
|
+
// Blocks within static inner content are fixed in place; a `lock`
|
|
2050
|
+
// attribute can't override the structural constraint.
|
|
2051
|
+
if (
|
|
2052
|
+
isInnerContentRoot( state, getBlockRootClientId( state, clientId ) )
|
|
2053
|
+
) {
|
|
2054
|
+
return false;
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2017
2057
|
const attributes = getBlockAttributes( state, clientId );
|
|
2018
2058
|
if ( attributes === null ) {
|
|
2019
2059
|
return true;
|
|
@@ -2175,6 +2215,7 @@ const getItemFromVariation = ( state, item ) => ( variation ) => {
|
|
|
2175
2215
|
...variation.attributes,
|
|
2176
2216
|
},
|
|
2177
2217
|
innerBlocks: variation.innerBlocks,
|
|
2218
|
+
innerContent: variation.innerContent,
|
|
2178
2219
|
keywords: variation.keywords || item.keywords,
|
|
2179
2220
|
frecency: calculateFrecency( time, count ),
|
|
2180
2221
|
// Pass through search-only flag for block-scope variations.
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
getLastInsertedBlocksClientIds,
|
|
12
12
|
isBlockSubtreeDisabled,
|
|
13
13
|
getEnabledClientIdsTree,
|
|
14
|
+
getListViewClientIdsTree,
|
|
14
15
|
getEnabledBlockParents,
|
|
15
16
|
getExpandedBlock,
|
|
16
17
|
isDragging,
|
|
@@ -761,6 +762,427 @@ describe( 'private selectors', () => {
|
|
|
761
762
|
},
|
|
762
763
|
] );
|
|
763
764
|
} );
|
|
765
|
+
|
|
766
|
+
it( 'filters out disabled blocks when a content-only section is being edited', () => {
|
|
767
|
+
const state = {
|
|
768
|
+
...baseState,
|
|
769
|
+
blocks: {
|
|
770
|
+
...baseState.blocks,
|
|
771
|
+
blockEditingModes: new Map( [
|
|
772
|
+
[ '', 'disabled' ],
|
|
773
|
+
[
|
|
774
|
+
'b26fc763-417d-4f01-b81c-2ec61e14a972',
|
|
775
|
+
'contentOnly',
|
|
776
|
+
],
|
|
777
|
+
[
|
|
778
|
+
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
779
|
+
'contentOnly',
|
|
780
|
+
],
|
|
781
|
+
] ),
|
|
782
|
+
},
|
|
783
|
+
// The Group (ef45d5fd) is the section being edited.
|
|
784
|
+
editedContentOnlySection:
|
|
785
|
+
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337',
|
|
786
|
+
derivedBlockEditingModes: new Map( [
|
|
787
|
+
[ '6cf70164-9097-4460-bcbf-200560546988', 'disabled' ],
|
|
788
|
+
] ),
|
|
789
|
+
};
|
|
790
|
+
expect( getEnabledClientIdsTree( state ) ).toEqual( [
|
|
791
|
+
{
|
|
792
|
+
clientId: 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337',
|
|
793
|
+
innerBlocks: [
|
|
794
|
+
{
|
|
795
|
+
clientId: 'b26fc763-417d-4f01-b81c-2ec61e14a972',
|
|
796
|
+
innerBlocks: [],
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
clientId: '9b9c5c3f-2e46-4f02-9e14-9fe9515b958f',
|
|
800
|
+
innerBlocks: [
|
|
801
|
+
{
|
|
802
|
+
clientId:
|
|
803
|
+
'b3247f75-fd94-4fef-97f9-5bfd162cc416',
|
|
804
|
+
innerBlocks: [],
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
clientId:
|
|
808
|
+
'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c',
|
|
809
|
+
innerBlocks: [],
|
|
810
|
+
},
|
|
811
|
+
],
|
|
812
|
+
},
|
|
813
|
+
],
|
|
814
|
+
},
|
|
815
|
+
] );
|
|
816
|
+
} );
|
|
817
|
+
} );
|
|
818
|
+
|
|
819
|
+
describe( 'getListViewClientIdsTree', () => {
|
|
820
|
+
const TEST_CONTENT_BLOCK = 'core/test-list-view-content-block';
|
|
821
|
+
const TEST_STRUCTURE_BLOCK = 'core/test-list-view-structure-block';
|
|
822
|
+
|
|
823
|
+
const createBaseState = () => ( {
|
|
824
|
+
settings: {},
|
|
825
|
+
blocks: {
|
|
826
|
+
byClientId: new Map( [
|
|
827
|
+
[
|
|
828
|
+
'header',
|
|
829
|
+
{
|
|
830
|
+
name: TEST_STRUCTURE_BLOCK,
|
|
831
|
+
},
|
|
832
|
+
],
|
|
833
|
+
[
|
|
834
|
+
'edited-pattern',
|
|
835
|
+
{
|
|
836
|
+
name: TEST_STRUCTURE_BLOCK,
|
|
837
|
+
},
|
|
838
|
+
],
|
|
839
|
+
[
|
|
840
|
+
'edited-content',
|
|
841
|
+
{
|
|
842
|
+
name: TEST_CONTENT_BLOCK,
|
|
843
|
+
},
|
|
844
|
+
],
|
|
845
|
+
[
|
|
846
|
+
'other-pattern',
|
|
847
|
+
{
|
|
848
|
+
name: TEST_STRUCTURE_BLOCK,
|
|
849
|
+
},
|
|
850
|
+
],
|
|
851
|
+
[
|
|
852
|
+
'other-content',
|
|
853
|
+
{
|
|
854
|
+
name: TEST_CONTENT_BLOCK,
|
|
855
|
+
},
|
|
856
|
+
],
|
|
857
|
+
[
|
|
858
|
+
'other-structure',
|
|
859
|
+
{
|
|
860
|
+
name: TEST_STRUCTURE_BLOCK,
|
|
861
|
+
},
|
|
862
|
+
],
|
|
863
|
+
] ),
|
|
864
|
+
attributes: new Map( [
|
|
865
|
+
[
|
|
866
|
+
'edited-pattern',
|
|
867
|
+
{
|
|
868
|
+
metadata: {
|
|
869
|
+
patternName: 'test/edited-pattern',
|
|
870
|
+
},
|
|
871
|
+
},
|
|
872
|
+
],
|
|
873
|
+
[
|
|
874
|
+
'other-pattern',
|
|
875
|
+
{
|
|
876
|
+
metadata: {
|
|
877
|
+
patternName: 'test/other-pattern',
|
|
878
|
+
},
|
|
879
|
+
},
|
|
880
|
+
],
|
|
881
|
+
] ),
|
|
882
|
+
order: new Map( [
|
|
883
|
+
[ '', [ 'header', 'edited-pattern', 'other-pattern' ] ],
|
|
884
|
+
[ 'header', [] ],
|
|
885
|
+
[ 'edited-pattern', [ 'edited-content' ] ],
|
|
886
|
+
[ 'edited-content', [] ],
|
|
887
|
+
[ 'other-pattern', [ 'other-content', 'other-structure' ] ],
|
|
888
|
+
[ 'other-content', [] ],
|
|
889
|
+
[ 'other-structure', [] ],
|
|
890
|
+
] ),
|
|
891
|
+
parents: new Map( [
|
|
892
|
+
[ 'header', '' ],
|
|
893
|
+
[ 'edited-pattern', '' ],
|
|
894
|
+
[ 'edited-content', 'edited-pattern' ],
|
|
895
|
+
[ 'other-pattern', '' ],
|
|
896
|
+
[ 'other-content', 'other-pattern' ],
|
|
897
|
+
[ 'other-structure', 'other-pattern' ],
|
|
898
|
+
] ),
|
|
899
|
+
blockEditingModes: new Map(),
|
|
900
|
+
},
|
|
901
|
+
blockListSettings: new Map(),
|
|
902
|
+
editedContentOnlySection: 'edited-pattern',
|
|
903
|
+
derivedBlockEditingModes: new Map( [
|
|
904
|
+
[ 'header', 'disabled' ],
|
|
905
|
+
[ 'other-pattern', 'disabled' ],
|
|
906
|
+
[ 'other-content', 'disabled' ],
|
|
907
|
+
[ 'other-structure', 'disabled' ],
|
|
908
|
+
] ),
|
|
909
|
+
} );
|
|
910
|
+
|
|
911
|
+
beforeAll( () => {
|
|
912
|
+
registerBlockType( TEST_CONTENT_BLOCK, {
|
|
913
|
+
apiVersion: 3,
|
|
914
|
+
title: 'Test content block',
|
|
915
|
+
category: 'text',
|
|
916
|
+
attributes: {
|
|
917
|
+
content: {
|
|
918
|
+
type: 'string',
|
|
919
|
+
role: 'content',
|
|
920
|
+
},
|
|
921
|
+
},
|
|
922
|
+
save: () => null,
|
|
923
|
+
} );
|
|
924
|
+
registerBlockType( TEST_STRUCTURE_BLOCK, {
|
|
925
|
+
apiVersion: 3,
|
|
926
|
+
title: 'Test structure block',
|
|
927
|
+
category: 'design',
|
|
928
|
+
save: () => null,
|
|
929
|
+
} );
|
|
930
|
+
} );
|
|
931
|
+
|
|
932
|
+
afterAll( () => {
|
|
933
|
+
unregisterBlockType( TEST_CONTENT_BLOCK );
|
|
934
|
+
unregisterBlockType( TEST_STRUCTURE_BLOCK );
|
|
935
|
+
} );
|
|
936
|
+
|
|
937
|
+
beforeEach( () => {
|
|
938
|
+
getListViewClientIdsTree.registry = {
|
|
939
|
+
select: jest.fn( () => ( {} ) ),
|
|
940
|
+
};
|
|
941
|
+
} );
|
|
942
|
+
|
|
943
|
+
it( 'includes disabled outside-section context while preserving the edited section', () => {
|
|
944
|
+
const state = createBaseState();
|
|
945
|
+
|
|
946
|
+
expect( getListViewClientIdsTree( state ) ).toEqual( [
|
|
947
|
+
{
|
|
948
|
+
clientId: 'header',
|
|
949
|
+
innerBlocks: [],
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
clientId: 'edited-pattern',
|
|
953
|
+
innerBlocks: [
|
|
954
|
+
{
|
|
955
|
+
clientId: 'edited-content',
|
|
956
|
+
innerBlocks: [],
|
|
957
|
+
},
|
|
958
|
+
],
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
clientId: 'other-pattern',
|
|
962
|
+
innerBlocks: [
|
|
963
|
+
{
|
|
964
|
+
clientId: 'other-content',
|
|
965
|
+
innerBlocks: [],
|
|
966
|
+
},
|
|
967
|
+
],
|
|
968
|
+
},
|
|
969
|
+
] );
|
|
970
|
+
} );
|
|
971
|
+
|
|
972
|
+
it( 'keeps descendants of explicitly disabled blocks hidden', () => {
|
|
973
|
+
const baseState = createBaseState();
|
|
974
|
+
const state = {
|
|
975
|
+
...baseState,
|
|
976
|
+
blocks: {
|
|
977
|
+
...baseState.blocks,
|
|
978
|
+
byClientId: new Map( [
|
|
979
|
+
...baseState.blocks.byClientId,
|
|
980
|
+
[
|
|
981
|
+
'header-content',
|
|
982
|
+
{
|
|
983
|
+
name: TEST_CONTENT_BLOCK,
|
|
984
|
+
},
|
|
985
|
+
],
|
|
986
|
+
] ),
|
|
987
|
+
order: new Map( [
|
|
988
|
+
...baseState.blocks.order,
|
|
989
|
+
[ 'header', [ 'header-content' ] ],
|
|
990
|
+
[ 'header-content', [] ],
|
|
991
|
+
] ),
|
|
992
|
+
parents: new Map( [
|
|
993
|
+
...baseState.blocks.parents,
|
|
994
|
+
[ 'header-content', 'header' ],
|
|
995
|
+
] ),
|
|
996
|
+
blockEditingModes: new Map( [ [ 'header', 'disabled' ] ] ),
|
|
997
|
+
},
|
|
998
|
+
derivedBlockEditingModes: new Map( [
|
|
999
|
+
...baseState.derivedBlockEditingModes,
|
|
1000
|
+
[ 'header-content', 'disabled' ],
|
|
1001
|
+
] ),
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
expect( getListViewClientIdsTree( state ) ).toEqual( [
|
|
1005
|
+
{
|
|
1006
|
+
clientId: 'edited-pattern',
|
|
1007
|
+
innerBlocks: [
|
|
1008
|
+
{
|
|
1009
|
+
clientId: 'edited-content',
|
|
1010
|
+
innerBlocks: [],
|
|
1011
|
+
},
|
|
1012
|
+
],
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
clientId: 'other-pattern',
|
|
1016
|
+
innerBlocks: [
|
|
1017
|
+
{
|
|
1018
|
+
clientId: 'other-content',
|
|
1019
|
+
innerBlocks: [],
|
|
1020
|
+
},
|
|
1021
|
+
],
|
|
1022
|
+
},
|
|
1023
|
+
] );
|
|
1024
|
+
} );
|
|
1025
|
+
|
|
1026
|
+
it( 'includes blocks with explicit modes inside explicitly disabled parents', () => {
|
|
1027
|
+
const baseState = createBaseState();
|
|
1028
|
+
const state = {
|
|
1029
|
+
...baseState,
|
|
1030
|
+
blocks: {
|
|
1031
|
+
...baseState.blocks,
|
|
1032
|
+
byClientId: new Map( [
|
|
1033
|
+
...baseState.blocks.byClientId,
|
|
1034
|
+
[
|
|
1035
|
+
'header-content',
|
|
1036
|
+
{
|
|
1037
|
+
name: TEST_CONTENT_BLOCK,
|
|
1038
|
+
},
|
|
1039
|
+
],
|
|
1040
|
+
] ),
|
|
1041
|
+
order: new Map( [
|
|
1042
|
+
...baseState.blocks.order,
|
|
1043
|
+
[ 'header', [ 'header-content' ] ],
|
|
1044
|
+
[ 'header-content', [] ],
|
|
1045
|
+
] ),
|
|
1046
|
+
parents: new Map( [
|
|
1047
|
+
...baseState.blocks.parents,
|
|
1048
|
+
[ 'header-content', 'header' ],
|
|
1049
|
+
] ),
|
|
1050
|
+
blockEditingModes: new Map( [
|
|
1051
|
+
[ 'header', 'disabled' ],
|
|
1052
|
+
[ 'header-content', 'contentOnly' ],
|
|
1053
|
+
] ),
|
|
1054
|
+
},
|
|
1055
|
+
derivedBlockEditingModes: new Map( [
|
|
1056
|
+
...baseState.derivedBlockEditingModes,
|
|
1057
|
+
[ 'header-content', 'disabled' ],
|
|
1058
|
+
] ),
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
expect( getListViewClientIdsTree( state ) ).toEqual( [
|
|
1062
|
+
{
|
|
1063
|
+
clientId: 'header-content',
|
|
1064
|
+
innerBlocks: [],
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
clientId: 'edited-pattern',
|
|
1068
|
+
innerBlocks: [
|
|
1069
|
+
{
|
|
1070
|
+
clientId: 'edited-content',
|
|
1071
|
+
innerBlocks: [],
|
|
1072
|
+
},
|
|
1073
|
+
],
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
clientId: 'other-pattern',
|
|
1077
|
+
innerBlocks: [
|
|
1078
|
+
{
|
|
1079
|
+
clientId: 'other-content',
|
|
1080
|
+
innerBlocks: [],
|
|
1081
|
+
},
|
|
1082
|
+
],
|
|
1083
|
+
},
|
|
1084
|
+
] );
|
|
1085
|
+
} );
|
|
1086
|
+
|
|
1087
|
+
it( 'keeps structural blocks hidden inside other content-only sections', () => {
|
|
1088
|
+
const state = createBaseState();
|
|
1089
|
+
|
|
1090
|
+
expect(
|
|
1091
|
+
getListViewClientIdsTree( state )[ 2 ].innerBlocks
|
|
1092
|
+
).toEqual( [
|
|
1093
|
+
{
|
|
1094
|
+
clientId: 'other-content',
|
|
1095
|
+
innerBlocks: [],
|
|
1096
|
+
},
|
|
1097
|
+
] );
|
|
1098
|
+
} );
|
|
1099
|
+
|
|
1100
|
+
it( 'uses section-block settings when deciding which disabled blocks were already hidden', () => {
|
|
1101
|
+
const baseState = createBaseState();
|
|
1102
|
+
const state = {
|
|
1103
|
+
...baseState,
|
|
1104
|
+
settings: {
|
|
1105
|
+
disableContentOnlyForTemplateParts: true,
|
|
1106
|
+
},
|
|
1107
|
+
blocks: {
|
|
1108
|
+
...baseState.blocks,
|
|
1109
|
+
byClientId: new Map( [
|
|
1110
|
+
[
|
|
1111
|
+
'edited-pattern',
|
|
1112
|
+
{
|
|
1113
|
+
name: TEST_STRUCTURE_BLOCK,
|
|
1114
|
+
},
|
|
1115
|
+
],
|
|
1116
|
+
[
|
|
1117
|
+
'edited-content',
|
|
1118
|
+
{
|
|
1119
|
+
name: TEST_CONTENT_BLOCK,
|
|
1120
|
+
},
|
|
1121
|
+
],
|
|
1122
|
+
[
|
|
1123
|
+
'template-part',
|
|
1124
|
+
{
|
|
1125
|
+
name: 'core/template-part',
|
|
1126
|
+
},
|
|
1127
|
+
],
|
|
1128
|
+
[
|
|
1129
|
+
'template-part-structure',
|
|
1130
|
+
{
|
|
1131
|
+
name: TEST_STRUCTURE_BLOCK,
|
|
1132
|
+
},
|
|
1133
|
+
],
|
|
1134
|
+
] ),
|
|
1135
|
+
attributes: new Map( [
|
|
1136
|
+
[
|
|
1137
|
+
'edited-pattern',
|
|
1138
|
+
{
|
|
1139
|
+
metadata: {
|
|
1140
|
+
patternName: 'test/edited-pattern',
|
|
1141
|
+
},
|
|
1142
|
+
},
|
|
1143
|
+
],
|
|
1144
|
+
] ),
|
|
1145
|
+
order: new Map( [
|
|
1146
|
+
[ '', [ 'edited-pattern', 'template-part' ] ],
|
|
1147
|
+
[ 'edited-pattern', [ 'edited-content' ] ],
|
|
1148
|
+
[ 'edited-content', [] ],
|
|
1149
|
+
[ 'template-part', [ 'template-part-structure' ] ],
|
|
1150
|
+
[ 'template-part-structure', [] ],
|
|
1151
|
+
] ),
|
|
1152
|
+
parents: new Map( [
|
|
1153
|
+
[ 'edited-pattern', '' ],
|
|
1154
|
+
[ 'edited-content', 'edited-pattern' ],
|
|
1155
|
+
[ 'template-part', '' ],
|
|
1156
|
+
[ 'template-part-structure', 'template-part' ],
|
|
1157
|
+
] ),
|
|
1158
|
+
},
|
|
1159
|
+
derivedBlockEditingModes: new Map( [
|
|
1160
|
+
[ 'template-part', 'disabled' ],
|
|
1161
|
+
[ 'template-part-structure', 'disabled' ],
|
|
1162
|
+
] ),
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
expect( getListViewClientIdsTree( state ) ).toEqual( [
|
|
1166
|
+
{
|
|
1167
|
+
clientId: 'edited-pattern',
|
|
1168
|
+
innerBlocks: [
|
|
1169
|
+
{
|
|
1170
|
+
clientId: 'edited-content',
|
|
1171
|
+
innerBlocks: [],
|
|
1172
|
+
},
|
|
1173
|
+
],
|
|
1174
|
+
},
|
|
1175
|
+
{
|
|
1176
|
+
clientId: 'template-part',
|
|
1177
|
+
innerBlocks: [
|
|
1178
|
+
{
|
|
1179
|
+
clientId: 'template-part-structure',
|
|
1180
|
+
innerBlocks: [],
|
|
1181
|
+
},
|
|
1182
|
+
],
|
|
1183
|
+
},
|
|
1184
|
+
] );
|
|
1185
|
+
} );
|
|
764
1186
|
} );
|
|
765
1187
|
|
|
766
1188
|
describe( 'getEnabledBlockParents', () => {
|