@wordpress/block-editor 14.6.0 → 14.7.1-next.082ed6819.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/components/block-controls/slot.js +6 -3
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +14 -28
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-lock/modal.js +1 -1
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-manager/category.js +79 -0
- package/build/components/block-manager/category.js.map +1 -0
- package/build/components/block-manager/checklist.js +40 -0
- package/build/components/block-manager/checklist.js.map +1 -0
- package/build/components/block-manager/index.js +108 -0
- package/build/components/block-manager/index.js.map +1 -0
- package/build/components/block-patterns-list/index.js +23 -26
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/index.js +1 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/async.js +51 -0
- package/build/components/block-preview/async.js.map +1 -0
- package/build/components/block-preview/index.js +4 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-toolbar/change-design.js +1 -4
- package/build/components/block-toolbar/change-design.js.map +1 -1
- package/build/components/block-toolbar/index.js +7 -2
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/switch-section-style.js +105 -0
- package/build/components/block-toolbar/switch-section-style.js.map +1 -0
- package/build/components/block-tools/index.js +12 -9
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -1
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/collab/block-comment-icon-slot.js +2 -6
- package/build/components/collab/block-comment-icon-slot.js.map +1 -1
- package/build/components/collab/block-comment-icon-toolbar-slot.js +2 -6
- package/build/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
- package/build/components/color-palette/with-color-context.js +4 -2
- package/build/components/color-palette/with-color-context.js.map +1 -1
- package/build/components/font-family/index.js +14 -13
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +26 -14
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +4 -4
- package/build/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build/components/iframe/index.js +156 -23
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +1 -2
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -6
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +3 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/utils.js +5 -1
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +7 -8
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.js +0 -5
- package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build/components/inserter/search-results.js +0 -2
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +2 -1
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +7 -4
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/media-placeholder/index.js +33 -25
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +1 -1
- package/build/components/tabbed-sidebar/index.js.map +1 -1
- package/build/components/url-input/index.js +3 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +5 -6
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/hooks/border.js +3 -3
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-family.js +1 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/style.js +6 -6
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +7 -7
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +6 -6
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +3 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +11 -9
- package/build/layouts/flex.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +4 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +12 -8
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +5 -4
- package/build/store/utils.js.map +1 -1
- package/build/utils/dom.js +27 -22
- package/build/utils/dom.js.map +1 -1
- package/build-module/components/block-controls/slot.js +6 -3
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +15 -27
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -1
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-manager/category.js +71 -0
- package/build-module/components/block-manager/category.js.map +1 -0
- package/build-module/components/block-manager/checklist.js +32 -0
- package/build-module/components/block-manager/checklist.js.map +1 -0
- package/build-module/components/block-manager/index.js +102 -0
- package/build-module/components/block-manager/index.js.map +1 -0
- package/build-module/components/block-patterns-list/index.js +23 -26
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/async.js +44 -0
- package/build-module/components/block-preview/async.js.map +1 -0
- package/build-module/components/block-preview/index.js +4 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +2 -2
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-toolbar/change-design.js +1 -4
- package/build-module/components/block-toolbar/change-design.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +7 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/switch-section-style.js +97 -0
- package/build-module/components/block-toolbar/switch-section-style.js.map +1 -0
- package/build-module/components/block-tools/index.js +13 -10
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -2
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -1
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-slot.js +2 -6
- package/build-module/components/collab/block-comment-icon-slot.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js +2 -6
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
- package/build-module/components/color-palette/with-color-context.js +4 -2
- package/build-module/components/color-palette/with-color-context.js.map +1 -1
- package/build-module/components/font-family/index.js +15 -14
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +26 -14
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +4 -4
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build-module/components/iframe/index.js +157 -24
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +1 -2
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +5 -7
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +4 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/utils.js +4 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +8 -9
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.js +1 -6
- package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build-module/components/inserter/search-results.js +0 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +2 -1
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +7 -4
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +33 -25
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +1 -1
- package/build-module/components/tabbed-sidebar/index.js.map +1 -1
- package/build-module/components/url-input/index.js +3 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +4 -4
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/hooks/border.js +3 -3
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +2 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-family.js +1 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/style.js +6 -6
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +7 -7
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +6 -6
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +3 -3
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +11 -9
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +6 -6
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-selectors.js +3 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +12 -8
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -3
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/dom.js +25 -21
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/content-rtl.css +30 -15
- package/build-style/content.css +30 -15
- package/build-style/style-rtl.css +92 -3
- package/build-style/style.css +92 -3
- package/build-types/utils/dom.d.ts +7 -9
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/components/block-canvas/style.scss +1 -1
- package/src/components/block-controls/slot.js +5 -3
- package/src/components/block-inspector/index.js +0 -2
- package/src/components/block-inspector/style.scss +2 -1
- package/src/components/block-list/block.js +28 -48
- package/src/components/block-lock/modal.js +1 -1
- package/src/components/block-manager/category.js +102 -0
- package/src/components/block-manager/checklist.js +34 -0
- package/src/components/block-manager/index.js +127 -0
- package/src/components/block-manager/style.scss +82 -0
- package/src/components/block-mover/README.md +15 -8
- package/src/components/block-mover/stories/index.story.js +73 -71
- package/src/components/block-mover/style.scss +3 -0
- package/src/components/block-patterns-list/README.md +8 -8
- package/src/components/block-patterns-list/index.js +35 -51
- package/src/components/block-patterns-list/stories/index.story.js +2 -19
- package/src/components/block-popover/index.js +4 -4
- package/src/components/block-preview/async.js +43 -0
- package/src/components/block-preview/index.js +6 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/src/components/block-settings-menu/index.js +2 -2
- package/src/components/block-toolbar/change-design.js +1 -7
- package/src/components/block-toolbar/index.js +6 -0
- package/src/components/block-toolbar/switch-section-style.js +115 -0
- package/src/components/block-tools/index.js +26 -10
- package/src/components/block-tools/style.scss +12 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -2
- package/src/components/block-tools/use-show-block-tools.js +3 -1
- package/src/components/collab/block-comment-icon-slot.js +2 -6
- package/src/components/collab/block-comment-icon-toolbar-slot.js +3 -5
- package/src/components/color-palette/with-color-context.js +25 -7
- package/src/components/default-block-appender/content.scss +13 -19
- package/src/components/font-family/index.js +13 -13
- package/src/components/global-styles/dimensions-panel.js +22 -16
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/use-global-styles-output.js +1 -1
- package/src/components/iframe/content.scss +16 -3
- package/src/components/iframe/get-compatibility-styles.js +4 -9
- package/src/components/iframe/index.js +204 -44
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +3 -6
- package/src/components/inserter/block-patterns-tab/index.js +0 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +15 -17
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +8 -0
- package/src/components/inserter/block-patterns-tab/utils.js +5 -0
- package/src/components/inserter/category-tabs/index.js +8 -9
- package/src/components/inserter/hooks/use-block-types-state.js +6 -1
- package/src/components/inserter/hooks/use-patterns-paging.js +1 -6
- package/src/components/inserter/search-results.js +0 -6
- package/src/components/inserter-draggable-blocks/index.js +10 -1
- package/src/components/inspector-controls/README.md +2 -0
- package/src/components/inspector-controls/slot.js +6 -4
- package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -3
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +10 -10
- package/src/components/media-placeholder/index.js +41 -37
- package/src/components/provider/test/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +15 -10
- package/src/components/rich-text/index.js +8 -1
- package/src/components/tabbed-sidebar/index.js +1 -1
- package/src/components/tabbed-sidebar/style.scss +1 -1
- package/src/components/url-input/index.js +3 -4
- package/src/components/use-block-commands/index.js +245 -234
- package/src/hooks/border.js +3 -9
- package/src/hooks/color.js +1 -1
- package/src/hooks/dimensions.js +2 -2
- package/src/hooks/font-family.js +1 -1
- package/src/hooks/style.js +6 -12
- package/src/hooks/supports.js +7 -7
- package/src/hooks/test/style.js +1 -2
- package/src/hooks/typography.js +6 -6
- package/src/hooks/utils.js +8 -3
- package/src/layouts/flex.js +26 -18
- package/src/private-apis.js +6 -6
- package/src/store/private-selectors.js +6 -7
- package/src/store/selectors.js +60 -45
- package/src/store/test/private-selectors.js +5 -0
- package/src/store/test/selectors.js +87 -58
- package/src/store/utils.js +12 -11
- package/src/style.scss +1 -0
- package/src/utils/dom.js +26 -21
- package/src/utils/test/dom.js +224 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-info-slot-fill/index.js +0 -39
- package/build/components/block-info-slot-fill/index.js.map +0 -1
- package/build-module/components/block-info-slot-fill/index.js +0 -32
- package/build-module/components/block-info-slot-fill/index.js.map +0 -1
- package/src/components/block-info-slot-fill/index.js +0 -27
- /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
package/src/hooks/typography.js
CHANGED
|
@@ -27,12 +27,12 @@ function omit( object, keys ) {
|
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const LETTER_SPACING_SUPPORT_KEY = 'typography.
|
|
31
|
-
const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.
|
|
32
|
-
const TEXT_DECORATION_SUPPORT_KEY = 'typography.
|
|
30
|
+
const LETTER_SPACING_SUPPORT_KEY = 'typography.letterSpacing';
|
|
31
|
+
const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.textTransform';
|
|
32
|
+
const TEXT_DECORATION_SUPPORT_KEY = 'typography.textDecoration';
|
|
33
33
|
const TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';
|
|
34
|
-
const FONT_STYLE_SUPPORT_KEY = 'typography.
|
|
35
|
-
const FONT_WEIGHT_SUPPORT_KEY = 'typography.
|
|
34
|
+
const FONT_STYLE_SUPPORT_KEY = 'typography.fontStyle';
|
|
35
|
+
const FONT_WEIGHT_SUPPORT_KEY = 'typography.fontWeight';
|
|
36
36
|
const WRITING_MODE_SUPPORT_KEY = 'typography.__experimentalWritingMode';
|
|
37
37
|
export const TYPOGRAPHY_SUPPORT_KEY = 'typography';
|
|
38
38
|
export const TYPOGRAPHY_SUPPORT_KEYS = [
|
|
@@ -133,7 +133,7 @@ export function TypographyPanel( { clientId, name, setAttributes, settings } ) {
|
|
|
133
133
|
|
|
134
134
|
const defaultControls = getBlockSupport( name, [
|
|
135
135
|
TYPOGRAPHY_SUPPORT_KEY,
|
|
136
|
-
'
|
|
136
|
+
'defaultControls',
|
|
137
137
|
] );
|
|
138
138
|
|
|
139
139
|
return (
|
package/src/hooks/utils.js
CHANGED
|
@@ -124,7 +124,7 @@ export function shouldSkipSerialization(
|
|
|
124
124
|
feature
|
|
125
125
|
) {
|
|
126
126
|
const support = getBlockSupport( blockNameOrType, featureSet );
|
|
127
|
-
const skipSerialization = support?.
|
|
127
|
+
const skipSerialization = support?.skipSerialization;
|
|
128
128
|
|
|
129
129
|
if ( Array.isArray( skipSerialization ) ) {
|
|
130
130
|
return skipSerialization.includes( feature );
|
|
@@ -562,8 +562,13 @@ export function createBlockEditFilter( features ) {
|
|
|
562
562
|
addFilter( 'editor.BlockEdit', 'core/editor/hooks', withBlockEditHooks );
|
|
563
563
|
}
|
|
564
564
|
|
|
565
|
-
function BlockProps( {
|
|
566
|
-
|
|
565
|
+
function BlockProps( {
|
|
566
|
+
index,
|
|
567
|
+
useBlockProps: hook,
|
|
568
|
+
setAllWrapperProps,
|
|
569
|
+
...props
|
|
570
|
+
} ) {
|
|
571
|
+
const wrapperProps = hook( props );
|
|
567
572
|
const setWrapperProps = ( next ) =>
|
|
568
573
|
setAllWrapperProps( ( prev ) => {
|
|
569
574
|
const nextAll = [ ...prev ];
|
package/src/layouts/flex.js
CHANGED
|
@@ -66,24 +66,27 @@ export default {
|
|
|
66
66
|
onChange,
|
|
67
67
|
layoutBlockSupport = {},
|
|
68
68
|
} ) {
|
|
69
|
-
const { allowOrientation = true } =
|
|
69
|
+
const { allowOrientation = true, allowJustification = true } =
|
|
70
|
+
layoutBlockSupport;
|
|
70
71
|
return (
|
|
71
72
|
<>
|
|
72
73
|
<Flex>
|
|
73
|
-
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
{ allowJustification && (
|
|
75
|
+
<FlexItem>
|
|
76
|
+
<FlexLayoutJustifyContentControl
|
|
77
|
+
layout={ layout }
|
|
78
|
+
onChange={ onChange }
|
|
79
|
+
/>
|
|
80
|
+
</FlexItem>
|
|
81
|
+
) }
|
|
82
|
+
{ allowOrientation && (
|
|
83
|
+
<FlexItem>
|
|
81
84
|
<OrientationControl
|
|
82
85
|
layout={ layout }
|
|
83
86
|
onChange={ onChange }
|
|
84
87
|
/>
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
</FlexItem>
|
|
89
|
+
) }
|
|
87
90
|
</Flex>
|
|
88
91
|
<FlexWrapControl layout={ layout } onChange={ onChange } />
|
|
89
92
|
</>
|
|
@@ -94,17 +97,22 @@ export default {
|
|
|
94
97
|
onChange,
|
|
95
98
|
layoutBlockSupport,
|
|
96
99
|
} ) {
|
|
97
|
-
|
|
100
|
+
const { allowVerticalAlignment = true, allowJustification = true } =
|
|
101
|
+
layoutBlockSupport;
|
|
102
|
+
|
|
103
|
+
if ( ! allowJustification && ! allowVerticalAlignment ) {
|
|
98
104
|
return null;
|
|
99
105
|
}
|
|
100
|
-
|
|
106
|
+
|
|
101
107
|
return (
|
|
102
108
|
<BlockControls group="block" __experimentalShareWithChildBlocks>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
109
|
+
{ allowJustification && (
|
|
110
|
+
<FlexLayoutJustifyContentControl
|
|
111
|
+
layout={ layout }
|
|
112
|
+
onChange={ onChange }
|
|
113
|
+
isToolbar
|
|
114
|
+
/>
|
|
115
|
+
) }
|
|
108
116
|
{ allowVerticalAlignment && (
|
|
109
117
|
<FlexLayoutVerticalAlignmentControl
|
|
110
118
|
layout={ layout }
|
package/src/private-apis.js
CHANGED
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
normalizeString,
|
|
14
14
|
} from './components/inserter/search-items';
|
|
15
15
|
import { PrivateListView } from './components/list-view';
|
|
16
|
-
import BlockInfo from './components/block-info-slot-fill';
|
|
17
16
|
import { useHasBlockToolbar } from './components/block-toolbar/use-has-block-toolbar';
|
|
18
17
|
import { cleanEmptyObject } from './hooks/utils';
|
|
19
18
|
import BlockQuickNavigation from './components/block-quick-navigation';
|
|
20
19
|
import { LayoutStyle } from './components/block-list/layout';
|
|
20
|
+
import BlockManager from './components/block-manager';
|
|
21
21
|
import { BlockRemovalWarningModal } from './components/block-removal-warning-modal';
|
|
22
22
|
import {
|
|
23
23
|
setBackgroundStyleDefaults,
|
|
@@ -48,8 +48,8 @@ import { PrivatePublishDateTimePicker } from './components/publish-date-time-pic
|
|
|
48
48
|
import useSpacingSizes from './components/spacing-sizes-control/hooks/use-spacing-sizes';
|
|
49
49
|
import useBlockDisplayTitle from './components/block-title/use-block-display-title';
|
|
50
50
|
import TabbedSidebar from './components/tabbed-sidebar';
|
|
51
|
-
import
|
|
52
|
-
import
|
|
51
|
+
import CommentIconSlotFill from './components/collab/block-comment-icon-slot';
|
|
52
|
+
import CommentIconToolbarSlotFill from './components/collab/block-comment-icon-toolbar-slot';
|
|
53
53
|
/**
|
|
54
54
|
* Private @wordpress/block-editor APIs.
|
|
55
55
|
*/
|
|
@@ -66,11 +66,11 @@ lock( privateApis, {
|
|
|
66
66
|
normalizeString,
|
|
67
67
|
PrivateListView,
|
|
68
68
|
ResizableBoxPopover,
|
|
69
|
-
BlockInfo,
|
|
70
69
|
useHasBlockToolbar,
|
|
71
70
|
cleanEmptyObject,
|
|
72
71
|
BlockQuickNavigation,
|
|
73
72
|
LayoutStyle,
|
|
73
|
+
BlockManager,
|
|
74
74
|
BlockRemovalWarningModal,
|
|
75
75
|
useLayoutClasses,
|
|
76
76
|
useLayoutStyles,
|
|
@@ -95,6 +95,6 @@ lock( privateApis, {
|
|
|
95
95
|
__unstableBlockStyleVariationOverridesWithConfig,
|
|
96
96
|
setBackgroundStyleDefaults,
|
|
97
97
|
sectionRootClientIdKey,
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
CommentIconSlotFill,
|
|
99
|
+
CommentIconToolbarSlotFill,
|
|
100
100
|
} );
|
|
@@ -109,17 +109,16 @@ function getEnabledClientIdsTreeUnmemoized( state, rootClientId ) {
|
|
|
109
109
|
*
|
|
110
110
|
* @return {Object[]} Tree of block objects with only clientID and innerBlocks set.
|
|
111
111
|
*/
|
|
112
|
-
export const getEnabledClientIdsTree =
|
|
113
|
-
getEnabledClientIdsTreeUnmemoized,
|
|
114
|
-
( state ) => [
|
|
112
|
+
export const getEnabledClientIdsTree = createRegistrySelector( ( select ) =>
|
|
113
|
+
createSelector( getEnabledClientIdsTreeUnmemoized, ( state ) => [
|
|
115
114
|
state.blocks.order,
|
|
116
115
|
state.blockEditingModes,
|
|
117
116
|
state.settings.templateLock,
|
|
118
117
|
state.blockListSettings,
|
|
119
|
-
state
|
|
118
|
+
select( STORE_NAME ).__unstableGetEditorMode( state ),
|
|
120
119
|
state.zoomLevel,
|
|
121
120
|
getSectionRootClientId( state ),
|
|
122
|
-
]
|
|
121
|
+
] )
|
|
123
122
|
);
|
|
124
123
|
|
|
125
124
|
/**
|
|
@@ -317,7 +316,7 @@ export const hasAllowedPatterns = createRegistrySelector( ( select ) =>
|
|
|
317
316
|
},
|
|
318
317
|
( state, rootClientId ) => [
|
|
319
318
|
...getAllPatternsDependants( select )( state ),
|
|
320
|
-
...getInsertBlockTypeDependants( state, rootClientId ),
|
|
319
|
+
...getInsertBlockTypeDependants( select )( state, rootClientId ),
|
|
321
320
|
]
|
|
322
321
|
)
|
|
323
322
|
);
|
|
@@ -331,7 +330,7 @@ function mapUserPattern(
|
|
|
331
330
|
id: userPattern.id,
|
|
332
331
|
type: INSERTER_PATTERN_TYPES.user,
|
|
333
332
|
title: userPattern.title.raw,
|
|
334
|
-
categories: userPattern.wp_pattern_category
|
|
333
|
+
categories: userPattern.wp_pattern_category?.map( ( catId ) => {
|
|
335
334
|
const category = __experimentalUserPatternCategories.find(
|
|
336
335
|
( { id } ) => id === catId
|
|
337
336
|
);
|
package/src/store/selectors.js
CHANGED
|
@@ -1794,10 +1794,12 @@ const canInsertBlockTypeUnmemoized = (
|
|
|
1794
1794
|
*
|
|
1795
1795
|
* @return {boolean} Whether the given block type is allowed to be inserted.
|
|
1796
1796
|
*/
|
|
1797
|
-
export const canInsertBlockType =
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1797
|
+
export const canInsertBlockType = createRegistrySelector( ( select ) =>
|
|
1798
|
+
createSelector(
|
|
1799
|
+
canInsertBlockTypeUnmemoized,
|
|
1800
|
+
( state, blockName, rootClientId ) =>
|
|
1801
|
+
getInsertBlockTypeDependants( select )( state, rootClientId )
|
|
1802
|
+
)
|
|
1801
1803
|
);
|
|
1802
1804
|
|
|
1803
1805
|
/**
|
|
@@ -2224,7 +2226,7 @@ export const getInserterItems = createRegistrySelector( ( select ) =>
|
|
|
2224
2226
|
unlock( select( STORE_NAME ) ).getReusableBlocks(),
|
|
2225
2227
|
state.blocks.order,
|
|
2226
2228
|
state.preferences.insertUsage,
|
|
2227
|
-
...getInsertBlockTypeDependants( state, rootClientId ),
|
|
2229
|
+
...getInsertBlockTypeDependants( select )( state, rootClientId ),
|
|
2228
2230
|
]
|
|
2229
2231
|
)
|
|
2230
2232
|
);
|
|
@@ -2255,44 +2257,51 @@ export const getInserterItems = createRegistrySelector( ( select ) =>
|
|
|
2255
2257
|
* this item.
|
|
2256
2258
|
* @property {number} frecency Heuristic that combines frequency and recency.
|
|
2257
2259
|
*/
|
|
2258
|
-
export const getBlockTransformItems =
|
|
2259
|
-
(
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
)
|
|
2268
|
-
|
|
2260
|
+
export const getBlockTransformItems = createRegistrySelector( ( select ) =>
|
|
2261
|
+
createSelector(
|
|
2262
|
+
( state, blocks, rootClientId = null ) => {
|
|
2263
|
+
const normalizedBlocks = Array.isArray( blocks )
|
|
2264
|
+
? blocks
|
|
2265
|
+
: [ blocks ];
|
|
2266
|
+
const buildBlockTypeTransformItem = buildBlockTypeItem( state, {
|
|
2267
|
+
buildScope: 'transform',
|
|
2268
|
+
} );
|
|
2269
|
+
const blockTypeTransformItems = getBlockTypes()
|
|
2270
|
+
.filter( ( blockType ) =>
|
|
2271
|
+
canIncludeBlockTypeInInserter(
|
|
2272
|
+
state,
|
|
2273
|
+
blockType,
|
|
2274
|
+
rootClientId
|
|
2275
|
+
)
|
|
2276
|
+
)
|
|
2277
|
+
.map( buildBlockTypeTransformItem );
|
|
2269
2278
|
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
);
|
|
2279
|
+
const itemsByName = Object.fromEntries(
|
|
2280
|
+
Object.entries( blockTypeTransformItems ).map(
|
|
2281
|
+
( [ , value ] ) => [ value.name, value ]
|
|
2282
|
+
)
|
|
2283
|
+
);
|
|
2276
2284
|
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2285
|
+
const possibleTransforms = getPossibleBlockTransformations(
|
|
2286
|
+
normalizedBlocks
|
|
2287
|
+
).reduce( ( accumulator, block ) => {
|
|
2288
|
+
if ( itemsByName[ block?.name ] ) {
|
|
2289
|
+
accumulator.push( itemsByName[ block.name ] );
|
|
2290
|
+
}
|
|
2291
|
+
return accumulator;
|
|
2292
|
+
}, [] );
|
|
2293
|
+
return orderBy(
|
|
2294
|
+
possibleTransforms,
|
|
2295
|
+
( block ) => itemsByName[ block.name ].frecency,
|
|
2296
|
+
'desc'
|
|
2297
|
+
);
|
|
2298
|
+
},
|
|
2299
|
+
( state, blocks, rootClientId ) => [
|
|
2300
|
+
getBlockTypes(),
|
|
2301
|
+
state.preferences.insertUsage,
|
|
2302
|
+
...getInsertBlockTypeDependants( select )( state, rootClientId ),
|
|
2303
|
+
]
|
|
2304
|
+
)
|
|
2296
2305
|
);
|
|
2297
2306
|
|
|
2298
2307
|
/**
|
|
@@ -2360,7 +2369,7 @@ export const getAllowedBlocks = createRegistrySelector( ( select ) =>
|
|
|
2360
2369
|
( state, rootClientId ) => [
|
|
2361
2370
|
getBlockTypes(),
|
|
2362
2371
|
unlock( select( STORE_NAME ) ).getReusableBlocks(),
|
|
2363
|
-
...getInsertBlockTypeDependants( state, rootClientId ),
|
|
2372
|
+
...getInsertBlockTypeDependants( select )( state, rootClientId ),
|
|
2364
2373
|
]
|
|
2365
2374
|
)
|
|
2366
2375
|
);
|
|
@@ -2435,7 +2444,7 @@ export const __experimentalGetParsedPattern = createRegistrySelector(
|
|
|
2435
2444
|
|
|
2436
2445
|
const getAllowedPatternsDependants = ( select ) => ( state, rootClientId ) => [
|
|
2437
2446
|
...getAllPatternsDependants( select )( state ),
|
|
2438
|
-
...getInsertBlockTypeDependants( state, rootClientId ),
|
|
2447
|
+
...getInsertBlockTypeDependants( select )( state, rootClientId ),
|
|
2439
2448
|
];
|
|
2440
2449
|
|
|
2441
2450
|
const patternsWithParsedBlocks = new WeakMap();
|
|
@@ -2764,8 +2773,14 @@ export function isNavigationMode( state ) {
|
|
|
2764
2773
|
* @return {string} the editor mode.
|
|
2765
2774
|
*/
|
|
2766
2775
|
export const __unstableGetEditorMode = createRegistrySelector(
|
|
2767
|
-
( select ) => () => {
|
|
2768
|
-
|
|
2776
|
+
( select ) => ( state ) => {
|
|
2777
|
+
if ( ! window?.__experimentalEditorWriteMode ) {
|
|
2778
|
+
return 'edit';
|
|
2779
|
+
}
|
|
2780
|
+
return (
|
|
2781
|
+
state.settings.editorTool ??
|
|
2782
|
+
select( preferencesStore ).get( 'core', 'editorTool' )
|
|
2783
|
+
);
|
|
2769
2784
|
}
|
|
2770
2785
|
);
|
|
2771
2786
|
|
|
@@ -292,6 +292,11 @@ describe( 'private selectors', () => {
|
|
|
292
292
|
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f': {},
|
|
293
293
|
},
|
|
294
294
|
};
|
|
295
|
+
getEnabledClientIdsTree.registry = {
|
|
296
|
+
select: jest.fn( () => ( {
|
|
297
|
+
__unstableGetEditorMode: () => 'edit',
|
|
298
|
+
} ) ),
|
|
299
|
+
};
|
|
295
300
|
|
|
296
301
|
it( 'should return tree containing only clientId and innerBlocks', () => {
|
|
297
302
|
const state = {
|
|
@@ -4615,68 +4615,97 @@ describe( 'getBlockEditingMode', () => {
|
|
|
4615
4615
|
).toBe( 'contentOnly' );
|
|
4616
4616
|
} );
|
|
4617
4617
|
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4618
|
+
describe( 'navigation mode', () => {
|
|
4619
|
+
const writeModeExperiment = window.__experimentalEditorWriteMode;
|
|
4620
|
+
beforeAll( () => {
|
|
4621
|
+
window.__experimentalEditorWriteMode = true;
|
|
4622
|
+
} );
|
|
4623
|
+
afterAll( () => {
|
|
4624
|
+
window.__experimentalEditorWriteMode = writeModeExperiment;
|
|
4625
|
+
} );
|
|
4626
|
+
it( 'in navigation mode, the root section container is default', () => {
|
|
4627
|
+
dispatch( preferencesStore ).set(
|
|
4628
|
+
'core',
|
|
4629
|
+
'editorTool',
|
|
4630
|
+
'navigation'
|
|
4631
|
+
);
|
|
4632
|
+
expect(
|
|
4633
|
+
getBlockEditingMode(
|
|
4634
|
+
navigationModeStateWithRootSection,
|
|
4635
|
+
'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337'
|
|
4636
|
+
)
|
|
4637
|
+
).toBe( 'default' );
|
|
4638
|
+
} );
|
|
4627
4639
|
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4640
|
+
it( 'in navigation mode, anything outside the section container is disabled', () => {
|
|
4641
|
+
dispatch( preferencesStore ).set(
|
|
4642
|
+
'core',
|
|
4643
|
+
'editorTool',
|
|
4644
|
+
'navigation'
|
|
4645
|
+
);
|
|
4646
|
+
expect(
|
|
4647
|
+
getBlockEditingMode(
|
|
4648
|
+
navigationModeStateWithRootSection,
|
|
4649
|
+
'6cf70164-9097-4460-bcbf-200560546988'
|
|
4650
|
+
)
|
|
4651
|
+
).toBe( 'disabled' );
|
|
4652
|
+
} );
|
|
4637
4653
|
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4654
|
+
it( 'in navigation mode, sections are contentOnly', () => {
|
|
4655
|
+
dispatch( preferencesStore ).set(
|
|
4656
|
+
'core',
|
|
4657
|
+
'editorTool',
|
|
4658
|
+
'navigation'
|
|
4659
|
+
);
|
|
4660
|
+
expect(
|
|
4661
|
+
getBlockEditingMode(
|
|
4662
|
+
navigationModeStateWithRootSection,
|
|
4663
|
+
'b26fc763-417d-4f01-b81c-2ec61e14a972'
|
|
4664
|
+
)
|
|
4665
|
+
).toBe( 'contentOnly' );
|
|
4666
|
+
expect(
|
|
4667
|
+
getBlockEditingMode(
|
|
4668
|
+
navigationModeStateWithRootSection,
|
|
4669
|
+
'9b9c5c3f-2e46-4f02-9e14-9fe9515b958f'
|
|
4670
|
+
)
|
|
4671
|
+
).toBe( 'contentOnly' );
|
|
4672
|
+
} );
|
|
4653
4673
|
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4674
|
+
it( 'in navigation mode, blocks with content attributes within sections are contentOnly', () => {
|
|
4675
|
+
dispatch( preferencesStore ).set(
|
|
4676
|
+
'core',
|
|
4677
|
+
'editorTool',
|
|
4678
|
+
'navigation'
|
|
4679
|
+
);
|
|
4680
|
+
hasContentRoleAttribute.mockReturnValueOnce( true );
|
|
4681
|
+
expect(
|
|
4682
|
+
getBlockEditingMode(
|
|
4683
|
+
navigationModeStateWithRootSection,
|
|
4684
|
+
'b3247f75-fd94-4fef-97f9-5bfd162cc416'
|
|
4685
|
+
)
|
|
4686
|
+
).toBe( 'contentOnly' );
|
|
4663
4687
|
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4688
|
+
hasContentRoleAttribute.mockReturnValueOnce( true );
|
|
4689
|
+
expect(
|
|
4690
|
+
getBlockEditingMode(
|
|
4691
|
+
navigationModeStateWithRootSection,
|
|
4692
|
+
'e178812d-ce5e-48c7-a945-8ae4ffcbbb7c'
|
|
4693
|
+
)
|
|
4694
|
+
).toBe( 'contentOnly' );
|
|
4695
|
+
} );
|
|
4672
4696
|
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4697
|
+
it( 'in navigation mode, blocks without content attributes within sections are disabled', () => {
|
|
4698
|
+
dispatch( preferencesStore ).set(
|
|
4699
|
+
'core',
|
|
4700
|
+
'editorTool',
|
|
4701
|
+
'navigation'
|
|
4702
|
+
);
|
|
4703
|
+
expect(
|
|
4704
|
+
getBlockEditingMode(
|
|
4705
|
+
navigationModeStateWithRootSection,
|
|
4706
|
+
'9b9c5c3f-2e46-4f02-9e14-9fed515b958s'
|
|
4707
|
+
)
|
|
4708
|
+
).toBe( 'disabled' );
|
|
4709
|
+
} );
|
|
4681
4710
|
} );
|
|
4682
4711
|
} );
|
package/src/store/utils.js
CHANGED
|
@@ -110,14 +110,15 @@ export const getAllPatternsDependants = ( select ) => ( state ) => {
|
|
|
110
110
|
];
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
export
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
113
|
+
export const getInsertBlockTypeDependants =
|
|
114
|
+
( select ) => ( state, rootClientId ) => {
|
|
115
|
+
return [
|
|
116
|
+
state.blockListSettings[ rootClientId ],
|
|
117
|
+
state.blocks.byClientId.get( rootClientId ),
|
|
118
|
+
state.settings.allowedBlockTypes,
|
|
119
|
+
state.settings.templateLock,
|
|
120
|
+
state.blockEditingModes,
|
|
121
|
+
select( STORE_NAME ).__unstableGetEditorMode( state ),
|
|
122
|
+
getSectionRootClientId( state ),
|
|
123
|
+
];
|
|
124
|
+
};
|
package/src/style.scss
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
@import "./components/block-card/style.scss";
|
|
11
11
|
@import "./components/block-compare/style.scss";
|
|
12
12
|
@import "./components/block-draggable/style.scss";
|
|
13
|
+
@import "./components/block-manager/style.scss";
|
|
13
14
|
@import "./components/block-mover/style.scss";
|
|
14
15
|
@import "./components/block-navigation/style.scss";
|
|
15
16
|
@import "./components/block-patterns-list/style.scss";
|
package/src/utils/dom.js
CHANGED
|
@@ -134,23 +134,21 @@ function isScrollable( element ) {
|
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
export const WITH_OVERFLOW_ELEMENT_BLOCKS = [ 'core/navigation' ];
|
|
137
138
|
/**
|
|
138
|
-
* Returns the
|
|
139
|
-
*
|
|
140
|
-
* Visible nested elements, including elements that overflow the parent, are
|
|
141
|
-
* taken into account.
|
|
142
|
-
*
|
|
143
|
-
* This function is useful for calculating the visible area of a block that
|
|
144
|
-
* contains nested elements that overflow the block, e.g. the Navigation block,
|
|
145
|
-
* which can contain overflowing Submenu blocks.
|
|
139
|
+
* Returns the bounding rectangle of an element, with special handling for blocks
|
|
140
|
+
* that have visible overflowing children (defined in WITH_OVERFLOW_ELEMENT_BLOCKS).
|
|
146
141
|
*
|
|
142
|
+
* For blocks like Navigation that can have overflowing elements (e.g. submenus),
|
|
143
|
+
* this function calculates the combined bounds of both the parent and its visible
|
|
144
|
+
* children. The returned rect may extend beyond the viewport.
|
|
147
145
|
* The returned rect represents the full extent of the element and its visible
|
|
148
146
|
* children, which may extend beyond the viewport.
|
|
149
147
|
*
|
|
150
148
|
* @param {Element} element Element.
|
|
151
149
|
* @return {DOMRect} Bounding client rect of the element and its visible children.
|
|
152
150
|
*/
|
|
153
|
-
export function
|
|
151
|
+
export function getElementBounds( element ) {
|
|
154
152
|
const viewport = element.ownerDocument.defaultView;
|
|
155
153
|
|
|
156
154
|
if ( ! viewport ) {
|
|
@@ -158,19 +156,26 @@ export function getVisibleElementBounds( element ) {
|
|
|
158
156
|
}
|
|
159
157
|
|
|
160
158
|
let bounds = element.getBoundingClientRect();
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
159
|
+
const dataType = element.getAttribute( 'data-type' );
|
|
160
|
+
|
|
161
|
+
/*
|
|
162
|
+
* For blocks with overflowing elements (like Navigation), include the bounds
|
|
163
|
+
* of visible children that extend beyond the parent container.
|
|
164
|
+
*/
|
|
165
|
+
if ( dataType && WITH_OVERFLOW_ELEMENT_BLOCKS.includes( dataType ) ) {
|
|
166
|
+
const stack = [ element ];
|
|
167
|
+
let currentElement;
|
|
168
|
+
|
|
169
|
+
while ( ( currentElement = stack.pop() ) ) {
|
|
170
|
+
// Children won’t affect bounds unless the element is not scrollable.
|
|
171
|
+
if ( ! isScrollable( currentElement ) ) {
|
|
172
|
+
for ( const child of currentElement.children ) {
|
|
173
|
+
if ( isElementVisible( child ) ) {
|
|
174
|
+
const childBounds = child.getBoundingClientRect();
|
|
175
|
+
bounds = rectUnion( bounds, childBounds );
|
|
176
|
+
stack.push( child );
|
|
177
|
+
}
|
|
171
178
|
}
|
|
172
|
-
bounds = rectUnion( bounds, childBounds );
|
|
173
|
-
stack.push( child );
|
|
174
179
|
}
|
|
175
180
|
}
|
|
176
181
|
}
|