@wordpress/block-editor 8.0.17 → 8.1.2-next.f435e9e01b.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/LICENSE.md +1 -1
- package/README.md +19 -6
- package/build/components/block-caption/index.native.js +14 -3
- package/build/components/block-caption/index.native.js.map +1 -1
- package/build/components/block-edit/index.js +9 -0
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +14 -19
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +3 -11
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-media-update-progress/index.native.js +2 -1
- package/build/components/block-media-update-progress/index.native.js.map +1 -1
- package/build/components/block-preview/auto.js +10 -2
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings/container.native.js +2 -1
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +110 -134
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/menu-items.js +63 -0
- package/build/components/block-styles/menu-items.js.map +1 -0
- package/build/components/block-styles/preview-panel.js +45 -0
- package/build/components/block-styles/preview-panel.js.map +1 -0
- package/build/components/block-styles/preview.native.js +2 -2
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-styles/use-styles-for-block.js +119 -0
- package/build/components/block-styles/use-styles-for-block.js.map +1 -0
- package/build/components/block-styles/utils.js +39 -0
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +3 -23
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -1
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +5 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +11 -1
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-types-list/index.native.js +2 -2
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/button-block-appender/index.js +2 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +1 -1
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.native.js +6 -3
- package/build/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
- package/build/components/colors-gradients/tools-panel-color-dropdown.js +89 -0
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
- package/build/components/contrast-checker/index.js +80 -44
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/contrast-checker/index.native.js +108 -0
- package/build/components/contrast-checker/index.native.js.map +1 -0
- package/build/components/default-block-appender/index.js +16 -19
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/default-style-picker/index.js +18 -3
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/iframe/index.js +4 -5
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +18 -18
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +18 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/default-block-appender.js +2 -4
- package/build/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +16 -14
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/index.js +61 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +1 -1
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/library.js +5 -3
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +11 -3
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/search-items.js +3 -1
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/tabs.native.js +7 -4
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +2 -1
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +14 -44
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +3 -5
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +4 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +1 -3
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +6 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.native.js +3 -2
- package/build/components/line-height-control/index.native.js.map +1 -1
- package/build/components/link-control/link-preview.js +1 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-item.js +11 -1
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -1
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +18 -5
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block-contents.js +3 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +26 -4
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +10 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/media-placeholder/index.js +3 -11
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +32 -6
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-replace-flow/index.native.js +13 -0
- package/build/components/media-replace-flow/index.native.js.map +1 -0
- package/build/components/media-upload-progress/index.native.js +2 -1
- package/build/components/media-upload-progress/index.native.js.map +1 -1
- package/build/components/panel-color-settings/index.js +7 -3
- package/build/components/panel-color-settings/index.js.map +1 -1
- package/build/components/provider/block-refs-provider.js +4 -1
- package/build/components/provider/block-refs-provider.js.map +1 -1
- package/build/components/rich-text/file-paste-handler.js +1 -1
- package/build/components/rich-text/file-paste-handler.js.map +1 -1
- package/build/components/rich-text/index.js +2 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +2 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/prevent-event-discovery.js +33 -0
- package/build/components/rich-text/prevent-event-discovery.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +3 -1
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +14 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/rich-text/utils.js +2 -1
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/selection-scroll-into-view/index.js +2 -1
- package/build/components/selection-scroll-into-view/index.js.map +1 -1
- package/build/components/use-display-block-controls/index.native.js +45 -0
- package/build/components/use-display-block-controls/index.native.js.map +1 -0
- package/build/components/use-on-block-drop/index.js +7 -3
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +3 -1
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/hooks/border-color.js +63 -5
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/border-radius.js +47 -0
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border-style.js +41 -0
- package/build/hooks/border-style.js.map +1 -1
- package/build/hooks/border-width.js +70 -31
- package/build/hooks/border-width.js.map +1 -1
- package/build/hooks/border.js +81 -11
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +25 -16
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color-panel.native.js +77 -0
- package/build/hooks/color-panel.native.js.map +1 -0
- package/build/hooks/color.js +179 -12
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-size.js +14 -0
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.native.js +2 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout.native.js +20 -0
- package/build/hooks/layout.native.js.map +1 -0
- package/build/hooks/letter-spacing.js +1 -1
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/typography.native.js +2 -4
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/utils.js +55 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/store/actions.js +1 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +5 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/defaults.native.js +2 -6
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/selectors.js +10 -5
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-paste-event-data.js +1 -1
- package/build/utils/get-paste-event-data.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +1 -1
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-caption/index.native.js +13 -3
- package/build-module/components/block-caption/index.native.js.map +1 -1
- package/build-module/components/block-edit/index.js +9 -0
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +14 -19
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +3 -10
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-media-update-progress/index.native.js +2 -1
- package/build-module/components/block-media-update-progress/index.native.js.map +1 -1
- package/build-module/components/block-preview/auto.js +10 -2
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +2 -1
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +112 -133
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/menu-items.js +50 -0
- package/build-module/components/block-styles/menu-items.js.map +1 -0
- package/build-module/components/block-styles/preview-panel.js +35 -0
- package/build-module/components/block-styles/preview-panel.js.map +1 -0
- package/build-module/components/block-styles/preview.native.js +2 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-styles/use-styles-for-block.js +107 -0
- package/build-module/components/block-styles/use-styles-for-block.js.map +1 -0
- package/build-module/components/block-styles/utils.js +34 -0
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +3 -21
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +2 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +5 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +11 -1
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -2
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +2 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +1 -1
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js +7 -4
- package/build-module/components/colors-gradients/panel-color-gradient-settings.native.js.map +1 -1
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +75 -0
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +1 -0
- package/build-module/components/contrast-checker/index.js +80 -45
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/contrast-checker/index.native.js +90 -0
- package/build-module/components/contrast-checker/index.native.js.map +1 -0
- package/build-module/components/default-block-appender/index.js +15 -18
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +17 -3
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -5
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +2 -2
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +2 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/default-block-appender.js +2 -4
- package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +16 -14
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/index.js +61 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +2 -2
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/library.js +5 -3
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +11 -4
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/search-items.js +3 -1
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +7 -4
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +2 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +15 -44
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +3 -5
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +4 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +1 -3
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +6 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.native.js +3 -2
- package/build-module/components/line-height-control/index.native.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +1 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-item.js +11 -1
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +2 -1
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +18 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +3 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +25 -4
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +8 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +3 -10
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +32 -6
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.native.js +4 -0
- package/build-module/components/media-replace-flow/index.native.js.map +1 -0
- package/build-module/components/media-upload-progress/index.native.js +2 -1
- package/build-module/components/media-upload-progress/index.native.js.map +1 -1
- package/build-module/components/panel-color-settings/index.js +7 -3
- package/build-module/components/panel-color-settings/index.js.map +1 -1
- package/build-module/components/provider/block-refs-provider.js +4 -1
- package/build-module/components/provider/block-refs-provider.js.map +1 -1
- package/build-module/components/rich-text/file-paste-handler.js +1 -1
- package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +2 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.js +25 -0
- package/build-module/components/rich-text/prevent-event-discovery.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +2 -1
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +14 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/utils.js +2 -1
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/selection-scroll-into-view/index.js +2 -1
- package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
- package/build-module/components/use-display-block-controls/index.native.js +34 -0
- package/build-module/components/use-display-block-controls/index.native.js.map +1 -0
- package/build-module/components/use-on-block-drop/index.js +7 -3
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +3 -4
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/hooks/border-color.js +61 -7
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/border-radius.js +42 -0
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border-style.js +36 -0
- package/build-module/hooks/border-style.js.map +1 -1
- package/build-module/hooks/border-width.js +66 -32
- package/build-module/hooks/border-width.js.map +1 -1
- package/build-module/hooks/border.js +80 -12
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +24 -14
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color-panel.native.js +62 -0
- package/build-module/hooks/color-panel.native.js.map +1 -0
- package/build-module/hooks/color.js +177 -13
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-size.js +12 -1
- package/build-module/hooks/font-size.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.native.js +16 -0
- package/build-module/hooks/layout.native.js.map +1 -0
- package/build-module/hooks/letter-spacing.js +1 -1
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/typography.native.js +2 -4
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/utils.js +52 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/store/actions.js +1 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +5 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/defaults.native.js +2 -5
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/selectors.js +10 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-paste-event-data.js +1 -1
- package/build-module/utils/get-paste-event-data.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +1 -1
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +256 -191
- package/build-style/style.css +256 -191
- package/package.json +30 -30
- package/src/components/block-caption/index.native.js +22 -4
- package/src/components/block-card/README.md +1 -1
- package/src/components/block-edit/index.js +8 -0
- package/src/components/block-edit/test/edit.native.js +10 -9
- package/src/components/block-inspector/index.js +18 -16
- package/src/components/block-list-appender/index.js +5 -21
- package/src/components/block-media-update-progress/index.native.js +1 -1
- package/src/components/block-media-update-progress/test/index.native.js +136 -93
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +108 -47
- package/src/components/block-mover/test/index.native.js +5 -5
- package/src/components/block-preview/README.md +14 -26
- package/src/components/block-preview/auto.js +7 -2
- package/src/components/block-preview/test/index.js +2 -0
- package/src/components/block-settings/container.native.js +1 -0
- package/src/components/block-styles/index.js +125 -145
- package/src/components/block-styles/menu-items.js +49 -0
- package/src/components/block-styles/preview-panel.js +36 -0
- package/src/components/block-styles/preview.native.js +5 -2
- package/src/components/block-styles/style.scss +59 -51
- package/src/components/block-styles/test/{index.js → utils.js} +60 -1
- package/src/components/block-styles/use-styles-for-block.js +99 -0
- package/src/components/block-styles/utils.js +39 -0
- package/src/components/block-switcher/block-styles-menu.js +3 -38
- package/src/components/block-tools/back-compat.js +1 -0
- package/src/components/block-tools/block-selection-button.js +7 -1
- package/src/components/block-tools/insertion-point.js +10 -1
- package/src/components/block-types-list/index.native.js +5 -2
- package/src/components/border-radius-control/style.scss +1 -1
- package/src/components/border-style-control/style.scss +0 -1
- package/src/components/button-block-appender/index.js +1 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +9 -5
- package/src/components/colors-gradients/dropdown.js +48 -43
- package/src/components/colors-gradients/panel-color-gradient-settings.native.js +13 -2
- package/src/components/colors-gradients/style.scss +10 -5
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +85 -0
- package/src/components/contrast-checker/README.md +3 -1
- package/src/components/contrast-checker/index.js +107 -64
- package/src/components/contrast-checker/index.native.js +113 -0
- package/src/components/contrast-checker/style.native.scss +26 -0
- package/src/components/contrast-checker/test/index.js +236 -2
- package/src/components/default-block-appender/index.js +17 -24
- package/src/components/default-block-appender/style.scss +4 -0
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +12 -24
- package/src/components/default-block-appender/test/index.js +4 -14
- package/src/components/default-style-picker/index.js +18 -6
- package/src/components/iframe/index.js +7 -3
- package/src/components/index.js +2 -2
- package/src/components/index.native.js +2 -0
- package/src/components/inner-blocks/README.md +2 -0
- package/src/components/inner-blocks/default-block-appender.js +2 -7
- package/src/components/inner-blocks/use-nested-settings-update.js +16 -14
- package/src/components/inserter/index.js +77 -5
- package/src/components/inserter/index.native.js +2 -2
- package/src/components/inserter/library.js +17 -12
- package/src/components/inserter/menu.js +31 -13
- package/src/components/inserter/search-items.js +3 -1
- package/src/components/inserter/tabs.native.js +5 -4
- package/src/components/inserter/test/block-types-tab.native.js +9 -10
- package/src/components/inserter/test/index.native.js +3 -7
- package/src/components/inserter/test/reusable-blocks-tab.native.js +8 -10
- package/src/components/inspector-controls/block-support-slot-container.js +3 -1
- package/src/components/inspector-controls/block-support-tools-panel.js +41 -58
- package/src/components/inspector-controls/fill.native.js +4 -3
- package/src/components/inspector-controls/groups.js +4 -0
- package/src/components/inspector-controls/slot.js +2 -7
- package/src/components/letter-spacing-control/index.js +6 -6
- package/src/components/line-height-control/index.native.js +2 -1
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/link-preview.js +1 -1
- package/src/components/link-control/search-item.js +11 -2
- package/src/components/link-control/search-results.js +1 -0
- package/src/components/link-control/style.scss +5 -10
- package/src/components/link-control/test/index.js +4 -0
- package/src/components/link-control/use-search-handler.js +25 -4
- package/src/components/list-view/block-contents.js +2 -0
- package/src/components/list-view/block-select-button.js +22 -1
- package/src/components/list-view/block.js +11 -0
- package/src/components/media-placeholder/index.js +3 -10
- package/src/components/media-replace-flow/index.js +35 -5
- package/src/components/media-replace-flow/index.native.js +3 -0
- package/src/components/media-upload/test/index.native.js +28 -47
- package/src/components/media-upload-progress/index.native.js +1 -0
- package/src/components/media-upload-progress/test/index.native.js +60 -47
- package/src/components/panel-color-settings/index.js +8 -4
- package/src/components/provider/block-refs-provider.js +4 -1
- package/src/components/rich-text/file-paste-handler.js +3 -1
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/index.native.js +1 -0
- package/src/components/rich-text/prevent-event-discovery.js +23 -0
- package/src/components/rich-text/use-input-rules.js +2 -1
- package/src/components/rich-text/use-paste-handler.js +16 -3
- package/src/components/rich-text/utils.js +1 -0
- package/src/components/selection-scroll-into-view/index.js +1 -0
- package/src/components/url-input/README.md +5 -0
- package/src/components/use-display-block-controls/index.native.js +38 -0
- package/src/components/use-on-block-drop/index.js +7 -3
- package/src/components/writing-flow/test/use-multi-selection.js +36 -0
- package/src/components/writing-flow/use-multi-selection.js +12 -9
- package/src/hooks/border-color.js +55 -3
- package/src/hooks/border-radius.js +32 -0
- package/src/hooks/border-style.js +26 -0
- package/src/hooks/border-width.js +56 -32
- package/src/hooks/border.js +115 -20
- package/src/hooks/border.scss +3 -17
- package/src/hooks/color-panel.js +25 -19
- package/src/hooks/color-panel.native.js +63 -0
- package/src/hooks/color.js +182 -12
- package/src/hooks/color.scss +85 -0
- package/src/hooks/font-size.js +29 -1
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.native.js +23 -0
- package/src/hooks/letter-spacing.js +1 -1
- package/src/hooks/typography.js +1 -1
- package/src/hooks/typography.native.js +1 -3
- package/src/hooks/utils.js +69 -1
- package/src/store/actions.js +1 -2
- package/src/store/defaults.js +2 -1
- package/src/store/defaults.native.js +2 -6
- package/src/store/selectors.js +10 -5
- package/src/style.scss +4 -3
- package/src/utils/get-paste-event-data.js +1 -1
- package/src/utils/parse-css-unit-to-px.js +1 -1
- package/src/utils/test/parse-css-unit-to-px.js +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/preserve-scroll-in-reorder/index.js +0 -22
- package/build/components/preserve-scroll-in-reorder/index.js.map +0 -1
- package/build/components/use-canvas-click-redirect/index.js +0 -66
- package/build/components/use-canvas-click-redirect/index.js.map +0 -1
- package/build-module/components/preserve-scroll-in-reorder/index.js +0 -12
- package/build-module/components/preserve-scroll-in-reorder/index.js.map +0 -1
- package/build-module/components/use-canvas-click-redirect/index.js +0 -54
- package/build-module/components/use-canvas-click-redirect/index.js.map +0 -1
- package/src/components/preserve-scroll-in-reorder/index.js +0 -12
- package/src/components/use-canvas-click-redirect/index.js +0 -57
package/src/hooks/border.js
CHANGED
|
@@ -2,23 +2,41 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
5
|
-
import {
|
|
5
|
+
import { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';
|
|
6
6
|
import { Platform } from '@wordpress/element';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
|
+
import {
|
|
13
|
+
BorderColorEdit,
|
|
14
|
+
hasBorderColorValue,
|
|
15
|
+
resetBorderColor,
|
|
16
|
+
} from './border-color';
|
|
17
|
+
import {
|
|
18
|
+
BorderRadiusEdit,
|
|
19
|
+
hasBorderRadiusValue,
|
|
20
|
+
resetBorderRadius,
|
|
21
|
+
} from './border-radius';
|
|
22
|
+
import {
|
|
23
|
+
BorderStyleEdit,
|
|
24
|
+
hasBorderStyleValue,
|
|
25
|
+
resetBorderStyle,
|
|
26
|
+
} from './border-style';
|
|
27
|
+
import {
|
|
28
|
+
BorderWidthEdit,
|
|
29
|
+
hasBorderWidthValue,
|
|
30
|
+
resetBorderWidth,
|
|
31
|
+
} from './border-width';
|
|
12
32
|
import InspectorControls from '../components/inspector-controls';
|
|
13
33
|
import useSetting from '../components/use-setting';
|
|
14
|
-
import {
|
|
15
|
-
import { BorderRadiusEdit } from './border-radius';
|
|
16
|
-
import { BorderStyleEdit } from './border-style';
|
|
17
|
-
import { BorderWidthEdit } from './border-width';
|
|
34
|
+
import { cleanEmptyObject } from './utils';
|
|
18
35
|
|
|
19
36
|
export const BORDER_SUPPORT_KEY = '__experimentalBorder';
|
|
20
37
|
|
|
21
38
|
export function BorderPanel( props ) {
|
|
39
|
+
const { clientId } = props;
|
|
22
40
|
const isDisabled = useIsBorderDisabled( props );
|
|
23
41
|
const isSupported = hasBorderSupport( props.name );
|
|
24
42
|
|
|
@@ -39,22 +57,80 @@ export function BorderPanel( props ) {
|
|
|
39
57
|
return null;
|
|
40
58
|
}
|
|
41
59
|
|
|
60
|
+
const defaultBorderControls = getBlockSupport( props.name, [
|
|
61
|
+
BORDER_SUPPORT_KEY,
|
|
62
|
+
'__experimentalDefaultControls',
|
|
63
|
+
] );
|
|
64
|
+
|
|
65
|
+
const createResetAllFilter = (
|
|
66
|
+
borderAttribute,
|
|
67
|
+
topLevelAttributes = {}
|
|
68
|
+
) => ( newAttributes ) => ( {
|
|
69
|
+
...newAttributes,
|
|
70
|
+
...topLevelAttributes,
|
|
71
|
+
style: {
|
|
72
|
+
...newAttributes.style,
|
|
73
|
+
border: {
|
|
74
|
+
...newAttributes.style?.border,
|
|
75
|
+
[ borderAttribute ]: undefined,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
} );
|
|
79
|
+
|
|
42
80
|
return (
|
|
43
|
-
<InspectorControls>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
<InspectorControls __experimentalGroup="border">
|
|
82
|
+
{ isWidthSupported && (
|
|
83
|
+
<ToolsPanelItem
|
|
84
|
+
className="single-column"
|
|
85
|
+
hasValue={ () => hasBorderWidthValue( props ) }
|
|
86
|
+
label={ __( 'Width' ) }
|
|
87
|
+
onDeselect={ () => resetBorderWidth( props ) }
|
|
88
|
+
isShownByDefault={ defaultBorderControls?.width }
|
|
89
|
+
resetAllFilter={ createResetAllFilter( 'width' ) }
|
|
90
|
+
panelId={ clientId }
|
|
91
|
+
>
|
|
92
|
+
<BorderWidthEdit { ...props } />
|
|
93
|
+
</ToolsPanelItem>
|
|
94
|
+
) }
|
|
95
|
+
{ isStyleSupported && (
|
|
96
|
+
<ToolsPanelItem
|
|
97
|
+
className="single-column"
|
|
98
|
+
hasValue={ () => hasBorderStyleValue( props ) }
|
|
99
|
+
label={ __( 'Style' ) }
|
|
100
|
+
onDeselect={ () => resetBorderStyle( props ) }
|
|
101
|
+
isShownByDefault={ defaultBorderControls?.style }
|
|
102
|
+
resetAllFilter={ createResetAllFilter( 'style' ) }
|
|
103
|
+
panelId={ clientId }
|
|
104
|
+
>
|
|
105
|
+
<BorderStyleEdit { ...props } />
|
|
106
|
+
</ToolsPanelItem>
|
|
107
|
+
) }
|
|
108
|
+
{ isColorSupported && (
|
|
109
|
+
<ToolsPanelItem
|
|
110
|
+
hasValue={ () => hasBorderColorValue( props ) }
|
|
111
|
+
label={ __( 'Color' ) }
|
|
112
|
+
onDeselect={ () => resetBorderColor( props ) }
|
|
113
|
+
isShownByDefault={ defaultBorderControls?.color }
|
|
114
|
+
resetAllFilter={ createResetAllFilter( 'color', {
|
|
115
|
+
borderColor: undefined,
|
|
116
|
+
} ) }
|
|
117
|
+
panelId={ clientId }
|
|
118
|
+
>
|
|
119
|
+
<BorderColorEdit { ...props } />
|
|
120
|
+
</ToolsPanelItem>
|
|
121
|
+
) }
|
|
122
|
+
{ isRadiusSupported && (
|
|
123
|
+
<ToolsPanelItem
|
|
124
|
+
hasValue={ () => hasBorderRadiusValue( props ) }
|
|
125
|
+
label={ __( 'Radius' ) }
|
|
126
|
+
onDeselect={ () => resetBorderRadius( props ) }
|
|
127
|
+
isShownByDefault={ defaultBorderControls?.radius }
|
|
128
|
+
resetAllFilter={ createResetAllFilter( 'radius' ) }
|
|
129
|
+
panelId={ clientId }
|
|
130
|
+
>
|
|
131
|
+
<BorderRadiusEdit { ...props } />
|
|
132
|
+
</ToolsPanelItem>
|
|
133
|
+
) }
|
|
58
134
|
</InspectorControls>
|
|
59
135
|
);
|
|
60
136
|
}
|
|
@@ -118,3 +194,22 @@ const useIsBorderDisabled = () => {
|
|
|
118
194
|
|
|
119
195
|
return configs.every( Boolean );
|
|
120
196
|
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Returns a new style object where the specified border attribute has been
|
|
200
|
+
* removed.
|
|
201
|
+
*
|
|
202
|
+
* @param {Object} style Styles from block attributes.
|
|
203
|
+
* @param {string} attribute The border style attribute to clear.
|
|
204
|
+
*
|
|
205
|
+
* @return {Object} Style object with the specified attribute removed.
|
|
206
|
+
*/
|
|
207
|
+
export function removeBorderAttribute( style, attribute ) {
|
|
208
|
+
return cleanEmptyObject( {
|
|
209
|
+
...style,
|
|
210
|
+
border: {
|
|
211
|
+
...style?.border,
|
|
212
|
+
[ attribute ]: undefined,
|
|
213
|
+
},
|
|
214
|
+
} );
|
|
215
|
+
}
|
package/src/hooks/border.scss
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
.block-
|
|
2
|
-
.
|
|
3
|
-
|
|
4
|
-
justify-content: space-between;
|
|
5
|
-
|
|
6
|
-
> * {
|
|
7
|
-
width: calc(50% - #{ $grid-unit-10 });
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.components-unit-control-wrapper {
|
|
12
|
-
margin-bottom: $grid-unit-30;
|
|
13
|
-
|
|
14
|
-
&:last-child {
|
|
15
|
-
margin-bottom: $grid-unit-10;
|
|
16
|
-
}
|
|
1
|
+
.border-block-support-panel {
|
|
2
|
+
.single-column {
|
|
3
|
+
grid-column: span 1;
|
|
17
4
|
}
|
|
18
5
|
}
|
|
19
|
-
|
package/src/hooks/color-panel.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useState, useEffect } from '@wordpress/element';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Internal dependencies
|
|
9
8
|
*/
|
|
10
|
-
import PanelColorGradientSettings from '../components/colors-gradients/panel-color-gradient-settings';
|
|
11
9
|
import ContrastChecker from '../components/contrast-checker';
|
|
10
|
+
import ToolsPanelColorDropdown from '../components/colors-gradients/tools-panel-color-dropdown';
|
|
12
11
|
import InspectorControls from '../components/inspector-controls';
|
|
13
12
|
import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
|
|
14
13
|
|
|
@@ -17,13 +16,14 @@ function getComputedStyle( node ) {
|
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
export default function ColorPanel( {
|
|
19
|
+
enableAlpha = false,
|
|
20
20
|
settings,
|
|
21
21
|
clientId,
|
|
22
22
|
enableContrastChecking = true,
|
|
23
|
-
showTitle = true,
|
|
24
23
|
} ) {
|
|
25
24
|
const [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();
|
|
26
25
|
const [ detectedColor, setDetectedColor ] = useState();
|
|
26
|
+
const [ detectedLinkColor, setDetectedLinkColor ] = useState();
|
|
27
27
|
const ref = useBlockRef( clientId );
|
|
28
28
|
|
|
29
29
|
useEffect( () => {
|
|
@@ -36,6 +36,11 @@ export default function ColorPanel( {
|
|
|
36
36
|
}
|
|
37
37
|
setDetectedColor( getComputedStyle( ref.current ).color );
|
|
38
38
|
|
|
39
|
+
const firstLinkElement = ref.current?.querySelector( 'a' );
|
|
40
|
+
if ( firstLinkElement && !! firstLinkElement.innerText ) {
|
|
41
|
+
setDetectedLinkColor( getComputedStyle( firstLinkElement ).color );
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
let backgroundColorNode = ref.current;
|
|
40
45
|
let backgroundColor = getComputedStyle( backgroundColorNode )
|
|
41
46
|
.backgroundColor;
|
|
@@ -54,22 +59,23 @@ export default function ColorPanel( {
|
|
|
54
59
|
} );
|
|
55
60
|
|
|
56
61
|
return (
|
|
57
|
-
<InspectorControls>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
<InspectorControls __experimentalGroup="color">
|
|
63
|
+
{ settings.map( ( setting, index ) => (
|
|
64
|
+
<ToolsPanelColorDropdown
|
|
65
|
+
key={ index }
|
|
66
|
+
settings={ setting }
|
|
67
|
+
panelId={ clientId }
|
|
68
|
+
enableAlpha={ enableAlpha }
|
|
69
|
+
/>
|
|
70
|
+
) ) }
|
|
71
|
+
{ enableContrastChecking && (
|
|
72
|
+
<ContrastChecker
|
|
73
|
+
backgroundColor={ detectedBackgroundColor }
|
|
74
|
+
textColor={ detectedColor }
|
|
75
|
+
enableAlphaChecker={ enableAlpha }
|
|
76
|
+
linkColor={ detectedLinkColor }
|
|
77
|
+
/>
|
|
78
|
+
) }
|
|
73
79
|
</InspectorControls>
|
|
74
80
|
);
|
|
75
81
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { useEffect, useState } 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 '../components/colors-gradients/panel-color-gradient-settings';
|
|
14
|
+
import ContrastChecker from '../components/contrast-checker';
|
|
15
|
+
import InspectorControls from '../components/inspector-controls';
|
|
16
|
+
|
|
17
|
+
const ColorPanel = ( { settings } ) => {
|
|
18
|
+
const globalStyles = useGlobalStyles();
|
|
19
|
+
|
|
20
|
+
const [ detectedBackgroundColor, setDetectedBackgroundColor ] = useState();
|
|
21
|
+
const [ detectedTextColor, setDetectedTextColor ] = useState();
|
|
22
|
+
|
|
23
|
+
const { baseGlobalStyles } = useSelect( ( select ) => {
|
|
24
|
+
const { getSettings } = select( blockEditorStore );
|
|
25
|
+
return {
|
|
26
|
+
baseGlobalStyles: getSettings()
|
|
27
|
+
?.__experimentalGlobalStylesBaseStyles?.color,
|
|
28
|
+
};
|
|
29
|
+
} );
|
|
30
|
+
|
|
31
|
+
useEffect( () => {
|
|
32
|
+
// The following logic is used to determine current text/background colors:
|
|
33
|
+
// 1. The globalStyles object is queried to determine whether a color has been
|
|
34
|
+
// set via a block's settings.
|
|
35
|
+
// 2. If a block-based theme is in use and no globalStyles exist, the theme's
|
|
36
|
+
// default/base colors are used.
|
|
37
|
+
// 3. If no globalStyles exist and a theme isn't block-based, there is no way
|
|
38
|
+
// to determine the default text/background color and the checker won't run.
|
|
39
|
+
const textColor = globalStyles?.color || baseGlobalStyles?.text;
|
|
40
|
+
const backgroundColor =
|
|
41
|
+
globalStyles?.backgroundColor || baseGlobalStyles?.background;
|
|
42
|
+
|
|
43
|
+
setDetectedTextColor( textColor );
|
|
44
|
+
setDetectedBackgroundColor( backgroundColor );
|
|
45
|
+
}, [ globalStyles, baseGlobalStyles ] );
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<InspectorControls>
|
|
49
|
+
<PanelColorGradientSettings
|
|
50
|
+
title={ __( 'Color' ) }
|
|
51
|
+
initialOpen={ false }
|
|
52
|
+
settings={ settings }
|
|
53
|
+
>
|
|
54
|
+
<ContrastChecker
|
|
55
|
+
backgroundColor={ detectedBackgroundColor }
|
|
56
|
+
textColor={ detectedTextColor }
|
|
57
|
+
/>
|
|
58
|
+
</PanelColorGradientSettings>
|
|
59
|
+
</InspectorControls>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default ColorPanel;
|
package/src/hooks/color.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { isObject
|
|
5
|
+
import { isObject } from 'lodash';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
getGradientValueBySlug,
|
|
27
27
|
getGradientSlugByValue,
|
|
28
28
|
} from '../components/gradients';
|
|
29
|
-
import { cleanEmptyObject } from './utils';
|
|
29
|
+
import { cleanEmptyObject, transformStyles, immutableSet } from './utils';
|
|
30
30
|
import ColorPanel from './color-panel';
|
|
31
31
|
import useSetting from '../components/use-setting';
|
|
32
32
|
|
|
@@ -77,6 +77,125 @@ const hasTextColorSupport = ( blockType ) => {
|
|
|
77
77
|
return colorSupport && colorSupport.text !== false;
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Checks whether a color has been set either with a named preset color in
|
|
82
|
+
* a top level block attribute or as a custom value within the style attribute
|
|
83
|
+
* object.
|
|
84
|
+
*
|
|
85
|
+
* @param {string} name Name of the color to check.
|
|
86
|
+
* @return {boolean} Whether or not a color has a value.
|
|
87
|
+
*/
|
|
88
|
+
const hasColor = ( name ) => ( props ) => {
|
|
89
|
+
if ( name === 'background' ) {
|
|
90
|
+
return (
|
|
91
|
+
!! props.attributes.backgroundColor ||
|
|
92
|
+
!! props.attributes.style?.color?.background ||
|
|
93
|
+
!! props.attributes.gradient ||
|
|
94
|
+
!! props.attributes.style?.color?.gradient
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if ( name === 'link' ) {
|
|
99
|
+
return !! props.attributes.style?.elements?.link?.color?.text;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
!! props.attributes[ `${ name }Color` ] ||
|
|
104
|
+
!! props.attributes.style?.color?.[ name ]
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Clears a single color property from a style object.
|
|
110
|
+
*
|
|
111
|
+
* @param {Array} path Path to color property to clear within styles object.
|
|
112
|
+
* @param {Object} style Block attributes style object.
|
|
113
|
+
* @return {Object} Styles with the color property omitted.
|
|
114
|
+
*/
|
|
115
|
+
const clearColorFromStyles = ( path, style ) =>
|
|
116
|
+
cleanEmptyObject( immutableSet( style, path, undefined ) );
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Resets the block attributes for text color.
|
|
120
|
+
*
|
|
121
|
+
* @param {Object} props Current block props.
|
|
122
|
+
* @param {Object} props.attributes Block attributes.
|
|
123
|
+
* @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.
|
|
124
|
+
*/
|
|
125
|
+
const resetTextColor = ( { attributes, setAttributes } ) => {
|
|
126
|
+
setAttributes( {
|
|
127
|
+
textColor: undefined,
|
|
128
|
+
style: clearColorFromStyles( [ 'color', 'text' ], attributes.style ),
|
|
129
|
+
} );
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Clears text color related properties from supplied attributes.
|
|
134
|
+
*
|
|
135
|
+
* @param {Object} attributes Block attributes.
|
|
136
|
+
* @return {Object} Update block attributes with text color properties omitted.
|
|
137
|
+
*/
|
|
138
|
+
const resetAllTextFilter = ( attributes ) => ( {
|
|
139
|
+
textColor: undefined,
|
|
140
|
+
style: clearColorFromStyles( [ 'color', 'text' ], attributes.style ),
|
|
141
|
+
} );
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Resets the block attributes for link color.
|
|
145
|
+
*
|
|
146
|
+
* @param {Object} props Current block props.
|
|
147
|
+
* @param {Object} props.attributes Block attributes.
|
|
148
|
+
* @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.
|
|
149
|
+
*/
|
|
150
|
+
const resetLinkColor = ( { attributes, setAttributes } ) => {
|
|
151
|
+
const path = [ 'elements', 'link', 'color', 'text' ];
|
|
152
|
+
setAttributes( { style: clearColorFromStyles( path, attributes.style ) } );
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Clears link color related properties from supplied attributes.
|
|
157
|
+
*
|
|
158
|
+
* @param {Object} attributes Block attributes.
|
|
159
|
+
* @return {Object} Update block attributes with link color properties omitted.
|
|
160
|
+
*/
|
|
161
|
+
const resetAllLinkFilter = ( attributes ) => ( {
|
|
162
|
+
style: clearColorFromStyles(
|
|
163
|
+
[ 'elements', 'link', 'color', 'text' ],
|
|
164
|
+
attributes.style
|
|
165
|
+
),
|
|
166
|
+
} );
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Clears all background color related properties including gradients from
|
|
170
|
+
* supplied block attributes.
|
|
171
|
+
*
|
|
172
|
+
* @param {Object} attributes Block attributes.
|
|
173
|
+
* @return {Object} Block attributes with background and gradient omitted.
|
|
174
|
+
*/
|
|
175
|
+
const clearBackgroundAndGradient = ( attributes ) => ( {
|
|
176
|
+
backgroundColor: undefined,
|
|
177
|
+
gradient: undefined,
|
|
178
|
+
style: {
|
|
179
|
+
...attributes.style,
|
|
180
|
+
color: {
|
|
181
|
+
...attributes.style?.color,
|
|
182
|
+
background: undefined,
|
|
183
|
+
gradient: undefined,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
} );
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Resets the block attributes for both background color and gradient.
|
|
190
|
+
*
|
|
191
|
+
* @param {Object} props Current block props.
|
|
192
|
+
* @param {Object} props.attributes Block attributes.
|
|
193
|
+
* @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.
|
|
194
|
+
*/
|
|
195
|
+
const resetBackgroundAndGradient = ( { attributes, setAttributes } ) => {
|
|
196
|
+
setAttributes( clearBackgroundAndGradient( attributes ) );
|
|
197
|
+
};
|
|
198
|
+
|
|
80
199
|
/**
|
|
81
200
|
* Filters registered block settings, extending attributes to include
|
|
82
201
|
* `backgroundColor` and `textColor` attribute.
|
|
@@ -136,7 +255,7 @@ export function addSaveProps( props, blockType, attributes ) {
|
|
|
136
255
|
|
|
137
256
|
const hasGradient = hasGradientSupport( blockType );
|
|
138
257
|
|
|
139
|
-
// I'd have
|
|
258
|
+
// I'd have preferred to avoid the "style" attribute usage here
|
|
140
259
|
const { backgroundColor, textColor, gradient, style } = attributes;
|
|
141
260
|
|
|
142
261
|
const backgroundClass = getColorClassName(
|
|
@@ -168,7 +287,7 @@ export function addSaveProps( props, blockType, attributes ) {
|
|
|
168
287
|
}
|
|
169
288
|
|
|
170
289
|
/**
|
|
171
|
-
* Filters registered block settings to
|
|
290
|
+
* Filters registered block settings to extend the block edit wrapper
|
|
172
291
|
* to apply the desired styles and classnames properly.
|
|
173
292
|
*
|
|
174
293
|
* @param {Object} settings Original block settings.
|
|
@@ -203,10 +322,6 @@ const getLinkColorFromAttributeValue = ( colors, value ) => {
|
|
|
203
322
|
return value;
|
|
204
323
|
};
|
|
205
324
|
|
|
206
|
-
function immutableSet( object, path, value ) {
|
|
207
|
-
return setWith( object ? clone( object ) : {}, path, value, clone );
|
|
208
|
-
}
|
|
209
|
-
|
|
210
325
|
/**
|
|
211
326
|
* Inspector control panel containing the color related configuration
|
|
212
327
|
*
|
|
@@ -371,13 +486,19 @@ export function ColorEdit( props ) {
|
|
|
371
486
|
props.setAttributes( { style: newStyle } );
|
|
372
487
|
};
|
|
373
488
|
|
|
489
|
+
const enableContrastChecking =
|
|
490
|
+
Platform.OS === 'web' && ! gradient && ! style?.color?.gradient;
|
|
491
|
+
|
|
492
|
+
const defaultColorControls = getBlockSupport( props.name, [
|
|
493
|
+
COLOR_SUPPORT_KEY,
|
|
494
|
+
'__experimentalDefaultControls',
|
|
495
|
+
] );
|
|
496
|
+
|
|
374
497
|
return (
|
|
375
498
|
<ColorPanel
|
|
376
|
-
enableContrastChecking={
|
|
377
|
-
// Turn on contrast checker for web only since it's not supported on mobile yet.
|
|
378
|
-
Platform.OS === 'web' && ! gradient && ! style?.color?.gradient
|
|
379
|
-
}
|
|
499
|
+
enableContrastChecking={ enableContrastChecking }
|
|
380
500
|
clientId={ props.clientId }
|
|
501
|
+
enableAlpha={ true }
|
|
381
502
|
settings={ [
|
|
382
503
|
...( hasTextColor
|
|
383
504
|
? [
|
|
@@ -389,6 +510,10 @@ export function ColorEdit( props ) {
|
|
|
389
510
|
textColor,
|
|
390
511
|
style?.color?.text
|
|
391
512
|
).color,
|
|
513
|
+
isShownByDefault: defaultColorControls?.text,
|
|
514
|
+
hasValue: () => hasColor( 'text' )( props ),
|
|
515
|
+
onDeselect: () => resetTextColor( props ),
|
|
516
|
+
resetAllFilter: resetAllTextFilter,
|
|
392
517
|
},
|
|
393
518
|
]
|
|
394
519
|
: [] ),
|
|
@@ -408,6 +533,13 @@ export function ColorEdit( props ) {
|
|
|
408
533
|
onGradientChange: hasGradientColor
|
|
409
534
|
? onChangeGradient
|
|
410
535
|
: undefined,
|
|
536
|
+
isShownByDefault:
|
|
537
|
+
defaultColorControls?.background,
|
|
538
|
+
hasValue: () =>
|
|
539
|
+
hasColor( 'background' )( props ),
|
|
540
|
+
onDeselect: () =>
|
|
541
|
+
resetBackgroundAndGradient( props ),
|
|
542
|
+
resetAllFilter: clearBackgroundAndGradient,
|
|
411
543
|
},
|
|
412
544
|
]
|
|
413
545
|
: [] ),
|
|
@@ -422,6 +554,10 @@ export function ColorEdit( props ) {
|
|
|
422
554
|
),
|
|
423
555
|
clearable: !! style?.elements?.link?.color
|
|
424
556
|
?.text,
|
|
557
|
+
isShownByDefault: defaultColorControls?.link,
|
|
558
|
+
hasValue: () => hasColor( 'link' )( props ),
|
|
559
|
+
onDeselect: () => resetLinkColor( props ),
|
|
560
|
+
resetAllFilter: resetAllLinkFilter,
|
|
425
561
|
},
|
|
426
562
|
]
|
|
427
563
|
: [] ),
|
|
@@ -484,6 +620,34 @@ export const withColorPaletteStyles = createHigherOrderComponent(
|
|
|
484
620
|
}
|
|
485
621
|
);
|
|
486
622
|
|
|
623
|
+
const MIGRATION_PATHS = {
|
|
624
|
+
linkColor: [ [ 'style', 'elements', 'link', 'color', 'text' ] ],
|
|
625
|
+
textColor: [ [ 'textColor' ], [ 'style', 'color', 'text' ] ],
|
|
626
|
+
backgroundColor: [
|
|
627
|
+
[ 'backgroundColor' ],
|
|
628
|
+
[ 'style', 'color', 'background' ],
|
|
629
|
+
],
|
|
630
|
+
gradient: [ [ 'gradient' ], [ 'style', 'color', 'gradient' ] ],
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
export function addTransforms( result, source, index, results ) {
|
|
634
|
+
const destinationBlockType = result.name;
|
|
635
|
+
const activeSupports = {
|
|
636
|
+
linkColor: hasLinkColorSupport( destinationBlockType ),
|
|
637
|
+
textColor: hasTextColorSupport( destinationBlockType ),
|
|
638
|
+
backgroundColor: hasBackgroundColorSupport( destinationBlockType ),
|
|
639
|
+
gradient: hasGradientSupport( destinationBlockType ),
|
|
640
|
+
};
|
|
641
|
+
return transformStyles(
|
|
642
|
+
activeSupports,
|
|
643
|
+
MIGRATION_PATHS,
|
|
644
|
+
result,
|
|
645
|
+
source,
|
|
646
|
+
index,
|
|
647
|
+
results
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
|
|
487
651
|
addFilter(
|
|
488
652
|
'blocks.registerBlockType',
|
|
489
653
|
'core/color/addAttribute',
|
|
@@ -507,3 +671,9 @@ addFilter(
|
|
|
507
671
|
'core/color/with-color-palette-styles',
|
|
508
672
|
withColorPaletteStyles
|
|
509
673
|
);
|
|
674
|
+
|
|
675
|
+
addFilter(
|
|
676
|
+
'blocks.switchToBlockType.transformedBlock',
|
|
677
|
+
'core/color/addTransforms',
|
|
678
|
+
addTransforms
|
|
679
|
+
);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
.color-block-support-panel {
|
|
2
|
+
.block-editor-contrast-checker {
|
|
3
|
+
/**
|
|
4
|
+
* Contrast checkers are forced to the bottom of the panel so all
|
|
5
|
+
* injected color controls can appear as a single item group without
|
|
6
|
+
* the contrast checkers suddenly appearing between items.
|
|
7
|
+
*/
|
|
8
|
+
order: 9999;
|
|
9
|
+
grid-column: span 2;
|
|
10
|
+
margin-top: $grid-unit-20;
|
|
11
|
+
|
|
12
|
+
.components-notice__content {
|
|
13
|
+
margin-right: 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Increased specificity required to remove the slot wrapper's row gap */
|
|
18
|
+
&#{&} {
|
|
19
|
+
.color-block-support-panel__inner-wrapper {
|
|
20
|
+
row-gap: 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The following styles replicate the separated border of the
|
|
26
|
+
* `ItemGroup` component but allows for hidden items. This is because
|
|
27
|
+
* to maintain the order of `ToolsPanel` controls, each `ToolsPanelItem`
|
|
28
|
+
* must at least render a placeholder which would otherwise interfere
|
|
29
|
+
* with the `:last-child` styles.
|
|
30
|
+
*/
|
|
31
|
+
.block-editor-tools-panel-color-gradient-settings__item {
|
|
32
|
+
padding: 0;
|
|
33
|
+
|
|
34
|
+
// Border styles.
|
|
35
|
+
border-left: 1px solid rgba(0, 0, 0, 0.1);
|
|
36
|
+
border-right: 1px solid rgba(0, 0, 0, 0.1);
|
|
37
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
38
|
+
|
|
39
|
+
&.first {
|
|
40
|
+
border-top-left-radius: 2px;
|
|
41
|
+
border-top-right-radius: 2px;
|
|
42
|
+
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&.last {
|
|
46
|
+
border-bottom-left-radius: 2px;
|
|
47
|
+
border-bottom-right-radius: 2px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
> div,
|
|
51
|
+
> div > button {
|
|
52
|
+
border-radius: inherit;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.block-editor-panel-color-gradient-settings__color-indicator {
|
|
57
|
+
// Show a diagonal line (crossed out) for empty swatches.
|
|
58
|
+
background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The following few styles fix the layout and spacing for the due to the
|
|
63
|
+
* introduced wrapper element by the `Item` component.
|
|
64
|
+
*/
|
|
65
|
+
.block-editor-tools-panel-color-dropdown {
|
|
66
|
+
display: block;
|
|
67
|
+
padding: 0;
|
|
68
|
+
|
|
69
|
+
> button {
|
|
70
|
+
height: 46px;
|
|
71
|
+
|
|
72
|
+
&.is-open {
|
|
73
|
+
background: $gray-100;
|
|
74
|
+
color: var(--wp-admin-theme-color);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.color-block-support-panel__item-group {
|
|
80
|
+
> div {
|
|
81
|
+
grid-column: span 2;
|
|
82
|
+
border-radius: inherit;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|