@wordpress/block-editor 11.7.0 → 12.0.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 +8 -0
- package/README.md +56 -57
- package/build/components/block-info-slot-fill/index.js +47 -0
- package/build/components/block-info-slot-fill/index.js.map +1 -0
- package/build/components/block-inspector/index.js +4 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/index.native.js +11 -21
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -9
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +1 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-toolbar/index.js +2 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +83 -9
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +11 -28
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/caption/index.native.js +0 -1
- package/build/components/caption/index.native.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/editor-styles/index.js +4 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +21 -14
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +15 -59
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +12 -12
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.native.js +174 -0
- package/build/components/global-styles/color-panel.native.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +21 -20
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +244 -0
- package/build/components/global-styles/effects-panel.js.map +1 -0
- package/build/components/global-styles/filters-panel.js +215 -0
- package/build/components/global-styles/filters-panel.js.map +1 -0
- package/build/components/global-styles/get-block-css-selector.js +1 -12
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/hooks.js +7 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +28 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -9
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +100 -82
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-size-control/use-dimension-handler.js +5 -3
- package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build/components/index.js +23 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -2
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +12 -7
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/index.js +2 -1
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +2 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/utils.js +5 -3
- package/build/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build/components/list-view/block-select-button.js +7 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +13 -21
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +37 -10
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +31 -7
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -1
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +7 -3
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +8 -2
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-replace-flow/index.js +5 -5
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -4
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +2 -7
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +6 -1
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +17 -14
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +38 -0
- package/build/components/resizable-box-popover/index.js.map +1 -0
- 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 +7 -11
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +8 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +1 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +121 -70
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/margin.js +27 -17
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -9
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/utils.js +22 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/utils.js +3 -2
- package/build/layouts/utils.js.map +1 -1
- package/build/private-apis.js +13 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +8 -1
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +6 -6
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +2 -2
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build/utils/use-should-contextual-toolbar-show.js +68 -0
- package/build/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-module/components/block-info-slot-fill/index.js +34 -0
- package/build-module/components/block-info-slot-fill/index.js.map +1 -0
- package/build-module/components/block-inspector/index.js +3 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +11 -19
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +2 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -9
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -9
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +2 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +79 -9
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +10 -27
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/caption/index.native.js +0 -1
- package/build-module/components/caption/index.native.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/editor-styles/index.js +4 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +21 -14
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +15 -59
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +13 -13
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.native.js +150 -0
- package/build-module/components/global-styles/color-panel.native.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +22 -21
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +228 -0
- package/build-module/components/global-styles/effects-panel.js.map +1 -0
- package/build-module/components/global-styles/filters-panel.js +201 -0
- package/build-module/components/global-styles/filters-panel.js.map +1 -0
- package/build-module/components/global-styles/get-block-css-selector.js +1 -12
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +7 -0
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +10 -10
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +101 -83
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-size-control/use-dimension-handler.js +5 -3
- package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +5 -2
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +12 -6
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -1
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/utils.js +4 -3
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +7 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +15 -22
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +36 -10
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +31 -8
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -1
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +7 -3
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +8 -4
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +5 -5
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -4
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +1 -5
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +5 -1
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +17 -14
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +26 -0
- package/build-module/components/resizable-box-popover/index.js.map +1 -0
- 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 +7 -10
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +7 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +1 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/duotone.js +118 -71
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/margin.js +29 -18
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +21 -10
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/utils.js +24 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/utils.js +3 -2
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/private-apis.js +9 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +8 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +5 -5
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +2 -2
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-module/utils/use-should-contextual-toolbar-show.js +56 -0
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-style/content-rtl.css +9 -6
- package/build-style/content.css +9 -6
- package/build-style/style-rtl.css +272 -54
- package/build-style/style.css +272 -54
- package/package.json +32 -32
- package/src/components/block-info-slot-fill/index.js +24 -0
- package/src/components/block-inspector/index.js +3 -0
- package/src/components/block-inspector/style.scss +6 -4
- package/src/components/block-list/content.scss +16 -15
- package/src/components/block-list/index.native.js +19 -38
- package/src/components/block-list/use-in-between-inserter.js +4 -1
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +9 -9
- package/src/components/block-mover/style.scss +10 -4
- package/src/components/block-mover/test/index.native.js +4 -4
- package/src/components/block-popover/inbetween.js +2 -13
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -12
- package/src/components/block-toolbar/index.js +4 -3
- package/src/components/block-toolbar/style.scss +56 -33
- package/src/components/block-tools/block-contextual-toolbar.js +94 -11
- package/src/components/block-tools/selected-block-popover.js +11 -44
- package/src/components/block-tools/style.scss +157 -3
- package/src/components/caption/index.native.js +0 -1
- package/src/components/date-format-picker/index.js +1 -1
- package/src/components/editor-styles/index.js +9 -5
- package/src/components/font-sizes/fluid-utils.js +31 -14
- package/src/components/font-sizes/test/fluid-utils.js +5 -16
- package/src/components/global-styles/README.md +129 -16
- package/src/components/global-styles/border-panel.js +13 -61
- package/src/components/global-styles/color-panel.js +13 -13
- package/src/components/global-styles/color-panel.native.js +207 -0
- package/src/components/global-styles/dimensions-panel.js +47 -20
- package/src/components/global-styles/effects-panel.js +228 -0
- package/src/components/global-styles/filters-panel.js +230 -0
- package/src/components/global-styles/get-block-css-selector.js +0 -11
- package/src/components/global-styles/hooks.js +10 -0
- package/src/components/global-styles/index.js +2 -0
- package/src/components/global-styles/style.scss +43 -0
- package/src/components/global-styles/test/typography-utils.js +63 -22
- package/src/components/global-styles/test/use-global-styles-output.js +130 -8
- package/src/components/global-styles/typography-panel.js +37 -11
- package/src/components/global-styles/use-global-styles-output.js +88 -72
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-size-control/use-dimension-handler.js +4 -3
- package/src/components/index.js +5 -1
- package/src/components/inserter/block-patterns-tab.js +3 -1
- package/src/components/inserter/block-types-tab.js +9 -6
- package/src/components/inserter/index.js +1 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/inspector-controls-tabs/utils.js +4 -3
- package/src/components/list-view/README.md +2 -0
- package/src/components/list-view/block-select-button.js +6 -1
- package/src/components/list-view/block.js +24 -31
- package/src/components/list-view/drop-indicator.js +67 -22
- package/src/components/list-view/index.js +26 -3
- package/src/components/list-view/leaf.js +1 -0
- package/src/components/list-view/style.scss +18 -4
- package/src/components/list-view/test/use-list-view-drop-zone.js +188 -0
- package/src/components/list-view/use-block-selection.js +1 -1
- package/src/components/list-view/use-list-view-client-ids.js +5 -3
- package/src/components/list-view/use-list-view-drop-zone.js +9 -3
- package/src/components/media-replace-flow/README.md +3 -2
- package/src/components/media-replace-flow/index.js +4 -5
- package/src/components/navigable-toolbar/index.js +12 -3
- package/src/components/off-canvas-editor/appender.js +1 -4
- package/src/components/off-canvas-editor/block-contents.js +4 -0
- package/src/components/off-canvas-editor/index.js +15 -11
- package/src/components/resizable-box-popover/index.js +27 -0
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +2 -5
- package/src/components/spacing-sizes-control/spacing-input-control.js +10 -0
- package/src/components/spacing-sizes-control/style.scss +7 -7
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +1 -1
- package/src/hooks/duotone.js +162 -99
- package/src/hooks/margin.js +31 -26
- package/src/hooks/padding.js +24 -18
- package/src/hooks/test/anchor.js +113 -0
- package/src/hooks/test/color.js +0 -9
- package/src/hooks/test/use-typography-props.js +2 -2
- package/src/hooks/test/utils.js +20 -101
- package/src/hooks/utils.js +23 -6
- package/src/layouts/utils.js +2 -2
- package/src/private-apis.js +8 -0
- package/src/store/actions.js +8 -1
- package/src/style.scss +1 -0
- package/src/utils/object.js +5 -5
- package/src/utils/test/object.js +53 -15
- package/src/utils/transform-styles/index.js +2 -2
- package/src/utils/use-should-contextual-toolbar-show.js +75 -0
- package/tsconfig.json +1 -0
- package/build/components/rich-text/use-native-props.js +0 -11
- package/build/components/rich-text/use-native-props.js.map +0 -1
- package/build/components/rich-text/use-native-props.native.js +0 -24
- package/build/components/rich-text/use-native-props.native.js.map +0 -1
- package/build/hooks/color-panel.native.js +0 -77
- package/build/hooks/color-panel.native.js.map +0 -1
- package/build-module/components/rich-text/use-native-props.js +0 -4
- package/build-module/components/rich-text/use-native-props.js.map +0 -1
- package/build-module/components/rich-text/use-native-props.native.js +0 -15
- package/build-module/components/rich-text/use-native-props.native.js.map +0 -1
- package/build-module/hooks/color-panel.native.js +0 -62
- package/build-module/hooks/color-panel.native.js.map +0 -1
- package/src/components/rich-text/use-native-props.js +0 -3
- package/src/components/rich-text/use-native-props.native.js +0 -17
- package/src/hooks/color-panel.native.js +0 -63
|
@@ -54,17 +54,18 @@ export const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
|
54
54
|
/**
|
|
55
55
|
* Show a hierarchical list of blocks.
|
|
56
56
|
*
|
|
57
|
-
* @param {Object}
|
|
58
|
-
* @param {string}
|
|
59
|
-
* @param {string}
|
|
60
|
-
* @param {Array}
|
|
61
|
-
* @param {boolean}
|
|
62
|
-
* @param {boolean}
|
|
63
|
-
* @param {Object}
|
|
64
|
-
* @param {string}
|
|
65
|
-
* @param {string}
|
|
66
|
-
* @param {string}
|
|
67
|
-
* @param {
|
|
57
|
+
* @param {Object} props Components props.
|
|
58
|
+
* @param {string} props.id An HTML element id for the root element of ListView.
|
|
59
|
+
* @param {string} props.parentClientId The client id of the parent block.
|
|
60
|
+
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
61
|
+
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
62
|
+
* @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
|
|
63
|
+
* @param {Object} props.LeafMoreMenu Optional more menu substitution.
|
|
64
|
+
* @param {string} props.description Optional accessible description for the tree grid component.
|
|
65
|
+
* @param {string} props.onSelect Optional callback to be invoked when a block is selected.
|
|
66
|
+
* @param {string} props.showAppender Flag to show or hide the block appender.
|
|
67
|
+
* @param {Function} props.renderAdditionalBlockUI Function that renders additional block content UI.
|
|
68
|
+
* @param {Object} ref Forwarded ref.
|
|
68
69
|
*/
|
|
69
70
|
function OffCanvasEditor(
|
|
70
71
|
{
|
|
@@ -77,6 +78,7 @@ function OffCanvasEditor(
|
|
|
77
78
|
LeafMoreMenu,
|
|
78
79
|
description = __( 'Block navigation structure' ),
|
|
79
80
|
onSelect,
|
|
81
|
+
renderAdditionalBlockUI,
|
|
80
82
|
},
|
|
81
83
|
ref
|
|
82
84
|
) {
|
|
@@ -200,6 +202,7 @@ function OffCanvasEditor(
|
|
|
200
202
|
expand,
|
|
201
203
|
collapse,
|
|
202
204
|
LeafMoreMenu,
|
|
205
|
+
renderAdditionalBlockUI,
|
|
203
206
|
} ),
|
|
204
207
|
[
|
|
205
208
|
isMounted.current,
|
|
@@ -208,6 +211,7 @@ function OffCanvasEditor(
|
|
|
208
211
|
expand,
|
|
209
212
|
collapse,
|
|
210
213
|
LeafMoreMenu,
|
|
214
|
+
renderAdditionalBlockUI,
|
|
211
215
|
]
|
|
212
216
|
);
|
|
213
217
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { ResizableBox } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import BlockPopover from '../block-popover';
|
|
10
|
+
|
|
11
|
+
export default function ResizableBoxPopover( {
|
|
12
|
+
clientId,
|
|
13
|
+
resizableBoxProps,
|
|
14
|
+
...props
|
|
15
|
+
} ) {
|
|
16
|
+
return (
|
|
17
|
+
<BlockPopover
|
|
18
|
+
clientId={ clientId }
|
|
19
|
+
__unstableCoverTarget
|
|
20
|
+
__unstablePopoverSlot="block-toolbar"
|
|
21
|
+
shift={ false }
|
|
22
|
+
{ ...props }
|
|
23
|
+
>
|
|
24
|
+
<ResizableBox { ...resizableBoxProps } />
|
|
25
|
+
</BlockPopover>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -46,7 +46,6 @@ import { useBlockEditContext } from '../block-edit';
|
|
|
46
46
|
import { RemoveBrowserShortcuts } from './remove-browser-shortcuts';
|
|
47
47
|
import { filePasteHandler } from './file-paste-handler';
|
|
48
48
|
import FormatToolbarContainer from './format-toolbar-container';
|
|
49
|
-
import { useNativeProps } from './use-native-props';
|
|
50
49
|
import { store as blockEditorStore } from '../../store';
|
|
51
50
|
import {
|
|
52
51
|
addActiveFormats,
|
|
@@ -97,7 +96,6 @@ function RichTextWrapper(
|
|
|
97
96
|
textAlign,
|
|
98
97
|
selectionColor,
|
|
99
98
|
tagsToEliminate,
|
|
100
|
-
rootTagsToEliminate,
|
|
101
99
|
disableEditingMenu,
|
|
102
100
|
fontSize,
|
|
103
101
|
fontFamily,
|
|
@@ -121,7 +119,6 @@ function RichTextWrapper(
|
|
|
121
119
|
|
|
122
120
|
const fallbackRef = useRef();
|
|
123
121
|
const { clientId, isSelected: blockIsSelected } = useBlockEditContext();
|
|
124
|
-
const nativeProps = useNativeProps();
|
|
125
122
|
const embedHandlerPickerRef = useRef();
|
|
126
123
|
const selector = ( select ) => {
|
|
127
124
|
const {
|
|
@@ -220,6 +217,7 @@ function RichTextWrapper(
|
|
|
220
217
|
selectionChangeEnd
|
|
221
218
|
);
|
|
222
219
|
},
|
|
220
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
223
221
|
[ clientId, identifier ]
|
|
224
222
|
);
|
|
225
223
|
|
|
@@ -373,6 +371,7 @@ function RichTextWrapper(
|
|
|
373
371
|
}
|
|
374
372
|
}
|
|
375
373
|
},
|
|
374
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
376
375
|
[
|
|
377
376
|
onReplace,
|
|
378
377
|
onSplit,
|
|
@@ -615,7 +614,6 @@ function RichTextWrapper(
|
|
|
615
614
|
}
|
|
616
615
|
__unstableMultilineRootTag={ __unstableMultilineRootTag }
|
|
617
616
|
// Native props.
|
|
618
|
-
{ ...nativeProps }
|
|
619
617
|
blockIsSelected={
|
|
620
618
|
originalIsSelected !== undefined
|
|
621
619
|
? originalIsSelected
|
|
@@ -628,7 +626,6 @@ function RichTextWrapper(
|
|
|
628
626
|
textAlign={ textAlign }
|
|
629
627
|
selectionColor={ selectionColor }
|
|
630
628
|
tagsToEliminate={ tagsToEliminate }
|
|
631
|
-
rootTagsToEliminate={ rootTagsToEliminate }
|
|
632
629
|
disableEditingMenu={ disableEditingMenu }
|
|
633
630
|
fontSize={ fontSize }
|
|
634
631
|
fontFamily={ fontFamily }
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from '@wordpress/components';
|
|
21
21
|
import { __, sprintf } from '@wordpress/i18n';
|
|
22
22
|
import { settings } from '@wordpress/icons';
|
|
23
|
+
import { usePrevious } from '@wordpress/compose';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Internal dependencies
|
|
@@ -71,6 +72,15 @@ export default function SpacingInputControl( {
|
|
|
71
72
|
! isValueSpacingPreset( value )
|
|
72
73
|
);
|
|
73
74
|
|
|
75
|
+
const previousValue = usePrevious( value );
|
|
76
|
+
if (
|
|
77
|
+
previousValue !== value &&
|
|
78
|
+
! isValueSpacingPreset( value ) &&
|
|
79
|
+
showCustomValueControl !== true
|
|
80
|
+
) {
|
|
81
|
+
setShowCustomValueControl( true );
|
|
82
|
+
}
|
|
83
|
+
|
|
74
84
|
const units = useCustomUnits( {
|
|
75
85
|
availableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],
|
|
76
86
|
} );
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
display: grid;
|
|
3
3
|
grid-template-columns: auto 1fr auto;
|
|
4
4
|
align-items: center;
|
|
5
|
-
grid-template-rows:
|
|
5
|
+
grid-template-rows: $grid-unit-30 auto;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.component-spacing-sizes-control {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.components-base-control__label {
|
|
22
|
-
margin-bottom:
|
|
22
|
+
margin-bottom: $grid-unit-10;
|
|
23
23
|
height: $grid-unit-20;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
grid-row: 1 / 1;
|
|
56
56
|
align-self: center;
|
|
57
57
|
margin-left: $grid-unit-05;
|
|
58
|
+
margin-bottom: $grid-unit-10;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
.components-spacing-sizes-control__custom-toggle-all {
|
|
@@ -85,20 +86,20 @@
|
|
|
85
86
|
.components-spacing-sizes-control__custom-value-range {
|
|
86
87
|
grid-column: span 2;
|
|
87
88
|
margin-left: $grid-unit-20;
|
|
88
|
-
margin-top: 8px;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
.components-spacing-sizes-control__custom-value-input {
|
|
91
|
+
.components-base-control.components-spacing-sizes-control__custom-value-input {
|
|
92
92
|
width: 124px;
|
|
93
|
-
margin-top: 8px;
|
|
94
93
|
grid-column: 1;
|
|
94
|
+
margin-bottom: 0;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
.components-range-control {
|
|
97
|
+
.components-base-control.components-range-control {
|
|
98
98
|
height: 40px;
|
|
99
99
|
/* Vertically center the RangeControl until it has true 40px height. */
|
|
100
100
|
display: flex;
|
|
101
101
|
align-items: center;
|
|
102
|
+
margin-bottom: 0;
|
|
102
103
|
|
|
103
104
|
> .components-base-control__field {
|
|
104
105
|
/* Fixes RangeControl contents when the outer wrapper is flex */
|
|
@@ -108,7 +109,6 @@
|
|
|
108
109
|
|
|
109
110
|
.components-spacing-sizes-control__range-control {
|
|
110
111
|
grid-column: span 3;
|
|
111
|
-
margin-top: 8px;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
.components-range-control__mark {
|
|
@@ -5,7 +5,7 @@ exports[`URLPopover matches the snapshot in its default state 1`] = `
|
|
|
5
5
|
<span>
|
|
6
6
|
<div
|
|
7
7
|
class="components-popover block-editor-url-popover is-positioned"
|
|
8
|
-
style="position: absolute; top: 0px; left: 0px; transform:
|
|
8
|
+
style="position: absolute; top: 0px; left: 0px; transform: translateZ(0);"
|
|
9
9
|
tabindex="-1"
|
|
10
10
|
>
|
|
11
11
|
<div
|
|
@@ -53,7 +53,7 @@ exports[`URLPopover matches the snapshot when the settings are toggled open 1`]
|
|
|
53
53
|
<span>
|
|
54
54
|
<div
|
|
55
55
|
class="components-popover block-editor-url-popover is-positioned"
|
|
56
|
-
style="position: absolute; top: 0px; left: 0px; transform:
|
|
56
|
+
style="position: absolute; top: 0px; left: 0px; transform: translateZ(0);"
|
|
57
57
|
tabindex="-1"
|
|
58
58
|
>
|
|
59
59
|
<div
|
|
@@ -108,7 +108,7 @@ exports[`URLPopover matches the snapshot when there are no settings 1`] = `
|
|
|
108
108
|
<span>
|
|
109
109
|
<div
|
|
110
110
|
class="components-popover block-editor-url-popover is-positioned"
|
|
111
|
-
style="position: absolute; top: 0px; left: 0px; transform:
|
|
111
|
+
style="position: absolute; top: 0px; left: 0px; transform: translateZ(0);"
|
|
112
112
|
tabindex="-1"
|
|
113
113
|
>
|
|
114
114
|
<div
|
package/src/hooks/anchor.js
CHANGED
|
@@ -80,7 +80,7 @@ export const withInspectorControl = createHigherOrderComponent(
|
|
|
80
80
|
{ isWeb && (
|
|
81
81
|
<ExternalLink
|
|
82
82
|
href={ __(
|
|
83
|
-
'https://wordpress.org/
|
|
83
|
+
'https://wordpress.org/documentation/article/page-jumps/'
|
|
84
84
|
) }
|
|
85
85
|
>
|
|
86
86
|
{ __( 'Learn more about anchors' ) }
|
package/src/hooks/border.js
CHANGED
|
@@ -84,7 +84,7 @@ function styleToAttributes( style ) {
|
|
|
84
84
|
|
|
85
85
|
const borderColorValue = style?.border?.color;
|
|
86
86
|
const borderColorSlug = borderColorValue?.startsWith( 'var:preset|color|' )
|
|
87
|
-
?
|
|
87
|
+
? borderColorValue.substring( 'var:preset|color|'.length )
|
|
88
88
|
: undefined;
|
|
89
89
|
const updatedStyle = { ...style };
|
|
90
90
|
updatedStyle.border = {
|
package/src/hooks/duotone.js
CHANGED
|
@@ -23,6 +23,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
23
23
|
*/
|
|
24
24
|
import {
|
|
25
25
|
BlockControls,
|
|
26
|
+
InspectorControls,
|
|
26
27
|
__experimentalDuotoneControl as DuotoneControl,
|
|
27
28
|
useSetting,
|
|
28
29
|
} from '../components';
|
|
@@ -32,7 +33,11 @@ import {
|
|
|
32
33
|
__unstableDuotoneStylesheet as DuotoneStylesheet,
|
|
33
34
|
__unstableDuotoneUnsetStylesheet as DuotoneUnsetStylesheet,
|
|
34
35
|
} from '../components/duotone';
|
|
36
|
+
import { getBlockCSSSelector } from '../components/global-styles/get-block-css-selector';
|
|
37
|
+
import { scopeSelector } from '../components/global-styles/utils';
|
|
38
|
+
import { useBlockSettings } from './utils';
|
|
35
39
|
import { store as blockEditorStore } from '../store';
|
|
40
|
+
import { default as StylesFiltersPanel } from '../components/global-styles/filters-panel';
|
|
36
41
|
|
|
37
42
|
const EMPTY_ARRAY = [];
|
|
38
43
|
|
|
@@ -104,9 +109,10 @@ export function getDuotonePresetFromColors( colors, duotonePalette ) {
|
|
|
104
109
|
return preset ? `var:preset|duotone|${ preset.slug }` : undefined;
|
|
105
110
|
}
|
|
106
111
|
|
|
107
|
-
function DuotonePanel( { attributes, setAttributes } ) {
|
|
112
|
+
function DuotonePanel( { attributes, setAttributes, name } ) {
|
|
108
113
|
const style = attributes?.style;
|
|
109
114
|
const duotoneStyle = style?.color?.duotone;
|
|
115
|
+
const settings = useBlockSettings( name );
|
|
110
116
|
|
|
111
117
|
const duotonePalette = useMultiOriginPresets( {
|
|
112
118
|
presetSetting: 'color.duotone',
|
|
@@ -130,30 +136,47 @@ function DuotonePanel( { attributes, setAttributes } ) {
|
|
|
130
136
|
: duotoneStyle;
|
|
131
137
|
|
|
132
138
|
return (
|
|
133
|
-
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
139
|
+
<>
|
|
140
|
+
<InspectorControls group="filter">
|
|
141
|
+
<StylesFiltersPanel
|
|
142
|
+
value={ { filter: { duotone: duotonePresetOrColors } } }
|
|
143
|
+
onChange={ ( newDuotone ) => {
|
|
144
|
+
const newStyle = {
|
|
145
|
+
color: {
|
|
146
|
+
...newDuotone?.filter,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
setAttributes( { style: newStyle } );
|
|
150
|
+
} }
|
|
151
|
+
settings={ settings }
|
|
152
|
+
/>
|
|
153
|
+
</InspectorControls>
|
|
154
|
+
<BlockControls group="block" __experimentalShareWithChildBlocks>
|
|
155
|
+
<DuotoneControl
|
|
156
|
+
duotonePalette={ duotonePalette }
|
|
157
|
+
colorPalette={ colorPalette }
|
|
158
|
+
disableCustomDuotone={ disableCustomDuotone }
|
|
159
|
+
disableCustomColors={ disableCustomColors }
|
|
160
|
+
value={ duotonePresetOrColors }
|
|
161
|
+
onChange={ ( newDuotone ) => {
|
|
162
|
+
const maybePreset = getDuotonePresetFromColors(
|
|
163
|
+
newDuotone,
|
|
164
|
+
duotonePalette
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const newStyle = {
|
|
168
|
+
...style,
|
|
169
|
+
color: {
|
|
170
|
+
...style?.color,
|
|
171
|
+
duotone: maybePreset ?? newDuotone, // use preset or fallback to custom colors.
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
setAttributes( { style: newStyle } );
|
|
175
|
+
} }
|
|
176
|
+
settings={ settings }
|
|
177
|
+
/>
|
|
178
|
+
</BlockControls>
|
|
179
|
+
</>
|
|
157
180
|
);
|
|
158
181
|
}
|
|
159
182
|
|
|
@@ -166,7 +189,9 @@ function DuotonePanel( { attributes, setAttributes } ) {
|
|
|
166
189
|
* @return {Object} Filtered block settings.
|
|
167
190
|
*/
|
|
168
191
|
function addDuotoneAttributes( settings ) {
|
|
169
|
-
|
|
192
|
+
// Previous `color.__experimentalDuotone` support flag is migrated via
|
|
193
|
+
// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.
|
|
194
|
+
if ( ! hasBlockSupport( settings, 'filter.duotone' ) ) {
|
|
170
195
|
return settings;
|
|
171
196
|
}
|
|
172
197
|
|
|
@@ -193,10 +218,13 @@ function addDuotoneAttributes( settings ) {
|
|
|
193
218
|
*/
|
|
194
219
|
const withDuotoneControls = createHigherOrderComponent(
|
|
195
220
|
( BlockEdit ) => ( props ) => {
|
|
221
|
+
// Previous `color.__experimentalDuotone` support flag is migrated via
|
|
222
|
+
// block_type_metadata_settings filter in `lib/block-supports/duotone.php`.
|
|
196
223
|
const hasDuotoneSupport = hasBlockSupport(
|
|
197
224
|
props.name,
|
|
198
|
-
'
|
|
225
|
+
'filter.duotone'
|
|
199
226
|
);
|
|
227
|
+
|
|
200
228
|
const isContentLocked = useSelect(
|
|
201
229
|
( select ) => {
|
|
202
230
|
return select(
|
|
@@ -222,76 +250,71 @@ const withDuotoneControls = createHigherOrderComponent(
|
|
|
222
250
|
'withDuotoneControls'
|
|
223
251
|
);
|
|
224
252
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
* const scope = '.a, .b .c';
|
|
232
|
-
* const selector = '> .x, .y';
|
|
233
|
-
* const merged = scopeSelector( scope, selector );
|
|
234
|
-
* // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'
|
|
235
|
-
* ```
|
|
236
|
-
*
|
|
237
|
-
* @param {string} scope Selector to scope to.
|
|
238
|
-
* @param {string} selector Original selector.
|
|
239
|
-
*
|
|
240
|
-
* @return {string} Scoped selector.
|
|
241
|
-
*/
|
|
242
|
-
function scopeSelector( scope, selector ) {
|
|
243
|
-
const scopes = scope.split( ',' );
|
|
244
|
-
const selectors = selector.split( ',' );
|
|
245
|
-
|
|
246
|
-
const selectorsScoped = [];
|
|
247
|
-
scopes.forEach( ( outer ) => {
|
|
248
|
-
selectors.forEach( ( inner ) => {
|
|
249
|
-
selectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );
|
|
250
|
-
} );
|
|
251
|
-
} );
|
|
252
|
-
|
|
253
|
-
return selectorsScoped.join( ', ' );
|
|
254
|
-
}
|
|
253
|
+
function DuotoneStyles( {
|
|
254
|
+
id: filterId,
|
|
255
|
+
selector: duotoneSelector,
|
|
256
|
+
attribute: duotoneAttr,
|
|
257
|
+
} ) {
|
|
258
|
+
const element = useContext( BlockList.__unstableElementContext );
|
|
255
259
|
|
|
256
|
-
function BlockDuotoneStyles( { name, duotoneStyle, id } ) {
|
|
257
260
|
const duotonePalette = useMultiOriginPresets( {
|
|
258
261
|
presetSetting: 'color.duotone',
|
|
259
262
|
defaultSetting: 'color.defaultDuotone',
|
|
260
263
|
} );
|
|
261
264
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
//
|
|
265
|
-
//
|
|
266
|
-
|
|
267
|
-
|
|
265
|
+
// Possible values for duotone attribute:
|
|
266
|
+
// 1. Array of colors - e.g. ['#000000', '#ffffff'].
|
|
267
|
+
// 2. Variable for an existing Duotone preset - e.g. 'var:preset|duotone|green-blue' or 'var(--wp--preset--duotone--green-blue)''
|
|
268
|
+
// 3. A CSS string - e.g. 'unset' to remove globally applied duotone.
|
|
269
|
+
const isCustom = Array.isArray( duotoneAttr );
|
|
270
|
+
const duotonePreset = isCustom
|
|
271
|
+
? undefined
|
|
272
|
+
: getColorsFromDuotonePreset( duotoneAttr, duotonePalette );
|
|
273
|
+
const isPreset = typeof duotoneAttr === 'string' && duotonePreset;
|
|
274
|
+
const isCSS = typeof duotoneAttr === 'string' && ! isPreset;
|
|
275
|
+
|
|
276
|
+
// Match the structure of WP_Duotone_Gutenberg::render_duotone_support() in PHP.
|
|
277
|
+
let colors = null;
|
|
278
|
+
if ( isPreset ) {
|
|
279
|
+
// Array of colors.
|
|
280
|
+
colors = duotonePreset;
|
|
281
|
+
} else if ( isCSS ) {
|
|
282
|
+
// CSS filter property string (e.g. 'unset').
|
|
283
|
+
colors = duotoneAttr;
|
|
284
|
+
} else if ( isCustom ) {
|
|
285
|
+
// Array of colors.
|
|
286
|
+
colors = duotoneAttr;
|
|
268
287
|
}
|
|
269
288
|
|
|
270
|
-
|
|
289
|
+
// Build the CSS selectors to which the filter will be applied.
|
|
290
|
+
const selectors = duotoneSelector.split( ',' );
|
|
271
291
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
292
|
+
const selectorsScoped = selectors.map( ( selectorPart ) => {
|
|
293
|
+
// Extra .editor-styles-wrapper specificity is needed in the editor
|
|
294
|
+
// since we're not using inline styles to apply the filter. We need to
|
|
295
|
+
// override duotone applied by global styles and theme.json.
|
|
296
|
+
|
|
297
|
+
// Assuming the selector part is a subclass selector (not a tag name)
|
|
298
|
+
// so we can prepend the filter id class. If we want to support elements
|
|
299
|
+
// such as `img` or namespaces, we'll need to add a case for that here.
|
|
300
|
+
return `.editor-styles-wrapper .${ filterId }${ selectorPart.trim() }`;
|
|
301
|
+
} );
|
|
275
302
|
|
|
276
|
-
const
|
|
277
|
-
getBlockType( name ).selectors?.filter?.duotone ||
|
|
278
|
-
getBlockSupport( name, 'color.__experimentalDuotone' );
|
|
303
|
+
const selector = selectorsScoped.join( ', ' );
|
|
279
304
|
|
|
280
|
-
|
|
281
|
-
// since we're not using inline styles to apply the filter. We need to
|
|
282
|
-
// override duotone applied by global styles and theme.json.
|
|
283
|
-
const selectorsGroup = scopeSelector(
|
|
284
|
-
`.editor-styles-wrapper .${ id }`,
|
|
285
|
-
duotoneSupportSelectors
|
|
286
|
-
);
|
|
305
|
+
const isValidFilter = Array.isArray( colors ) || colors === 'unset';
|
|
287
306
|
|
|
288
|
-
return
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
307
|
+
return (
|
|
308
|
+
element &&
|
|
309
|
+
isValidFilter &&
|
|
310
|
+
createPortal(
|
|
311
|
+
<InlineDuotone
|
|
312
|
+
selector={ selector }
|
|
313
|
+
id={ filterId }
|
|
314
|
+
colors={ colors }
|
|
315
|
+
/>,
|
|
316
|
+
element
|
|
317
|
+
)
|
|
295
318
|
);
|
|
296
319
|
}
|
|
297
320
|
|
|
@@ -304,16 +327,56 @@ function BlockDuotoneStyles( { name, duotoneStyle, id } ) {
|
|
|
304
327
|
*/
|
|
305
328
|
const withDuotoneStyles = createHigherOrderComponent(
|
|
306
329
|
( BlockListBlock ) => ( props ) => {
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
330
|
+
const id = useInstanceId( BlockListBlock );
|
|
331
|
+
|
|
332
|
+
const selector = useMemo( () => {
|
|
333
|
+
const blockType = getBlockType( props.name );
|
|
334
|
+
|
|
335
|
+
if ( blockType ) {
|
|
336
|
+
// Backwards compatibility for `supports.color.__experimentalDuotone`
|
|
337
|
+
// is provided via the `block_type_metadata_settings` filter. If
|
|
338
|
+
// `supports.filter.duotone` has not been set and the
|
|
339
|
+
// experimental property has been, the experimental property
|
|
340
|
+
// value is copied into `supports.filter.duotone`.
|
|
341
|
+
const duotoneSupport = getBlockSupport(
|
|
342
|
+
blockType,
|
|
343
|
+
'filter.duotone',
|
|
344
|
+
false
|
|
345
|
+
);
|
|
346
|
+
if ( ! duotoneSupport ) {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// If the experimental duotone support was set, that value is
|
|
351
|
+
// to be treated as a selector and requires scoping.
|
|
352
|
+
const experimentalDuotone = getBlockSupport(
|
|
353
|
+
blockType,
|
|
354
|
+
'color.__experimentalDuotone',
|
|
355
|
+
false
|
|
356
|
+
);
|
|
357
|
+
if ( experimentalDuotone ) {
|
|
358
|
+
const rootSelector = getBlockCSSSelector( blockType );
|
|
359
|
+
return typeof experimentalDuotone === 'string'
|
|
360
|
+
? scopeSelector( rootSelector, experimentalDuotone )
|
|
361
|
+
: rootSelector;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// Regular filter.duotone support uses filter.duotone selectors with fallbacks.
|
|
365
|
+
return getBlockCSSSelector( blockType, 'filter.duotone', {
|
|
366
|
+
fallback: true,
|
|
367
|
+
} );
|
|
368
|
+
}
|
|
369
|
+
}, [ props.name ] );
|
|
370
|
+
|
|
371
|
+
const attribute = props?.attributes?.style?.color?.duotone;
|
|
372
|
+
|
|
373
|
+
const filterClass = `wp-duotone-${ id }`;
|
|
374
|
+
|
|
375
|
+
const shouldRender = selector && attribute;
|
|
376
|
+
|
|
377
|
+
const className = shouldRender
|
|
378
|
+
? classnames( props?.className, filterClass )
|
|
315
379
|
: props?.className;
|
|
316
|
-
const duotoneStyle = props?.attributes?.style?.color?.duotone;
|
|
317
380
|
|
|
318
381
|
// CAUTION: code added before this line will be executed
|
|
319
382
|
// for all blocks, not just those that support duotone. Code added
|
|
@@ -321,11 +384,11 @@ const withDuotoneStyles = createHigherOrderComponent(
|
|
|
321
384
|
// performance.
|
|
322
385
|
return (
|
|
323
386
|
<>
|
|
324
|
-
{
|
|
325
|
-
<
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
387
|
+
{ shouldRender && (
|
|
388
|
+
<DuotoneStyles
|
|
389
|
+
id={ filterClass }
|
|
390
|
+
selector={ selector }
|
|
391
|
+
attribute={ attribute }
|
|
329
392
|
/>
|
|
330
393
|
) }
|
|
331
394
|
<BlockListBlock { ...props } className={ className } />
|