@wordpress/block-editor 12.13.0 → 12.14.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-heading-level-dropdown/index.js +1 -1
- package/build/components/block-heading-level-dropdown/index.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-quick-navigation/index.js +6 -4
- package/build/components/block-quick-navigation/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-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/editable-text/index.js +1 -2
- package/build/components/editable-text/index.js.map +1 -1
- package/build/components/iframe/index.js +4 -3
- package/build/components/iframe/index.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 +70 -0
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
- 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/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/navigable-toolbar/index.js +69 -18
- package/build/components/navigable-toolbar/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 +3 -1
- 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 +1158 -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-paste-handler.js +2 -5
- package/build/components/rich-text/use-paste-handler.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/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-rename-ui.js +7 -5
- package/build/hooks/block-rename-ui.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 +4 -4
- 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/layout.js +90 -86
- 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/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 +16 -13
- package/build/store/selectors.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/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-quick-navigation/index.js +7 -5
- package/build-module/components/block-quick-navigation/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-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/editable-text/index.js +1 -2
- package/build-module/components/editable-text/index.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/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} +2 -2
- 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 +58 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
- 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/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/navigable-toolbar/index.js +69 -17
- package/build-module/components/navigable-toolbar/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 +3 -1
- 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 +1148 -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-paste-handler.js +2 -5
- package/build-module/components/rich-text/use-paste-handler.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/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-rename-ui.js +5 -3
- package/build-module/hooks/block-rename-ui.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 +4 -4
- 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/layout.js +90 -86
- 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/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 +15 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +16 -15
- package/build-style/style.css +16 -15
- package/package.json +31 -31
- package/src/components/block-heading-level-dropdown/index.js +1 -1
- package/src/components/block-list/index.js +4 -18
- package/src/components/block-list-appender/index.js +20 -4
- package/src/components/block-quick-navigation/index.js +11 -5
- 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/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/editable-text/index.js +1 -8
- package/src/components/iframe/index.js +4 -3
- 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} +4 -1
- 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 +175 -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 +96 -0
- package/src/components/inserter/block-patterns-tab/utils.js +76 -0
- 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/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/media-replace-flow/style.scss +2 -2
- package/src/components/navigable-toolbar/index.js +71 -25
- package/src/components/plain-text/README.md +3 -3
- package/src/components/provider/use-block-sync.js +2 -21
- package/src/components/rich-text/README.md +9 -8
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +3 -1
- 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 +1363 -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-paste-handler.js +1 -6
- package/src/components/url-popover/image-url-input-ui.js +1 -0
- 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-rename-ui.js +6 -4
- package/src/hooks/content-lock-ui.js +3 -3
- package/src/hooks/custom-class-name.js +7 -6
- package/src/hooks/custom-fields.js +5 -5
- package/src/hooks/duotone.js +23 -33
- package/src/hooks/layout.js +114 -105
- package/src/hooks/position.js +8 -21
- package/src/hooks/style.js +17 -31
- package/src/hooks/test/align.js +4 -4
- package/src/hooks/utils.js +33 -1
- 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 +13 -19
- 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/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/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/store/utils.js +0 -12
- /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
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
|
|
|
@@ -333,7 +331,7 @@ export function addAttribute( settings ) {
|
|
|
333
331
|
*
|
|
334
332
|
* @return {Function} Wrapped component.
|
|
335
333
|
*/
|
|
336
|
-
export const
|
|
334
|
+
export const withLayoutControls = createHigherOrderComponent(
|
|
337
335
|
( BlockEdit ) => ( props ) => {
|
|
338
336
|
const supportLayout = hasLayoutBlockSupport( props.name );
|
|
339
337
|
|
|
@@ -342,9 +340,55 @@ export const withInspectorControls = createHigherOrderComponent(
|
|
|
342
340
|
<BlockEdit key="edit" { ...props } />,
|
|
343
341
|
];
|
|
344
342
|
},
|
|
345
|
-
'
|
|
343
|
+
'withLayoutControls'
|
|
346
344
|
);
|
|
347
345
|
|
|
346
|
+
function BlockWithLayoutStyles( { block: BlockListBlock, props } ) {
|
|
347
|
+
const { name, attributes } = props;
|
|
348
|
+
const id = useInstanceId( BlockListBlock );
|
|
349
|
+
const { layout } = attributes;
|
|
350
|
+
const { default: defaultBlockLayout } =
|
|
351
|
+
getBlockSupport( name, layoutBlockSupportKey ) || {};
|
|
352
|
+
const usedLayout =
|
|
353
|
+
layout?.inherit || layout?.contentSize || layout?.wideSize
|
|
354
|
+
? { ...layout, type: 'constrained' }
|
|
355
|
+
: layout || defaultBlockLayout || {};
|
|
356
|
+
const layoutClasses = useLayoutClasses( attributes, name );
|
|
357
|
+
|
|
358
|
+
// Higher specificity to override defaults from theme.json.
|
|
359
|
+
const selector = `.wp-container-${ id }.wp-container-${ id }`;
|
|
360
|
+
const [ blockGapSupport ] = useSettings( 'spacing.blockGap' );
|
|
361
|
+
const hasBlockGapSupport = blockGapSupport !== null;
|
|
362
|
+
|
|
363
|
+
// Get CSS string for the current layout type.
|
|
364
|
+
// The CSS and `style` element is only output if it is not empty.
|
|
365
|
+
const fullLayoutType = getLayoutType( usedLayout?.type || 'default' );
|
|
366
|
+
const css = fullLayoutType?.getLayoutStyle?.( {
|
|
367
|
+
blockName: name,
|
|
368
|
+
selector,
|
|
369
|
+
layout: usedLayout,
|
|
370
|
+
style: attributes?.style,
|
|
371
|
+
hasBlockGapSupport,
|
|
372
|
+
} );
|
|
373
|
+
|
|
374
|
+
// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.
|
|
375
|
+
const layoutClassNames = classnames(
|
|
376
|
+
{
|
|
377
|
+
[ `wp-container-${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.
|
|
378
|
+
},
|
|
379
|
+
layoutClasses
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
useStyleOverride( { css } );
|
|
383
|
+
|
|
384
|
+
return (
|
|
385
|
+
<BlockListBlock
|
|
386
|
+
{ ...props }
|
|
387
|
+
__unstableLayoutClassNames={ layoutClassNames }
|
|
388
|
+
/>
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
|
|
348
392
|
/**
|
|
349
393
|
* Override the default block element to add the layout styles.
|
|
350
394
|
*
|
|
@@ -354,76 +398,60 @@ export const withInspectorControls = createHigherOrderComponent(
|
|
|
354
398
|
*/
|
|
355
399
|
export const withLayoutStyles = createHigherOrderComponent(
|
|
356
400
|
( 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.
|
|
401
|
+
const blockSupportsLayout = hasLayoutBlockSupport( props.name );
|
|
402
|
+
const shouldRenderLayoutStyles = useSelect(
|
|
403
|
+
( select ) => {
|
|
404
|
+
// The callback returns early to avoid block editor subscription.
|
|
405
|
+
if ( ! blockSupportsLayout ) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
return ! select( blockEditorStore ).getSettings()
|
|
410
|
+
.disableLayoutStyles;
|
|
401
411
|
},
|
|
402
|
-
|
|
412
|
+
[ blockSupportsLayout ]
|
|
403
413
|
);
|
|
404
414
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
useEffect( () => {
|
|
410
|
-
if ( ! css ) return;
|
|
411
|
-
setStyleOverride( selector, { css } );
|
|
412
|
-
return () => {
|
|
413
|
-
deleteStyleOverride( selector );
|
|
414
|
-
};
|
|
415
|
-
}, [ selector, css, setStyleOverride, deleteStyleOverride ] );
|
|
415
|
+
if ( ! shouldRenderLayoutStyles ) {
|
|
416
|
+
return <BlockListBlock { ...props } />;
|
|
417
|
+
}
|
|
416
418
|
|
|
417
419
|
return (
|
|
418
|
-
<BlockListBlock
|
|
419
|
-
{ ...props }
|
|
420
|
-
__unstableLayoutClassNames={ layoutClassNames }
|
|
421
|
-
/>
|
|
420
|
+
<BlockWithLayoutStyles block={ BlockListBlock } props={ props } />
|
|
422
421
|
);
|
|
423
422
|
},
|
|
424
423
|
'withLayoutStyles'
|
|
425
424
|
);
|
|
426
425
|
|
|
426
|
+
function BlockWithChildLayoutStyles( { block: BlockListBlock, props } ) {
|
|
427
|
+
const layout = props.attributes.style?.layout ?? {};
|
|
428
|
+
const { selfStretch, flexSize } = layout;
|
|
429
|
+
|
|
430
|
+
const id = useInstanceId( BlockListBlock );
|
|
431
|
+
const selector = `.wp-container-content-${ id }`;
|
|
432
|
+
|
|
433
|
+
let css = '';
|
|
434
|
+
if ( selfStretch === 'fixed' && flexSize ) {
|
|
435
|
+
css = `${ selector } {
|
|
436
|
+
flex-basis: ${ flexSize };
|
|
437
|
+
box-sizing: border-box;
|
|
438
|
+
}`;
|
|
439
|
+
} else if ( selfStretch === 'fill' ) {
|
|
440
|
+
css = `${ selector } {
|
|
441
|
+
flex-grow: 1;
|
|
442
|
+
}`;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// Attach a `wp-container-content` id-based classname.
|
|
446
|
+
const className = classnames( props.className, {
|
|
447
|
+
[ `wp-container-content-${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.
|
|
448
|
+
} );
|
|
449
|
+
|
|
450
|
+
useStyleOverride( { css } );
|
|
451
|
+
|
|
452
|
+
return <BlockListBlock { ...props } className={ className } />;
|
|
453
|
+
}
|
|
454
|
+
|
|
427
455
|
/**
|
|
428
456
|
* Override the default block element to add the child layout styles.
|
|
429
457
|
*
|
|
@@ -433,52 +461,33 @@ export const withLayoutStyles = createHigherOrderComponent(
|
|
|
433
461
|
*/
|
|
434
462
|
export const withChildLayoutStyles = createHigherOrderComponent(
|
|
435
463
|
( BlockListBlock ) => ( props ) => {
|
|
436
|
-
const
|
|
437
|
-
const { style: { layout = {} } = {} } = attributes;
|
|
464
|
+
const layout = props.attributes.style?.layout ?? {};
|
|
438
465
|
const { selfStretch, flexSize } = layout;
|
|
439
466
|
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
467
|
|
|
447
|
-
const
|
|
448
|
-
|
|
468
|
+
const shouldRenderChildLayoutStyles = useSelect(
|
|
469
|
+
( select ) => {
|
|
470
|
+
// The callback returns early to avoid block editor subscription.
|
|
471
|
+
if ( ! hasChildLayout ) {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
449
474
|
|
|
450
|
-
|
|
475
|
+
return ! select( blockEditorStore ).getSettings()
|
|
476
|
+
.disableLayoutStyles;
|
|
477
|
+
},
|
|
478
|
+
[ hasChildLayout ]
|
|
479
|
+
);
|
|
451
480
|
|
|
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
|
-
}`;
|
|
481
|
+
if ( ! shouldRenderChildLayoutStyles ) {
|
|
482
|
+
return <BlockListBlock { ...props } />;
|
|
461
483
|
}
|
|
462
484
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
const { setStyleOverride, deleteStyleOverride } = unlock(
|
|
470
|
-
useDispatch( blockEditorStore )
|
|
485
|
+
return (
|
|
486
|
+
<BlockWithChildLayoutStyles
|
|
487
|
+
block={ BlockListBlock }
|
|
488
|
+
props={ props }
|
|
489
|
+
/>
|
|
471
490
|
);
|
|
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
491
|
},
|
|
483
492
|
'withChildLayoutStyles'
|
|
484
493
|
);
|
|
@@ -501,5 +510,5 @@ addFilter(
|
|
|
501
510
|
addFilter(
|
|
502
511
|
'editor.BlockEdit',
|
|
503
512
|
'core/editor/layout/with-inspector-controls',
|
|
504
|
-
|
|
513
|
+
withLayoutControls
|
|
505
514
|
);
|
package/src/hooks/position.js
CHANGED
|
@@ -14,22 +14,16 @@ import {
|
|
|
14
14
|
} from '@wordpress/components';
|
|
15
15
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
16
16
|
import { useSelect } from '@wordpress/data';
|
|
17
|
-
import {
|
|
18
|
-
useContext,
|
|
19
|
-
useMemo,
|
|
20
|
-
createPortal,
|
|
21
|
-
Platform,
|
|
22
|
-
} from '@wordpress/element';
|
|
17
|
+
import { useMemo, Platform } from '@wordpress/element';
|
|
23
18
|
import { addFilter } from '@wordpress/hooks';
|
|
24
19
|
|
|
25
20
|
/**
|
|
26
21
|
* Internal dependencies
|
|
27
22
|
*/
|
|
28
|
-
import BlockList from '../components/block-list';
|
|
29
23
|
import { useSettings } from '../components/use-settings';
|
|
30
24
|
import InspectorControls from '../components/inspector-controls';
|
|
31
25
|
import useBlockDisplayInformation from '../components/use-block-display-information';
|
|
32
|
-
import { cleanEmptyObject } from './utils';
|
|
26
|
+
import { cleanEmptyObject, useStyleOverride } from './utils';
|
|
33
27
|
import { unlock } from '../lock-unlock';
|
|
34
28
|
import { store as blockEditorStore } from '../store';
|
|
35
29
|
|
|
@@ -329,7 +323,7 @@ export function PositionPanel( props ) {
|
|
|
329
323
|
*
|
|
330
324
|
* @return {Function} Wrapped component.
|
|
331
325
|
*/
|
|
332
|
-
export const
|
|
326
|
+
export const withPositionControls = createHigherOrderComponent(
|
|
333
327
|
( BlockEdit ) => ( props ) => {
|
|
334
328
|
const { name: blockName } = props;
|
|
335
329
|
const positionSupport = hasBlockSupport(
|
|
@@ -346,7 +340,7 @@ export const withInspectorControls = createHigherOrderComponent(
|
|
|
346
340
|
<BlockEdit key="edit" { ...props } />,
|
|
347
341
|
];
|
|
348
342
|
},
|
|
349
|
-
'
|
|
343
|
+
'withPositionControls'
|
|
350
344
|
);
|
|
351
345
|
|
|
352
346
|
/**
|
|
@@ -368,7 +362,6 @@ export const withPositionStyles = createHigherOrderComponent(
|
|
|
368
362
|
hasPositionBlockSupport && ! isPositionDisabled;
|
|
369
363
|
|
|
370
364
|
const id = useInstanceId( BlockListBlock );
|
|
371
|
-
const element = useContext( BlockList.__unstableElementContext );
|
|
372
365
|
|
|
373
366
|
// Higher specificity to override defaults in editor UI.
|
|
374
367
|
const positionSelector = `.wp-container-${ id }.wp-container-${ id }`;
|
|
@@ -392,15 +385,9 @@ export const withPositionStyles = createHigherOrderComponent(
|
|
|
392
385
|
!! attributes?.style?.position?.type,
|
|
393
386
|
} );
|
|
394
387
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
element &&
|
|
399
|
-
!! css &&
|
|
400
|
-
createPortal( <style>{ css }</style>, element ) }
|
|
401
|
-
<BlockListBlock { ...props } className={ className } />
|
|
402
|
-
</>
|
|
403
|
-
);
|
|
388
|
+
useStyleOverride( { css } );
|
|
389
|
+
|
|
390
|
+
return <BlockListBlock { ...props } className={ className } />;
|
|
404
391
|
},
|
|
405
392
|
'withPositionStyles'
|
|
406
393
|
);
|
|
@@ -413,5 +400,5 @@ addFilter(
|
|
|
413
400
|
addFilter(
|
|
414
401
|
'editor.BlockEdit',
|
|
415
402
|
'core/editor/position/with-inspector-controls',
|
|
416
|
-
|
|
403
|
+
withPositionControls
|
|
417
404
|
);
|
package/src/hooks/style.js
CHANGED
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { useMemo } from '@wordpress/element';
|
|
10
10
|
import { addFilter } from '@wordpress/hooks';
|
|
11
11
|
import {
|
|
12
12
|
getBlockSupport,
|
|
@@ -19,7 +19,6 @@ import { getCSSRules, compileCSS } from '@wordpress/style-engine';
|
|
|
19
19
|
/**
|
|
20
20
|
* Internal dependencies
|
|
21
21
|
*/
|
|
22
|
-
import BlockList from '../components/block-list';
|
|
23
22
|
import { BACKGROUND_SUPPORT_KEY, BackgroundImagePanel } from './background';
|
|
24
23
|
import { BORDER_SUPPORT_KEY, BorderPanel } from './border';
|
|
25
24
|
import { COLOR_SUPPORT_KEY, ColorEdit } from './color';
|
|
@@ -34,7 +33,7 @@ import {
|
|
|
34
33
|
DimensionsPanel,
|
|
35
34
|
} from './dimensions';
|
|
36
35
|
import useDisplayBlockControls from '../components/use-display-block-controls';
|
|
37
|
-
import { shouldSkipSerialization } from './utils';
|
|
36
|
+
import { shouldSkipSerialization, useStyleOverride } from './utils';
|
|
38
37
|
import { scopeSelector } from '../components/global-styles/utils';
|
|
39
38
|
import { useBlockEditingMode } from '../components/block-editing-mode';
|
|
40
39
|
|
|
@@ -354,7 +353,7 @@ export function addEditProps( settings ) {
|
|
|
354
353
|
*
|
|
355
354
|
* @return {Function} Wrapped component.
|
|
356
355
|
*/
|
|
357
|
-
export const
|
|
356
|
+
export const withBlockStyleControls = createHigherOrderComponent(
|
|
358
357
|
( BlockEdit ) => ( props ) => {
|
|
359
358
|
if ( ! hasStyleSupport( props.name ) ) {
|
|
360
359
|
return <BlockEdit key="edit" { ...props } />;
|
|
@@ -378,7 +377,7 @@ export const withBlockControls = createHigherOrderComponent(
|
|
|
378
377
|
</>
|
|
379
378
|
);
|
|
380
379
|
},
|
|
381
|
-
'
|
|
380
|
+
'withBlockStyleControls'
|
|
382
381
|
);
|
|
383
382
|
|
|
384
383
|
// Defines which element types are supported, including their hover styles or
|
|
@@ -484,33 +483,20 @@ const withElementsStyles = createHigherOrderComponent(
|
|
|
484
483
|
: undefined;
|
|
485
484
|
}, [ baseElementSelector, blockElementStyles, props.name ] );
|
|
486
485
|
|
|
487
|
-
|
|
486
|
+
useStyleOverride( { css: styles } );
|
|
488
487
|
|
|
489
488
|
return (
|
|
490
|
-
|
|
491
|
-
{
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
<BlockListBlock
|
|
503
|
-
{ ...props }
|
|
504
|
-
className={
|
|
505
|
-
props.attributes.style?.elements
|
|
506
|
-
? classnames(
|
|
507
|
-
props.className,
|
|
508
|
-
blockElementsContainerIdentifier
|
|
509
|
-
)
|
|
510
|
-
: props.className
|
|
511
|
-
}
|
|
512
|
-
/>
|
|
513
|
-
</>
|
|
489
|
+
<BlockListBlock
|
|
490
|
+
{ ...props }
|
|
491
|
+
className={
|
|
492
|
+
props.attributes.style?.elements
|
|
493
|
+
? classnames(
|
|
494
|
+
props.className,
|
|
495
|
+
blockElementsContainerIdentifier
|
|
496
|
+
)
|
|
497
|
+
: props.className
|
|
498
|
+
}
|
|
499
|
+
/>
|
|
514
500
|
);
|
|
515
501
|
},
|
|
516
502
|
'withElementsStyles'
|
|
@@ -537,7 +523,7 @@ addFilter(
|
|
|
537
523
|
addFilter(
|
|
538
524
|
'editor.BlockEdit',
|
|
539
525
|
'core/style/with-block-controls',
|
|
540
|
-
|
|
526
|
+
withBlockStyleControls
|
|
541
527
|
);
|
|
542
528
|
|
|
543
529
|
addFilter(
|
package/src/hooks/test/align.js
CHANGED
|
@@ -22,7 +22,7 @@ import BlockEdit from '../../components/block-edit';
|
|
|
22
22
|
import BlockEditorProvider from '../../components/provider';
|
|
23
23
|
import {
|
|
24
24
|
getValidAlignments,
|
|
25
|
-
|
|
25
|
+
withAlignmentControls,
|
|
26
26
|
withDataAlign,
|
|
27
27
|
addAssignedAlign,
|
|
28
28
|
} from '../align';
|
|
@@ -157,7 +157,7 @@ describe( 'align', () => {
|
|
|
157
157
|
} );
|
|
158
158
|
} );
|
|
159
159
|
|
|
160
|
-
describe( '
|
|
160
|
+
describe( 'withAlignControls', () => {
|
|
161
161
|
const componentProps = {
|
|
162
162
|
name: 'core/foo',
|
|
163
163
|
attributes: {},
|
|
@@ -167,7 +167,7 @@ describe( 'align', () => {
|
|
|
167
167
|
it( 'should do nothing if no valid alignments', () => {
|
|
168
168
|
registerBlockType( 'core/foo', blockSettings );
|
|
169
169
|
|
|
170
|
-
const EnhancedComponent =
|
|
170
|
+
const EnhancedComponent = withAlignmentControls(
|
|
171
171
|
( { wrapperProps } ) => <div { ...wrapperProps } />
|
|
172
172
|
);
|
|
173
173
|
|
|
@@ -197,7 +197,7 @@ describe( 'align', () => {
|
|
|
197
197
|
},
|
|
198
198
|
} );
|
|
199
199
|
|
|
200
|
-
const EnhancedComponent =
|
|
200
|
+
const EnhancedComponent = withAlignmentControls(
|
|
201
201
|
( { wrapperProps } ) => <div { ...wrapperProps } />
|
|
202
202
|
);
|
|
203
203
|
|
package/src/hooks/utils.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
5
|
-
import { useMemo } from '@wordpress/element';
|
|
5
|
+
import { useMemo, useEffect, useId } from '@wordpress/element';
|
|
6
|
+
import { useDispatch } from '@wordpress/data';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
@@ -10,6 +11,8 @@ import { useMemo } from '@wordpress/element';
|
|
|
10
11
|
import { useSettings } from '../components';
|
|
11
12
|
import { useSettingsForBlockElement } from '../components/global-styles/hooks';
|
|
12
13
|
import { getValueFromObjectPath, setImmutably } from '../utils/object';
|
|
14
|
+
import { store as blockEditorStore } from '../store';
|
|
15
|
+
import { unlock } from '../lock-unlock';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Removed falsy values from nested object.
|
|
@@ -115,6 +118,35 @@ export function shouldSkipSerialization( blockType, featureSet, feature ) {
|
|
|
115
118
|
return skipSerialization;
|
|
116
119
|
}
|
|
117
120
|
|
|
121
|
+
export function useStyleOverride( { id, css, assets, __unstableType } = {} ) {
|
|
122
|
+
const { setStyleOverride, deleteStyleOverride } = unlock(
|
|
123
|
+
useDispatch( blockEditorStore )
|
|
124
|
+
);
|
|
125
|
+
const fallbackId = useId();
|
|
126
|
+
useEffect( () => {
|
|
127
|
+
// Unmount if there is CSS and assets are empty.
|
|
128
|
+
if ( ! css && ! assets ) return;
|
|
129
|
+
const _id = id || fallbackId;
|
|
130
|
+
setStyleOverride( _id, {
|
|
131
|
+
id,
|
|
132
|
+
css,
|
|
133
|
+
assets,
|
|
134
|
+
__unstableType,
|
|
135
|
+
} );
|
|
136
|
+
return () => {
|
|
137
|
+
deleteStyleOverride( _id );
|
|
138
|
+
};
|
|
139
|
+
}, [
|
|
140
|
+
id,
|
|
141
|
+
css,
|
|
142
|
+
assets,
|
|
143
|
+
__unstableType,
|
|
144
|
+
fallbackId,
|
|
145
|
+
setStyleOverride,
|
|
146
|
+
deleteStyleOverride,
|
|
147
|
+
] );
|
|
148
|
+
}
|
|
149
|
+
|
|
118
150
|
/**
|
|
119
151
|
* Based on the block and its context, returns an object of all the block settings.
|
|
120
152
|
* This object can be passed as a prop to all the Styles UI components
|
package/src/private-apis.js
CHANGED
|
@@ -10,8 +10,9 @@ import ResizableBoxPopover from './components/resizable-box-popover';
|
|
|
10
10
|
import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
|
|
11
11
|
import { PrivateListView } from './components/list-view';
|
|
12
12
|
import BlockInfo from './components/block-info-slot-fill';
|
|
13
|
+
import BlockContextualToolbar from './components/block-tools/block-contextual-toolbar';
|
|
13
14
|
import { useShouldContextualToolbarShow } from './utils/use-should-contextual-toolbar-show';
|
|
14
|
-
import { cleanEmptyObject } from './hooks/utils';
|
|
15
|
+
import { cleanEmptyObject, useStyleOverride } from './hooks/utils';
|
|
15
16
|
import BlockQuickNavigation from './components/block-quick-navigation';
|
|
16
17
|
import { LayoutStyle } from './components/block-list/layout';
|
|
17
18
|
import { BlockRemovalWarningModal } from './components/block-removal-warning-modal';
|
|
@@ -41,8 +42,10 @@ lock( privateApis, {
|
|
|
41
42
|
PrivateListView,
|
|
42
43
|
ResizableBoxPopover,
|
|
43
44
|
BlockInfo,
|
|
45
|
+
BlockContextualToolbar,
|
|
44
46
|
useShouldContextualToolbarShow,
|
|
45
47
|
cleanEmptyObject,
|
|
48
|
+
useStyleOverride,
|
|
46
49
|
BlockQuickNavigation,
|
|
47
50
|
LayoutStyle,
|
|
48
51
|
BlockRemovalWarningModal,
|