@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
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSharedValue } from 'react-native-reanimated';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
import { useCallback } from '@wordpress/element';
|
|
11
|
+
import { useThrottle } from '@wordpress/compose';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { store as blockEditorStore } from '../../store';
|
|
17
|
+
import { useBlockListContext } from '../block-list/block-list-context';
|
|
18
|
+
import { getDistanceToNearestEdge } from '../../utils/math';
|
|
19
|
+
import useOnBlockDrop from '../use-on-block-drop';
|
|
20
|
+
|
|
21
|
+
/** @typedef {import('../../utils/math').WPPoint} WPPoint */
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The orientation of a block list.
|
|
25
|
+
*
|
|
26
|
+
* @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Given a list of blocks layouts finds the index that a block should be dropped at.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} blocksLayouts Blocks layouts object.
|
|
33
|
+
* @param {WPPoint} position The position of the item being dragged.
|
|
34
|
+
* @param {WPBlockListOrientation} orientation The orientation of a block list.
|
|
35
|
+
* @param {boolean} isRTL Check if current locale is RTL.
|
|
36
|
+
*
|
|
37
|
+
* @return {number|undefined} The block index that's closest to the drag position.
|
|
38
|
+
*/
|
|
39
|
+
export function getNearestBlockIndex(
|
|
40
|
+
blocksLayouts,
|
|
41
|
+
position,
|
|
42
|
+
orientation,
|
|
43
|
+
isRTL
|
|
44
|
+
) {
|
|
45
|
+
const allowedEdges =
|
|
46
|
+
orientation === 'horizontal'
|
|
47
|
+
? [ 'left', 'right' ]
|
|
48
|
+
: [ 'top', 'bottom' ];
|
|
49
|
+
|
|
50
|
+
const isRightToLeft = isRTL;
|
|
51
|
+
|
|
52
|
+
let candidateIndex;
|
|
53
|
+
let candidateDistance;
|
|
54
|
+
|
|
55
|
+
// Only enabled for root level blocks.
|
|
56
|
+
blocksLayouts.forEach( ( element, index ) => {
|
|
57
|
+
const { x, y, width, height } = element;
|
|
58
|
+
const rect = {
|
|
59
|
+
x: element.x,
|
|
60
|
+
y: element.y,
|
|
61
|
+
top: y,
|
|
62
|
+
right: x + width,
|
|
63
|
+
bottom: y + height,
|
|
64
|
+
left: x,
|
|
65
|
+
width,
|
|
66
|
+
height,
|
|
67
|
+
};
|
|
68
|
+
const [ distance, edge ] = getDistanceToNearestEdge(
|
|
69
|
+
position,
|
|
70
|
+
rect,
|
|
71
|
+
allowedEdges
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if ( candidateDistance === undefined || distance < candidateDistance ) {
|
|
75
|
+
// If the user is dropping to the trailing edge of the block
|
|
76
|
+
// add 1 to the index to represent dragging after.
|
|
77
|
+
// Take RTL languages into account where the left edge is
|
|
78
|
+
// the trailing edge.
|
|
79
|
+
const isTrailingEdge =
|
|
80
|
+
edge === 'bottom' ||
|
|
81
|
+
( ! isRightToLeft && edge === 'right' ) ||
|
|
82
|
+
( isRightToLeft && edge === 'left' );
|
|
83
|
+
const offset = isTrailingEdge ? 1 : 0;
|
|
84
|
+
|
|
85
|
+
// Update the currently known best candidate.
|
|
86
|
+
candidateDistance = distance;
|
|
87
|
+
candidateIndex = index + offset;
|
|
88
|
+
}
|
|
89
|
+
} );
|
|
90
|
+
return candidateIndex;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {Object} WPBlockDropZoneConfig
|
|
95
|
+
* @property {string} rootClientId The root client id for the block list.
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A React hook that can be used to make a block list handle drag and drop.
|
|
100
|
+
*
|
|
101
|
+
* @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
|
|
102
|
+
*
|
|
103
|
+
* @return {Object} An object that contains `targetBlockIndex` and the event
|
|
104
|
+
* handlers `onBlockDragOver`, `onBlockDragEnd` and `onBlockDrop`.
|
|
105
|
+
*/
|
|
106
|
+
export default function useBlockDropZone( {
|
|
107
|
+
// An undefined value represents a top-level block. Default to an empty
|
|
108
|
+
// string for this so that `targetRootClientId` can be easily compared to
|
|
109
|
+
// values returned by the `getRootBlockClientId` selector, which also uses
|
|
110
|
+
// an empty string to represent top-level blocks.
|
|
111
|
+
rootClientId: targetRootClientId = '',
|
|
112
|
+
} = {} ) {
|
|
113
|
+
const targetBlockIndex = useSharedValue( null );
|
|
114
|
+
|
|
115
|
+
const { getBlockListSettings, getSettings } = useSelect( blockEditorStore );
|
|
116
|
+
const {
|
|
117
|
+
blocksLayouts,
|
|
118
|
+
getBlockLayoutsOrderedByYCoord,
|
|
119
|
+
} = useBlockListContext();
|
|
120
|
+
|
|
121
|
+
const getSortedBlocksLayouts = useCallback( () => {
|
|
122
|
+
return getBlockLayoutsOrderedByYCoord( blocksLayouts.current );
|
|
123
|
+
}, [ blocksLayouts.current ] );
|
|
124
|
+
|
|
125
|
+
const isRTL = getSettings().isRTL;
|
|
126
|
+
|
|
127
|
+
const onBlockDrop = useOnBlockDrop();
|
|
128
|
+
|
|
129
|
+
const throttled = useThrottle(
|
|
130
|
+
useCallback(
|
|
131
|
+
( event ) => {
|
|
132
|
+
const sortedBlockLayouts = getSortedBlocksLayouts();
|
|
133
|
+
|
|
134
|
+
const targetIndex = getNearestBlockIndex(
|
|
135
|
+
sortedBlockLayouts,
|
|
136
|
+
{ x: event.x, y: event.y },
|
|
137
|
+
getBlockListSettings( targetRootClientId )?.orientation,
|
|
138
|
+
isRTL
|
|
139
|
+
);
|
|
140
|
+
if ( targetIndex !== null ) {
|
|
141
|
+
targetBlockIndex.value = targetIndex ?? 0;
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
[
|
|
145
|
+
getSortedBlocksLayouts,
|
|
146
|
+
getNearestBlockIndex,
|
|
147
|
+
getBlockListSettings,
|
|
148
|
+
targetBlockIndex,
|
|
149
|
+
]
|
|
150
|
+
),
|
|
151
|
+
200
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
onBlockDragOver( event ) {
|
|
156
|
+
throttled( event );
|
|
157
|
+
},
|
|
158
|
+
onBlockDragEnd() {
|
|
159
|
+
throttled.cancel();
|
|
160
|
+
targetBlockIndex.value = null;
|
|
161
|
+
},
|
|
162
|
+
onBlockDrop: ( event ) => {
|
|
163
|
+
if ( targetBlockIndex.value !== null ) {
|
|
164
|
+
onBlockDrop( {
|
|
165
|
+
...event,
|
|
166
|
+
targetRootClientId,
|
|
167
|
+
targetBlockIndex: targetBlockIndex.value,
|
|
168
|
+
} );
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
targetBlockIndex,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { cloneBlock } from '@wordpress/blocks';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as blockEditorStore } from '../../store';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A function that returns an event handler function for block drop events.
|
|
14
|
+
*
|
|
15
|
+
* @param {Function} getBlockIndex A function that gets the index of a block.
|
|
16
|
+
* @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
|
|
17
|
+
* @param {Function} moveBlocksToPosition A function that moves blocks.
|
|
18
|
+
* @param {Function} insertBlocks A function that inserts blocks.
|
|
19
|
+
* @param {Function} clearSelectedBlock A function that clears block selection.
|
|
20
|
+
* @return {Function} The event handler for a block drop event.
|
|
21
|
+
*/
|
|
22
|
+
export function onBlockDrop(
|
|
23
|
+
getBlockIndex,
|
|
24
|
+
getClientIdsOfDescendants,
|
|
25
|
+
moveBlocksToPosition,
|
|
26
|
+
insertBlocks,
|
|
27
|
+
clearSelectedBlock
|
|
28
|
+
) {
|
|
29
|
+
return ( {
|
|
30
|
+
blocks,
|
|
31
|
+
srcClientIds: sourceClientIds,
|
|
32
|
+
srcRootClientId: sourceRootClientId,
|
|
33
|
+
targetBlockIndex,
|
|
34
|
+
targetRootClientId,
|
|
35
|
+
type: dropType,
|
|
36
|
+
} ) => {
|
|
37
|
+
// If the user is inserting a block.
|
|
38
|
+
if ( dropType === 'inserter' ) {
|
|
39
|
+
clearSelectedBlock();
|
|
40
|
+
const blocksToInsert = blocks.map( ( block ) =>
|
|
41
|
+
cloneBlock( block )
|
|
42
|
+
);
|
|
43
|
+
insertBlocks(
|
|
44
|
+
blocksToInsert,
|
|
45
|
+
targetBlockIndex,
|
|
46
|
+
targetRootClientId,
|
|
47
|
+
true,
|
|
48
|
+
null
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// If the user is moving a block.
|
|
53
|
+
if ( dropType === 'block' ) {
|
|
54
|
+
const sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );
|
|
55
|
+
|
|
56
|
+
// If the user is dropping to the same position, return early.
|
|
57
|
+
if (
|
|
58
|
+
sourceRootClientId === targetRootClientId &&
|
|
59
|
+
sourceBlockIndex === targetBlockIndex
|
|
60
|
+
) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// If the user is attempting to drop a block within its own
|
|
65
|
+
// nested blocks, return early as this would create infinite
|
|
66
|
+
// recursion.
|
|
67
|
+
if (
|
|
68
|
+
sourceClientIds.includes( targetRootClientId ) ||
|
|
69
|
+
getClientIdsOfDescendants( sourceClientIds ).some(
|
|
70
|
+
( id ) => id === targetRootClientId
|
|
71
|
+
)
|
|
72
|
+
) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const isAtSameLevel = sourceRootClientId === targetRootClientId;
|
|
77
|
+
const draggedBlockCount = sourceClientIds.length;
|
|
78
|
+
|
|
79
|
+
// If the block is kept at the same level and moved downwards,
|
|
80
|
+
// subtract to take into account that the blocks being dragged
|
|
81
|
+
// were removed from the block list above the insertion point.
|
|
82
|
+
const insertIndex =
|
|
83
|
+
isAtSameLevel && sourceBlockIndex < targetBlockIndex
|
|
84
|
+
? targetBlockIndex - draggedBlockCount
|
|
85
|
+
: targetBlockIndex;
|
|
86
|
+
|
|
87
|
+
moveBlocksToPosition(
|
|
88
|
+
sourceClientIds,
|
|
89
|
+
sourceRootClientId,
|
|
90
|
+
targetRootClientId,
|
|
91
|
+
insertIndex
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A React hook for handling block drop events.
|
|
99
|
+
*
|
|
100
|
+
* @return {Function} The event handler for a block drop event.
|
|
101
|
+
*/
|
|
102
|
+
export default function useOnBlockDrop() {
|
|
103
|
+
const { getBlockIndex, getClientIdsOfDescendants } = useSelect(
|
|
104
|
+
blockEditorStore
|
|
105
|
+
);
|
|
106
|
+
const {
|
|
107
|
+
insertBlocks,
|
|
108
|
+
moveBlocksToPosition,
|
|
109
|
+
clearSelectedBlock,
|
|
110
|
+
} = useDispatch( blockEditorStore );
|
|
111
|
+
|
|
112
|
+
return onBlockDrop(
|
|
113
|
+
getBlockIndex,
|
|
114
|
+
getClientIdsOfDescendants,
|
|
115
|
+
moveBlocksToPosition,
|
|
116
|
+
insertBlocks,
|
|
117
|
+
clearSelectedBlock
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -7,7 +7,10 @@ import { get } from 'lodash';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect } from '@wordpress/data';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,
|
|
12
|
+
hasBlockSupport,
|
|
13
|
+
} from '@wordpress/blocks';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Internal dependencies
|
|
@@ -91,8 +94,10 @@ const removeCustomPrefixes = ( path ) => {
|
|
|
91
94
|
};
|
|
92
95
|
|
|
93
96
|
/**
|
|
94
|
-
* Hook that retrieves the
|
|
95
|
-
*
|
|
97
|
+
* Hook that retrieves the given setting for the block instance in use.
|
|
98
|
+
*
|
|
99
|
+
* It looks up the settings first in the block instance hierarchy.
|
|
100
|
+
* If none is found, it'll look it up in the block editor store.
|
|
96
101
|
*
|
|
97
102
|
* @param {string} path The path to the setting.
|
|
98
103
|
* @return {any} Returns the value defined for the setting.
|
|
@@ -102,7 +107,7 @@ const removeCustomPrefixes = ( path ) => {
|
|
|
102
107
|
* ```
|
|
103
108
|
*/
|
|
104
109
|
export default function useSetting( path ) {
|
|
105
|
-
const { name: blockName } = useBlockEditContext();
|
|
110
|
+
const { name: blockName, clientId } = useBlockEditContext();
|
|
106
111
|
|
|
107
112
|
const setting = useSelect(
|
|
108
113
|
( select ) => {
|
|
@@ -113,28 +118,59 @@ export default function useSetting( path ) {
|
|
|
113
118
|
);
|
|
114
119
|
return undefined;
|
|
115
120
|
}
|
|
116
|
-
const settings = select( blockEditorStore ).getSettings();
|
|
117
121
|
|
|
118
|
-
|
|
119
|
-
// We cascade to the all value if the block one is not available.
|
|
122
|
+
let result;
|
|
120
123
|
const normalizedPath = removeCustomPrefixes( path );
|
|
121
|
-
const defaultsPath = `__experimentalFeatures.${ normalizedPath }`;
|
|
122
|
-
const blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;
|
|
123
|
-
const experimentalFeaturesResult =
|
|
124
|
-
get( settings, blockPath ) ?? get( settings, defaultsPath );
|
|
125
124
|
|
|
126
|
-
|
|
125
|
+
// 1. Take settings from the block instance or its ancestors.
|
|
126
|
+
const candidates = [
|
|
127
|
+
...select( blockEditorStore ).getBlockParents( clientId ),
|
|
128
|
+
clientId, // The current block is added last, so it overwrites any ancestor.
|
|
129
|
+
];
|
|
130
|
+
candidates.forEach( ( candidateClientId ) => {
|
|
131
|
+
const candidateBlockName = select(
|
|
132
|
+
blockEditorStore
|
|
133
|
+
).getBlockName( candidateClientId );
|
|
134
|
+
if (
|
|
135
|
+
hasBlockSupport(
|
|
136
|
+
candidateBlockName,
|
|
137
|
+
'__experimentalSettings',
|
|
138
|
+
false
|
|
139
|
+
)
|
|
140
|
+
) {
|
|
141
|
+
const candidateAtts = select(
|
|
142
|
+
blockEditorStore
|
|
143
|
+
).getBlockAttributes( candidateClientId );
|
|
144
|
+
const candidateResult =
|
|
145
|
+
get(
|
|
146
|
+
candidateAtts,
|
|
147
|
+
`settings.blocks.${ blockName }.${ normalizedPath }`
|
|
148
|
+
) ??
|
|
149
|
+
get( candidateAtts, `settings.${ normalizedPath }` );
|
|
150
|
+
if ( candidateResult !== undefined ) {
|
|
151
|
+
result = candidateResult;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
} );
|
|
155
|
+
|
|
156
|
+
// 2. Fall back to the settings from the block editor store (__experimentalFeatures).
|
|
157
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
158
|
+
if ( result === undefined ) {
|
|
159
|
+
const defaultsPath = `__experimentalFeatures.${ normalizedPath }`;
|
|
160
|
+
const blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;
|
|
161
|
+
result =
|
|
162
|
+
get( settings, blockPath ) ?? get( settings, defaultsPath );
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Return if the setting was found in either the block instance or the store.
|
|
166
|
+
if ( result !== undefined ) {
|
|
127
167
|
if ( PATHS_WITH_MERGE[ normalizedPath ] ) {
|
|
128
|
-
return
|
|
129
|
-
experimentalFeaturesResult.custom ??
|
|
130
|
-
experimentalFeaturesResult.theme ??
|
|
131
|
-
experimentalFeaturesResult.default
|
|
132
|
-
);
|
|
168
|
+
return result.custom ?? result.theme ?? result.default;
|
|
133
169
|
}
|
|
134
|
-
return
|
|
170
|
+
return result;
|
|
135
171
|
}
|
|
136
172
|
|
|
137
|
-
//
|
|
173
|
+
// 3. Otherwise, use deprecated settings.
|
|
138
174
|
const deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]
|
|
139
175
|
? deprecatedFlags[ normalizedPath ]( settings )
|
|
140
176
|
: undefined;
|
|
@@ -142,13 +178,13 @@ export default function useSetting( path ) {
|
|
|
142
178
|
return deprecatedSettingsValue;
|
|
143
179
|
}
|
|
144
180
|
|
|
145
|
-
//
|
|
181
|
+
// 4. Fallback for typography.dropCap:
|
|
146
182
|
// This is only necessary to support typography.dropCap.
|
|
147
183
|
// when __experimentalFeatures are not present (core without plugin).
|
|
148
184
|
// To remove when __experimentalFeatures are ported to core.
|
|
149
185
|
return normalizedPath === 'typography.dropCap' ? true : undefined;
|
|
150
186
|
},
|
|
151
|
-
[ blockName, path ]
|
|
187
|
+
[ blockName, clientId, path ]
|
|
152
188
|
);
|
|
153
189
|
|
|
154
190
|
return setting;
|
|
@@ -13,50 +13,55 @@ import { moreHorizontal } from '@wordpress/icons';
|
|
|
13
13
|
|
|
14
14
|
function Warning( { className, actions, children, secondaryActions } ) {
|
|
15
15
|
return (
|
|
16
|
-
<div
|
|
17
|
-
<div className=
|
|
18
|
-
<
|
|
16
|
+
<div style={ { display: 'contents', all: 'initial' } }>
|
|
17
|
+
<div className={ classnames( className, 'block-editor-warning' ) }>
|
|
18
|
+
<div className="block-editor-warning__contents">
|
|
19
|
+
<p className="block-editor-warning__message">
|
|
20
|
+
{ children }
|
|
21
|
+
</p>
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
{ ( Children.count( actions ) > 0 || secondaryActions ) && (
|
|
24
|
+
<div className="block-editor-warning__actions">
|
|
25
|
+
{ Children.count( actions ) > 0 &&
|
|
26
|
+
Children.map( actions, ( action, i ) => (
|
|
27
|
+
<span
|
|
28
|
+
key={ i }
|
|
29
|
+
className="block-editor-warning__action"
|
|
30
|
+
>
|
|
31
|
+
{ action }
|
|
32
|
+
</span>
|
|
33
|
+
) ) }
|
|
34
|
+
{ secondaryActions && (
|
|
35
|
+
<DropdownMenu
|
|
36
|
+
className="block-editor-warning__secondary"
|
|
37
|
+
icon={ moreHorizontal }
|
|
38
|
+
label={ __( 'More options' ) }
|
|
39
|
+
popoverProps={ {
|
|
40
|
+
position: 'bottom left',
|
|
41
|
+
className:
|
|
42
|
+
'block-editor-warning__dropdown',
|
|
43
|
+
} }
|
|
44
|
+
noIcons
|
|
27
45
|
>
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
onClick={ item.onClick }
|
|
48
|
-
key={ pos }
|
|
49
|
-
>
|
|
50
|
-
{ item.title }
|
|
51
|
-
</MenuItem>
|
|
52
|
-
)
|
|
53
|
-
) }
|
|
54
|
-
</MenuGroup>
|
|
55
|
-
) }
|
|
56
|
-
</DropdownMenu>
|
|
57
|
-
) }
|
|
58
|
-
</div>
|
|
59
|
-
) }
|
|
46
|
+
{ () => (
|
|
47
|
+
<MenuGroup>
|
|
48
|
+
{ secondaryActions.map(
|
|
49
|
+
( item, pos ) => (
|
|
50
|
+
<MenuItem
|
|
51
|
+
onClick={ item.onClick }
|
|
52
|
+
key={ pos }
|
|
53
|
+
>
|
|
54
|
+
{ item.title }
|
|
55
|
+
</MenuItem>
|
|
56
|
+
)
|
|
57
|
+
) }
|
|
58
|
+
</MenuGroup>
|
|
59
|
+
) }
|
|
60
|
+
</DropdownMenu>
|
|
61
|
+
) }
|
|
62
|
+
</div>
|
|
63
|
+
) }
|
|
64
|
+
</div>
|
|
60
65
|
</div>
|
|
61
66
|
</div>
|
|
62
67
|
);
|
|
@@ -2,16 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Warning should match snapshot 1`] = `
|
|
4
4
|
<div
|
|
5
|
-
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"all": "initial",
|
|
8
|
+
"display": "contents",
|
|
9
|
+
}
|
|
10
|
+
}
|
|
6
11
|
>
|
|
7
12
|
<div
|
|
8
|
-
className="block-editor-
|
|
13
|
+
className="block-editor-warning"
|
|
9
14
|
>
|
|
10
|
-
<
|
|
11
|
-
className="block-editor-
|
|
15
|
+
<div
|
|
16
|
+
className="block-editor-warning__contents"
|
|
12
17
|
>
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
<p
|
|
19
|
+
className="block-editor-warning__message"
|
|
20
|
+
>
|
|
21
|
+
error
|
|
22
|
+
</p>
|
|
23
|
+
</div>
|
|
15
24
|
</div>
|
|
16
25
|
</div>
|
|
17
26
|
`;
|
|
@@ -18,7 +18,7 @@ describe( 'Warning', () => {
|
|
|
18
18
|
it( 'should have valid class', () => {
|
|
19
19
|
const wrapper = shallow( <Warning /> );
|
|
20
20
|
|
|
21
|
-
expect( wrapper.
|
|
21
|
+
expect( wrapper.find( '.block-editor-warning' ) ).toHaveLength( 1 );
|
|
22
22
|
expect( wrapper.find( '.block-editor-warning__actions' ) ).toHaveLength(
|
|
23
23
|
0
|
|
24
24
|
);
|
|
@@ -11,10 +11,9 @@ import { store as blockEditorStore } from '../../store';
|
|
|
11
11
|
import { getBlockClientId } from '../../utils/dom';
|
|
12
12
|
|
|
13
13
|
export default function useClickSelection() {
|
|
14
|
-
const {
|
|
14
|
+
const { selectBlock } = useDispatch( blockEditorStore );
|
|
15
15
|
const {
|
|
16
16
|
isSelectionEnabled,
|
|
17
|
-
getBlockParents,
|
|
18
17
|
getBlockSelectionStart,
|
|
19
18
|
hasMultiSelection,
|
|
20
19
|
} = useSelect( blockEditorStore );
|
|
@@ -54,10 +53,8 @@ export default function useClickSelection() {
|
|
|
54
53
|
};
|
|
55
54
|
},
|
|
56
55
|
[
|
|
57
|
-
multiSelect,
|
|
58
56
|
selectBlock,
|
|
59
57
|
isSelectionEnabled,
|
|
60
|
-
getBlockParents,
|
|
61
58
|
getBlockSelectionStart,
|
|
62
59
|
hasMultiSelection,
|
|
63
60
|
]
|
|
@@ -30,6 +30,16 @@ export default function useInput() {
|
|
|
30
30
|
} = useDispatch( blockEditorStore );
|
|
31
31
|
|
|
32
32
|
return useRefEffect( ( node ) => {
|
|
33
|
+
function onBeforeInput( event ) {
|
|
34
|
+
if ( ! hasMultiSelection() ) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Prevent the browser to format something when we have multiselection.
|
|
38
|
+
if ( event.inputType?.startsWith( 'format' ) ) {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
33
43
|
function onKeyDown( event ) {
|
|
34
44
|
if ( event.defaultPrevented ) {
|
|
35
45
|
return;
|
|
@@ -102,9 +112,11 @@ export default function useInput() {
|
|
|
102
112
|
}
|
|
103
113
|
}
|
|
104
114
|
|
|
115
|
+
node.addEventListener( 'beforeinput', onBeforeInput );
|
|
105
116
|
node.addEventListener( 'keydown', onKeyDown );
|
|
106
117
|
node.addEventListener( 'compositionstart', onCompositionStart );
|
|
107
118
|
return () => {
|
|
119
|
+
node.removeEventListener( 'beforeinput', onBeforeInput );
|
|
108
120
|
node.removeEventListener( 'keydown', onKeyDown );
|
|
109
121
|
node.removeEventListener( 'compositionstart', onCompositionStart );
|
|
110
122
|
};
|