@wordpress/block-editor 12.13.0 → 12.15.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 +4 -0
- package/README.md +1 -1
- package/build/components/block-heading-level-dropdown/index.js +1 -1
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -0
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +2 -9
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +16 -3
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-parent-selector/index.js +1 -1
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +25 -16
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +4 -2
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-list/index.js +36 -19
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +6 -4
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-rename/index.js +28 -0
- package/build/components/block-rename/index.js.map +1 -0
- package/build/components/block-rename/is-empty-string.js +10 -0
- package/build/components/block-rename/is-empty-string.js.map +1 -0
- package/build/components/block-rename/modal.js +87 -0
- package/build/components/block-rename/modal.js.map +1 -0
- package/build/components/block-rename/rename-control.js +74 -0
- package/build/components/block-rename/rename-control.js.map +1 -0
- package/build/components/block-rename/use-block-rename.js +17 -0
- package/build/components/block-rename/use-block-rename.js.map +1 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js +33 -20
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +7 -0
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +0 -8
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +18 -14
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +11 -81
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/empty-block-inserter.js +56 -0
- package/build/components/block-tools/empty-block-inserter.js.map +1 -0
- package/build/components/block-tools/index.js +48 -9
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/selected-block-tools.js +113 -0
- package/build/components/block-tools/selected-block-tools.js.map +1 -0
- package/build/components/block-tools/use-selected-block-tool-props.js +56 -0
- package/build/components/block-tools/use-selected-block-tool-props.js.map +1 -0
- package/build/components/block-types-list/index.js +6 -2
- package/build/components/block-types-list/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +8 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/editable-text/index.js +1 -2
- package/build/components/editable-text/index.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +1 -1
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- package/build/components/iframe/index.js +4 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-size-control/index.js +0 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +3 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/warning-max-depth-exceeded.native.js +29 -31
- package/build/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/{explorer.js → index.js} +7 -7
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -4
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/index.js +75 -0
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +108 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
- package/build/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +18 -34
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +55 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/utils.js +69 -0
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
- package/build/components/inserter/hooks/use-patterns-state.js +2 -1
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +9 -5
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +15 -12
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.js +3 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter-listbox/index.js +11 -6
- package/build/components/inserter-listbox/index.js.map +1 -1
- package/build/components/inserter-listbox/item.js +24 -23
- package/build/components/inserter-listbox/item.js.map +1 -1
- package/build/components/inserter-listbox/row.js +5 -5
- package/build/components/inserter-listbox/row.js.map +1 -1
- package/build/components/link-control/index.js +6 -5
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +39 -0
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +16 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/index.js +3 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-expand-selected-item.js +2 -3
- package/build/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +69 -18
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/preview-options/index.js +4 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +1 -14
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/index.js +0 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +4 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/format-edit.js +45 -0
- package/build/components/rich-text/native/format-edit.js.map +1 -0
- package/build/components/rich-text/native/get-format-colors.native.js +41 -0
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -0
- package/build/components/rich-text/native/index.js +9 -0
- package/build/components/rich-text/native/index.js.map +1 -0
- package/build/components/rich-text/native/index.native.js +1189 -0
- package/build/components/rich-text/native/index.native.js.map +1 -0
- package/build/components/rich-text/native/toolbar-button-with-options.native.js +58 -0
- package/build/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
- package/build/components/rich-text/native/use-format-types.js +111 -0
- package/build/components/rich-text/native/use-format-types.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +30 -1
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +2 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +4 -1
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +2 -1
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-settings/index.js +2 -2
- package/build/components/use-settings/index.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +7 -3
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +10 -10
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +2 -2
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +7 -6
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +16 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +7 -8
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-renaming.js +42 -0
- package/build/hooks/block-renaming.js.map +1 -1
- package/build/hooks/content-lock-ui.js +5 -5
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +8 -7
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-fields.js +57 -52
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/duotone.js +9 -20
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +103 -93
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +10 -9
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +10 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +30 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +4 -3
- package/build/layouts/constrained.js.map +1 -1
- package/build/private-apis.js +3 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +30 -37
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +18 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +18 -13
- package/build/store/selectors.js.map +1 -1
- package/build/utils/transform-styles/index.js +26 -6
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -0
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +3 -10
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +16 -3
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +1 -1
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +24 -15
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +4 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +36 -19
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +7 -5
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-rename/index.js +4 -0
- package/build-module/components/block-rename/index.js.map +1 -0
- package/build-module/components/block-rename/is-empty-string.js +4 -0
- package/build-module/components/block-rename/is-empty-string.js.map +1 -0
- package/build-module/components/block-rename/modal.js +79 -0
- package/build-module/components/block-rename/modal.js.map +1 -0
- package/build-module/components/block-rename/rename-control.js +66 -0
- package/build-module/components/block-rename/rename-control.js.map +1 -0
- package/build-module/components/block-rename/use-block-rename.js +10 -0
- package/build-module/components/block-rename/use-block-rename.js.map +1 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +34 -21
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +7 -0
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +0 -8
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +17 -13
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +11 -80
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/empty-block-inserter.js +48 -0
- package/build-module/components/block-tools/empty-block-inserter.js.map +1 -0
- package/build-module/components/block-tools/index.js +48 -9
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-tools.js +105 -0
- package/build-module/components/block-tools/selected-block-tools.js.map +1 -0
- package/build-module/components/block-tools/use-selected-block-tool-props.js +50 -0
- package/build-module/components/block-tools/use-selected-block-tool-props.js.map +1 -0
- package/build-module/components/block-types-list/index.js +6 -2
- package/build-module/components/block-types-list/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +8 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/editable-text/index.js +1 -2
- package/build-module/components/editable-text/index.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +1 -1
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-size-control/index.js +0 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +3 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js +30 -32
- package/build-module/components/inner-blocks/warning-max-depth-exceeded.native.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/{explorer.js → index.js} +5 -5
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +3 -3
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/index.js +66 -0
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +42 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +100 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
- package/build-module/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +7 -20
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +47 -0
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js +57 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
- package/build-module/components/inserter/hooks/use-patterns-state.js +2 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +9 -5
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +15 -12
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.js +4 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter-listbox/index.js +13 -8
- package/build-module/components/inserter-listbox/index.js.map +1 -1
- package/build-module/components/inserter-listbox/item.js +25 -23
- package/build-module/components/inserter-listbox/item.js.map +1 -1
- package/build-module/components/inserter-listbox/row.js +6 -5
- package/build-module/components/inserter-listbox/row.js.map +1 -1
- package/build-module/components/link-control/index.js +7 -6
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +39 -0
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/index.js +3 -2
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-expand-selected-item.js +2 -3
- package/build-module/components/list-view/use-list-view-expand-selected-item.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +69 -17
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/preview-options/index.js +4 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +1 -14
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +4 -2
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/format-edit.js +38 -0
- package/build-module/components/rich-text/native/format-edit.js.map +1 -0
- package/build-module/components/rich-text/native/get-format-colors.native.js +34 -0
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -0
- package/build-module/components/rich-text/native/index.js +2 -0
- package/build-module/components/rich-text/native/index.js.map +1 -0
- package/build-module/components/rich-text/native/index.native.js +1179 -0
- package/build-module/components/rich-text/native/index.native.js.map +1 -0
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +51 -0
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
- package/build-module/components/rich-text/native/use-format-types.js +104 -0
- package/build-module/components/rich-text/native/use-format-types.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +31 -2
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +2 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +2 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +4 -1
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +2 -1
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +2 -2
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +7 -3
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +8 -8
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +2 -2
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +5 -4
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +17 -5
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +5 -6
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-renaming.js +40 -0
- package/build-module/hooks/block-renaming.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +3 -3
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +6 -5
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-fields.js +57 -52
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/duotone.js +10 -21
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +0 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +103 -93
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +11 -10
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +10 -13
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +30 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +4 -3
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/private-apis.js +4 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +29 -37
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +17 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +17 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +24 -7
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +6 -6
- package/build-style/content.css +6 -6
- package/build-style/style-rtl.css +26 -20
- package/build-style/style.css +26 -20
- package/package.json +31 -31
- package/src/components/block-heading-level-dropdown/index.js +1 -1
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-list/index.js +4 -18
- package/src/components/block-list-appender/index.js +20 -4
- package/src/components/block-parent-selector/index.js +1 -1
- package/src/components/block-pattern-setup/index.js +38 -22
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -0
- package/src/components/block-pattern-setup/style.scss +4 -1
- package/src/components/block-patterns-list/README.md +4 -4
- package/src/components/block-patterns-list/index.js +60 -34
- package/src/components/block-patterns-list/style.scss +7 -0
- package/src/components/block-quick-navigation/index.js +11 -5
- package/src/components/block-rename/index.js +3 -0
- package/src/components/block-rename/is-empty-string.js +3 -0
- package/src/components/block-rename/modal.js +115 -0
- package/src/components/block-rename/rename-control.js +80 -0
- package/src/components/block-rename/use-block-rename.js +10 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +38 -34
- package/src/components/block-settings-menu-controls/index.js +9 -0
- package/src/components/block-styles/index.js +0 -10
- package/src/components/block-switcher/pattern-transformations-menu.js +20 -14
- package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -4
- package/src/components/block-toolbar/style.scss +8 -0
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-contextual-toolbar.js +11 -134
- package/src/components/block-tools/empty-block-inserter.js +56 -0
- package/src/components/block-tools/index.js +72 -16
- package/src/components/block-tools/selected-block-tools.js +127 -0
- package/src/components/block-tools/style.scss +0 -10
- package/src/components/block-tools/use-selected-block-tool-props.js +66 -0
- package/src/components/block-types-list/index.js +5 -4
- package/src/components/button-block-appender/content.scss +2 -2
- package/src/components/date-format-picker/index.js +7 -0
- package/src/components/editable-text/README.md +0 -36
- package/src/components/editable-text/index.js +1 -8
- package/src/components/global-styles/advanced-panel.js +1 -1
- package/src/components/iframe/index.js +4 -3
- package/src/components/image-size-control/index.js +0 -6
- package/src/components/inner-blocks/index.js +6 -2
- package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +57 -33
- package/src/components/inserter/block-patterns-explorer/{explorer.js → index.js} +4 -4
- package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +9 -2
- package/src/components/inserter/block-patterns-tab/index.js +118 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +179 -0
- package/src/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +15 -21
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +101 -0
- package/src/components/inserter/block-patterns-tab/utils.js +78 -0
- package/src/components/inserter/hooks/use-patterns-state.js +3 -1
- package/src/components/inserter/media-tab/media-list.js +7 -7
- package/src/components/inserter/media-tab/media-preview.js +27 -22
- package/src/components/inserter/menu.js +4 -5
- package/src/components/inserter-listbox/index.js +11 -7
- package/src/components/inserter-listbox/item.js +11 -12
- package/src/components/inserter-listbox/row.js +6 -12
- package/src/components/link-control/README.md +2 -2
- package/src/components/link-control/index.js +15 -6
- package/src/components/link-control/style.scss +8 -5
- package/src/components/list-view/block-select-button.js +44 -1
- package/src/components/list-view/block.js +11 -11
- package/src/components/list-view/index.js +2 -0
- package/src/components/list-view/use-list-view-expand-selected-item.js +7 -8
- package/src/components/media-replace-flow/style.scss +2 -2
- package/src/components/navigable-toolbar/index.js +71 -25
- package/src/components/plain-text/README.md +2 -30
- package/src/components/preview-options/index.js +2 -0
- package/src/components/provider/use-block-sync.js +2 -21
- package/src/components/rich-text/README.md +6 -63
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +4 -2
- package/src/components/rich-text/native/format-edit.js +44 -0
- package/src/components/rich-text/native/get-format-colors.native.js +54 -0
- package/src/components/rich-text/native/index.js +1 -0
- package/src/components/rich-text/native/index.native.js +1406 -0
- package/src/components/rich-text/native/style.native.scss +28 -0
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +79 -0
- package/src/components/rich-text/native/test/index.native.js +278 -0
- package/src/components/rich-text/native/test/performance/rich-text.native.js +44 -0
- package/src/components/rich-text/native/toolbar-button-with-options.native.js +61 -0
- package/src/components/rich-text/native/use-format-types.js +146 -0
- package/src/components/rich-text/use-input-rules.js +30 -2
- package/src/components/rich-text/use-paste-handler.js +1 -6
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/src/components/url-input/README.md +1 -74
- package/src/components/url-popover/image-url-input-ui.js +1 -0
- package/src/components/use-block-drop-zone/index.js +4 -1
- package/src/components/use-moving-animation/index.js +1 -1
- package/src/components/use-settings/index.js +2 -2
- package/src/components/use-settings/test/index.js +1 -1
- package/src/components/writing-flow/use-tab-nav.js +8 -3
- package/src/hooks/align.js +8 -8
- package/src/hooks/align.native.js +2 -2
- package/src/hooks/anchor.js +21 -23
- package/src/hooks/background.js +28 -6
- package/src/hooks/block-hooks.js +20 -16
- package/src/hooks/block-renaming.js +47 -0
- package/src/hooks/content-lock-ui.js +3 -3
- package/src/hooks/custom-class-name.js +7 -6
- package/src/hooks/custom-fields.js +73 -70
- package/src/hooks/duotone.js +23 -33
- package/src/hooks/index.js +0 -1
- package/src/hooks/layout.js +126 -113
- package/src/hooks/position.js +8 -21
- package/src/hooks/style.js +17 -31
- package/src/hooks/test/__snapshots__/align.native.js.snap +5 -5
- package/src/hooks/test/align.js +4 -4
- package/src/hooks/utils.js +33 -1
- package/src/layouts/constrained.js +57 -50
- package/src/private-apis.js +4 -1
- package/src/store/actions.js +26 -72
- package/src/store/reducer.js +19 -0
- package/src/store/selectors.js +15 -19
- package/src/style.scss +1 -1
- package/src/utils/test/transform-styles.js +49 -0
- package/src/utils/transform-styles/index.js +39 -13
- package/build/components/block-tools/selected-block-popover.js +0 -221
- package/build/components/block-tools/selected-block-popover.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
- package/build/components/inserter/block-patterns-filter.js.map +0 -1
- package/build/components/inserter/block-patterns-tab.js +0 -270
- package/build/components/inserter/block-patterns-tab.js.map +0 -1
- package/build/hooks/block-rename-ui.js +0 -165
- package/build/hooks/block-rename-ui.js.map +0 -1
- package/build/store/utils.js +0 -22
- package/build/store/utils.js.map +0 -1
- package/build-module/components/block-tools/selected-block-popover.js +0 -213
- package/build-module/components/block-tools/selected-block-popover.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
- package/build-module/components/inserter/block-patterns-filter.js.map +0 -1
- package/build-module/components/inserter/block-patterns-tab.js +0 -254
- package/build-module/components/inserter/block-patterns-tab.js.map +0 -1
- package/build-module/hooks/block-rename-ui.js +0 -157
- package/build-module/hooks/block-rename-ui.js.map +0 -1
- package/build-module/store/utils.js +0 -16
- package/build-module/store/utils.js.map +0 -1
- package/src/components/block-tools/selected-block-popover.js +0 -265
- package/src/components/inserter/block-patterns-tab.js +0 -448
- package/src/hooks/block-rename-ui.js +0 -226
- package/src/store/utils.js +0 -12
- /package/src/{hooks/block-rename-ui.scss → components/block-rename/style.scss} +0 -0
- /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
|
@@ -34,6 +34,65 @@ function addAttribute( settings ) {
|
|
|
34
34
|
return settings;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
function CustomFieldsControl( props ) {
|
|
38
|
+
const blockEditingMode = useBlockEditingMode();
|
|
39
|
+
if ( blockEditingMode !== 'default' ) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// If the block is a paragraph or image block, we need to know which
|
|
44
|
+
// attribute to use for the connection. Only the `content` attribute
|
|
45
|
+
// of the paragraph block and the `url` attribute of the image block are supported.
|
|
46
|
+
let attributeName;
|
|
47
|
+
if ( props.name === 'core/paragraph' ) attributeName = 'content';
|
|
48
|
+
if ( props.name === 'core/image' ) attributeName = 'url';
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<InspectorControls>
|
|
52
|
+
<PanelBody title={ __( 'Connections' ) } initialOpen={ true }>
|
|
53
|
+
<TextControl
|
|
54
|
+
__nextHasNoMarginBottom
|
|
55
|
+
autoComplete="off"
|
|
56
|
+
label={ __( 'Custom field meta_key' ) }
|
|
57
|
+
value={
|
|
58
|
+
props.attributes?.connections?.attributes?.[
|
|
59
|
+
attributeName
|
|
60
|
+
]?.value || ''
|
|
61
|
+
}
|
|
62
|
+
onChange={ ( nextValue ) => {
|
|
63
|
+
if ( nextValue === '' ) {
|
|
64
|
+
props.setAttributes( {
|
|
65
|
+
connections: undefined,
|
|
66
|
+
[ attributeName ]: undefined,
|
|
67
|
+
placeholder: undefined,
|
|
68
|
+
} );
|
|
69
|
+
} else {
|
|
70
|
+
props.setAttributes( {
|
|
71
|
+
connections: {
|
|
72
|
+
attributes: {
|
|
73
|
+
// The attributeName will be either `content` or `url`.
|
|
74
|
+
[ attributeName ]: {
|
|
75
|
+
// Source will be variable, could be post_meta, user_meta, term_meta, etc.
|
|
76
|
+
// Could even be a custom source like a social media attribute.
|
|
77
|
+
source: 'meta_fields',
|
|
78
|
+
value: nextValue,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
[ attributeName ]: undefined,
|
|
83
|
+
placeholder: sprintf(
|
|
84
|
+
'This content will be replaced on the frontend by the value of "%s" custom field.',
|
|
85
|
+
nextValue
|
|
86
|
+
),
|
|
87
|
+
} );
|
|
88
|
+
}
|
|
89
|
+
} }
|
|
90
|
+
/>
|
|
91
|
+
</PanelBody>
|
|
92
|
+
</InspectorControls>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
37
96
|
/**
|
|
38
97
|
* Override the default edit UI to include a new block inspector control for
|
|
39
98
|
* assigning a connection to blocks that has support for connections.
|
|
@@ -44,9 +103,8 @@ function addAttribute( settings ) {
|
|
|
44
103
|
*
|
|
45
104
|
* @return {Component} Wrapped component.
|
|
46
105
|
*/
|
|
47
|
-
const
|
|
106
|
+
const withCustomFieldsControls = createHigherOrderComponent( ( BlockEdit ) => {
|
|
48
107
|
return ( props ) => {
|
|
49
|
-
const blockEditingMode = useBlockEditingMode();
|
|
50
108
|
const hasCustomFieldsSupport = hasBlockSupport(
|
|
51
109
|
props.name,
|
|
52
110
|
'__experimentalConnections',
|
|
@@ -56,84 +114,29 @@ const withInspectorControl = createHigherOrderComponent( ( BlockEdit ) => {
|
|
|
56
114
|
// Check if the current block is a paragraph or image block.
|
|
57
115
|
// Currently, only these two blocks are supported.
|
|
58
116
|
if ( ! [ 'core/paragraph', 'core/image' ].includes( props.name ) ) {
|
|
59
|
-
return <BlockEdit { ...props } />;
|
|
117
|
+
return <BlockEdit key="edit" { ...props } />;
|
|
60
118
|
}
|
|
61
119
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<>
|
|
72
|
-
<BlockEdit { ...props } />
|
|
73
|
-
{ blockEditingMode === 'default' && (
|
|
74
|
-
<InspectorControls>
|
|
75
|
-
<PanelBody
|
|
76
|
-
title={ __( 'Connections' ) }
|
|
77
|
-
initialOpen={ true }
|
|
78
|
-
>
|
|
79
|
-
<TextControl
|
|
80
|
-
__nextHasNoMarginBottom
|
|
81
|
-
autoComplete="off"
|
|
82
|
-
label={ __( 'Custom field meta_key' ) }
|
|
83
|
-
value={
|
|
84
|
-
props.attributes?.connections
|
|
85
|
-
?.attributes?.[ attributeName ]
|
|
86
|
-
?.value || ''
|
|
87
|
-
}
|
|
88
|
-
onChange={ ( nextValue ) => {
|
|
89
|
-
if ( nextValue === '' ) {
|
|
90
|
-
props.setAttributes( {
|
|
91
|
-
connections: undefined,
|
|
92
|
-
[ attributeName ]: undefined,
|
|
93
|
-
placeholder: undefined,
|
|
94
|
-
} );
|
|
95
|
-
} else {
|
|
96
|
-
props.setAttributes( {
|
|
97
|
-
connections: {
|
|
98
|
-
attributes: {
|
|
99
|
-
// The attributeName will be either `content` or `url`.
|
|
100
|
-
[ attributeName ]: {
|
|
101
|
-
// Source will be variable, could be post_meta, user_meta, term_meta, etc.
|
|
102
|
-
// Could even be a custom source like a social media attribute.
|
|
103
|
-
source: 'meta_fields',
|
|
104
|
-
value: nextValue,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
[ attributeName ]: undefined,
|
|
109
|
-
placeholder: sprintf(
|
|
110
|
-
'This content will be replaced on the frontend by the value of "%s" custom field.',
|
|
111
|
-
nextValue
|
|
112
|
-
),
|
|
113
|
-
} );
|
|
114
|
-
}
|
|
115
|
-
} }
|
|
116
|
-
/>
|
|
117
|
-
</PanelBody>
|
|
118
|
-
</InspectorControls>
|
|
119
|
-
) }
|
|
120
|
-
</>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return <BlockEdit { ...props } />;
|
|
120
|
+
return (
|
|
121
|
+
<>
|
|
122
|
+
<BlockEdit key="edit" { ...props } />
|
|
123
|
+
{ hasCustomFieldsSupport && props.isSelected && (
|
|
124
|
+
<CustomFieldsControl { ...props } />
|
|
125
|
+
) }
|
|
126
|
+
</>
|
|
127
|
+
);
|
|
125
128
|
};
|
|
126
|
-
}, '
|
|
129
|
+
}, 'withCustomFieldsControls' );
|
|
127
130
|
|
|
128
131
|
if ( window.__experimentalConnections ) {
|
|
129
132
|
addFilter(
|
|
130
133
|
'blocks.registerBlockType',
|
|
131
|
-
'core/connections/attribute',
|
|
134
|
+
'core/editor/connections/attribute',
|
|
132
135
|
addAttribute
|
|
133
136
|
);
|
|
134
137
|
addFilter(
|
|
135
138
|
'editor.BlockEdit',
|
|
136
|
-
'core/connections/with-inspector-
|
|
137
|
-
|
|
139
|
+
'core/editor/connections/with-inspector-controls',
|
|
140
|
+
withCustomFieldsControls
|
|
138
141
|
);
|
|
139
142
|
}
|
package/src/hooks/duotone.js
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
17
17
|
import { addFilter } from '@wordpress/hooks';
|
|
18
18
|
import { useMemo, useEffect } from '@wordpress/element';
|
|
19
|
-
import { useDispatch } from '@wordpress/data';
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Internal dependencies
|
|
@@ -34,12 +33,10 @@ import {
|
|
|
34
33
|
} from '../components/duotone/utils';
|
|
35
34
|
import { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';
|
|
36
35
|
import { scopeSelector } from '../components/global-styles/utils';
|
|
37
|
-
import { useBlockSettings } from './utils';
|
|
36
|
+
import { useBlockSettings, useStyleOverride } from './utils';
|
|
38
37
|
import { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';
|
|
39
38
|
import { useBlockEditingMode } from '../components/block-editing-mode';
|
|
40
39
|
import { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';
|
|
41
|
-
import { store as blockEditorStore } from '../store';
|
|
42
|
-
import { unlock } from '../lock-unlock';
|
|
43
40
|
|
|
44
41
|
const EMPTY_ARRAY = [];
|
|
45
42
|
|
|
@@ -291,8 +288,27 @@ function DuotoneStyles( {
|
|
|
291
288
|
|
|
292
289
|
const isValidFilter = Array.isArray( colors ) || colors === 'unset';
|
|
293
290
|
|
|
294
|
-
|
|
295
|
-
|
|
291
|
+
useStyleOverride(
|
|
292
|
+
isValidFilter
|
|
293
|
+
? {
|
|
294
|
+
css:
|
|
295
|
+
colors !== 'unset'
|
|
296
|
+
? getDuotoneStylesheet( selector, filterId )
|
|
297
|
+
: getDuotoneUnsetStylesheet( selector ),
|
|
298
|
+
__unstableType: 'presets',
|
|
299
|
+
}
|
|
300
|
+
: undefined
|
|
301
|
+
);
|
|
302
|
+
useStyleOverride(
|
|
303
|
+
isValidFilter
|
|
304
|
+
? {
|
|
305
|
+
assets:
|
|
306
|
+
colors !== 'unset'
|
|
307
|
+
? getDuotoneFilter( filterId, colors )
|
|
308
|
+
: '',
|
|
309
|
+
__unstableType: 'svgs',
|
|
310
|
+
}
|
|
311
|
+
: undefined
|
|
296
312
|
);
|
|
297
313
|
|
|
298
314
|
const blockElement = useBlockElement( clientId );
|
|
@@ -300,19 +316,6 @@ function DuotoneStyles( {
|
|
|
300
316
|
useEffect( () => {
|
|
301
317
|
if ( ! isValidFilter ) return;
|
|
302
318
|
|
|
303
|
-
setStyleOverride( filterId, {
|
|
304
|
-
css:
|
|
305
|
-
colors !== 'unset'
|
|
306
|
-
? getDuotoneStylesheet( selector, filterId )
|
|
307
|
-
: getDuotoneUnsetStylesheet( selector ),
|
|
308
|
-
__unstableType: 'presets',
|
|
309
|
-
} );
|
|
310
|
-
setStyleOverride( `duotone-${ filterId }`, {
|
|
311
|
-
assets:
|
|
312
|
-
colors !== 'unset' ? getDuotoneFilter( filterId, colors ) : '',
|
|
313
|
-
__unstableType: 'svgs',
|
|
314
|
-
} );
|
|
315
|
-
|
|
316
319
|
// Safari does not always update the duotone filter when the duotone colors
|
|
317
320
|
// are changed. When using Safari, force the block element to be repainted by
|
|
318
321
|
// the browser to ensure any changes are reflected visually. This logic matches
|
|
@@ -329,20 +332,7 @@ function DuotoneStyles( {
|
|
|
329
332
|
blockElement.offsetHeight;
|
|
330
333
|
blockElement.style.display = display;
|
|
331
334
|
}
|
|
332
|
-
|
|
333
|
-
return () => {
|
|
334
|
-
deleteStyleOverride( filterId );
|
|
335
|
-
deleteStyleOverride( `duotone-${ filterId }` );
|
|
336
|
-
};
|
|
337
|
-
}, [
|
|
338
|
-
isValidFilter,
|
|
339
|
-
blockElement,
|
|
340
|
-
colors,
|
|
341
|
-
selector,
|
|
342
|
-
filterId,
|
|
343
|
-
setStyleOverride,
|
|
344
|
-
deleteStyleOverride,
|
|
345
|
-
] );
|
|
335
|
+
}, [ isValidFilter, blockElement ] );
|
|
346
336
|
|
|
347
337
|
return null;
|
|
348
338
|
}
|
package/src/hooks/index.js
CHANGED
package/src/hooks/layout.js
CHANGED
|
@@ -9,7 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
10
10
|
import { addFilter } from '@wordpress/hooks';
|
|
11
11
|
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
|
|
12
|
-
import { useSelect
|
|
12
|
+
import { useSelect } from '@wordpress/data';
|
|
13
13
|
import {
|
|
14
14
|
Button,
|
|
15
15
|
ButtonGroup,
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
PanelBody,
|
|
18
18
|
} from '@wordpress/components';
|
|
19
19
|
import { __ } from '@wordpress/i18n';
|
|
20
|
-
import { useEffect } from '@wordpress/element';
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Internal dependencies
|
|
@@ -29,8 +28,7 @@ import { getLayoutType, getLayoutTypes } from '../layouts';
|
|
|
29
28
|
import { useBlockEditingMode } from '../components/block-editing-mode';
|
|
30
29
|
import { LAYOUT_DEFINITIONS } from '../layouts/definitions';
|
|
31
30
|
import { kebabCase } from '../utils/object';
|
|
32
|
-
import { useBlockSettings } from './utils';
|
|
33
|
-
import { unlock } from '../lock-unlock';
|
|
31
|
+
import { useBlockSettings, useStyleOverride } from './utils';
|
|
34
32
|
|
|
35
33
|
const layoutBlockSupportKey = 'layout';
|
|
36
34
|
|
|
@@ -137,10 +135,9 @@ export function useLayoutStyles( blockAttributes = {}, blockName, selector ) {
|
|
|
137
135
|
|
|
138
136
|
function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
139
137
|
const settings = useBlockSettings( blockName );
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
// Block settings come from theme.json under settings.[blockName].
|
|
139
|
+
const { layout: layoutSettings } = settings;
|
|
140
|
+
// Layout comes from block attributes.
|
|
144
141
|
const { layout } = attributes;
|
|
145
142
|
const [ defaultThemeLayout ] = useSettings( 'layout' );
|
|
146
143
|
const { themeSupportsLayout } = useSelect( ( select ) => {
|
|
@@ -155,17 +152,22 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
|
155
152
|
return null;
|
|
156
153
|
}
|
|
157
154
|
|
|
155
|
+
// Layout block support comes from the block's block.json.
|
|
158
156
|
const layoutBlockSupport = getBlockSupport(
|
|
159
157
|
blockName,
|
|
160
158
|
layoutBlockSupportKey,
|
|
161
159
|
{}
|
|
162
160
|
);
|
|
161
|
+
const blockSupportAndThemeSettings = {
|
|
162
|
+
...layoutSettings,
|
|
163
|
+
...layoutBlockSupport,
|
|
164
|
+
};
|
|
163
165
|
const {
|
|
164
166
|
allowSwitching,
|
|
165
|
-
allowEditing =
|
|
167
|
+
allowEditing = true,
|
|
166
168
|
allowInheriting = true,
|
|
167
169
|
default: defaultBlockLayout,
|
|
168
|
-
} =
|
|
170
|
+
} = blockSupportAndThemeSettings;
|
|
169
171
|
|
|
170
172
|
if ( ! allowEditing ) {
|
|
171
173
|
return null;
|
|
@@ -262,14 +264,14 @@ function LayoutPanel( { setAttributes, attributes, name: blockName } ) {
|
|
|
262
264
|
<layoutType.inspectorControls
|
|
263
265
|
layout={ usedLayout }
|
|
264
266
|
onChange={ onChangeLayout }
|
|
265
|
-
layoutBlockSupport={
|
|
267
|
+
layoutBlockSupport={ blockSupportAndThemeSettings }
|
|
266
268
|
/>
|
|
267
269
|
) }
|
|
268
270
|
{ constrainedType && displayControlsForLegacyLayouts && (
|
|
269
271
|
<constrainedType.inspectorControls
|
|
270
272
|
layout={ usedLayout }
|
|
271
273
|
onChange={ onChangeLayout }
|
|
272
|
-
layoutBlockSupport={
|
|
274
|
+
layoutBlockSupport={ blockSupportAndThemeSettings }
|
|
273
275
|
/>
|
|
274
276
|
) }
|
|
275
277
|
</PanelBody>
|
|
@@ -333,7 +335,7 @@ export function addAttribute( settings ) {
|
|
|
333
335
|
*
|
|
334
336
|
* @return {Function} Wrapped component.
|
|
335
337
|
*/
|
|
336
|
-
export const
|
|
338
|
+
export const withLayoutControls = createHigherOrderComponent(
|
|
337
339
|
( BlockEdit ) => ( props ) => {
|
|
338
340
|
const supportLayout = hasLayoutBlockSupport( props.name );
|
|
339
341
|
|
|
@@ -342,9 +344,55 @@ export const withInspectorControls = createHigherOrderComponent(
|
|
|
342
344
|
<BlockEdit key="edit" { ...props } />,
|
|
343
345
|
];
|
|
344
346
|
},
|
|
345
|
-
'
|
|
347
|
+
'withLayoutControls'
|
|
346
348
|
);
|
|
347
349
|
|
|
350
|
+
function BlockWithLayoutStyles( { block: BlockListBlock, props } ) {
|
|
351
|
+
const { name, attributes } = props;
|
|
352
|
+
const id = useInstanceId( BlockListBlock );
|
|
353
|
+
const { layout } = attributes;
|
|
354
|
+
const { default: defaultBlockLayout } =
|
|
355
|
+
getBlockSupport( name, layoutBlockSupportKey ) || {};
|
|
356
|
+
const usedLayout =
|
|
357
|
+
layout?.inherit || layout?.contentSize || layout?.wideSize
|
|
358
|
+
? { ...layout, type: 'constrained' }
|
|
359
|
+
: layout || defaultBlockLayout || {};
|
|
360
|
+
const layoutClasses = useLayoutClasses( attributes, name );
|
|
361
|
+
|
|
362
|
+
// Higher specificity to override defaults from theme.json.
|
|
363
|
+
const selector = `.wp-container-${ id }.wp-container-${ id }`;
|
|
364
|
+
const [ blockGapSupport ] = useSettings( 'spacing.blockGap' );
|
|
365
|
+
const hasBlockGapSupport = blockGapSupport !== null;
|
|
366
|
+
|
|
367
|
+
// Get CSS string for the current layout type.
|
|
368
|
+
// The CSS and `style` element is only output if it is not empty.
|
|
369
|
+
const fullLayoutType = getLayoutType( usedLayout?.type || 'default' );
|
|
370
|
+
const css = fullLayoutType?.getLayoutStyle?.( {
|
|
371
|
+
blockName: name,
|
|
372
|
+
selector,
|
|
373
|
+
layout: usedLayout,
|
|
374
|
+
style: attributes?.style,
|
|
375
|
+
hasBlockGapSupport,
|
|
376
|
+
} );
|
|
377
|
+
|
|
378
|
+
// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.
|
|
379
|
+
const layoutClassNames = classnames(
|
|
380
|
+
{
|
|
381
|
+
[ `wp-container-${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.
|
|
382
|
+
},
|
|
383
|
+
layoutClasses
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
useStyleOverride( { css } );
|
|
387
|
+
|
|
388
|
+
return (
|
|
389
|
+
<BlockListBlock
|
|
390
|
+
{ ...props }
|
|
391
|
+
__unstableLayoutClassNames={ layoutClassNames }
|
|
392
|
+
/>
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
|
|
348
396
|
/**
|
|
349
397
|
* Override the default block element to add the layout styles.
|
|
350
398
|
*
|
|
@@ -354,76 +402,60 @@ export const withInspectorControls = createHigherOrderComponent(
|
|
|
354
402
|
*/
|
|
355
403
|
export const withLayoutStyles = createHigherOrderComponent(
|
|
356
404
|
( BlockListBlock ) => ( props ) => {
|
|
357
|
-
const
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
const { default: defaultBlockLayout } =
|
|
368
|
-
getBlockSupport( name, layoutBlockSupportKey ) || {};
|
|
369
|
-
const usedLayout =
|
|
370
|
-
layout?.inherit || layout?.contentSize || layout?.wideSize
|
|
371
|
-
? { ...layout, type: 'constrained' }
|
|
372
|
-
: layout || defaultBlockLayout || {};
|
|
373
|
-
const layoutClasses = blockSupportsLayout
|
|
374
|
-
? useLayoutClasses( attributes, name )
|
|
375
|
-
: null;
|
|
376
|
-
// Higher specificity to override defaults from theme.json.
|
|
377
|
-
const selector = `.wp-container-${ id }.wp-container-${ id }`;
|
|
378
|
-
const [ blockGapSupport ] = useSettings( 'spacing.blockGap' );
|
|
379
|
-
const hasBlockGapSupport = blockGapSupport !== null;
|
|
380
|
-
|
|
381
|
-
// Get CSS string for the current layout type.
|
|
382
|
-
// The CSS and `style` element is only output if it is not empty.
|
|
383
|
-
let css;
|
|
384
|
-
if ( shouldRenderLayoutStyles ) {
|
|
385
|
-
const fullLayoutType = getLayoutType(
|
|
386
|
-
usedLayout?.type || 'default'
|
|
387
|
-
);
|
|
388
|
-
css = fullLayoutType?.getLayoutStyle?.( {
|
|
389
|
-
blockName: name,
|
|
390
|
-
selector,
|
|
391
|
-
layout: usedLayout,
|
|
392
|
-
style: attributes?.style,
|
|
393
|
-
hasBlockGapSupport,
|
|
394
|
-
} );
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.
|
|
398
|
-
const layoutClassNames = classnames(
|
|
399
|
-
{
|
|
400
|
-
[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.
|
|
405
|
+
const blockSupportsLayout = hasLayoutBlockSupport( props.name );
|
|
406
|
+
const shouldRenderLayoutStyles = useSelect(
|
|
407
|
+
( select ) => {
|
|
408
|
+
// The callback returns early to avoid block editor subscription.
|
|
409
|
+
if ( ! blockSupportsLayout ) {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return ! select( blockEditorStore ).getSettings()
|
|
414
|
+
.disableLayoutStyles;
|
|
401
415
|
},
|
|
402
|
-
|
|
403
|
-
);
|
|
404
|
-
|
|
405
|
-
const { setStyleOverride, deleteStyleOverride } = unlock(
|
|
406
|
-
useDispatch( blockEditorStore )
|
|
416
|
+
[ blockSupportsLayout ]
|
|
407
417
|
);
|
|
408
418
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
return () => {
|
|
413
|
-
deleteStyleOverride( selector );
|
|
414
|
-
};
|
|
415
|
-
}, [ selector, css, setStyleOverride, deleteStyleOverride ] );
|
|
419
|
+
if ( ! shouldRenderLayoutStyles ) {
|
|
420
|
+
return <BlockListBlock { ...props } />;
|
|
421
|
+
}
|
|
416
422
|
|
|
417
423
|
return (
|
|
418
|
-
<BlockListBlock
|
|
419
|
-
{ ...props }
|
|
420
|
-
__unstableLayoutClassNames={ layoutClassNames }
|
|
421
|
-
/>
|
|
424
|
+
<BlockWithLayoutStyles block={ BlockListBlock } props={ props } />
|
|
422
425
|
);
|
|
423
426
|
},
|
|
424
427
|
'withLayoutStyles'
|
|
425
428
|
);
|
|
426
429
|
|
|
430
|
+
function BlockWithChildLayoutStyles( { block: BlockListBlock, props } ) {
|
|
431
|
+
const layout = props.attributes.style?.layout ?? {};
|
|
432
|
+
const { selfStretch, flexSize } = layout;
|
|
433
|
+
|
|
434
|
+
const id = useInstanceId( BlockListBlock );
|
|
435
|
+
const selector = `.wp-container-content-${ id }`;
|
|
436
|
+
|
|
437
|
+
let css = '';
|
|
438
|
+
if ( selfStretch === 'fixed' && flexSize ) {
|
|
439
|
+
css = `${ selector } {
|
|
440
|
+
flex-basis: ${ flexSize };
|
|
441
|
+
box-sizing: border-box;
|
|
442
|
+
}`;
|
|
443
|
+
} else if ( selfStretch === 'fill' ) {
|
|
444
|
+
css = `${ selector } {
|
|
445
|
+
flex-grow: 1;
|
|
446
|
+
}`;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// Attach a `wp-container-content` id-based classname.
|
|
450
|
+
const className = classnames( props.className, {
|
|
451
|
+
[ `wp-container-content-${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.
|
|
452
|
+
} );
|
|
453
|
+
|
|
454
|
+
useStyleOverride( { css } );
|
|
455
|
+
|
|
456
|
+
return <BlockListBlock { ...props } className={ className } />;
|
|
457
|
+
}
|
|
458
|
+
|
|
427
459
|
/**
|
|
428
460
|
* Override the default block element to add the child layout styles.
|
|
429
461
|
*
|
|
@@ -433,52 +465,33 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
433
465
|
*/
|
|
434
466
|
export const withChildLayoutStyles = createHigherOrderComponent(
|
|
435
467
|
( BlockListBlock ) => ( props ) => {
|
|
436
|
-
const
|
|
437
|
-
const { style: { layout = {} } = {} } = attributes;
|
|
468
|
+
const layout = props.attributes.style?.layout ?? {};
|
|
438
469
|
const { selfStretch, flexSize } = layout;
|
|
439
470
|
const hasChildLayout = selfStretch || flexSize;
|
|
440
|
-
const disableLayoutStyles = useSelect( ( select ) => {
|
|
441
|
-
const { getSettings } = select( blockEditorStore );
|
|
442
|
-
return !! getSettings().disableLayoutStyles;
|
|
443
|
-
} );
|
|
444
|
-
const shouldRenderChildLayoutStyles =
|
|
445
|
-
hasChildLayout && ! disableLayoutStyles;
|
|
446
471
|
|
|
447
|
-
const
|
|
448
|
-
|
|
472
|
+
const shouldRenderChildLayoutStyles = useSelect(
|
|
473
|
+
( select ) => {
|
|
474
|
+
// The callback returns early to avoid block editor subscription.
|
|
475
|
+
if ( ! hasChildLayout ) {
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
449
478
|
|
|
450
|
-
|
|
479
|
+
return ! select( blockEditorStore ).getSettings()
|
|
480
|
+
.disableLayoutStyles;
|
|
481
|
+
},
|
|
482
|
+
[ hasChildLayout ]
|
|
483
|
+
);
|
|
451
484
|
|
|
452
|
-
if (
|
|
453
|
-
|
|
454
|
-
flex-basis: ${ flexSize };
|
|
455
|
-
box-sizing: border-box;
|
|
456
|
-
}`;
|
|
457
|
-
} else if ( selfStretch === 'fill' ) {
|
|
458
|
-
css += `${ selector } {
|
|
459
|
-
flex-grow: 1;
|
|
460
|
-
}`;
|
|
485
|
+
if ( ! shouldRenderChildLayoutStyles ) {
|
|
486
|
+
return <BlockListBlock { ...props } />;
|
|
461
487
|
}
|
|
462
488
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
const { setStyleOverride, deleteStyleOverride } = unlock(
|
|
470
|
-
useDispatch( blockEditorStore )
|
|
489
|
+
return (
|
|
490
|
+
<BlockWithChildLayoutStyles
|
|
491
|
+
block={ BlockListBlock }
|
|
492
|
+
props={ props }
|
|
493
|
+
/>
|
|
471
494
|
);
|
|
472
|
-
|
|
473
|
-
useEffect( () => {
|
|
474
|
-
if ( ! css ) return;
|
|
475
|
-
setStyleOverride( selector, { css } );
|
|
476
|
-
return () => {
|
|
477
|
-
deleteStyleOverride( selector );
|
|
478
|
-
};
|
|
479
|
-
}, [ selector, css, setStyleOverride, deleteStyleOverride ] );
|
|
480
|
-
|
|
481
|
-
return <BlockListBlock { ...props } className={ className } />;
|
|
482
495
|
},
|
|
483
496
|
'withChildLayoutStyles'
|
|
484
497
|
);
|
|
@@ -501,5 +514,5 @@ addFilter(
|
|
|
501
514
|
addFilter(
|
|
502
515
|
'editor.BlockEdit',
|
|
503
516
|
'core/editor/layout/with-inspector-controls',
|
|
504
|
-
|
|
517
|
+
withLayoutControls
|
|
505
518
|
);
|