@wordpress/block-editor 11.8.0 → 12.1.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 +10 -0
- package/README.md +16 -4
- package/build/components/block-controls/slot.js +12 -4
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-controls/slot.native.js +10 -1
- package/build/components/block-controls/slot.native.js.map +1 -1
- package/build/components/block-draggable/index.js +11 -7
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/use-scroll-when-dragging.js +2 -2
- package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
- 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/block-invalid-warning.native.js +15 -7
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block-list-item-cell.native.js +15 -2
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +158 -195
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +57 -0
- package/build/components/block-list/block-outline.native.js.map +1 -0
- package/build/components/block-list/block.native.js +343 -300
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +202 -298
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/insertion-point.native.js +4 -2
- package/build/components/block-list/insertion-point.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +8 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +15 -4
- package/build/components/block-settings-menu-controls/index.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 +40 -11
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +8 -30
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.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/advanced-panel.js +86 -0
- package/build/components/global-styles/advanced-panel.js.map +1 -0
- package/build/components/global-styles/border-panel.js +2 -32
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +16 -13
- 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 +12 -12
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +1 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +78 -14
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +24 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +10 -10
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +114 -81
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +30 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +24 -8
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/index.js +7 -0
- package/build/components/index.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/inserter-draggable-blocks/index.js +5 -0
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/fill.js +1 -1
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +1 -1
- package/build/components/inspector-controls/fill.native.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/slot.js +3 -6
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls/slot.native.js +1 -1
- package/build/components/inspector-controls/slot.native.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/line-height-control/index.js +7 -2
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +9 -8
- package/build/components/link-control/use-internal-input-value.js.map +1 -1
- package/build/components/list-view/block-contents.js +7 -2
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +9 -3
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +16 -25
- 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 +38 -18
- 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-drop-zone.js +163 -11
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-placeholder/index.js +68 -7
- package/build/components/media-placeholder/index.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/multi-selection-inspector/index.js +2 -2
- package/build/components/multi-selection-inspector/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/leaf-more-menu.js +3 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/preview-options/index.js +6 -1
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +1 -2
- package/build/components/url-input/index.js.map +1 -1
- package/build/hooks/align.js +1 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/border.js +1 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +8 -12
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/duotone.js +29 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout.js +2 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +1 -1
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +1 -1
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/use-editor-wrapper-styles.native.js +255 -0
- package/build/hooks/use-editor-wrapper-styles.native.js.map +1 -0
- package/build/hooks/use-typography-props.js +14 -10
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/hooks/utils.js +15 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/index.native.js +31 -0
- package/build/index.native.js.map +1 -0
- package/build/private-apis.js +10 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +7 -0
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +5 -5
- 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 +72 -0
- package/build/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-module/components/block-controls/slot.js +11 -4
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-controls/slot.native.js +9 -1
- package/build-module/components/block-controls/slot.native.js.map +1 -1
- package/build-module/components/block-draggable/index.js +10 -6
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/use-scroll-when-dragging.js +2 -2
- package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
- 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/block-invalid-warning.native.js +16 -8
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block-list-item-cell.native.js +13 -2
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +160 -190
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +44 -0
- package/build-module/components/block-list/block-outline.native.js.map +1 -0
- package/build-module/components/block-list/block.native.js +341 -299
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +203 -293
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/insertion-point.native.js +4 -2
- package/build-module/components/block-list/insertion-point.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +8 -9
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +13 -5
- package/build-module/components/block-settings-menu-controls/index.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 +37 -11
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +8 -29
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.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/advanced-panel.js +74 -0
- package/build-module/components/global-styles/advanced-panel.js.map +1 -0
- package/build-module/components/global-styles/border-panel.js +2 -32
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +18 -15
- 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 +13 -13
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +2 -2
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +78 -16
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +11 -11
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +112 -81
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +25 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +24 -8
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.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/inserter-draggable-blocks/index.js +4 -0
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +1 -1
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +1 -1
- package/build-module/components/inspector-controls/fill.native.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/slot.js +4 -7
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls/slot.native.js +1 -1
- package/build-module/components/inspector-controls/slot.native.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/line-height-control/index.js +7 -2
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +9 -8
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +7 -3
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +9 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +18 -26
- 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 +39 -19
- 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-drop-zone.js +160 -11
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +66 -7
- package/build-module/components/media-placeholder/index.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/multi-selection-inspector/index.js +2 -2
- package/build-module/components/multi-selection-inspector/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/leaf-more-menu.js +3 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/preview-options/index.js +7 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/hooks/align.js +1 -1
- package/build-module/hooks/align.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/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +8 -11
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/duotone.js +28 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout.js +2 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +1 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +1 -1
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/use-editor-wrapper-styles.native.js +242 -0
- package/build-module/hooks/use-editor-wrapper-styles.native.js.map +1 -0
- package/build-module/hooks/use-typography-props.js +14 -10
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/hooks/utils.js +16 -4
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.native.js +6 -0
- package/build-module/index.native.js.map +1 -0
- package/build-module/private-apis.js +7 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +7 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +4 -4
- 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 +60 -0
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-style/content-rtl.css +9 -7
- package/build-style/content.css +9 -7
- package/build-style/style-rtl.css +257 -56
- package/build-style/style.css +257 -56
- package/package.json +32 -32
- package/src/components/block-breadcrumb/style.scss +2 -1
- package/src/components/block-controls/slot.js +8 -4
- package/src/components/block-controls/slot.native.js +6 -1
- package/src/components/block-draggable/index.js +10 -6
- package/src/components/block-draggable/use-scroll-when-dragging.js +8 -2
- package/src/components/block-info-slot-fill/index.js +24 -0
- package/src/components/block-inspector/index.js +3 -0
- package/src/components/block-list/block-invalid-warning.native.js +17 -9
- package/src/components/block-list/block-list-item-cell.native.js +10 -1
- package/src/components/block-list/block-list-item.native.js +180 -208
- package/src/components/block-list/block-outline.native.js +58 -0
- package/src/components/block-list/block.native.js +564 -524
- package/src/components/block-list/content.scss +16 -16
- package/src/components/block-list/index.native.js +229 -298
- package/src/components/block-list/insertion-point.native.js +2 -2
- package/src/components/block-list/test/block-invalid-warning.native.js +48 -0
- package/src/components/block-list/test/index.native.js +205 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -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-pattern-setup/style.scss +1 -4
- package/src/components/block-patterns-list/style.scss +1 -4
- package/src/components/block-settings-menu/block-settings-dropdown.js +10 -17
- package/src/components/block-settings-menu-controls/index.js +24 -4
- package/src/components/block-styles/style.scss +4 -4
- 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 +64 -15
- package/src/components/block-tools/selected-block-popover.js +11 -46
- package/src/components/block-tools/style.scss +165 -3
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +16 -2
- 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/advanced-panel.js +82 -0
- package/src/components/global-styles/border-panel.js +1 -30
- package/src/components/global-styles/color-panel.js +19 -14
- package/src/components/global-styles/color-panel.native.js +207 -0
- package/src/components/global-styles/dimensions-panel.js +23 -13
- package/src/components/global-styles/effects-panel.js +2 -2
- package/src/components/global-styles/filters-panel.js +90 -17
- package/src/components/global-styles/hooks.js +1 -5
- package/src/components/global-styles/index.js +6 -1
- package/src/components/global-styles/style.scss +16 -1
- package/src/components/global-styles/test/typography-utils.js +63 -22
- package/src/components/global-styles/test/use-global-styles-output.js +126 -4
- package/src/components/global-styles/test/utils.js +57 -1
- package/src/components/global-styles/typography-panel.js +38 -12
- package/src/components/global-styles/use-global-styles-output.js +85 -67
- package/src/components/global-styles/utils.js +27 -0
- package/src/components/image-editor/use-save-image.js +20 -9
- package/src/components/index.js +1 -0
- package/src/components/inserter/block-types-tab.js +9 -6
- package/src/components/inserter/index.js +1 -1
- package/src/components/inserter-draggable-blocks/index.js +4 -0
- package/src/components/inspector-controls/fill.js +1 -1
- package/src/components/inspector-controls/fill.native.js +1 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls/slot.js +4 -9
- package/src/components/inspector-controls/slot.native.js +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/line-height-control/index.js +7 -2
- package/src/components/line-height-control/stories/index.js +1 -1
- package/src/components/link-control/test/index.js +42 -0
- package/src/components/link-control/use-internal-input-value.js +8 -7
- package/src/components/list-view/block-contents.js +26 -20
- package/src/components/list-view/block-select-button.js +11 -2
- package/src/components/list-view/block.js +28 -33
- package/src/components/list-view/drop-indicator.js +67 -22
- package/src/components/list-view/index.js +33 -14
- package/src/components/list-view/leaf.js +1 -0
- package/src/components/list-view/style.scss +18 -3
- package/src/components/list-view/test/use-list-view-drop-zone.js +88 -12
- package/src/components/list-view/use-block-selection.js +1 -1
- package/src/components/list-view/use-list-view-drop-zone.js +194 -11
- package/src/components/media-placeholder/index.js +74 -1
- package/src/components/media-replace-flow/README.md +3 -2
- package/src/components/media-replace-flow/index.js +4 -5
- package/src/components/multi-selection-inspector/index.js +2 -2
- 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/leaf-more-menu.js +2 -1
- package/src/components/preview-options/index.js +9 -2
- package/src/components/spacing-sizes-control/spacing-input-control.js +1 -0
- package/src/components/url-input/index.js +1 -2
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
- package/src/hooks/align.js +2 -1
- package/src/hooks/border.js +2 -1
- package/src/hooks/color.js +2 -1
- package/src/hooks/content-lock-ui.js +3 -15
- package/src/hooks/duotone.js +47 -25
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.js +4 -2
- package/src/hooks/position.js +2 -1
- package/src/hooks/style.js +2 -1
- package/src/hooks/test/anchor.js +113 -0
- package/src/hooks/test/color.js +0 -9
- package/src/hooks/test/use-editor-wrapper-styles.native.js +282 -0
- package/src/hooks/test/use-typography-props.js +49 -4
- package/src/hooks/test/utils.js +20 -101
- package/src/hooks/use-editor-wrapper-styles.native.js +250 -0
- package/src/hooks/use-editor-wrapper-styles.native.scss +11 -0
- package/src/hooks/use-typography-props.js +10 -11
- package/src/hooks/utils.js +20 -3
- package/src/index.native.js +6 -0
- package/src/private-apis.js +6 -0
- package/src/store/actions.js +7 -0
- package/src/utils/object.js +4 -4
- package/src/utils/test/object.js +21 -21
- package/src/utils/transform-styles/index.js +2 -2
- package/src/utils/use-should-contextual-toolbar-show.js +85 -0
- package/tsconfig.json +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/color-panel.native.js +0 -77
- package/build/hooks/color-panel.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/hooks/color-panel.native.js +0 -63
|
@@ -6,18 +6,17 @@
|
|
|
6
6
|
|
|
7
7
|
// Defaults.
|
|
8
8
|
const DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';
|
|
9
|
-
const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '
|
|
9
|
+
const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '320px';
|
|
10
10
|
const DEFAULT_SCALE_FACTOR = 1;
|
|
11
|
-
const
|
|
11
|
+
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;
|
|
12
|
+
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;
|
|
12
13
|
const DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Computes a fluid font-size value that uses clamp(). A minimum and maximum
|
|
16
17
|
* font size OR a single font size can be specified.
|
|
17
18
|
*
|
|
18
|
-
* If a single font size is specified, it is scaled up and down
|
|
19
|
-
* minimumFontSizeFactor and maximumFontSizeFactor to arrive at the minimum and
|
|
20
|
-
* maximum sizes.
|
|
19
|
+
* If a single font size is specified, it is scaled up and down using a logarithmic scale.
|
|
21
20
|
*
|
|
22
21
|
* @example
|
|
23
22
|
* ```js
|
|
@@ -33,14 +32,13 @@ const DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';
|
|
|
33
32
|
* ```
|
|
34
33
|
*
|
|
35
34
|
* @param {Object} args
|
|
36
|
-
* @param {?string} args.minimumViewPortWidth
|
|
37
|
-
* @param {?string} args.maximumViewPortWidth
|
|
38
|
-
* @param {string|number} [args.fontSize]
|
|
39
|
-
* @param {?string} args.maximumFontSize
|
|
40
|
-
* @param {?string} args.minimumFontSize
|
|
41
|
-
* @param {?number} args.scaleFactor
|
|
42
|
-
* @param {?
|
|
43
|
-
* @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.
|
|
35
|
+
* @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.
|
|
36
|
+
* @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.
|
|
37
|
+
* @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.
|
|
38
|
+
* @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.
|
|
39
|
+
* @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.
|
|
40
|
+
* @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.
|
|
41
|
+
* @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.
|
|
44
42
|
*
|
|
45
43
|
* @return {string|null} A font-size value using clamp().
|
|
46
44
|
*/
|
|
@@ -51,7 +49,6 @@ export function getComputedFluidTypographyValue( {
|
|
|
51
49
|
minimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
|
|
52
50
|
maximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
|
|
53
51
|
scaleFactor = DEFAULT_SCALE_FACTOR,
|
|
54
|
-
minimumFontSizeFactor = DEFAULT_MINIMUM_FONT_SIZE_FACTOR,
|
|
55
52
|
minimumFontSizeLimit,
|
|
56
53
|
} ) {
|
|
57
54
|
// Validate incoming settings and set defaults.
|
|
@@ -106,6 +103,26 @@ export function getComputedFluidTypographyValue( {
|
|
|
106
103
|
* the given font size multiplied by the min font size scale factor.
|
|
107
104
|
*/
|
|
108
105
|
if ( ! minimumFontSize ) {
|
|
106
|
+
const fontSizeValueInPx =
|
|
107
|
+
fontSizeParsed.unit === 'px'
|
|
108
|
+
? fontSizeParsed.value
|
|
109
|
+
: fontSizeParsed.value * 16;
|
|
110
|
+
|
|
111
|
+
/*
|
|
112
|
+
* The scale factor is a multiplier that affects how quickly the curve will move towards the minimum,
|
|
113
|
+
* that is, how quickly the size factor reaches 0 given increasing font size values.
|
|
114
|
+
* For a - b * log2(), lower values of b will make the curve move towards the minimum faster.
|
|
115
|
+
* The scale factor is constrained between min and max values.
|
|
116
|
+
*/
|
|
117
|
+
const minimumFontSizeFactor = Math.min(
|
|
118
|
+
Math.max(
|
|
119
|
+
1 - 0.075 * Math.log2( fontSizeValueInPx ),
|
|
120
|
+
DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN
|
|
121
|
+
),
|
|
122
|
+
DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Calculates the minimum font size.
|
|
109
126
|
const calculatedMinimumFontSize = roundToPrecision(
|
|
110
127
|
fontSizeParsed.value * minimumFontSizeFactor,
|
|
111
128
|
3
|
|
@@ -24,7 +24,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
24
24
|
maximumFontSize: '45px',
|
|
25
25
|
} );
|
|
26
26
|
expect( fluidTypographyValues ).toBe(
|
|
27
|
-
'clamp(20px, 1.25rem + ((1vw -
|
|
27
|
+
'clamp(20px, 1.25rem + ((1vw - 3.2px) * 1.953), 45px)'
|
|
28
28
|
);
|
|
29
29
|
} );
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
33
33
|
fontSize: '30px',
|
|
34
34
|
} );
|
|
35
35
|
expect( fluidTypographyValues ).toBe(
|
|
36
|
-
'clamp(
|
|
36
|
+
'clamp(18.959px, 1.185rem + ((1vw - 3.2px) * 0.863), 30px)'
|
|
37
37
|
);
|
|
38
38
|
} );
|
|
39
39
|
|
|
@@ -42,7 +42,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
42
42
|
fontSize: '30px',
|
|
43
43
|
} );
|
|
44
44
|
expect( fluidTypographyValues ).toBe(
|
|
45
|
-
'clamp(
|
|
45
|
+
'clamp(18.959px, 1.185rem + ((1vw - 3.2px) * 0.863), 30px)'
|
|
46
46
|
);
|
|
47
47
|
} );
|
|
48
48
|
|
|
@@ -53,7 +53,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
53
53
|
maximumViewPortWidth: '1000px',
|
|
54
54
|
} );
|
|
55
55
|
expect( fluidTypographyValues ).toBe(
|
|
56
|
-
'clamp(
|
|
56
|
+
'clamp(18.959px, 1.185rem + ((1vw - 5px) * 2.208), 30px)'
|
|
57
57
|
);
|
|
58
58
|
} );
|
|
59
59
|
|
|
@@ -63,18 +63,7 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
63
63
|
scaleFactor: '2',
|
|
64
64
|
} );
|
|
65
65
|
expect( fluidTypographyValues ).toBe(
|
|
66
|
-
'clamp(
|
|
67
|
-
);
|
|
68
|
-
} );
|
|
69
|
-
|
|
70
|
-
it( 'should return a fluid font size when given a min and max font size factor', () => {
|
|
71
|
-
const fluidTypographyValues = getComputedFluidTypographyValue( {
|
|
72
|
-
fontSize: '30px',
|
|
73
|
-
minimumFontSizeFactor: '0.5',
|
|
74
|
-
maximumFontSizeFactor: '2',
|
|
75
|
-
} );
|
|
76
|
-
expect( fluidTypographyValues ).toBe(
|
|
77
|
-
'clamp(15px, 0.938rem + ((1vw - 7.68px) * 1.803), 30px)'
|
|
66
|
+
'clamp(18.959px, 1.185rem + ((1vw - 3.2px) * 1.725), 30px)'
|
|
78
67
|
);
|
|
79
68
|
} );
|
|
80
69
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
TextareaControl,
|
|
6
|
+
Tooltip,
|
|
7
|
+
__experimentalVStack as VStack,
|
|
8
|
+
} from '@wordpress/components';
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { Icon, info } from '@wordpress/icons';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { default as transformStyles } from '../../utils/transform-styles';
|
|
17
|
+
|
|
18
|
+
export default function AdvancedPanel( {
|
|
19
|
+
value,
|
|
20
|
+
onChange,
|
|
21
|
+
inheritedValue = value,
|
|
22
|
+
} ) {
|
|
23
|
+
// Custom CSS
|
|
24
|
+
const [ cssError, setCSSError ] = useState( null );
|
|
25
|
+
const customCSS = inheritedValue?.css;
|
|
26
|
+
function handleOnChange( newValue ) {
|
|
27
|
+
onChange( {
|
|
28
|
+
...value,
|
|
29
|
+
css: newValue,
|
|
30
|
+
} );
|
|
31
|
+
if ( cssError ) {
|
|
32
|
+
const [ transformed ] = transformStyles(
|
|
33
|
+
[ { css: value } ],
|
|
34
|
+
'.editor-styles-wrapper'
|
|
35
|
+
);
|
|
36
|
+
if ( transformed ) {
|
|
37
|
+
setCSSError( null );
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function handleOnBlur( event ) {
|
|
42
|
+
if ( ! event?.target?.value ) {
|
|
43
|
+
setCSSError( null );
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const [ transformed ] = transformStyles(
|
|
48
|
+
[ { css: event.target.value } ],
|
|
49
|
+
'.editor-styles-wrapper'
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
setCSSError(
|
|
53
|
+
transformed === null
|
|
54
|
+
? __( 'There is an error with your CSS structure.' )
|
|
55
|
+
: null
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<VStack spacing={ 3 }>
|
|
61
|
+
<TextareaControl
|
|
62
|
+
label={ __( 'Additional CSS' ) }
|
|
63
|
+
__nextHasNoMarginBottom
|
|
64
|
+
value={ customCSS }
|
|
65
|
+
onChange={ ( newValue ) => handleOnChange( newValue ) }
|
|
66
|
+
onBlur={ handleOnBlur }
|
|
67
|
+
className="block-editor-global-styles-advanced-panel__custom-css-input"
|
|
68
|
+
spellCheck={ false }
|
|
69
|
+
/>
|
|
70
|
+
{ cssError && (
|
|
71
|
+
<Tooltip text={ cssError }>
|
|
72
|
+
<div className="block-editor-global-styles-advanced-panel__custom-css-validation-wrapper">
|
|
73
|
+
<Icon
|
|
74
|
+
icon={ info }
|
|
75
|
+
className="block-editor-global-styles-advanced-panel__custom-css-validation-icon"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
</Tooltip>
|
|
79
|
+
) }
|
|
80
|
+
</VStack>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -45,35 +45,6 @@ function useHasBorderWidthControl( settings ) {
|
|
|
45
45
|
return settings?.border?.width;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function applyFallbackStyle( border ) {
|
|
49
|
-
if ( ! border ) {
|
|
50
|
-
return border;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if ( ! border.style && ( border.color || border.width ) ) {
|
|
54
|
-
return { ...border, style: 'solid' };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return border;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function applyAllFallbackStyles( border ) {
|
|
61
|
-
if ( ! border ) {
|
|
62
|
-
return border;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if ( hasSplitBorders( border ) ) {
|
|
66
|
-
return {
|
|
67
|
-
top: applyFallbackStyle( border.top ),
|
|
68
|
-
right: applyFallbackStyle( border.right ),
|
|
69
|
-
bottom: applyFallbackStyle( border.bottom ),
|
|
70
|
-
left: applyFallbackStyle( border.left ),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return applyFallbackStyle( border );
|
|
75
|
-
}
|
|
76
|
-
|
|
77
48
|
function BorderToolsPanel( {
|
|
78
49
|
resetAllFilter,
|
|
79
50
|
onChange,
|
|
@@ -186,7 +157,7 @@ export default function BorderPanel( {
|
|
|
186
157
|
const onBorderChange = ( newBorder ) => {
|
|
187
158
|
// Ensure we have a visible border style when a border width or
|
|
188
159
|
// color is being selected.
|
|
189
|
-
const updatedBorder =
|
|
160
|
+
const updatedBorder = { ...newBorder };
|
|
190
161
|
|
|
191
162
|
if ( hasSplitBorders( updatedBorder ) ) {
|
|
192
163
|
[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
Button,
|
|
21
21
|
} from '@wordpress/components';
|
|
22
22
|
import { useCallback } from '@wordpress/element';
|
|
23
|
-
import { __ } from '@wordpress/i18n';
|
|
23
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Internal dependencies
|
|
@@ -28,7 +28,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
28
28
|
import ColorGradientControl from '../colors-gradients/control';
|
|
29
29
|
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
|
|
30
30
|
import { getValueFromVariable } from './utils';
|
|
31
|
-
import {
|
|
31
|
+
import { setImmutably } from '../../utils/object';
|
|
32
32
|
|
|
33
33
|
export function useHasColorPanel( settings ) {
|
|
34
34
|
const hasTextPanel = useHasTextPanel( settings );
|
|
@@ -230,6 +230,11 @@ function ColorPanelDropdown( {
|
|
|
230
230
|
{ 'is-open': isOpen }
|
|
231
231
|
),
|
|
232
232
|
'aria-expanded': isOpen,
|
|
233
|
+
'aria-label': sprintf(
|
|
234
|
+
/* translators: %s is the type of color property, e.g., "background" */
|
|
235
|
+
__( 'Color %s styles' ),
|
|
236
|
+
label
|
|
237
|
+
),
|
|
233
238
|
};
|
|
234
239
|
|
|
235
240
|
return (
|
|
@@ -330,7 +335,7 @@ export default function ColorPanel( {
|
|
|
330
335
|
const hasTextColor = () => !! userTextColor;
|
|
331
336
|
const setTextColor = ( newColor ) => {
|
|
332
337
|
onChange(
|
|
333
|
-
|
|
338
|
+
setImmutably(
|
|
334
339
|
value,
|
|
335
340
|
[ 'color', 'text' ],
|
|
336
341
|
encodeColorValue( newColor )
|
|
@@ -347,7 +352,7 @@ export default function ColorPanel( {
|
|
|
347
352
|
const userGradient = decodeValue( value?.color?.gradient );
|
|
348
353
|
const hasBackground = () => !! userBackgroundColor || !! userGradient;
|
|
349
354
|
const setBackgroundColor = ( newColor ) => {
|
|
350
|
-
const newValue =
|
|
355
|
+
const newValue = setImmutably(
|
|
351
356
|
value,
|
|
352
357
|
[ 'color', 'background' ],
|
|
353
358
|
encodeColorValue( newColor )
|
|
@@ -356,7 +361,7 @@ export default function ColorPanel( {
|
|
|
356
361
|
onChange( newValue );
|
|
357
362
|
};
|
|
358
363
|
const setGradient = ( newGradient ) => {
|
|
359
|
-
const newValue =
|
|
364
|
+
const newValue = setImmutably(
|
|
360
365
|
value,
|
|
361
366
|
[ 'color', 'gradient' ],
|
|
362
367
|
encodeGradientValue( newGradient )
|
|
@@ -365,7 +370,7 @@ export default function ColorPanel( {
|
|
|
365
370
|
onChange( newValue );
|
|
366
371
|
};
|
|
367
372
|
const resetBackground = () => {
|
|
368
|
-
const newValue =
|
|
373
|
+
const newValue = setImmutably(
|
|
369
374
|
value,
|
|
370
375
|
[ 'color', 'background' ],
|
|
371
376
|
undefined
|
|
@@ -382,7 +387,7 @@ export default function ColorPanel( {
|
|
|
382
387
|
const userLinkColor = decodeValue( value?.elements?.link?.color?.text );
|
|
383
388
|
const setLinkColor = ( newColor ) => {
|
|
384
389
|
onChange(
|
|
385
|
-
|
|
390
|
+
setImmutably(
|
|
386
391
|
value,
|
|
387
392
|
[ 'elements', 'link', 'color', 'text' ],
|
|
388
393
|
encodeColorValue( newColor )
|
|
@@ -397,7 +402,7 @@ export default function ColorPanel( {
|
|
|
397
402
|
);
|
|
398
403
|
const setHoverLinkColor = ( newColor ) => {
|
|
399
404
|
onChange(
|
|
400
|
-
|
|
405
|
+
setImmutably(
|
|
401
406
|
value,
|
|
402
407
|
[ 'elements', 'link', ':hover', 'color', 'text' ],
|
|
403
408
|
encodeColorValue( newColor )
|
|
@@ -406,12 +411,12 @@ export default function ColorPanel( {
|
|
|
406
411
|
};
|
|
407
412
|
const hasLink = () => !! userLinkColor || !! userHoverLinkColor;
|
|
408
413
|
const resetLink = () => {
|
|
409
|
-
let newValue =
|
|
414
|
+
let newValue = setImmutably(
|
|
410
415
|
value,
|
|
411
416
|
[ 'elements', 'link', ':hover', 'color', 'text' ],
|
|
412
417
|
undefined
|
|
413
418
|
);
|
|
414
|
-
newValue =
|
|
419
|
+
newValue = setImmutably(
|
|
415
420
|
newValue,
|
|
416
421
|
[ 'elements', 'link', 'color', 'text' ],
|
|
417
422
|
undefined
|
|
@@ -591,7 +596,7 @@ export default function ColorPanel( {
|
|
|
591
596
|
elementGradientUserColor
|
|
592
597
|
);
|
|
593
598
|
const resetElement = () => {
|
|
594
|
-
const newValue =
|
|
599
|
+
const newValue = setImmutably(
|
|
595
600
|
value,
|
|
596
601
|
[ 'elements', name, 'color', 'background' ],
|
|
597
602
|
undefined
|
|
@@ -603,7 +608,7 @@ export default function ColorPanel( {
|
|
|
603
608
|
|
|
604
609
|
const setElementTextColor = ( newTextColor ) => {
|
|
605
610
|
onChange(
|
|
606
|
-
|
|
611
|
+
setImmutably(
|
|
607
612
|
value,
|
|
608
613
|
[ 'elements', name, 'color', 'text' ],
|
|
609
614
|
encodeColorValue( newTextColor )
|
|
@@ -611,7 +616,7 @@ export default function ColorPanel( {
|
|
|
611
616
|
);
|
|
612
617
|
};
|
|
613
618
|
const setElementBackgroundColor = ( newBackgroundColor ) => {
|
|
614
|
-
const newValue =
|
|
619
|
+
const newValue = setImmutably(
|
|
615
620
|
value,
|
|
616
621
|
[ 'elements', name, 'color', 'background' ],
|
|
617
622
|
encodeColorValue( newBackgroundColor )
|
|
@@ -620,7 +625,7 @@ export default function ColorPanel( {
|
|
|
620
625
|
onChange( newValue );
|
|
621
626
|
};
|
|
622
627
|
const setElementGradient = ( newGradient ) => {
|
|
623
|
-
const newValue =
|
|
628
|
+
const newValue = setImmutably(
|
|
624
629
|
value,
|
|
625
630
|
[ 'elements', name, 'color', 'gradient' ],
|
|
626
631
|
encodeGradientValue( newGradient )
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { useEffect, useState, useMemo, useCallback } from '@wordpress/element';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { useGlobalStyles } from '@wordpress/components';
|
|
8
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import PanelColorGradientSettings from '../colors-gradients/panel-color-gradient-settings';
|
|
14
|
+
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
|
|
15
|
+
import { getValueFromVariable } from './utils';
|
|
16
|
+
import { setImmutably } from '../../utils/object';
|
|
17
|
+
import ContrastChecker from '../contrast-checker';
|
|
18
|
+
import InspectorControls from '../inspector-controls';
|
|
19
|
+
import {
|
|
20
|
+
useHasColorPanel,
|
|
21
|
+
useHasTextPanel,
|
|
22
|
+
useHasBackgroundPanel,
|
|
23
|
+
} from './color-panel.js';
|
|
24
|
+
|
|
25
|
+
const ColorPanel = ( {
|
|
26
|
+
value,
|
|
27
|
+
inheritedValue = value,
|
|
28
|
+
onChange,
|
|
29
|
+
settings,
|
|
30
|
+
} ) => {
|
|
31
|
+
const colors = useColorsPerOrigin( settings );
|
|
32
|
+
const gradients = useGradientsPerOrigin( settings );
|
|
33
|
+
const globalStyles = useGlobalStyles();
|
|
34
|
+
|
|
35
|
+
const [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();
|
|
36
|
+
const [ detectedTextColor, setDetectedTextColor ] = useState();
|
|
37
|
+
|
|
38
|
+
const { baseGlobalStyles } = useSelect( ( select ) => {
|
|
39
|
+
const { getSettings } = select( blockEditorStore );
|
|
40
|
+
return {
|
|
41
|
+
baseGlobalStyles:
|
|
42
|
+
getSettings()?.__experimentalGlobalStylesBaseStyles?.color,
|
|
43
|
+
};
|
|
44
|
+
} );
|
|
45
|
+
|
|
46
|
+
const decodeValue = ( rawValue ) =>
|
|
47
|
+
getValueFromVariable( { settings }, '', rawValue );
|
|
48
|
+
const encodeColorValue = useCallback(
|
|
49
|
+
( colorValue ) => {
|
|
50
|
+
const allColors = colors.flatMap(
|
|
51
|
+
( { colors: originColors } ) => originColors
|
|
52
|
+
);
|
|
53
|
+
const colorObject = allColors.find(
|
|
54
|
+
( { color } ) => color === colorValue
|
|
55
|
+
);
|
|
56
|
+
return colorObject
|
|
57
|
+
? 'var:preset|color|' + colorObject.slug
|
|
58
|
+
: colorValue;
|
|
59
|
+
},
|
|
60
|
+
[ colors ]
|
|
61
|
+
);
|
|
62
|
+
const encodeGradientValue = useCallback(
|
|
63
|
+
( gradientValue ) => {
|
|
64
|
+
const allGradients = gradients.flatMap(
|
|
65
|
+
( { gradients: originGradients } ) => originGradients
|
|
66
|
+
);
|
|
67
|
+
const gradientObject = allGradients.find(
|
|
68
|
+
( { gradient } ) => gradient === gradientValue
|
|
69
|
+
);
|
|
70
|
+
return gradientObject
|
|
71
|
+
? 'var:preset|gradient|' + gradientObject.slug
|
|
72
|
+
: gradientValue;
|
|
73
|
+
},
|
|
74
|
+
[ gradients ]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// Text Color
|
|
78
|
+
const showTextPanel = useHasTextPanel( settings );
|
|
79
|
+
const textColor = decodeValue( inheritedValue?.color?.text );
|
|
80
|
+
const setTextColor = useCallback(
|
|
81
|
+
( newColor ) => {
|
|
82
|
+
onChange(
|
|
83
|
+
setImmutably(
|
|
84
|
+
value,
|
|
85
|
+
[ 'color', 'text' ],
|
|
86
|
+
encodeColorValue( newColor )
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
},
|
|
90
|
+
[ encodeColorValue, onChange, value ]
|
|
91
|
+
);
|
|
92
|
+
const resetTextColor = useCallback(
|
|
93
|
+
() => setTextColor( undefined ),
|
|
94
|
+
[ setTextColor ]
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
// BackgroundColor
|
|
98
|
+
const showBackgroundPanel = useHasBackgroundPanel( settings );
|
|
99
|
+
const backgroundColor = decodeValue( inheritedValue?.color?.background );
|
|
100
|
+
const gradient = decodeValue( inheritedValue?.color?.gradient );
|
|
101
|
+
const setBackgroundColor = useCallback(
|
|
102
|
+
( newColor ) => {
|
|
103
|
+
const newValue = setImmutably(
|
|
104
|
+
value,
|
|
105
|
+
[ 'color', 'background' ],
|
|
106
|
+
encodeColorValue( newColor )
|
|
107
|
+
);
|
|
108
|
+
newValue.color.gradient = undefined;
|
|
109
|
+
onChange( newValue );
|
|
110
|
+
},
|
|
111
|
+
[ encodeColorValue, onChange, value ]
|
|
112
|
+
);
|
|
113
|
+
const setGradient = useCallback(
|
|
114
|
+
( newGradient ) => {
|
|
115
|
+
const newValue = setImmutably(
|
|
116
|
+
value,
|
|
117
|
+
[ 'color', 'gradient' ],
|
|
118
|
+
encodeGradientValue( newGradient )
|
|
119
|
+
);
|
|
120
|
+
newValue.color.background = undefined;
|
|
121
|
+
onChange( newValue );
|
|
122
|
+
},
|
|
123
|
+
[ encodeGradientValue, onChange, value ]
|
|
124
|
+
);
|
|
125
|
+
const resetBackground = useCallback( () => {
|
|
126
|
+
const newValue = setImmutably(
|
|
127
|
+
value,
|
|
128
|
+
[ 'color', 'background' ],
|
|
129
|
+
undefined
|
|
130
|
+
);
|
|
131
|
+
newValue.color.gradient = undefined;
|
|
132
|
+
onChange( newValue );
|
|
133
|
+
}, [ onChange, value ] );
|
|
134
|
+
const currentGradients = settings?.color?.gradients;
|
|
135
|
+
const withoutGradientsSupport =
|
|
136
|
+
Array.isArray( currentGradients ) && currentGradients.length === 0;
|
|
137
|
+
|
|
138
|
+
const items = useMemo(
|
|
139
|
+
() =>
|
|
140
|
+
[
|
|
141
|
+
showTextPanel && {
|
|
142
|
+
label: __( 'Text' ),
|
|
143
|
+
colorValue: textColor,
|
|
144
|
+
onColorChange: setTextColor,
|
|
145
|
+
onColorCleared: resetTextColor,
|
|
146
|
+
},
|
|
147
|
+
showBackgroundPanel && {
|
|
148
|
+
label: __( 'Background' ),
|
|
149
|
+
colorValue: backgroundColor,
|
|
150
|
+
onColorChange: setBackgroundColor,
|
|
151
|
+
onColorCleared: resetBackground,
|
|
152
|
+
onGradientChange: ! withoutGradientsSupport
|
|
153
|
+
? setGradient
|
|
154
|
+
: undefined,
|
|
155
|
+
gradientValue: gradient,
|
|
156
|
+
},
|
|
157
|
+
].filter( Boolean ),
|
|
158
|
+
[
|
|
159
|
+
backgroundColor,
|
|
160
|
+
gradient,
|
|
161
|
+
resetBackground,
|
|
162
|
+
resetTextColor,
|
|
163
|
+
setBackgroundColor,
|
|
164
|
+
setGradient,
|
|
165
|
+
setTextColor,
|
|
166
|
+
showBackgroundPanel,
|
|
167
|
+
showTextPanel,
|
|
168
|
+
textColor,
|
|
169
|
+
withoutGradientsSupport,
|
|
170
|
+
]
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
useEffect( () => {
|
|
174
|
+
// The following logic is used to determine current text/background colors:
|
|
175
|
+
// 1. The globalStyles object is queried to determine whether a color has been
|
|
176
|
+
// set via a block's settings.
|
|
177
|
+
// 2. If a block-based theme is in use and no globalStyles exist, the theme's
|
|
178
|
+
// default/base colors are used.
|
|
179
|
+
// 3. If no globalStyles exist and a theme isn't block-based, there is no way
|
|
180
|
+
// to determine the default text/background color and the checker won't run.
|
|
181
|
+
const currentDetectedTextColor =
|
|
182
|
+
globalStyles?.color || baseGlobalStyles?.text;
|
|
183
|
+
const currentDetectedBackgroundColor =
|
|
184
|
+
globalStyles?.backgroundColor || baseGlobalStyles?.background;
|
|
185
|
+
|
|
186
|
+
setDetectedTextColor( currentDetectedTextColor );
|
|
187
|
+
setDetectedBackgroundColor( currentDetectedBackgroundColor );
|
|
188
|
+
}, [ globalStyles, baseGlobalStyles ] );
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<InspectorControls>
|
|
192
|
+
<PanelColorGradientSettings
|
|
193
|
+
title={ __( 'Color' ) }
|
|
194
|
+
initialOpen={ false }
|
|
195
|
+
settings={ items }
|
|
196
|
+
>
|
|
197
|
+
<ContrastChecker
|
|
198
|
+
backgroundColor={ detectedBackgroundColor }
|
|
199
|
+
textColor={ detectedTextColor }
|
|
200
|
+
/>
|
|
201
|
+
</PanelColorGradientSettings>
|
|
202
|
+
</InspectorControls>
|
|
203
|
+
);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export { useHasColorPanel };
|
|
207
|
+
export default ColorPanel;
|
|
@@ -28,7 +28,7 @@ import SpacingSizesControl from '../spacing-sizes-control';
|
|
|
28
28
|
import HeightControl from '../height-control';
|
|
29
29
|
import ChildLayoutControl from '../child-layout-control';
|
|
30
30
|
import { cleanEmptyObject } from '../../hooks/utils';
|
|
31
|
-
import {
|
|
31
|
+
import { setImmutably } from '../../utils/object';
|
|
32
32
|
|
|
33
33
|
const AXIAL_SIDES = [ 'horizontal', 'vertical' ];
|
|
34
34
|
|
|
@@ -184,12 +184,12 @@ function DimensionsToolsPanel( {
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
const DEFAULT_CONTROLS = {
|
|
187
|
-
contentSize:
|
|
188
|
-
wideSize:
|
|
189
|
-
padding:
|
|
190
|
-
margin:
|
|
191
|
-
blockGap:
|
|
192
|
-
minHeight:
|
|
187
|
+
contentSize: true,
|
|
188
|
+
wideSize: true,
|
|
189
|
+
padding: true,
|
|
190
|
+
margin: true,
|
|
191
|
+
blockGap: true,
|
|
192
|
+
minHeight: true,
|
|
193
193
|
childLayout: true,
|
|
194
194
|
};
|
|
195
195
|
|
|
@@ -226,7 +226,11 @@ export default function DimensionsPanel( {
|
|
|
226
226
|
const contentSizeValue = decodeValue( inheritedValue?.layout?.contentSize );
|
|
227
227
|
const setContentSizeValue = ( newValue ) => {
|
|
228
228
|
onChange(
|
|
229
|
-
|
|
229
|
+
setImmutably(
|
|
230
|
+
value,
|
|
231
|
+
[ 'layout', 'contentSize' ],
|
|
232
|
+
newValue || undefined
|
|
233
|
+
)
|
|
230
234
|
);
|
|
231
235
|
};
|
|
232
236
|
const hasUserSetContentSizeValue = () => !! value?.layout?.contentSize;
|
|
@@ -237,7 +241,13 @@ export default function DimensionsPanel( {
|
|
|
237
241
|
useHasWideSize( settings ) && includeLayoutControls;
|
|
238
242
|
const wideSizeValue = decodeValue( inheritedValue?.layout?.wideSize );
|
|
239
243
|
const setWideSizeValue = ( newValue ) => {
|
|
240
|
-
onChange(
|
|
244
|
+
onChange(
|
|
245
|
+
setImmutably(
|
|
246
|
+
value,
|
|
247
|
+
[ 'layout', 'wideSize' ],
|
|
248
|
+
newValue || undefined
|
|
249
|
+
)
|
|
250
|
+
);
|
|
241
251
|
};
|
|
242
252
|
const hasUserSetWideSizeValue = () => !! value?.layout?.wideSize;
|
|
243
253
|
const resetWideSizeValue = () => setWideSizeValue( undefined );
|
|
@@ -254,7 +264,7 @@ export default function DimensionsPanel( {
|
|
|
254
264
|
paddingSides.some( ( side ) => AXIAL_SIDES.includes( side ) );
|
|
255
265
|
const setPaddingValues = ( newPaddingValues ) => {
|
|
256
266
|
const padding = filterValuesBySides( newPaddingValues, paddingSides );
|
|
257
|
-
onChange(
|
|
267
|
+
onChange( setImmutably( value, [ 'spacing', 'padding' ], padding ) );
|
|
258
268
|
};
|
|
259
269
|
const hasPaddingValue = () =>
|
|
260
270
|
!! value?.spacing?.padding &&
|
|
@@ -274,7 +284,7 @@ export default function DimensionsPanel( {
|
|
|
274
284
|
marginSides.some( ( side ) => AXIAL_SIDES.includes( side ) );
|
|
275
285
|
const setMarginValues = ( newMarginValues ) => {
|
|
276
286
|
const margin = filterValuesBySides( newMarginValues, marginSides );
|
|
277
|
-
onChange(
|
|
287
|
+
onChange( setImmutably( value, [ 'spacing', 'margin' ], margin ) );
|
|
278
288
|
};
|
|
279
289
|
const hasMarginValue = () =>
|
|
280
290
|
!! value?.spacing?.margin &&
|
|
@@ -293,7 +303,7 @@ export default function DimensionsPanel( {
|
|
|
293
303
|
gapSides && gapSides.some( ( side ) => AXIAL_SIDES.includes( side ) );
|
|
294
304
|
const setGapValue = ( newGapValue ) => {
|
|
295
305
|
onChange(
|
|
296
|
-
|
|
306
|
+
setImmutably( value, [ 'spacing', 'blockGap' ], newGapValue )
|
|
297
307
|
);
|
|
298
308
|
};
|
|
299
309
|
const setGapValues = ( nextBoxGapValue ) => {
|
|
@@ -318,7 +328,7 @@ export default function DimensionsPanel( {
|
|
|
318
328
|
const minHeightValue = decodeValue( inheritedValue?.dimensions?.minHeight );
|
|
319
329
|
const setMinHeightValue = ( newValue ) => {
|
|
320
330
|
onChange(
|
|
321
|
-
|
|
331
|
+
setImmutably( value, [ 'dimensions', 'minHeight' ], newValue )
|
|
322
332
|
);
|
|
323
333
|
};
|
|
324
334
|
const resetMinHeightValue = () => {
|