@wordpress/block-editor 13.1.0 → 13.3.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 +21 -17
- package/README.md +1 -2
- package/build/components/block-breadcrumb/index.js +12 -1
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-lock/modal.js +67 -67
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +0 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/button.js +1 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +12 -6
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +5 -7
- package/build/components/block-patterns-paging/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +20 -17
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-rename/modal.js +4 -12
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +4 -1
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +7 -58
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build/components/block-tools/index.js +14 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -2
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-tools/zoom-out-popover.js +57 -0
- package/build/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build/components/block-tools/zoom-out-toolbar.js +138 -0
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build/components/button-block-appender/index.js +3 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +193 -127
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +10 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/dimensions-tool/index.js +6 -4
- package/build/components/dimensions-tool/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +26 -61
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +178 -116
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +2 -1
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -1
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +8 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +50 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +50 -0
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +25 -9
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +17 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/grid/grid-item-movers.js +94 -0
- package/build/components/grid/grid-item-movers.js.map +1 -0
- package/build/components/{grid-visualizer → grid}/grid-item-resizer.js +18 -56
- package/build/components/grid/grid-item-resizer.js.map +1 -0
- package/build/components/grid/grid-visualizer.js +305 -0
- package/build/components/grid/grid-visualizer.js.map +1 -0
- package/build/components/{grid-visualizer → grid}/index.js +14 -0
- package/build/components/grid/index.js.map +1 -0
- package/build/components/grid/use-get-number-of-blocks-before-cell.js +40 -0
- package/build/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
- package/build/components/grid/use-grid-layout-sync.js +169 -0
- package/build/components/grid/use-grid-layout-sync.js.map +1 -0
- package/build/components/grid/utils.js +145 -0
- package/build/components/grid/utils.js.map +1 -0
- package/build/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/inner-blocks/index.js +1 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build/components/inserter/menu.js +26 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +2 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/media-placeholder/index.js +19 -23
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +3 -1
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/rich-text/event-listeners/input-rules.js +1 -0
- package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build/components/rich-text/index.native.js +10 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +14 -0
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +66 -0
- package/build/components/tabbed-sidebar/index.js.map +1 -0
- package/build/components/url-popover/index.js +3 -0
- package/build/components/url-popover/index.js.map +1 -1
- package/build/hooks/background.js +26 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +11 -17
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-style-variation.js +195 -11
- package/build/hooks/block-style-variation.js.map +1 -1
- package/build/hooks/duotone.js +16 -11
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/grid-visualizer.js +65 -0
- package/build/hooks/grid-visualizer.js.map +1 -0
- package/build/hooks/index.js +15 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +65 -40
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/position.js +2 -9
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +16 -6
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +5 -2
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +44 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +92 -76
- package/build/layouts/grid.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +6 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +17 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/defaults.native.js +0 -3
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/utils/format-font-style.js +45 -0
- package/build/utils/format-font-style.js.map +1 -0
- package/build/utils/format-font-weight.js +68 -0
- package/build/utils/format-font-weight.js.map +1 -0
- package/build/utils/get-editor-region.js +34 -0
- package/build/utils/get-editor-region.js.map +1 -0
- package/build/utils/get-font-styles-and-weights.js +167 -0
- package/build/utils/get-font-styles-and-weights.js.map +1 -0
- package/build/utils/pasting.js +5 -13
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +12 -1
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-lock/modal.js +67 -67
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +0 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/button.js +1 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +12 -6
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +5 -7
- package/build-module/components/block-patterns-paging/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +20 -17
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +5 -13
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +4 -1
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +10 -61
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +9 -2
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build-module/components/block-tools/index.js +14 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -2
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-popover.js +48 -0
- package/build-module/components/block-tools/zoom-out-popover.js.map +1 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js +131 -0
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -0
- package/build-module/components/button-block-appender/index.js +3 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +194 -128
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +11 -3
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/dimensions-tool/index.js +6 -4
- package/build-module/components/dimensions-tool/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +28 -63
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +181 -119
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -2
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +3 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +3 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +8 -0
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +3 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +52 -14
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +48 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +25 -9
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +15 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/grid/grid-item-movers.js +87 -0
- package/build-module/components/grid/grid-item-movers.js.map +1 -0
- package/build-module/components/{grid-visualizer → grid}/grid-item-resizer.js +13 -51
- package/build-module/components/grid/grid-item-resizer.js.map +1 -0
- package/build-module/components/grid/grid-visualizer.js +297 -0
- package/build-module/components/grid/grid-visualizer.js.map +1 -0
- package/build-module/components/grid/index.js +5 -0
- package/build-module/components/grid/index.js.map +1 -0
- package/build-module/components/grid/use-get-number-of-blocks-before-cell.js +33 -0
- package/build-module/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
- package/build-module/components/grid/use-grid-layout-sync.js +162 -0
- package/build-module/components/grid/use-grid-layout-sync.js.map +1 -0
- package/build-module/components/grid/utils.js +131 -0
- package/build-module/components/grid/utils.js.map +1 -0
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +1 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -19
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +26 -4
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -2
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +19 -23
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +3 -1
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/input-rules.js +1 -1
- package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +11 -5
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +14 -0
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +5 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +60 -0
- package/build-module/components/tabbed-sidebar/index.js.map +1 -0
- package/build-module/components/url-popover/index.js +3 -0
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/hooks/background.js +26 -4
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +11 -17
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-style-variation.js +193 -11
- package/build-module/hooks/block-style-variation.js.map +1 -1
- package/build-module/hooks/duotone.js +16 -11
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/grid-visualizer.js +64 -0
- package/build-module/hooks/grid-visualizer.js.map +1 -0
- package/build-module/hooks/index.js +3 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +63 -38
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/position.js +2 -9
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +16 -6
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +5 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +44 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +92 -76
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +8 -3
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +17 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/defaults.native.js +0 -3
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/utils/format-font-style.js +39 -0
- package/build-module/utils/format-font-style.js.map +1 -0
- package/build-module/utils/format-font-weight.js +62 -0
- package/build-module/utils/format-font-weight.js.map +1 -0
- package/build-module/utils/get-editor-region.js +28 -0
- package/build-module/utils/get-editor-region.js.map +1 -0
- package/build-module/utils/get-font-styles-and-weights.js +160 -0
- package/build-module/utils/get-font-styles-and-weights.js.map +1 -0
- package/build-module/utils/pasting.js +5 -13
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/content-rtl.css +1 -0
- package/build-style/content.css +1 -0
- package/build-style/style-rtl.css +238 -106
- package/build-style/style.css +238 -106
- package/package.json +32 -32
- package/src/components/block-breadcrumb/index.js +16 -1
- package/src/components/block-lock/modal.js +95 -82
- package/src/components/block-lock/style.scss +11 -1
- package/src/components/block-lock/toolbar.js +0 -1
- package/src/components/block-mover/button.js +1 -1
- package/src/components/block-mover/index.js +37 -24
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -2
- package/src/components/block-patterns-paging/index.js +8 -11
- package/src/components/block-patterns-paging/style.scss +18 -0
- package/src/components/block-quick-navigation/index.js +21 -28
- package/src/components/block-rename/modal.js +2 -8
- package/src/components/block-switcher/test/index.js +6 -6
- package/src/components/block-toolbar/shuffle.js +4 -1
- package/src/components/block-toolbar/style.scss +1 -11
- package/src/components/block-tools/block-selection-button.js +11 -83
- package/src/components/block-tools/block-toolbar-breadcrumb.js +9 -4
- package/src/components/block-tools/index.js +21 -1
- package/src/components/block-tools/style.scss +15 -0
- package/src/components/block-tools/use-show-block-tools.js +14 -6
- package/src/components/block-tools/zoom-out-mode-inserters.js +5 -4
- package/src/components/block-tools/zoom-out-popover.js +49 -0
- package/src/components/block-tools/zoom-out-toolbar.js +140 -0
- package/src/components/button-block-appender/index.js +2 -1
- package/src/components/child-layout-control/index.js +243 -160
- package/src/components/date-format-picker/index.js +10 -1
- package/src/components/date-format-picker/style.scss +0 -9
- package/src/components/dimensions-tool/index.js +97 -89
- package/src/components/font-appearance-control/index.js +29 -83
- package/src/components/font-appearance-control/style.scss +3 -5
- package/src/components/global-styles/background-panel.js +249 -170
- package/src/components/global-styles/border-panel.js +3 -2
- package/src/components/global-styles/color-panel.js +3 -2
- package/src/components/global-styles/dimensions-panel.js +3 -2
- package/src/components/global-styles/filters-panel.js +3 -2
- package/src/components/global-styles/hooks.js +9 -0
- package/src/components/global-styles/image-settings-panel.js +3 -2
- package/src/components/global-styles/style.scss +105 -20
- package/src/components/global-styles/test/typography-utils.js +269 -0
- package/src/components/global-styles/test/use-global-styles-output.js +38 -3
- package/src/components/global-styles/typography-panel.js +49 -12
- package/src/components/global-styles/typography-utils.js +63 -0
- package/src/components/global-styles/use-global-styles-output.js +25 -9
- package/src/components/global-styles/utils.js +17 -6
- package/src/components/grid/grid-item-movers.js +112 -0
- package/src/components/{grid-visualizer → grid}/grid-item-resizer.js +15 -52
- package/src/components/grid/grid-visualizer.js +384 -0
- package/src/components/grid/index.js +4 -0
- package/src/components/grid/style.scss +98 -0
- package/src/components/grid/use-get-number-of-blocks-before-cell.js +30 -0
- package/src/components/grid/use-grid-layout-sync.js +170 -0
- package/src/components/grid/utils.js +178 -0
- package/src/components/iframe/content.scss +1 -0
- package/src/components/image-editor/aspect-ratio-dropdown.js +0 -1
- package/src/components/inner-blocks/index.js +4 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +1 -16
- package/src/components/inserter/menu.js +47 -13
- package/src/components/inserter/quick-inserter.js +6 -1
- package/src/components/inserter/style.scss +1 -49
- package/src/components/inspector-controls/block-support-tools-panel.js +3 -3
- package/src/components/link-control/link-preview.js +1 -1
- package/src/components/media-placeholder/index.js +22 -32
- package/src/components/navigable-toolbar/index.js +3 -1
- package/src/components/rich-text/event-listeners/input-rules.js +1 -1
- package/src/components/rich-text/index.native.js +10 -8
- package/src/components/rich-text/native/index.native.js +17 -0
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +6 -1
- package/src/components/tabbed-sidebar/README.md +76 -0
- package/src/components/tabbed-sidebar/index.js +70 -0
- package/src/components/tabbed-sidebar/style.scss +53 -0
- package/src/components/url-popover/index.js +3 -0
- package/src/hooks/background.js +25 -10
- package/src/hooks/block-hooks.js +9 -16
- package/src/hooks/block-style-variation.js +226 -9
- package/src/hooks/duotone.js +16 -12
- package/src/hooks/grid-visualizer.js +64 -0
- package/src/hooks/index.js +3 -0
- package/src/hooks/layout-child.js +75 -39
- package/src/hooks/position.js +3 -10
- package/src/hooks/test/get-variation-styles-with-ref-values.js +91 -0
- package/src/hooks/use-bindings-attributes.js +18 -4
- package/src/hooks/utils.js +5 -1
- package/src/layouts/constrained.js +43 -2
- package/src/layouts/grid.js +175 -88
- package/src/lock-unlock.js +1 -1
- package/src/private-apis.js +12 -1
- package/src/store/actions.js +21 -1
- package/src/store/defaults.js +0 -2
- package/src/store/defaults.native.js +0 -3
- package/src/store/private-keys.js +1 -0
- package/src/style.scss +2 -2
- package/src/utils/format-font-style.js +40 -0
- package/src/utils/format-font-weight.js +63 -0
- package/src/utils/get-editor-region.js +31 -0
- package/src/utils/get-font-styles-and-weights.js +191 -0
- package/src/utils/pasting.js +5 -12
- package/src/utils/test/format-font-style.js +34 -0
- package/src/utils/test/format-font-weight.js +66 -0
- package/src/utils/test/get-font-styles-and-weights.js +513 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/grid-visualizer/grid-item-resizer.js.map +0 -1
- package/build/components/grid-visualizer/grid-visualizer.js +0 -92
- package/build/components/grid-visualizer/grid-visualizer.js.map +0 -1
- package/build/components/grid-visualizer/index.js.map +0 -1
- package/build/components/grid-visualizer/utils.js +0 -10
- package/build/components/grid-visualizer/utils.js.map +0 -1
- package/build-module/components/grid-visualizer/grid-item-resizer.js.map +0 -1
- package/build-module/components/grid-visualizer/grid-visualizer.js +0 -84
- package/build-module/components/grid-visualizer/grid-visualizer.js.map +0 -1
- package/build-module/components/grid-visualizer/index.js +0 -3
- package/build-module/components/grid-visualizer/index.js.map +0 -1
- package/build-module/components/grid-visualizer/utils.js +0 -4
- package/build-module/components/grid-visualizer/utils.js.map +0 -1
- package/src/components/grid-visualizer/grid-visualizer.js +0 -101
- package/src/components/grid-visualizer/index.js +0 -2
- package/src/components/grid-visualizer/style.scss +0 -34
- package/src/components/grid-visualizer/utils.js +0 -5
- package/src/hooks/position.scss +0 -18
- /package/src/components/font-sizes/{README.MD → README.md} +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Tabbed Panel
|
|
2
|
+
|
|
3
|
+
The `TabbedPanel` component is used to create the secondary panels in the editor.
|
|
4
|
+
|
|
5
|
+
## Development guidelines
|
|
6
|
+
|
|
7
|
+
This acts as a wrapper for the `Tabs` component, but adding conventions that can be shared between all secondary panels, for example:
|
|
8
|
+
|
|
9
|
+
- A close button
|
|
10
|
+
- Tabs that fill the panel
|
|
11
|
+
- Custom scollbars
|
|
12
|
+
|
|
13
|
+
### Usage
|
|
14
|
+
|
|
15
|
+
Renders a block alignment toolbar with alignments options.
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import { TabbedSidebar } from '@wordpress/components';
|
|
19
|
+
|
|
20
|
+
const MyTabbedSidebar = () => (
|
|
21
|
+
<TabbedSidebar
|
|
22
|
+
tabs={ [
|
|
23
|
+
{
|
|
24
|
+
name: 'slug-1',
|
|
25
|
+
title: _x( 'Title 1', 'context' ),
|
|
26
|
+
panel: <PanelContents>,
|
|
27
|
+
panelRef: useRef('an-optional-ref'),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'slug-2',
|
|
31
|
+
title: _x( 'Title 2', 'context' ),
|
|
32
|
+
panel: <PanelContents />,
|
|
33
|
+
},
|
|
34
|
+
] }
|
|
35
|
+
onClose={ onClickCloseButton }
|
|
36
|
+
onSelect={ onSelectTab }
|
|
37
|
+
defaultTabId="slug-1"
|
|
38
|
+
ref={ tabsRef }
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Props
|
|
44
|
+
|
|
45
|
+
### `defaultTabId`
|
|
46
|
+
|
|
47
|
+
- **Type:** `String`
|
|
48
|
+
- **Default:** `undefined`
|
|
49
|
+
|
|
50
|
+
This is passed to the `Tabs` component so it can handle the tab to select by default when it component renders.
|
|
51
|
+
|
|
52
|
+
### `onClose`
|
|
53
|
+
|
|
54
|
+
- **Type:** `Function`
|
|
55
|
+
|
|
56
|
+
The function that is called when the close button is clicked.
|
|
57
|
+
|
|
58
|
+
### `onSelect`
|
|
59
|
+
|
|
60
|
+
- **Type:** `Function`
|
|
61
|
+
|
|
62
|
+
This is passed to the `Tabs` component - it will be called when a tab has been selected. It is passed the selected tab's ID as an argument.
|
|
63
|
+
|
|
64
|
+
### `selectedTab`
|
|
65
|
+
|
|
66
|
+
- **Type:** `String`
|
|
67
|
+
- **Default:** `undefined`
|
|
68
|
+
|
|
69
|
+
This is passed to the `Tabs` component - it will display this tab as selected.
|
|
70
|
+
|
|
71
|
+
### `tabs`
|
|
72
|
+
|
|
73
|
+
- **Type:** `Array`
|
|
74
|
+
- **Default:** `undefined`
|
|
75
|
+
|
|
76
|
+
An array of tabs which will be rendered as `TabList` and `TabPanel` components.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
privateApis as componentsPrivateApis,
|
|
7
|
+
} from '@wordpress/components';
|
|
8
|
+
import { forwardRef } from '@wordpress/element';
|
|
9
|
+
import { closeSmall } from '@wordpress/icons';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { unlock } from '../../lock-unlock';
|
|
15
|
+
|
|
16
|
+
const { Tabs } = unlock( componentsPrivateApis );
|
|
17
|
+
|
|
18
|
+
function TabbedSidebar(
|
|
19
|
+
{ defaultTabId, onClose, onSelect, selectedTab, tabs, closeButtonLabel },
|
|
20
|
+
ref
|
|
21
|
+
) {
|
|
22
|
+
return (
|
|
23
|
+
<div className="block-editor-tabbed-sidebar">
|
|
24
|
+
<Tabs
|
|
25
|
+
selectOnMove={ false }
|
|
26
|
+
defaultTabId={ defaultTabId }
|
|
27
|
+
onSelect={ onSelect }
|
|
28
|
+
selectedTabId={ selectedTab }
|
|
29
|
+
>
|
|
30
|
+
<div className="block-editor-tabbed-sidebar__tablist-and-close-button">
|
|
31
|
+
<Button
|
|
32
|
+
className="block-editor-tabbed-sidebar__close-button"
|
|
33
|
+
icon={ closeSmall }
|
|
34
|
+
label={ closeButtonLabel }
|
|
35
|
+
onClick={ () => onClose() }
|
|
36
|
+
size="small"
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
<Tabs.TabList
|
|
40
|
+
className="block-editor-tabbed-sidebar__tablist"
|
|
41
|
+
ref={ ref }
|
|
42
|
+
>
|
|
43
|
+
{ tabs.map( ( tab ) => (
|
|
44
|
+
<Tabs.Tab
|
|
45
|
+
key={ tab.name }
|
|
46
|
+
tabId={ tab.name }
|
|
47
|
+
className="block-editor-tabbed-sidebar__tab"
|
|
48
|
+
>
|
|
49
|
+
{ tab.title }
|
|
50
|
+
</Tabs.Tab>
|
|
51
|
+
) ) }
|
|
52
|
+
</Tabs.TabList>
|
|
53
|
+
</div>
|
|
54
|
+
{ tabs.map( ( tab ) => (
|
|
55
|
+
<Tabs.TabPanel
|
|
56
|
+
key={ tab.name }
|
|
57
|
+
tabId={ tab.name }
|
|
58
|
+
focusable={ false }
|
|
59
|
+
className="block-editor-tabbed-sidebar__tabpanel"
|
|
60
|
+
ref={ tab.panelRef }
|
|
61
|
+
>
|
|
62
|
+
{ tab.panel }
|
|
63
|
+
</Tabs.TabPanel>
|
|
64
|
+
) ) }
|
|
65
|
+
</Tabs>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default forwardRef( TabbedSidebar );
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.block-editor-tabbed-sidebar {
|
|
2
|
+
height: 100%;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
flex-grow: 1;
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
|
|
8
|
+
@include break-medium() {
|
|
9
|
+
width: 350px;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.block-editor-tabbed-sidebar__tablist-and-close-button {
|
|
14
|
+
border-bottom: $border-width solid $gray-300;
|
|
15
|
+
display: flex;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
padding-right: $grid-unit-15;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
.block-editor-tabbed-sidebar__close-button {
|
|
22
|
+
background: $white;
|
|
23
|
+
/* stylelint-disable-next-line property-disallowed-list -- This should be removed when https://github.com/WordPress/gutenberg/issues/59013 is fixed. */
|
|
24
|
+
order: 1;
|
|
25
|
+
align-self: center;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.block-editor-tabbed-sidebar__tablist {
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
flex-grow: 1;
|
|
31
|
+
margin-bottom: -$border-width;
|
|
32
|
+
width: 100%;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.block-editor-tabbed-sidebar__tab {
|
|
36
|
+
flex-grow: 1;
|
|
37
|
+
margin-bottom: -$border-width;
|
|
38
|
+
|
|
39
|
+
&[id$="reusable"] {
|
|
40
|
+
flex-grow: inherit;
|
|
41
|
+
// These are to align the `reusable` icon with the search icon.
|
|
42
|
+
padding-left: $grid-unit-20;
|
|
43
|
+
padding-right: $grid-unit-20;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.block-editor-tabbed-sidebar__tabpanel {
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-grow: 1;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
overflow-y: auto;
|
|
52
|
+
scrollbar-gutter: auto;
|
|
53
|
+
}
|
package/src/hooks/background.js
CHANGED
|
@@ -16,6 +16,10 @@ import {
|
|
|
16
16
|
useHasBackgroundPanel,
|
|
17
17
|
hasBackgroundImageValue,
|
|
18
18
|
} from '../components/global-styles/background-panel';
|
|
19
|
+
import {
|
|
20
|
+
globalStylesDataKey,
|
|
21
|
+
globalStylesLinksDataKey,
|
|
22
|
+
} from '../store/private-keys';
|
|
19
23
|
|
|
20
24
|
export const BACKGROUND_SUPPORT_KEY = 'background';
|
|
21
25
|
|
|
@@ -134,10 +138,25 @@ export function BackgroundImagePanel( {
|
|
|
134
138
|
setAttributes,
|
|
135
139
|
settings,
|
|
136
140
|
} ) {
|
|
137
|
-
const style = useSelect(
|
|
138
|
-
( select ) =>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
const { style, inheritedValue, _links } = useSelect(
|
|
142
|
+
( select ) => {
|
|
143
|
+
const { getBlockAttributes, getSettings } =
|
|
144
|
+
select( blockEditorStore );
|
|
145
|
+
const _settings = getSettings();
|
|
146
|
+
return {
|
|
147
|
+
style: getBlockAttributes( clientId )?.style,
|
|
148
|
+
_links: _settings[ globalStylesLinksDataKey ],
|
|
149
|
+
/*
|
|
150
|
+
* @TODO 1. Pass inherited value down to all block style controls,
|
|
151
|
+
* See: packages/block-editor/src/hooks/style.js
|
|
152
|
+
* @TODO 2. Add support for block style variations,
|
|
153
|
+
* See implementation: packages/block-editor/src/hooks/block-style-variation.js
|
|
154
|
+
*/
|
|
155
|
+
inheritedValue:
|
|
156
|
+
_settings[ globalStylesDataKey ]?.blocks?.[ name ],
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
[ clientId, name ]
|
|
141
160
|
);
|
|
142
161
|
|
|
143
162
|
if (
|
|
@@ -147,11 +166,6 @@ export function BackgroundImagePanel( {
|
|
|
147
166
|
return null;
|
|
148
167
|
}
|
|
149
168
|
|
|
150
|
-
const defaultControls = getBlockSupport( name, [
|
|
151
|
-
BACKGROUND_SUPPORT_KEY,
|
|
152
|
-
'__experimentalDefaultControls',
|
|
153
|
-
] );
|
|
154
|
-
|
|
155
169
|
const onChange = ( newStyle ) => {
|
|
156
170
|
setAttributes( {
|
|
157
171
|
style: cleanEmptyObject( newStyle ),
|
|
@@ -170,13 +184,14 @@ export function BackgroundImagePanel( {
|
|
|
170
184
|
|
|
171
185
|
return (
|
|
172
186
|
<StylesBackgroundPanel
|
|
187
|
+
inheritedValue={ inheritedValue }
|
|
173
188
|
as={ BackgroundInspectorControl }
|
|
174
189
|
panelId={ clientId }
|
|
175
|
-
defaultControls={ defaultControls }
|
|
176
190
|
defaultValues={ BACKGROUND_DEFAULT_VALUES }
|
|
177
191
|
settings={ updatedSettings }
|
|
178
192
|
onChange={ onChange }
|
|
179
193
|
value={ style }
|
|
194
|
+
themeFileURIs={ _links?.[ 'wp:theme-file' ] }
|
|
180
195
|
/>
|
|
181
196
|
);
|
|
182
197
|
}
|
package/src/hooks/block-hooks.js
CHANGED
|
@@ -43,25 +43,12 @@ function BlockHooksControlPure( {
|
|
|
43
43
|
[ blockTypes, name, ignoredHookedBlocks ]
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
const { blockIndex, rootClientId, innerBlocksLength } = useSelect(
|
|
47
|
-
( select ) => {
|
|
48
|
-
const { getBlocks, getBlockIndex, getBlockRootClientId } =
|
|
49
|
-
select( blockEditorStore );
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
blockIndex: getBlockIndex( clientId ),
|
|
53
|
-
innerBlocksLength: getBlocks( clientId )?.length,
|
|
54
|
-
rootClientId: getBlockRootClientId( clientId ),
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
[ clientId ]
|
|
58
|
-
);
|
|
59
|
-
|
|
60
46
|
const hookedBlockClientIds = useSelect(
|
|
61
47
|
( select ) => {
|
|
62
|
-
const { getBlocks, getGlobalBlockCount } =
|
|
48
|
+
const { getBlocks, getBlockRootClientId, getGlobalBlockCount } =
|
|
63
49
|
select( blockEditorStore );
|
|
64
50
|
|
|
51
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
65
52
|
const _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce(
|
|
66
53
|
( clientIds, block ) => {
|
|
67
54
|
// If the block doesn't exist anywhere in the block tree,
|
|
@@ -127,9 +114,11 @@ function BlockHooksControlPure( {
|
|
|
127
114
|
|
|
128
115
|
return EMPTY_OBJECT;
|
|
129
116
|
},
|
|
130
|
-
[ hookedBlocksForCurrentBlock, name, clientId
|
|
117
|
+
[ hookedBlocksForCurrentBlock, name, clientId ]
|
|
131
118
|
);
|
|
132
119
|
|
|
120
|
+
const { getBlockIndex, getBlockCount, getBlockRootClientId } =
|
|
121
|
+
useSelect( blockEditorStore );
|
|
133
122
|
const { insertBlock, removeBlock } = useDispatch( blockEditorStore );
|
|
134
123
|
|
|
135
124
|
if ( ! hookedBlocksForCurrentBlock.length ) {
|
|
@@ -150,6 +139,10 @@ function BlockHooksControlPure( {
|
|
|
150
139
|
);
|
|
151
140
|
|
|
152
141
|
const insertBlockIntoDesignatedLocation = ( block, relativePosition ) => {
|
|
142
|
+
const blockIndex = getBlockIndex( clientId );
|
|
143
|
+
const innerBlocksLength = getBlockCount( clientId );
|
|
144
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
145
|
+
|
|
153
146
|
switch ( relativePosition ) {
|
|
154
147
|
case 'before':
|
|
155
148
|
case 'after':
|
|
@@ -14,8 +14,27 @@ import {
|
|
|
14
14
|
getBlockSelectors,
|
|
15
15
|
} from '../components/global-styles';
|
|
16
16
|
import { useStyleOverride } from './utils';
|
|
17
|
+
import { getValueFromObjectPath } from '../utils/object';
|
|
17
18
|
import { store as blockEditorStore } from '../store';
|
|
18
19
|
import { globalStylesDataKey } from '../store/private-keys';
|
|
20
|
+
import { unlock } from '../lock-unlock';
|
|
21
|
+
|
|
22
|
+
const VARIATION_PREFIX = 'is-style-';
|
|
23
|
+
|
|
24
|
+
function getVariationMatches( className ) {
|
|
25
|
+
if ( ! className ) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
return className.split( /\s+/ ).reduce( ( matches, name ) => {
|
|
29
|
+
if ( name.startsWith( VARIATION_PREFIX ) ) {
|
|
30
|
+
const match = name.slice( VARIATION_PREFIX.length );
|
|
31
|
+
if ( match !== 'default' ) {
|
|
32
|
+
matches.push( match );
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return matches;
|
|
36
|
+
}, [] );
|
|
37
|
+
}
|
|
19
38
|
|
|
20
39
|
/**
|
|
21
40
|
* Get the first block style variation that has been registered from the class string.
|
|
@@ -28,14 +47,13 @@ import { globalStylesDataKey } from '../store/private-keys';
|
|
|
28
47
|
function getVariationNameFromClass( className, registeredStyles = [] ) {
|
|
29
48
|
// The global flag affects how capturing groups work in JS. So the regex
|
|
30
49
|
// below will only return full CSS classes not just the variation name.
|
|
31
|
-
const matches =
|
|
50
|
+
const matches = getVariationMatches( className );
|
|
32
51
|
|
|
33
52
|
if ( ! matches ) {
|
|
34
53
|
return null;
|
|
35
54
|
}
|
|
36
55
|
|
|
37
|
-
for ( const
|
|
38
|
-
const variation = variationClass.substring( 9 ); // Remove 'is-style-' prefix.
|
|
56
|
+
for ( const variation of matches ) {
|
|
39
57
|
if ( registeredStyles.some( ( style ) => style.name === variation ) ) {
|
|
40
58
|
return variation;
|
|
41
59
|
}
|
|
@@ -43,6 +61,197 @@ function getVariationNameFromClass( className, registeredStyles = [] ) {
|
|
|
43
61
|
return null;
|
|
44
62
|
}
|
|
45
63
|
|
|
64
|
+
// A helper component to apply a style override using the useStyleOverride hook.
|
|
65
|
+
function OverrideStyles( { override } ) {
|
|
66
|
+
useStyleOverride( override );
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* This component is used to generate new block style variation overrides
|
|
71
|
+
* based on an incoming theme config. If a matching style is found in the config,
|
|
72
|
+
* a new override is created and returned. The overrides can be used in conjunction with
|
|
73
|
+
* useStyleOverride to apply the new styles to the editor. Its use is
|
|
74
|
+
* subject to change.
|
|
75
|
+
*
|
|
76
|
+
* @param {Object} props Props.
|
|
77
|
+
* @param {Object} props.config A global styles object, containing settings and styles.
|
|
78
|
+
* @return {JSX.Element|undefined} An array of new block variation overrides.
|
|
79
|
+
*/
|
|
80
|
+
export function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {
|
|
81
|
+
const { getBlockStyles, overrides } = useSelect(
|
|
82
|
+
( select ) => ( {
|
|
83
|
+
getBlockStyles: select( blocksStore ).getBlockStyles,
|
|
84
|
+
overrides: unlock( select( blockEditorStore ) ).getStyleOverrides(),
|
|
85
|
+
} ),
|
|
86
|
+
[]
|
|
87
|
+
);
|
|
88
|
+
const { getBlockName } = useSelect( blockEditorStore );
|
|
89
|
+
|
|
90
|
+
const overridesWithConfig = useMemo( () => {
|
|
91
|
+
if ( ! overrides?.length ) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const newOverrides = [];
|
|
95
|
+
const overriddenClientIds = [];
|
|
96
|
+
for ( const [ , override ] of overrides ) {
|
|
97
|
+
if (
|
|
98
|
+
override?.variation &&
|
|
99
|
+
override?.clientId &&
|
|
100
|
+
/*
|
|
101
|
+
* Because this component overwrites existing style overrides,
|
|
102
|
+
* filter out any overrides that are already present in the store.
|
|
103
|
+
*/
|
|
104
|
+
! overriddenClientIds.includes( override.clientId )
|
|
105
|
+
) {
|
|
106
|
+
const blockName = getBlockName( override.clientId );
|
|
107
|
+
const configStyles =
|
|
108
|
+
config?.styles?.blocks?.[ blockName ]?.variations?.[
|
|
109
|
+
override.variation
|
|
110
|
+
];
|
|
111
|
+
if ( configStyles ) {
|
|
112
|
+
const variationConfig = {
|
|
113
|
+
settings: config?.settings,
|
|
114
|
+
// The variation style data is all that is needed to generate
|
|
115
|
+
// the styles for the current application to a block. The variation
|
|
116
|
+
// name is updated to match the instance specific class name.
|
|
117
|
+
styles: {
|
|
118
|
+
blocks: {
|
|
119
|
+
[ blockName ]: {
|
|
120
|
+
variations: {
|
|
121
|
+
[ `${ override.variation }-${ override.clientId }` ]:
|
|
122
|
+
configStyles,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
const blockSelectors = getBlockSelectors(
|
|
129
|
+
getBlockTypes(),
|
|
130
|
+
getBlockStyles,
|
|
131
|
+
override.clientId
|
|
132
|
+
);
|
|
133
|
+
const hasBlockGapSupport = false;
|
|
134
|
+
const hasFallbackGapSupport = true;
|
|
135
|
+
const disableLayoutStyles = true;
|
|
136
|
+
const disableRootPadding = true;
|
|
137
|
+
const variationStyles = toStyles(
|
|
138
|
+
variationConfig,
|
|
139
|
+
blockSelectors,
|
|
140
|
+
hasBlockGapSupport,
|
|
141
|
+
hasFallbackGapSupport,
|
|
142
|
+
disableLayoutStyles,
|
|
143
|
+
disableRootPadding,
|
|
144
|
+
{
|
|
145
|
+
blockGap: false,
|
|
146
|
+
blockStyles: true,
|
|
147
|
+
layoutStyles: false,
|
|
148
|
+
marginReset: false,
|
|
149
|
+
presets: false,
|
|
150
|
+
rootPadding: false,
|
|
151
|
+
variationStyles: true,
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
newOverrides.push( {
|
|
155
|
+
id: `${ override.variation }-${ override.clientId }`,
|
|
156
|
+
css: variationStyles,
|
|
157
|
+
__unstableType: 'variation',
|
|
158
|
+
variation: override.variation,
|
|
159
|
+
// The clientId will be stored with the override and used to ensure
|
|
160
|
+
// the order of overrides matches the order of blocks so that the
|
|
161
|
+
// correct CSS cascade is maintained.
|
|
162
|
+
clientId: override.clientId,
|
|
163
|
+
} );
|
|
164
|
+
overriddenClientIds.push( override.clientId );
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return newOverrides;
|
|
169
|
+
}, [ config, overrides, getBlockStyles, getBlockName ] );
|
|
170
|
+
|
|
171
|
+
if ( ! overridesWithConfig || ! overridesWithConfig.length ) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<>
|
|
177
|
+
{ overridesWithConfig.map( ( override ) => (
|
|
178
|
+
<OverrideStyles key={ override.id } override={ override } />
|
|
179
|
+
) ) }
|
|
180
|
+
</>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Retrieves any variation styles data and resolves any referenced values.
|
|
186
|
+
*
|
|
187
|
+
* @param {Object} globalStyles A complete global styles object, containing settings and styles.
|
|
188
|
+
* @param {string} name The name of the desired block type.
|
|
189
|
+
* @param {variation} variation The of the block style variation to retrieve data for.
|
|
190
|
+
*
|
|
191
|
+
* @return {Object|undefined} The global styles data for the specified variation.
|
|
192
|
+
*/
|
|
193
|
+
export function getVariationStylesWithRefValues(
|
|
194
|
+
globalStyles,
|
|
195
|
+
name,
|
|
196
|
+
variation
|
|
197
|
+
) {
|
|
198
|
+
if ( ! globalStyles?.styles?.blocks?.[ name ]?.variations?.[ variation ] ) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Helper to recursively look for `ref` values to resolve.
|
|
203
|
+
const replaceRefs = ( variationStyles ) => {
|
|
204
|
+
Object.keys( variationStyles ).forEach( ( key ) => {
|
|
205
|
+
const value = variationStyles[ key ];
|
|
206
|
+
|
|
207
|
+
// Only process objects.
|
|
208
|
+
if ( typeof value === 'object' && value !== null ) {
|
|
209
|
+
// Process `ref` value if present.
|
|
210
|
+
if ( value.ref !== undefined ) {
|
|
211
|
+
if (
|
|
212
|
+
typeof value.ref !== 'string' ||
|
|
213
|
+
value.ref.trim() === ''
|
|
214
|
+
) {
|
|
215
|
+
// Remove invalid ref.
|
|
216
|
+
delete variationStyles[ key ];
|
|
217
|
+
} else {
|
|
218
|
+
// Resolve `ref` value.
|
|
219
|
+
const refValue = getValueFromObjectPath(
|
|
220
|
+
globalStyles,
|
|
221
|
+
value.ref
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
if ( refValue ) {
|
|
225
|
+
variationStyles[ key ] = refValue;
|
|
226
|
+
} else {
|
|
227
|
+
delete variationStyles[ key ];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
// Recursively resolve `ref` values in nested objects.
|
|
232
|
+
replaceRefs( value );
|
|
233
|
+
|
|
234
|
+
// After recursion, if value is empty due to explicitly
|
|
235
|
+
// `undefined` ref value, remove it.
|
|
236
|
+
if ( Object.keys( value ).length === 0 ) {
|
|
237
|
+
delete variationStyles[ key ];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
} );
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// Deep clone variation node to avoid mutating it within global styles and losing refs.
|
|
245
|
+
const styles = JSON.parse(
|
|
246
|
+
JSON.stringify(
|
|
247
|
+
globalStyles.styles.blocks[ name ].variations[ variation ]
|
|
248
|
+
)
|
|
249
|
+
);
|
|
250
|
+
replaceRefs( styles );
|
|
251
|
+
|
|
252
|
+
return styles;
|
|
253
|
+
}
|
|
254
|
+
|
|
46
255
|
function useBlockStyleVariation( name, variation, clientId ) {
|
|
47
256
|
// Prefer global styles data in GlobalStylesContext, which are available
|
|
48
257
|
// if in the site editor. Otherwise fall back to whatever is in the
|
|
@@ -57,9 +266,14 @@ function useBlockStyleVariation( name, variation, clientId ) {
|
|
|
57
266
|
}, [] );
|
|
58
267
|
|
|
59
268
|
return useMemo( () => {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
269
|
+
const variationStyles = getVariationStylesWithRefValues(
|
|
270
|
+
{
|
|
271
|
+
settings: mergedConfig?.settings ?? globalSettings,
|
|
272
|
+
styles: mergedConfig?.styles ?? globalStyles,
|
|
273
|
+
},
|
|
274
|
+
name,
|
|
275
|
+
variation
|
|
276
|
+
);
|
|
63
277
|
|
|
64
278
|
return {
|
|
65
279
|
settings: mergedConfig?.settings ?? globalSettings,
|
|
@@ -94,7 +308,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
94
308
|
|
|
95
309
|
const registeredStyles = getBlockStyles( name );
|
|
96
310
|
const variation = getVariationNameFromClass( className, registeredStyles );
|
|
97
|
-
const variationClass =
|
|
311
|
+
const variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;
|
|
98
312
|
|
|
99
313
|
const { settings, styles } = useBlockStyleVariation(
|
|
100
314
|
name,
|
|
@@ -116,7 +330,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
116
330
|
const hasBlockGapSupport = false;
|
|
117
331
|
const hasFallbackGapSupport = true;
|
|
118
332
|
const disableLayoutStyles = true;
|
|
119
|
-
const
|
|
333
|
+
const disableRootPadding = true;
|
|
120
334
|
|
|
121
335
|
return toStyles(
|
|
122
336
|
variationConfig,
|
|
@@ -124,7 +338,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
124
338
|
hasBlockGapSupport,
|
|
125
339
|
hasFallbackGapSupport,
|
|
126
340
|
disableLayoutStyles,
|
|
127
|
-
|
|
341
|
+
disableRootPadding,
|
|
128
342
|
{
|
|
129
343
|
blockGap: false,
|
|
130
344
|
blockStyles: true,
|
|
@@ -132,6 +346,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
132
346
|
marginReset: false,
|
|
133
347
|
presets: false,
|
|
134
348
|
rootPadding: false,
|
|
349
|
+
variationStyles: true,
|
|
135
350
|
}
|
|
136
351
|
);
|
|
137
352
|
}, [ variation, settings, styles, getBlockStyles, clientId ] );
|
|
@@ -140,6 +355,7 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
140
355
|
id: `variation-${ clientId }`,
|
|
141
356
|
css: variationStyles,
|
|
142
357
|
__unstableType: 'variation',
|
|
358
|
+
variation,
|
|
143
359
|
// The clientId will be stored with the override and used to ensure
|
|
144
360
|
// the order of overrides matches the order of blocks so that the
|
|
145
361
|
// correct CSS cascade is maintained.
|
|
@@ -152,5 +368,6 @@ function useBlockProps( { name, className, clientId } ) {
|
|
|
152
368
|
export default {
|
|
153
369
|
hasSupport: () => true,
|
|
154
370
|
attributeKeys: [ 'className' ],
|
|
371
|
+
isMatch: ( { className } ) => getVariationMatches( className ).length > 0,
|
|
155
372
|
useBlockProps,
|
|
156
373
|
};
|
package/src/hooks/duotone.js
CHANGED
|
@@ -295,26 +295,30 @@ function useDuotoneStyles( {
|
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
// Safari does not always update the duotone filter when the duotone
|
|
299
|
-
// are changed. When using Safari, force the block element to be
|
|
300
|
-
// the browser to ensure any changes are reflected
|
|
301
|
-
// that used on the site frontend in
|
|
298
|
+
// Safari does not always update the duotone filter when the duotone
|
|
299
|
+
// colors are changed. When using Safari, force the block element to be
|
|
300
|
+
// repainted by the browser to ensure any changes are reflected
|
|
301
|
+
// visually. This logic matches that used on the site frontend in
|
|
302
|
+
// `block-supports/duotone.php`.
|
|
302
303
|
if ( blockElement && isSafari ) {
|
|
303
304
|
const display = blockElement.style.display;
|
|
304
|
-
// Switch to `inline-block` to force a repaint. In the editor,
|
|
305
|
-
// is used instead of `none` to ensure that scroll
|
|
306
|
-
// as `none` results in the editor
|
|
305
|
+
// Switch to `inline-block` to force a repaint. In the editor,
|
|
306
|
+
// `inline-block` is used instead of `none` to ensure that scroll
|
|
307
|
+
// position is not affected, as `none` results in the editor
|
|
308
|
+
// scrolling to the top of the block.
|
|
307
309
|
blockElement.style.display = 'inline-block';
|
|
308
|
-
// Simply accessing el.offsetHeight flushes layout and style
|
|
309
|
-
//
|
|
310
|
+
// Simply accessing el.offsetHeight flushes layout and style changes
|
|
311
|
+
// in WebKit without having to wait for setTimeout.
|
|
310
312
|
// eslint-disable-next-line no-unused-expressions
|
|
311
313
|
blockElement.offsetHeight;
|
|
312
314
|
blockElement.style.display = display;
|
|
313
315
|
}
|
|
314
|
-
|
|
316
|
+
// `colors` must be a dependency so this effect runs when the colors
|
|
317
|
+
// change in Safari.
|
|
318
|
+
}, [ isValidFilter, blockElement, colors ] );
|
|
315
319
|
}
|
|
316
320
|
|
|
317
|
-
function useBlockProps( { name, style } ) {
|
|
321
|
+
function useBlockProps( { clientId, name, style } ) {
|
|
318
322
|
const id = useInstanceId( useBlockProps );
|
|
319
323
|
const selector = useMemo( () => {
|
|
320
324
|
const blockType = getBlockType( name );
|
|
@@ -362,7 +366,7 @@ function useBlockProps( { name, style } ) {
|
|
|
362
366
|
const shouldRender = selector && attribute;
|
|
363
367
|
|
|
364
368
|
useDuotoneStyles( {
|
|
365
|
-
clientId
|
|
369
|
+
clientId,
|
|
366
370
|
id: filterClass,
|
|
367
371
|
selector,
|
|
368
372
|
attribute,
|