@wordpress/block-editor 8.6.0 → 9.2.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 +11 -0
- package/README.md +5 -2
- package/build/components/block-alignment-control/constants.js +48 -0
- package/build/components/block-alignment-control/constants.js.map +1 -0
- package/build/components/block-alignment-control/ui.js +9 -40
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +92 -0
- package/build/components/block-alignment-control/ui.native.js.map +1 -0
- package/build/components/block-alignment-matrix-control/index.js +1 -6
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-content-overlay/index.js +4 -82
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.native.js +65 -0
- package/build/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js +157 -0
- package/build/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build/components/block-draggable/index.native.js +488 -0
- package/build/components/block-draggable/index.native.js.map +1 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js +130 -0
- package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build/components/block-list/block-list-context.native.js +195 -0
- package/build/components/block-list/block-list-context.native.js.map +1 -0
- package/build/components/block-list/block-list-item-cell.native.js +67 -0
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build/components/block-list/block-list-item.native.js +12 -9
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block.native.js +27 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +34 -32
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/index.native.js +75 -23
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +8 -4
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +10 -3
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-mover/index.native.js +17 -4
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +11 -5
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-popover/inbetween.js +19 -8
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +20 -16
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +1 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -0
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +1 -29
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +16 -2
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +10 -3
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/color-style-selector/index.js +9 -0
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +122 -41
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +35 -60
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +22 -5
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/iframe/index.js +51 -50
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +3 -1
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/index.js +14 -23
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/index.js +21 -7
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +2 -2
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -5
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/link-control/constants.js +11 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/search-results.js +4 -3
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +4 -4
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/block.js +15 -15
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/context.js +1 -4
- package/build/components/list-view/context.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +0 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +15 -32
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/media-placeholder/index.js +0 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +0 -2
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/index.native.js +10 -4
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +62 -7
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +55 -0
- package/build/components/publish-date-time-picker/index.js.map +1 -0
- package/build/components/rich-text/format-toolbar-container.js +0 -1
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +2 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +5 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/url-input/index.js +11 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +167 -0
- package/build/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build/components/use-on-block-drop/index.native.js +95 -0
- package/build/components/use-on-block-drop/index.native.js.map +1 -0
- package/build/components/use-setting/index.js +42 -18
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/warning/index.js +6 -1
- package/build/components/warning/index.js.map +1 -1
- package/build/components/writing-flow/use-click-selection.js +1 -3
- package/build/components/writing-flow/use-click-selection.js.map +1 -1
- package/build/components/writing-flow/use-input.js +15 -0
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +49 -8
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/elements/index.js +9 -0
- package/build/elements/index.js.map +1 -0
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +2 -7
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +14 -7
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +8 -88
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +16 -6
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/margin.js +64 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +60 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/settings.js +32 -0
- package/build/hooks/settings.js.map +1 -0
- package/build/hooks/style.js +14 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +6 -2
- package/build/hooks/typography.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +5 -2
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +14 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +17 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +43 -13
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +36 -0
- package/build-module/components/block-alignment-control/constants.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +4 -35
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +78 -0
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
- package/build-module/components/block-alignment-matrix-control/index.js +1 -6
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +3 -78
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.native.js +51 -0
- package/build-module/components/block-draggable/draggable-chip.native.js.map +1 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js +137 -0
- package/build-module/components/block-draggable/dropping-insertion-point.native.js.map +1 -0
- package/build-module/components/block-draggable/index.native.js +453 -0
- package/build-module/components/block-draggable/index.native.js.map +1 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +120 -0
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -0
- package/build-module/components/block-list/block-list-context.native.js +179 -0
- package/build-module/components/block-list/block-list-context.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item-cell.native.js +59 -0
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -0
- package/build-module/components/block-list/block-list-item.native.js +12 -9
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block.native.js +26 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +35 -33
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +72 -23
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +9 -5
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +9 -3
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +18 -5
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +10 -5
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +19 -8
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +21 -15
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +1 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -0
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +2 -29
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +13 -2
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +11 -4
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/color-style-selector/index.js +6 -0
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +124 -43
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +36 -64
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +23 -6
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/iframe/index.js +52 -51
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -1
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/index.js +2 -3
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/index.js +21 -7
- 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/quick-inserter.js +4 -5
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/link-control/constants.js +5 -0
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -4
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +5 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/block.js +15 -16
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -13
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/context.js +1 -4
- package/build-module/components/list-view/context.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +0 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +15 -31
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +0 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +0 -2
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +8 -3
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +63 -8
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +42 -0
- package/build-module/components/publish-date-time-picker/index.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar-container.js +0 -1
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -2
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +5 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +11 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +148 -0
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -0
- package/build-module/components/use-on-block-drop/index.native.js +83 -0
- package/build-module/components/use-on-block-drop/index.native.js.map +1 -0
- package/build-module/components/use-setting/index.js +43 -19
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/warning/index.js +6 -1
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/components/writing-flow/use-click-selection.js +1 -3
- package/build-module/components/writing-flow/use-click-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +15 -0
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +49 -8
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/elements/index.js +2 -0
- package/build-module/elements/index.js.map +1 -0
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +2 -7
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +11 -6
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +8 -88
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +19 -9
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/margin.js +61 -13
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +57 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/settings.js +29 -0
- package/build-module/hooks/settings.js.map +1 -0
- package/build-module/hooks/style.js +15 -14
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +6 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +4 -2
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +12 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +17 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +37 -12
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +100 -225
- package/build-style/style.css +100 -225
- package/package.json +30 -30
- package/src/components/block-alignment-control/constants.js +45 -0
- package/src/components/block-alignment-control/ui.js +69 -109
- package/src/components/block-alignment-control/ui.native.js +86 -0
- package/src/components/block-alignment-matrix-control/index.js +1 -5
- package/src/components/block-content-overlay/index.js +8 -95
- package/src/components/block-content-overlay/style.scss +2 -12
- package/src/components/block-draggable/draggable-chip.native.js +49 -0
- package/src/components/block-draggable/dropping-insertion-point.native.js +181 -0
- package/src/components/block-draggable/dropping-insertion-point.native.scss +8 -0
- package/src/components/block-draggable/index.native.js +462 -0
- package/src/components/block-draggable/style.native.scss +19 -0
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +73 -0
- package/src/components/block-draggable/test/helpers.native.js +183 -0
- package/src/components/block-draggable/test/index.native.js +496 -0
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +135 -0
- package/src/components/block-list/block-list-context.native.js +175 -0
- package/src/components/block-list/block-list-item-cell.native.js +49 -0
- package/src/components/block-list/block-list-item.native.js +7 -11
- package/src/components/block-list/block.native.js +37 -8
- package/src/components/block-list/index.js +44 -44
- package/src/components/block-list/index.native.js +54 -13
- package/src/components/block-list/style.scss +7 -18
- package/src/components/block-list/test/block-list-context.native.js +253 -0
- package/src/components/block-list/test/fixtures/block-list-context.native.js +79 -0
- package/src/components/block-list/use-block-props/index.js +10 -5
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
- package/src/components/block-list/use-in-between-inserter.js +1 -1
- package/src/components/block-mobile-toolbar/index.native.js +9 -1
- package/src/components/block-mover/index.native.js +22 -6
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -0
- package/src/components/block-navigation/dropdown.js +12 -8
- package/src/components/block-popover/inbetween.js +21 -8
- package/src/components/block-popover/index.js +18 -15
- package/src/components/block-popover/style.scss +4 -0
- package/src/components/block-preview/index.js +1 -4
- package/src/components/block-switcher/style.scss +2 -39
- package/src/components/block-tools/block-selection-button.js +1 -0
- package/src/components/block-tools/selected-block-popover.js +1 -36
- package/src/components/block-tools/style.scss +1 -12
- package/src/components/block-variation-transforms/index.js +6 -2
- package/src/components/border-radius-control/input-controls.js +16 -8
- package/src/components/border-radius-control/style.scss +3 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/color-style-selector/index.js +18 -9
- package/src/components/colors-gradients/dropdown.js +130 -62
- package/src/components/colors-gradients/panel-color-gradient-settings.js +30 -76
- package/src/components/colors-gradients/style.scss +52 -50
- package/src/components/convert-to-group-buttons/toolbar.js +30 -13
- package/src/components/duotone-control/style.scss +1 -7
- package/src/components/iframe/index.js +62 -54
- package/src/components/image-editor/use-save-image.js +2 -1
- package/src/components/image-size-control/README.md +1 -1
- package/src/components/index.js +2 -3
- package/src/components/inserter/index.js +20 -0
- package/src/components/inserter/index.native.js +2 -2
- package/src/components/inserter/quick-inserter.js +3 -11
- package/src/components/inserter/style.native.scss +1 -0
- package/src/components/inserter/style.scss +2 -1
- package/src/components/link-control/constants.js +11 -0
- package/src/components/link-control/search-results.js +4 -5
- package/src/components/link-control/use-search-handler.js +11 -5
- package/src/components/list-view/block.js +24 -34
- package/src/components/list-view/branch.js +10 -20
- package/src/components/list-view/context.js +1 -4
- package/src/components/list-view/drop-indicator.js +0 -1
- package/src/components/list-view/index.js +11 -41
- package/src/components/list-view/style.scss +2 -1
- package/src/components/media-placeholder/index.js +0 -2
- package/src/components/media-replace-flow/index.js +0 -2
- package/src/components/media-upload/index.native.js +6 -2
- package/src/components/media-upload/test/index.native.js +31 -6
- package/src/components/navigable-toolbar/index.js +12 -2
- package/src/components/plain-text/index.native.js +64 -8
- package/src/components/preview-options/style.scss +0 -4
- package/src/components/publish-date-time-picker/README.md +52 -0
- package/src/components/publish-date-time-picker/index.js +50 -0
- package/src/components/publish-date-time-picker/style.scss +20 -0
- package/src/components/rich-text/format-toolbar-container.js +0 -1
- package/src/components/rich-text/index.js +3 -1
- package/src/components/rich-text/index.native.js +4 -0
- package/src/components/rich-text/style.scss +2 -8
- package/src/components/url-input/index.js +9 -4
- package/src/components/use-block-drop-zone/index.native.js +173 -0
- package/src/components/use-on-block-drop/index.native.js +119 -0
- package/src/components/use-setting/index.js +57 -21
- package/src/components/warning/index.js +47 -42
- package/src/components/warning/test/__snapshots__/index.js.snap +15 -6
- package/src/components/warning/test/index.js +1 -1
- package/src/components/writing-flow/use-click-selection.js +1 -4
- package/src/components/writing-flow/use-input.js +12 -0
- package/src/components/writing-flow/use-selection-observer.js +55 -10
- package/src/elements/index.js +1 -0
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +2 -11
- package/src/hooks/border.scss +0 -48
- package/src/hooks/color-panel.js +13 -9
- package/src/hooks/color.js +5 -74
- package/src/hooks/color.scss +5 -58
- package/src/hooks/dimensions.js +55 -41
- package/src/hooks/index.js +1 -0
- package/src/hooks/margin.js +64 -15
- package/src/hooks/padding.js +60 -15
- package/src/hooks/padding.scss +12 -0
- package/src/hooks/settings.js +32 -0
- package/src/hooks/style.js +25 -39
- package/src/hooks/test/settings.js +48 -0
- package/src/hooks/typography.js +2 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +11 -3
- package/src/store/actions.js +12 -0
- package/src/store/defaults.js +0 -1
- package/src/store/reducer.js +14 -1
- package/src/store/selectors.js +42 -12
- package/src/store/test/reducer.js +5 -0
- package/src/store/test/selectors.js +17 -0
- package/src/style.scss +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/border-style-control/index.js +0 -60
- package/build/components/border-style-control/index.js.map +0 -1
- package/build/components/colors/color-panel.js +0 -82
- package/build/components/colors/color-panel.js.map +0 -1
- package/build/components/colors/color-panel.native.js +0 -11
- package/build/components/colors/color-panel.native.js.map +0 -1
- package/build/components/colors-gradients/tools-panel-color-dropdown.js +0 -89
- package/build/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/build-module/components/border-style-control/index.js +0 -50
- package/build-module/components/border-style-control/index.js.map +0 -1
- package/build-module/components/colors/color-panel.js +0 -70
- package/build-module/components/colors/color-panel.js.map +0 -1
- package/build-module/components/colors/color-panel.native.js +0 -4
- package/build-module/components/colors/color-panel.native.js.map +0 -1
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js +0 -75
- package/build-module/components/colors-gradients/tools-panel-color-dropdown.js.map +0 -1
- package/src/components/block-alignment-matrix-control/style.scss +0 -10
- package/src/components/border-style-control/index.js +0 -47
- package/src/components/border-style-control/style.scss +0 -18
- package/src/components/colors/color-panel.js +0 -91
- package/src/components/colors/color-panel.native.js +0 -3
- package/src/components/colors-gradients/tools-panel-color-dropdown.js +0 -85
|
@@ -76,36 +76,81 @@ export default function useSelectionObserver() {
|
|
|
76
76
|
const { multiSelect, selectBlock, selectionChange } = useDispatch(
|
|
77
77
|
blockEditorStore
|
|
78
78
|
);
|
|
79
|
-
const { getBlockParents } = useSelect(
|
|
79
|
+
const { getBlockParents, getBlockSelectionStart } = useSelect(
|
|
80
|
+
blockEditorStore
|
|
81
|
+
);
|
|
80
82
|
return useRefEffect(
|
|
81
83
|
( node ) => {
|
|
82
84
|
const { ownerDocument } = node;
|
|
83
85
|
const { defaultView } = ownerDocument;
|
|
84
86
|
|
|
85
|
-
function onSelectionChange() {
|
|
87
|
+
function onSelectionChange( event ) {
|
|
86
88
|
const selection = defaultView.getSelection();
|
|
87
|
-
|
|
88
89
|
// If no selection is found, end multi selection and disable the
|
|
89
90
|
// contentEditable wrapper.
|
|
90
|
-
if ( ! selection.rangeCount
|
|
91
|
+
if ( ! selection.rangeCount ) {
|
|
92
|
+
setContentEditableWrapper( node, false );
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// If selection is collapsed and we haven't used `shift+click`,
|
|
96
|
+
// end multi selection and disable the contentEditable wrapper.
|
|
97
|
+
// We have to check about `shift+click` case because elements
|
|
98
|
+
// that don't support text selection might be involved, and we might
|
|
99
|
+
// update the clientIds to multi-select blocks.
|
|
100
|
+
// For now we check if the event is a `mouse` event.
|
|
101
|
+
const isClickShift = event.shiftKey && event.type === 'mouseup';
|
|
102
|
+
if ( selection.isCollapsed && ! isClickShift ) {
|
|
91
103
|
setContentEditableWrapper( node, false );
|
|
92
104
|
return;
|
|
93
105
|
}
|
|
94
106
|
|
|
95
|
-
|
|
107
|
+
let startClientId = getBlockClientId(
|
|
96
108
|
extractSelectionStartNode( selection )
|
|
97
109
|
);
|
|
98
|
-
|
|
110
|
+
let endClientId = getBlockClientId(
|
|
99
111
|
extractSelectionEndNode( selection )
|
|
100
112
|
);
|
|
101
|
-
|
|
113
|
+
// If the selection has changed and we had pressed `shift+click`,
|
|
114
|
+
// we need to check if in an element that doesn't support
|
|
115
|
+
// text selection has been clicked.
|
|
116
|
+
if ( isClickShift ) {
|
|
117
|
+
const selectedClientId = getBlockSelectionStart();
|
|
118
|
+
const clickedClientId = getBlockClientId( event.target );
|
|
119
|
+
// `endClientId` is not defined if we end the selection by clicking a non-selectable block.
|
|
120
|
+
// We need to check if there was already a selection with a non-selectable focusNode.
|
|
121
|
+
const focusNodeIsNonSelectable =
|
|
122
|
+
clickedClientId !== endClientId;
|
|
123
|
+
if (
|
|
124
|
+
( startClientId === endClientId &&
|
|
125
|
+
selection.isCollapsed ) ||
|
|
126
|
+
! endClientId ||
|
|
127
|
+
focusNodeIsNonSelectable
|
|
128
|
+
) {
|
|
129
|
+
endClientId = clickedClientId;
|
|
130
|
+
}
|
|
131
|
+
// Handle the case when we have a non-selectable block
|
|
132
|
+
// selected and click another one.
|
|
133
|
+
if ( startClientId !== selectedClientId ) {
|
|
134
|
+
startClientId = selectedClientId;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// If the selection did not involve a block, return.
|
|
139
|
+
if (
|
|
140
|
+
startClientId === undefined &&
|
|
141
|
+
endClientId === undefined
|
|
142
|
+
) {
|
|
143
|
+
setContentEditableWrapper( node, false );
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
102
146
|
|
|
147
|
+
const isSingularSelection = startClientId === endClientId;
|
|
103
148
|
if ( isSingularSelection ) {
|
|
104
|
-
selectBlock(
|
|
149
|
+
selectBlock( startClientId );
|
|
105
150
|
} else {
|
|
106
151
|
const startPath = [
|
|
107
|
-
...getBlockParents(
|
|
108
|
-
|
|
152
|
+
...getBlockParents( startClientId ),
|
|
153
|
+
startClientId,
|
|
109
154
|
];
|
|
110
155
|
const endPath = [
|
|
111
156
|
...getBlockParents( endClientId ),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const __experimentalElementButtonClassName = 'wp-element-button';
|
package/src/hooks/anchor.js
CHANGED
|
@@ -117,7 +117,7 @@ export const withInspectorControl = createHigherOrderComponent(
|
|
|
117
117
|
* We plan to remove scoping anchors to 'core/heading' to support
|
|
118
118
|
* anchors for all eligble blocks. Additionally we plan to explore
|
|
119
119
|
* leveraging InspectorAdvancedControls instead of a custom
|
|
120
|
-
* PanelBody title. https://
|
|
120
|
+
* PanelBody title. https://github.com/WordPress/gutenberg/issues/28363
|
|
121
121
|
*/ }
|
|
122
122
|
{ ! isWeb && props.name === 'core/heading' && (
|
|
123
123
|
<InspectorControls>
|
package/src/hooks/border.js
CHANGED
|
@@ -269,17 +269,8 @@ export function BorderPanel( props ) {
|
|
|
269
269
|
colors={ colors }
|
|
270
270
|
enableAlpha={ true }
|
|
271
271
|
onChange={ onBorderChange }
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
top:
|
|
275
|
-
'block-editor__border-box-control__popover-top',
|
|
276
|
-
right:
|
|
277
|
-
'block-editor__border-box-control__popover-right',
|
|
278
|
-
bottom:
|
|
279
|
-
'block-editor__border-box-control__popover-bottom',
|
|
280
|
-
left:
|
|
281
|
-
'block-editor__border-box-control__popover-left',
|
|
282
|
-
} }
|
|
272
|
+
popoverPlacement="left-start"
|
|
273
|
+
popoverOffset={ 40 }
|
|
283
274
|
showStyle={ isStyleSupported }
|
|
284
275
|
value={ hydratedBorder }
|
|
285
276
|
__experimentalHasMultipleOrigins={ true }
|
package/src/hooks/border.scss
CHANGED
|
@@ -3,51 +3,3 @@
|
|
|
3
3
|
grid-column: span 1;
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
.block-editor__border-box-control__popover,
|
|
8
|
-
.block-editor__border-box-control__popover-top,
|
|
9
|
-
.block-editor__border-box-control__popover-right,
|
|
10
|
-
.block-editor__border-box-control__popover-bottom,
|
|
11
|
-
.block-editor__border-box-control__popover-left {
|
|
12
|
-
.components-popover__content {
|
|
13
|
-
width: 282px;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
$split-border-control-offset: 55px;
|
|
18
|
-
|
|
19
|
-
@include break-medium() {
|
|
20
|
-
.block-editor__border-box-control__popover,
|
|
21
|
-
.block-editor__border-box-control__popover-left {
|
|
22
|
-
.components-popover__content {
|
|
23
|
-
margin-right: #{ $grid-unit-50 + $grid-unit-15 } !important;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.block-editor__border-box-control__popover-top,
|
|
28
|
-
.block-editor__border-box-control__popover-bottom {
|
|
29
|
-
.components-popover__content {
|
|
30
|
-
margin-right: #{ $grid-unit-50 + $grid-unit-15 + $split-border-control-offset } !important;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.block-editor__border-box-control__popover-right {
|
|
35
|
-
.components-popover__content {
|
|
36
|
-
margin-right: #{ $grid-unit-50 + $grid-unit-15 + ( $split-border-control-offset * 2 )} !important;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.block-editor__border-box-control__popover,
|
|
41
|
-
.block-editor__border-box-control__popover-top,
|
|
42
|
-
.block-editor__border-box-control__popover-right,
|
|
43
|
-
.block-editor__border-box-control__popover-bottom,
|
|
44
|
-
.block-editor__border-box-control__popover-left {
|
|
45
|
-
&.is-from-top .components-popover__content {
|
|
46
|
-
margin-top: #{ -($grid-unit-50 + $grid-unit-15) } !important;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
&.is-from-bottom .components-popover__content {
|
|
50
|
-
margin-bottom: #{ -($grid-unit-50 + $grid-unit-15) } !important;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
package/src/hooks/color-panel.js
CHANGED
|
@@ -6,9 +6,10 @@ import { useState, useEffect } from '@wordpress/element';
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
|
+
import ColorGradientSettingsDropdown from '../components/colors-gradients/dropdown';
|
|
9
10
|
import ContrastChecker from '../components/contrast-checker';
|
|
10
|
-
import ToolsPanelColorDropdown from '../components/colors-gradients/tools-panel-color-dropdown';
|
|
11
11
|
import InspectorControls from '../components/inspector-controls';
|
|
12
|
+
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
12
13
|
import { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';
|
|
13
14
|
|
|
14
15
|
function getComputedStyle( node ) {
|
|
@@ -58,16 +59,19 @@ export default function ColorPanel( {
|
|
|
58
59
|
setDetectedBackgroundColor( backgroundColor );
|
|
59
60
|
} );
|
|
60
61
|
|
|
62
|
+
const colorGradientSettings = useMultipleOriginColorsAndGradients();
|
|
63
|
+
|
|
61
64
|
return (
|
|
62
65
|
<InspectorControls __experimentalGroup="color">
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
<ColorGradientSettingsDropdown
|
|
67
|
+
enableAlpha={ enableAlpha }
|
|
68
|
+
panelId={ clientId }
|
|
69
|
+
settings={ settings }
|
|
70
|
+
__experimentalIsItemGroup={ false }
|
|
71
|
+
__experimentalHasMultipleOrigins
|
|
72
|
+
__experimentalIsRenderedInSidebar
|
|
73
|
+
{ ...colorGradientSettings }
|
|
74
|
+
/>
|
|
71
75
|
{ enableContrastChecking && (
|
|
72
76
|
<ContrastChecker
|
|
73
77
|
backgroundColor={ detectedBackgroundColor }
|
package/src/hooks/color.js
CHANGED
|
@@ -76,34 +76,6 @@ const hasTextColorSupport = ( blockType ) => {
|
|
|
76
76
|
return colorSupport && colorSupport.text !== false;
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
/**
|
|
80
|
-
* Checks whether a color has been set either with a named preset color in
|
|
81
|
-
* a top level block attribute or as a custom value within the style attribute
|
|
82
|
-
* object.
|
|
83
|
-
*
|
|
84
|
-
* @param {string} name Name of the color to check.
|
|
85
|
-
* @return {boolean} Whether or not a color has a value.
|
|
86
|
-
*/
|
|
87
|
-
const hasColor = ( name ) => ( props ) => {
|
|
88
|
-
if ( name === 'background' ) {
|
|
89
|
-
return (
|
|
90
|
-
!! props.attributes.backgroundColor ||
|
|
91
|
-
!! props.attributes.style?.color?.background ||
|
|
92
|
-
!! props.attributes.gradient ||
|
|
93
|
-
!! props.attributes.style?.color?.gradient
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if ( name === 'link' ) {
|
|
98
|
-
return !! props.attributes.style?.elements?.link?.color?.text;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
!! props.attributes[ `${ name }Color` ] ||
|
|
103
|
-
!! props.attributes.style?.color?.[ name ]
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
79
|
/**
|
|
108
80
|
* Clears a single color property from a style object.
|
|
109
81
|
*
|
|
@@ -114,20 +86,6 @@ const hasColor = ( name ) => ( props ) => {
|
|
|
114
86
|
const clearColorFromStyles = ( path, style ) =>
|
|
115
87
|
cleanEmptyObject( immutableSet( style, path, undefined ) );
|
|
116
88
|
|
|
117
|
-
/**
|
|
118
|
-
* Resets the block attributes for text color.
|
|
119
|
-
*
|
|
120
|
-
* @param {Object} props Current block props.
|
|
121
|
-
* @param {Object} props.attributes Block attributes.
|
|
122
|
-
* @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.
|
|
123
|
-
*/
|
|
124
|
-
const resetTextColor = ( { attributes, setAttributes } ) => {
|
|
125
|
-
setAttributes( {
|
|
126
|
-
textColor: undefined,
|
|
127
|
-
style: clearColorFromStyles( [ 'color', 'text' ], attributes.style ),
|
|
128
|
-
} );
|
|
129
|
-
};
|
|
130
|
-
|
|
131
89
|
/**
|
|
132
90
|
* Clears text color related properties from supplied attributes.
|
|
133
91
|
*
|
|
@@ -139,18 +97,6 @@ const resetAllTextFilter = ( attributes ) => ( {
|
|
|
139
97
|
style: clearColorFromStyles( [ 'color', 'text' ], attributes.style ),
|
|
140
98
|
} );
|
|
141
99
|
|
|
142
|
-
/**
|
|
143
|
-
* Resets the block attributes for link color.
|
|
144
|
-
*
|
|
145
|
-
* @param {Object} props Current block props.
|
|
146
|
-
* @param {Object} props.attributes Block attributes.
|
|
147
|
-
* @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.
|
|
148
|
-
*/
|
|
149
|
-
const resetLinkColor = ( { attributes, setAttributes } ) => {
|
|
150
|
-
const path = [ 'elements', 'link', 'color', 'text' ];
|
|
151
|
-
setAttributes( { style: clearColorFromStyles( path, attributes.style ) } );
|
|
152
|
-
};
|
|
153
|
-
|
|
154
100
|
/**
|
|
155
101
|
* Clears link color related properties from supplied attributes.
|
|
156
102
|
*
|
|
@@ -184,17 +130,6 @@ const clearBackgroundAndGradient = ( attributes ) => ( {
|
|
|
184
130
|
},
|
|
185
131
|
} );
|
|
186
132
|
|
|
187
|
-
/**
|
|
188
|
-
* Resets the block attributes for both background color and gradient.
|
|
189
|
-
*
|
|
190
|
-
* @param {Object} props Current block props.
|
|
191
|
-
* @param {Object} props.attributes Block attributes.
|
|
192
|
-
* @param {Function} props.setAttributes Block's setAttributes prop used to apply reset.
|
|
193
|
-
*/
|
|
194
|
-
const resetBackgroundAndGradient = ( { attributes, setAttributes } ) => {
|
|
195
|
-
setAttributes( clearBackgroundAndGradient( attributes ) );
|
|
196
|
-
};
|
|
197
|
-
|
|
198
133
|
/**
|
|
199
134
|
* Filters registered block settings, extending attributes to include
|
|
200
135
|
* `backgroundColor` and `textColor` attribute.
|
|
@@ -496,12 +431,16 @@ export function ColorEdit( props ) {
|
|
|
496
431
|
|
|
497
432
|
const newStyle = cleanEmptyObject(
|
|
498
433
|
immutableSet(
|
|
499
|
-
style,
|
|
434
|
+
localAttributes.current?.style,
|
|
500
435
|
[ 'elements', 'link', 'color', 'text' ],
|
|
501
436
|
newLinkColorValue
|
|
502
437
|
)
|
|
503
438
|
);
|
|
504
439
|
props.setAttributes( { style: newStyle } );
|
|
440
|
+
localAttributes.current = {
|
|
441
|
+
...localAttributes.current,
|
|
442
|
+
...{ style: newStyle },
|
|
443
|
+
};
|
|
505
444
|
};
|
|
506
445
|
|
|
507
446
|
const enableContrastChecking =
|
|
@@ -529,8 +468,6 @@ export function ColorEdit( props ) {
|
|
|
529
468
|
style?.color?.text
|
|
530
469
|
).color,
|
|
531
470
|
isShownByDefault: defaultColorControls?.text,
|
|
532
|
-
hasValue: () => hasColor( 'text' )( props ),
|
|
533
|
-
onDeselect: () => resetTextColor( props ),
|
|
534
471
|
resetAllFilter: resetAllTextFilter,
|
|
535
472
|
},
|
|
536
473
|
]
|
|
@@ -553,10 +490,6 @@ export function ColorEdit( props ) {
|
|
|
553
490
|
: undefined,
|
|
554
491
|
isShownByDefault:
|
|
555
492
|
defaultColorControls?.background,
|
|
556
|
-
hasValue: () =>
|
|
557
|
-
hasColor( 'background' )( props ),
|
|
558
|
-
onDeselect: () =>
|
|
559
|
-
resetBackgroundAndGradient( props ),
|
|
560
493
|
resetAllFilter: clearBackgroundAndGradient,
|
|
561
494
|
},
|
|
562
495
|
]
|
|
@@ -573,8 +506,6 @@ export function ColorEdit( props ) {
|
|
|
573
506
|
clearable: !! style?.elements?.link?.color
|
|
574
507
|
?.text,
|
|
575
508
|
isShownByDefault: defaultColorControls?.link,
|
|
576
|
-
hasValue: () => hasColor( 'link' )( props ),
|
|
577
|
-
onDeselect: () => resetLinkColor( props ),
|
|
578
509
|
resetAllFilter: resetAllLinkFilter,
|
|
579
510
|
},
|
|
580
511
|
]
|
package/src/hooks/color.scss
CHANGED
|
@@ -22,64 +22,11 @@
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* must at least render a placeholder which would otherwise interfere
|
|
29
|
-
* with the `:last-child` styles.
|
|
25
|
+
* After converting PanelColorGradientSettings to render as a ToolsPanel
|
|
26
|
+
* we need to remove the top margin when wrapping inner content due to
|
|
27
|
+
* rendering via SlotFills.
|
|
30
28
|
*/
|
|
31
|
-
.block-editor-tools-panel-color-gradient-settings__item {
|
|
32
|
-
|
|
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
|
-
}
|
|
29
|
+
.block-editor-tools-panel-color-gradient-settings__item.first {
|
|
30
|
+
margin-top: 0;
|
|
84
31
|
}
|
|
85
32
|
}
|
package/src/hooks/dimensions.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from './gap';
|
|
20
20
|
import {
|
|
21
21
|
MarginEdit,
|
|
22
|
+
MarginVisualizer,
|
|
22
23
|
hasMarginSupport,
|
|
23
24
|
hasMarginValue,
|
|
24
25
|
resetMargin,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
} from './margin';
|
|
27
28
|
import {
|
|
28
29
|
PaddingEdit,
|
|
30
|
+
PaddingVisualizer,
|
|
29
31
|
hasPaddingSupport,
|
|
30
32
|
hasPaddingValue,
|
|
31
33
|
resetPadding,
|
|
@@ -71,44 +73,48 @@ export function DimensionsPanel( props ) {
|
|
|
71
73
|
} );
|
|
72
74
|
|
|
73
75
|
return (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
76
|
+
<>
|
|
77
|
+
<InspectorControls __experimentalGroup="dimensions">
|
|
78
|
+
{ ! isPaddingDisabled && (
|
|
79
|
+
<ToolsPanelItem
|
|
80
|
+
hasValue={ () => hasPaddingValue( props ) }
|
|
81
|
+
label={ __( 'Padding' ) }
|
|
82
|
+
onDeselect={ () => resetPadding( props ) }
|
|
83
|
+
resetAllFilter={ createResetAllFilter( 'padding' ) }
|
|
84
|
+
isShownByDefault={ defaultSpacingControls?.padding }
|
|
85
|
+
panelId={ props.clientId }
|
|
86
|
+
>
|
|
87
|
+
<PaddingEdit { ...props } />
|
|
88
|
+
</ToolsPanelItem>
|
|
89
|
+
) }
|
|
90
|
+
{ ! isMarginDisabled && (
|
|
91
|
+
<ToolsPanelItem
|
|
92
|
+
hasValue={ () => hasMarginValue( props ) }
|
|
93
|
+
label={ __( 'Margin' ) }
|
|
94
|
+
onDeselect={ () => resetMargin( props ) }
|
|
95
|
+
resetAllFilter={ createResetAllFilter( 'margin' ) }
|
|
96
|
+
isShownByDefault={ defaultSpacingControls?.margin }
|
|
97
|
+
panelId={ props.clientId }
|
|
98
|
+
>
|
|
99
|
+
<MarginEdit { ...props } />
|
|
100
|
+
</ToolsPanelItem>
|
|
101
|
+
) }
|
|
102
|
+
{ ! isGapDisabled && (
|
|
103
|
+
<ToolsPanelItem
|
|
104
|
+
hasValue={ () => hasGapValue( props ) }
|
|
105
|
+
label={ __( 'Block spacing' ) }
|
|
106
|
+
onDeselect={ () => resetGap( props ) }
|
|
107
|
+
resetAllFilter={ createResetAllFilter( 'blockGap' ) }
|
|
108
|
+
isShownByDefault={ defaultSpacingControls?.blockGap }
|
|
109
|
+
panelId={ props.clientId }
|
|
110
|
+
>
|
|
111
|
+
<GapEdit { ...props } />
|
|
112
|
+
</ToolsPanelItem>
|
|
113
|
+
) }
|
|
114
|
+
</InspectorControls>
|
|
115
|
+
{ ! isPaddingDisabled && <PaddingVisualizer { ...props } /> }
|
|
116
|
+
{ ! isMarginDisabled && <MarginVisualizer { ...props } /> }
|
|
117
|
+
</>
|
|
112
118
|
);
|
|
113
119
|
}
|
|
114
120
|
|
|
@@ -147,7 +153,7 @@ const useIsDimensionsDisabled = ( props = {} ) => {
|
|
|
147
153
|
};
|
|
148
154
|
|
|
149
155
|
/**
|
|
150
|
-
* Custom hook to retrieve which padding/margin is supported
|
|
156
|
+
* Custom hook to retrieve which padding/margin/blockGap is supported
|
|
151
157
|
* e.g. top, right, bottom or left.
|
|
152
158
|
*
|
|
153
159
|
* Sides are opted into by default. It is only if a specific side is set to
|
|
@@ -156,7 +162,7 @@ const useIsDimensionsDisabled = ( props = {} ) => {
|
|
|
156
162
|
* @param {string} blockName Block name.
|
|
157
163
|
* @param {string} feature The feature custom sides relate to e.g. padding or margins.
|
|
158
164
|
*
|
|
159
|
-
* @return {
|
|
165
|
+
* @return {?string[]} Strings representing the custom sides available.
|
|
160
166
|
*/
|
|
161
167
|
export function useCustomSides( blockName, feature ) {
|
|
162
168
|
const support = getBlockSupport( blockName, SPACING_SUPPORT_KEY );
|
|
@@ -166,7 +172,15 @@ export function useCustomSides( blockName, feature ) {
|
|
|
166
172
|
return;
|
|
167
173
|
}
|
|
168
174
|
|
|
169
|
-
|
|
175
|
+
// Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).
|
|
176
|
+
if ( Array.isArray( support[ feature ] ) ) {
|
|
177
|
+
return support[ feature ];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Finally, attempt to return `.sides` if the setting is an object.
|
|
181
|
+
if ( support[ feature ]?.sides ) {
|
|
182
|
+
return support[ feature ].sides;
|
|
183
|
+
}
|
|
170
184
|
}
|
|
171
185
|
|
|
172
186
|
/**
|
package/src/hooks/index.js
CHANGED
package/src/hooks/margin.js
CHANGED
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Platform,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
useEffect,
|
|
11
|
+
} from '@wordpress/element';
|
|
6
12
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
7
13
|
import {
|
|
8
14
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
9
15
|
__experimentalBoxControl as BoxControl,
|
|
10
16
|
} from '@wordpress/components';
|
|
17
|
+
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
20
|
* Internal dependencies
|
|
@@ -20,6 +27,7 @@ import {
|
|
|
20
27
|
useIsDimensionsSupportValid,
|
|
21
28
|
} from './dimensions';
|
|
22
29
|
import { cleanEmptyObject } from './utils';
|
|
30
|
+
import BlockPopover from '../components/block-popover';
|
|
23
31
|
|
|
24
32
|
/**
|
|
25
33
|
* Determines if there is margin support.
|
|
@@ -124,26 +132,12 @@ export function MarginEdit( props ) {
|
|
|
124
132
|
} );
|
|
125
133
|
};
|
|
126
134
|
|
|
127
|
-
const onChangeShowVisualizer = ( next ) => {
|
|
128
|
-
const newStyle = {
|
|
129
|
-
...style,
|
|
130
|
-
visualizers: {
|
|
131
|
-
margin: next,
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
setAttributes( {
|
|
136
|
-
style: cleanEmptyObject( newStyle ),
|
|
137
|
-
} );
|
|
138
|
-
};
|
|
139
|
-
|
|
140
135
|
return Platform.select( {
|
|
141
136
|
web: (
|
|
142
137
|
<>
|
|
143
138
|
<BoxControl
|
|
144
139
|
values={ style?.spacing?.margin }
|
|
145
140
|
onChange={ onChange }
|
|
146
|
-
onChangeShowVisualizer={ onChangeShowVisualizer }
|
|
147
141
|
label={ __( 'Margin' ) }
|
|
148
142
|
sides={ sides }
|
|
149
143
|
units={ units }
|
|
@@ -155,3 +149,58 @@ export function MarginEdit( props ) {
|
|
|
155
149
|
native: null,
|
|
156
150
|
} );
|
|
157
151
|
}
|
|
152
|
+
|
|
153
|
+
export function MarginVisualizer( { clientId, attributes } ) {
|
|
154
|
+
const margin = attributes?.style?.spacing?.margin;
|
|
155
|
+
const style = useMemo( () => {
|
|
156
|
+
return {
|
|
157
|
+
borderTopWidth: margin?.top ?? 0,
|
|
158
|
+
borderRightWidth: margin?.right ?? 0,
|
|
159
|
+
borderBottomWidth: margin?.bottom ?? 0,
|
|
160
|
+
borderLeftWidth: margin?.left ?? 0,
|
|
161
|
+
top: margin?.top ? `-${ margin.top }` : 0,
|
|
162
|
+
right: margin?.right ? `-${ margin.right }` : 0,
|
|
163
|
+
bottom: margin?.bottom ? `-${ margin.bottom }` : 0,
|
|
164
|
+
left: margin?.left ? `-${ margin.left }` : 0,
|
|
165
|
+
};
|
|
166
|
+
}, [ margin ] );
|
|
167
|
+
|
|
168
|
+
const [ isActive, setIsActive ] = useState( false );
|
|
169
|
+
const valueRef = useRef( margin );
|
|
170
|
+
const timeoutRef = useRef();
|
|
171
|
+
|
|
172
|
+
const clearTimer = () => {
|
|
173
|
+
if ( timeoutRef.current ) {
|
|
174
|
+
window.clearTimeout( timeoutRef.current );
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
useEffect( () => {
|
|
179
|
+
if ( ! isShallowEqual( margin, valueRef.current ) ) {
|
|
180
|
+
setIsActive( true );
|
|
181
|
+
valueRef.current = margin;
|
|
182
|
+
|
|
183
|
+
clearTimer();
|
|
184
|
+
|
|
185
|
+
timeoutRef.current = setTimeout( () => {
|
|
186
|
+
setIsActive( false );
|
|
187
|
+
}, 400 );
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return () => clearTimer();
|
|
191
|
+
}, [ margin ] );
|
|
192
|
+
|
|
193
|
+
if ( ! isActive ) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<BlockPopover
|
|
199
|
+
clientId={ clientId }
|
|
200
|
+
__unstableCoverTarget
|
|
201
|
+
__unstableRefreshSize={ margin }
|
|
202
|
+
>
|
|
203
|
+
<div className="block-editor__padding-visualizer" style={ style } />
|
|
204
|
+
</BlockPopover>
|
|
205
|
+
);
|
|
206
|
+
}
|