@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
|
@@ -5,7 +5,9 @@ import { createBlobURL } from '@wordpress/blob';
|
|
|
5
5
|
|
|
6
6
|
export function filePasteHandler( files ) {
|
|
7
7
|
return files
|
|
8
|
-
.filter( ( { type } ) =>
|
|
8
|
+
.filter( ( { type } ) =>
|
|
9
|
+
/^image\/(?:jpe?g|png|gif|webp)$/.test( type )
|
|
10
|
+
)
|
|
9
11
|
.map( ( file ) => `<img src="${ createBlobURL( file ) }">` )
|
|
10
12
|
.join( '' );
|
|
11
13
|
}
|
|
@@ -400,6 +400,7 @@ function RichTextWrapper(
|
|
|
400
400
|
deprecated( 'wp.blockEditor.RichText wrapperClassName prop', {
|
|
401
401
|
since: '5.4',
|
|
402
402
|
alternative: 'className prop or create your own wrapper div',
|
|
403
|
+
version: '6.2',
|
|
403
404
|
} );
|
|
404
405
|
|
|
405
406
|
const className = classnames( 'block-editor-rich-text', wrapperClassName );
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { insert } from '@wordpress/rich-text';
|
|
5
|
+
|
|
6
|
+
export function preventEventDiscovery( value ) {
|
|
7
|
+
const searchText = 'tales of gutenberg';
|
|
8
|
+
const addText =
|
|
9
|
+
' 🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️';
|
|
10
|
+
const { start, text } = value;
|
|
11
|
+
|
|
12
|
+
if ( start < searchText.length ) {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const charactersBefore = text.slice( start - searchText.length, start );
|
|
17
|
+
|
|
18
|
+
if ( charactersBefore.toLowerCase() !== searchText ) {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return insert( value, addText );
|
|
23
|
+
}
|
|
@@ -11,6 +11,7 @@ import { useDispatch } from '@wordpress/data';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import { store as blockEditorStore } from '../../store';
|
|
14
|
+
import { preventEventDiscovery } from './prevent-event-discovery';
|
|
14
15
|
|
|
15
16
|
export function useInputRules( props ) {
|
|
16
17
|
const {
|
|
@@ -85,7 +86,7 @@ export function useInputRules( props ) {
|
|
|
85
86
|
|
|
86
87
|
return accumlator;
|
|
87
88
|
},
|
|
88
|
-
value
|
|
89
|
+
preventEventDiscovery( value )
|
|
89
90
|
);
|
|
90
91
|
|
|
91
92
|
if ( transformed !== value ) {
|
|
@@ -155,9 +155,22 @@ export function usePasteHandler( props ) {
|
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
|
|
158
|
+
// Process any attached files, unless we detect Microsoft Office as
|
|
159
|
+
// the source.
|
|
160
|
+
//
|
|
161
|
+
// When content is copied from Microsoft Office, an image of the
|
|
162
|
+
// content is rendered and attached to the clipboard along with the
|
|
163
|
+
// plain-text and HTML content. This artifact is a distraction from
|
|
164
|
+
// the relevant clipboard data, so we ignore it.
|
|
165
|
+
//
|
|
166
|
+
// Props https://github.com/pubpub/pubpub/commit/2f933277a15a263a1ab4bbd36b96d3a106544aec
|
|
167
|
+
if (
|
|
168
|
+
files &&
|
|
169
|
+
files.length &&
|
|
170
|
+
! html?.includes(
|
|
171
|
+
'xmlns:o="urn:schemas-microsoft-com:office:office'
|
|
172
|
+
)
|
|
173
|
+
) {
|
|
161
174
|
const content = pasteHandler( {
|
|
162
175
|
HTML: filePasteHandler( files ),
|
|
163
176
|
mode: 'BLOCKS',
|
|
@@ -147,6 +147,11 @@ _Optional._ If this property is added, a label will be generated using label pro
|
|
|
147
147
|
|
|
148
148
|
_Optional._ Adds and optional class to the parent `div` that wraps the URLInput field and popover
|
|
149
149
|
|
|
150
|
+
### `placeholder: String`
|
|
151
|
+
|
|
152
|
+
_Optional._ Placeholder text to show when the field is empty, similar to the
|
|
153
|
+
[`input` and `textarea` attribute of the same name](https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/HTML5_updates#The_placeholder_attribute).
|
|
154
|
+
|
|
150
155
|
### `disableSuggestions: Boolean`
|
|
151
156
|
|
|
152
157
|
_Optional._ Provides additional control over whether suggestions are disabled.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { hasBlockSupport } from '@wordpress/blocks';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { useBlockEditContext } from '../block-edit/context';
|
|
11
|
+
import { store as blockEditorStore } from '../../store';
|
|
12
|
+
|
|
13
|
+
export default function useDisplayBlockControls() {
|
|
14
|
+
const { isSelected, clientId, name } = useBlockEditContext();
|
|
15
|
+
return useSelect(
|
|
16
|
+
( select ) => {
|
|
17
|
+
const { getBlockName, getBlockRootClientId } = select(
|
|
18
|
+
blockEditorStore
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const parentId = getBlockRootClientId( clientId );
|
|
22
|
+
const parentBlockName = getBlockName( parentId );
|
|
23
|
+
|
|
24
|
+
const hideControls = hasBlockSupport(
|
|
25
|
+
parentBlockName,
|
|
26
|
+
'__experimentalHideChildBlockControls',
|
|
27
|
+
false
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if ( ! hideControls && isSelected ) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return false;
|
|
35
|
+
},
|
|
36
|
+
[ clientId, isSelected, name ]
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -256,10 +256,14 @@ export default function useOnBlockDrop( targetRootClientId, targetBlockIndex ) {
|
|
|
256
256
|
const files = getFilesFromDataTransfer( event.dataTransfer );
|
|
257
257
|
const html = event.dataTransfer.getData( 'text/html' );
|
|
258
258
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
/**
|
|
260
|
+
* From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.
|
|
261
|
+
* The order of the checks is important to recognise the HTML drop.
|
|
262
|
+
*/
|
|
263
|
+
if ( html ) {
|
|
262
264
|
_onHTMLDrop( html );
|
|
265
|
+
} else if ( files.length ) {
|
|
266
|
+
_onFilesDrop( files );
|
|
263
267
|
} else {
|
|
264
268
|
_onDrop( event );
|
|
265
269
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { toggleRichText } from '../use-multi-selection';
|
|
5
|
+
|
|
6
|
+
describe( 'toggleRichText', () => {
|
|
7
|
+
function getContainer( isContentEditible ) {
|
|
8
|
+
const container = document.createDocumentFragment();
|
|
9
|
+
[
|
|
10
|
+
'rich-text',
|
|
11
|
+
'rich-text editor-post-title__input',
|
|
12
|
+
'some-other-class',
|
|
13
|
+
].forEach( ( className ) => {
|
|
14
|
+
const element = document.createElement( 'div' );
|
|
15
|
+
element.setAttribute( 'class', className );
|
|
16
|
+
if ( isContentEditible ) {
|
|
17
|
+
element.setAttribute( 'contenteditable', true );
|
|
18
|
+
}
|
|
19
|
+
container.appendChild( element );
|
|
20
|
+
} );
|
|
21
|
+
return container;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
it( 'should set the `contenteditable` attribute on eligible rich text nodes', () => {
|
|
25
|
+
const container = getContainer();
|
|
26
|
+
toggleRichText( container, true );
|
|
27
|
+
let nodes = container.querySelectorAll( '[contenteditable=true]' );
|
|
28
|
+
|
|
29
|
+
expect( nodes ).toHaveLength( 1 );
|
|
30
|
+
expect( nodes[ 0 ].className ).toBe( 'rich-text' );
|
|
31
|
+
|
|
32
|
+
toggleRichText( container, false );
|
|
33
|
+
nodes = container.querySelectorAll( '[contenteditable=true]' );
|
|
34
|
+
expect( nodes ).toHaveLength( 0 );
|
|
35
|
+
} );
|
|
36
|
+
} );
|
|
@@ -15,16 +15,19 @@ import { useSelect } from '@wordpress/data';
|
|
|
15
15
|
import { store as blockEditorStore } from '../../store';
|
|
16
16
|
import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
|
|
17
17
|
|
|
18
|
-
function toggleRichText( container, toggle ) {
|
|
19
|
-
Array.from(
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
export function toggleRichText( container, toggle ) {
|
|
19
|
+
Array.from(
|
|
20
|
+
container.querySelectorAll(
|
|
21
|
+
// Exclude the Post Title from multi-select disable.
|
|
22
|
+
'.rich-text:not( .editor-post-title__input )'
|
|
23
|
+
)
|
|
24
|
+
).forEach( ( node ) => {
|
|
25
|
+
if ( toggle ) {
|
|
26
|
+
node.setAttribute( 'contenteditable', true );
|
|
27
|
+
} else {
|
|
28
|
+
node.removeAttribute( 'contenteditable' );
|
|
26
29
|
}
|
|
27
|
-
);
|
|
30
|
+
} );
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
/**
|
|
@@ -9,7 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
import { addFilter } from '@wordpress/hooks';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
12
|
-
import { useState } from '@wordpress/element';
|
|
12
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
@@ -22,7 +22,11 @@ import {
|
|
|
22
22
|
getColorObjectByAttributeValues,
|
|
23
23
|
} from '../components/colors';
|
|
24
24
|
import useSetting from '../components/use-setting';
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
hasBorderSupport,
|
|
27
|
+
removeBorderAttribute,
|
|
28
|
+
shouldSkipSerialization,
|
|
29
|
+
} from './border';
|
|
26
30
|
import { cleanEmptyObject } from './utils';
|
|
27
31
|
|
|
28
32
|
// Defining empty array here instead of inline avoids unnecessary re-renders of
|
|
@@ -52,15 +56,30 @@ export function BorderColorEdit( props ) {
|
|
|
52
56
|
( colors, origin ) => colors.concat( origin.colors ),
|
|
53
57
|
[]
|
|
54
58
|
);
|
|
59
|
+
const { color: customBorderColor } = style?.border || {};
|
|
55
60
|
const [ colorValue, setColorValue ] = useState(
|
|
56
61
|
() =>
|
|
57
62
|
getColorObjectByAttributeValues(
|
|
58
63
|
availableColors,
|
|
59
64
|
borderColor,
|
|
60
|
-
|
|
65
|
+
customBorderColor
|
|
61
66
|
)?.color
|
|
62
67
|
);
|
|
63
68
|
|
|
69
|
+
// Detect changes in the color attributes and update the colorValue to keep the
|
|
70
|
+
// UI in sync. This is necessary for situations when border controls interact with
|
|
71
|
+
// each other: eg, setting the border width to zero causes the color and style
|
|
72
|
+
// selections to be cleared.
|
|
73
|
+
useEffect( () => {
|
|
74
|
+
setColorValue(
|
|
75
|
+
getColorObjectByAttributeValues(
|
|
76
|
+
availableColors,
|
|
77
|
+
borderColor,
|
|
78
|
+
customBorderColor
|
|
79
|
+
)?.color
|
|
80
|
+
);
|
|
81
|
+
}, [ borderColor, customBorderColor, availableColors ] );
|
|
82
|
+
|
|
64
83
|
const onChangeColor = ( value ) => {
|
|
65
84
|
setColorValue( value );
|
|
66
85
|
|
|
@@ -106,6 +125,39 @@ export function BorderColorEdit( props ) {
|
|
|
106
125
|
);
|
|
107
126
|
}
|
|
108
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Checks if there is a current value in the border color block support
|
|
130
|
+
* attributes.
|
|
131
|
+
*
|
|
132
|
+
* @param {Object} props Block props.
|
|
133
|
+
* @return {boolean} Whether or not the block has a border color value set.
|
|
134
|
+
*/
|
|
135
|
+
export function hasBorderColorValue( props ) {
|
|
136
|
+
const {
|
|
137
|
+
attributes: { borderColor, style },
|
|
138
|
+
} = props;
|
|
139
|
+
|
|
140
|
+
return !! borderColor || !! style?.border?.color;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Resets the border color block support attributes. This can be used when
|
|
145
|
+
* disabling the border color support controls for a block via a progressive
|
|
146
|
+
* discovery panel.
|
|
147
|
+
*
|
|
148
|
+
* @param {Object} props Block props.
|
|
149
|
+
* @param {Object} props.attributes Block's attributes.
|
|
150
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
151
|
+
*/
|
|
152
|
+
export function resetBorderColor( { attributes = {}, setAttributes } ) {
|
|
153
|
+
const { style } = attributes;
|
|
154
|
+
|
|
155
|
+
setAttributes( {
|
|
156
|
+
borderColor: undefined,
|
|
157
|
+
style: removeBorderAttribute( style, 'color' ),
|
|
158
|
+
} );
|
|
159
|
+
}
|
|
160
|
+
|
|
109
161
|
/**
|
|
110
162
|
* Filters registered block settings, extending attributes to include
|
|
111
163
|
* `borderColor` if needed.
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import BorderRadiusControl from '../components/border-radius-control';
|
|
5
5
|
import { cleanEmptyObject } from './utils';
|
|
6
|
+
import { removeBorderAttribute } from './border';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Inspector control panel containing the border radius related configuration.
|
|
@@ -40,3 +41,34 @@ export function BorderRadiusEdit( props ) {
|
|
|
40
41
|
/>
|
|
41
42
|
);
|
|
42
43
|
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Checks if there is a current value in the border radius block support
|
|
47
|
+
* attributes.
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} props Block props.
|
|
50
|
+
* @return {boolean} Whether or not the block has a border radius value set.
|
|
51
|
+
*/
|
|
52
|
+
export function hasBorderRadiusValue( props ) {
|
|
53
|
+
const borderRadius = props.attributes.style?.border?.radius;
|
|
54
|
+
|
|
55
|
+
if ( typeof borderRadius === 'object' ) {
|
|
56
|
+
return Object.entries( borderRadius ).some( Boolean );
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return !! borderRadius;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Resets the border radius block support attributes. This can be used when
|
|
64
|
+
* disabling the border radius support controls for a block via a progressive
|
|
65
|
+
* discovery panel.
|
|
66
|
+
*
|
|
67
|
+
* @param {Object} props Block props.
|
|
68
|
+
* @param {Object} props.attributes Block's attributes.
|
|
69
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
70
|
+
*/
|
|
71
|
+
export function resetBorderRadius( { attributes = {}, setAttributes } ) {
|
|
72
|
+
const { style } = attributes;
|
|
73
|
+
setAttributes( { style: removeBorderAttribute( style, 'radius' ) } );
|
|
74
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import BorderStyleControl from '../components/border-style-control';
|
|
5
5
|
import { cleanEmptyObject } from './utils';
|
|
6
|
+
import { removeBorderAttribute } from './border';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Inspector control for configuring border style property.
|
|
@@ -36,3 +37,28 @@ export const BorderStyleEdit = ( props ) => {
|
|
|
36
37
|
/>
|
|
37
38
|
);
|
|
38
39
|
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Checks if there is a current value in the border style block support
|
|
43
|
+
* attributes.
|
|
44
|
+
*
|
|
45
|
+
* @param {Object} props Block props.
|
|
46
|
+
* @return {boolean} Whether or not the block has a border style value set.
|
|
47
|
+
*/
|
|
48
|
+
export function hasBorderStyleValue( props ) {
|
|
49
|
+
return !! props.attributes.style?.border?.style;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Resets the border style block support attribute. This can be used when
|
|
54
|
+
* disabling the border style support control for a block via a progressive
|
|
55
|
+
* discovery panel.
|
|
56
|
+
*
|
|
57
|
+
* @param {Object} props Block props.
|
|
58
|
+
* @param {Object} props.attributes Block's attributes.
|
|
59
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
60
|
+
*/
|
|
61
|
+
export function resetBorderStyle( { attributes = {}, setAttributes } ) {
|
|
62
|
+
const { style } = attributes;
|
|
63
|
+
setAttributes( { style: removeBorderAttribute( style, 'style' ) } );
|
|
64
|
+
}
|
|
@@ -5,13 +5,14 @@ import {
|
|
|
5
5
|
__experimentalUnitControl as UnitControl,
|
|
6
6
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
7
7
|
} from '@wordpress/components';
|
|
8
|
-
import {
|
|
8
|
+
import { useState } from '@wordpress/element';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
14
|
import { cleanEmptyObject } from './utils';
|
|
15
|
+
import { removeBorderAttribute } from './border';
|
|
15
16
|
import useSetting from '../components/use-setting';
|
|
16
17
|
|
|
17
18
|
const MIN_BORDER_WIDTH = 0;
|
|
@@ -31,25 +32,12 @@ export const BorderWidthEdit = ( props ) => {
|
|
|
31
32
|
|
|
32
33
|
const { width, color: customBorderColor, style: borderStyle } =
|
|
33
34
|
style?.border || {};
|
|
35
|
+
|
|
36
|
+
// Used to temporarily track previous border color & style selections to be
|
|
37
|
+
// able to restore them when border width changes from zero value.
|
|
34
38
|
const [ styleSelection, setStyleSelection ] = useState();
|
|
35
39
|
const [ colorSelection, setColorSelection ] = useState();
|
|
36
|
-
|
|
37
|
-
// Temporarily track previous border color & style selections to be able to
|
|
38
|
-
// restore them when border width changes from zero value.
|
|
39
|
-
useEffect( () => {
|
|
40
|
-
if ( borderStyle !== 'none' ) {
|
|
41
|
-
setStyleSelection( borderStyle );
|
|
42
|
-
}
|
|
43
|
-
}, [ borderStyle ] );
|
|
44
|
-
|
|
45
|
-
useEffect( () => {
|
|
46
|
-
if ( borderColor || customBorderColor ) {
|
|
47
|
-
setColorSelection( {
|
|
48
|
-
name: !! borderColor ? borderColor : undefined,
|
|
49
|
-
color: !! customBorderColor ? customBorderColor : undefined,
|
|
50
|
-
} );
|
|
51
|
-
}
|
|
52
|
-
}, [ borderColor, customBorderColor ] );
|
|
40
|
+
const [ customColorSelection, setCustomColorSelection ] = useState();
|
|
53
41
|
|
|
54
42
|
const onChange = ( newWidth ) => {
|
|
55
43
|
let newStyle = {
|
|
@@ -64,28 +52,39 @@ export const BorderWidthEdit = ( props ) => {
|
|
|
64
52
|
let borderPaletteColor = borderColor;
|
|
65
53
|
|
|
66
54
|
const hasZeroWidth = parseFloat( newWidth ) === 0;
|
|
55
|
+
const hadPreviousZeroWidth = parseFloat( width ) === 0;
|
|
67
56
|
|
|
68
57
|
// Setting the border width explicitly to zero will also set the
|
|
69
58
|
// border style to `none` and clear border color attributes.
|
|
70
|
-
if ( hasZeroWidth ) {
|
|
59
|
+
if ( hasZeroWidth && ! hadPreviousZeroWidth ) {
|
|
60
|
+
// Before clearing color and style selections, keep track of
|
|
61
|
+
// the current selections so they can be restored when the width
|
|
62
|
+
// changes to a non-zero value.
|
|
63
|
+
setColorSelection( borderColor );
|
|
64
|
+
setCustomColorSelection( customBorderColor );
|
|
65
|
+
setStyleSelection( borderStyle );
|
|
66
|
+
|
|
67
|
+
// Clear style and color attributes.
|
|
71
68
|
borderPaletteColor = undefined;
|
|
72
69
|
newStyle.border.color = undefined;
|
|
73
70
|
newStyle.border.style = 'none';
|
|
74
71
|
}
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
if ( ! hasZeroWidth && hadPreviousZeroWidth ) {
|
|
74
|
+
// Restore previous border style selection if width is now not zero and
|
|
75
|
+
// border style was 'none'. This is to support changes to the UI which
|
|
76
|
+
// change the border style UI to a segmented control without a "none"
|
|
77
|
+
// option.
|
|
78
|
+
if ( borderStyle === 'none' ) {
|
|
79
|
+
newStyle.border.style = styleSelection;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Restore previous border color selection if width is no longer zero
|
|
83
|
+
// and current border color is undefined.
|
|
84
|
+
if ( borderColor === undefined ) {
|
|
85
|
+
borderPaletteColor = colorSelection;
|
|
86
|
+
newStyle.border.color = customColorSelection;
|
|
87
|
+
}
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
// If width was reset, clean out undefined styles.
|
|
@@ -113,3 +112,28 @@ export const BorderWidthEdit = ( props ) => {
|
|
|
113
112
|
/>
|
|
114
113
|
);
|
|
115
114
|
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Checks if there is a current value in the border width block support
|
|
118
|
+
* attributes.
|
|
119
|
+
*
|
|
120
|
+
* @param {Object} props Block props.
|
|
121
|
+
* @return {boolean} Whether or not the block has a border width value set.
|
|
122
|
+
*/
|
|
123
|
+
export function hasBorderWidthValue( props ) {
|
|
124
|
+
return !! props.attributes.style?.border?.width;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Resets the border width block support attribute. This can be used when
|
|
129
|
+
* disabling the border width support control for a block via a progressive
|
|
130
|
+
* discovery panel.
|
|
131
|
+
*
|
|
132
|
+
* @param {Object} props Block props.
|
|
133
|
+
* @param {Object} props.attributes Block's attributes.
|
|
134
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
135
|
+
*/
|
|
136
|
+
export function resetBorderWidth( { attributes = {}, setAttributes } ) {
|
|
137
|
+
const { style } = attributes;
|
|
138
|
+
setAttributes( { style: removeBorderAttribute( style, 'width' ) } );
|
|
139
|
+
}
|