@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,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = DroppingInsertionPoint;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
13
|
+
|
|
14
|
+
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
15
|
+
|
|
16
|
+
var _data = require("@wordpress/data");
|
|
17
|
+
|
|
18
|
+
var _reactNativeBridge = require("@wordpress/react-native-bridge");
|
|
19
|
+
|
|
20
|
+
var _store = require("../../store");
|
|
21
|
+
|
|
22
|
+
var _blockListContext = require("../block-list/block-list-context");
|
|
23
|
+
|
|
24
|
+
var _droppingInsertionPoint = _interopRequireDefault(require("./dropping-insertion-point.scss"));
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* External dependencies
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* WordPress dependencies
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Internal dependencies
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Dropping zone indicator component.
|
|
44
|
+
*
|
|
45
|
+
* This component shows where a block can be dropped when it's being dragged.
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} props Component props.
|
|
48
|
+
* @param {Object} props.scroll Scroll offset object.
|
|
49
|
+
* @param {Object} props.currentYPosition Current Y coordinate position when dragging.
|
|
50
|
+
* @param {import('react-native-reanimated').SharedValue} props.isDragging Whether or not dragging has started.
|
|
51
|
+
* @param {import('react-native-reanimated').SharedValue} props.targetBlockIndex Current block target index.
|
|
52
|
+
*
|
|
53
|
+
* @return {JSX.Element} The component to be rendered.
|
|
54
|
+
*/
|
|
55
|
+
function DroppingInsertionPoint(_ref) {
|
|
56
|
+
let {
|
|
57
|
+
scroll,
|
|
58
|
+
currentYPosition,
|
|
59
|
+
isDragging,
|
|
60
|
+
targetBlockIndex
|
|
61
|
+
} = _ref;
|
|
62
|
+
const {
|
|
63
|
+
getBlockOrder,
|
|
64
|
+
isBlockBeingDragged,
|
|
65
|
+
isDraggingBlocks,
|
|
66
|
+
getPreviousBlockClientId,
|
|
67
|
+
getNextBlockClientId
|
|
68
|
+
} = (0, _data.useSelect)(_store.store);
|
|
69
|
+
const {
|
|
70
|
+
blocksLayouts,
|
|
71
|
+
findBlockLayoutByClientId
|
|
72
|
+
} = (0, _blockListContext.useBlockListContext)();
|
|
73
|
+
const {
|
|
74
|
+
top,
|
|
75
|
+
bottom
|
|
76
|
+
} = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
77
|
+
const {
|
|
78
|
+
height
|
|
79
|
+
} = (0, _reactNativeSafeAreaContext.useSafeAreaFrame)();
|
|
80
|
+
const safeAreaOffset = top + bottom;
|
|
81
|
+
const maxHeight = height - (safeAreaOffset + _droppingInsertionPoint.default['dropping-insertion-point'].height);
|
|
82
|
+
const blockYPosition = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
83
|
+
const opacity = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
84
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => isDragging.value, value => {
|
|
85
|
+
if (!value) {
|
|
86
|
+
opacity.value = 0;
|
|
87
|
+
blockYPosition.value = 0;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
function getSelectedBlockIndicatorPosition(positions) {
|
|
92
|
+
const currentYPositionWithScroll = currentYPosition.value + scroll.offsetY.value;
|
|
93
|
+
const midpoint = (positions.top + positions.bottom) / 2;
|
|
94
|
+
return midpoint < currentYPositionWithScroll ? positions.bottom : positions.top;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function setIndicatorPosition(index) {
|
|
98
|
+
const insertionPointIndex = index;
|
|
99
|
+
const order = getBlockOrder();
|
|
100
|
+
const isDraggingAnyBlocks = isDraggingBlocks();
|
|
101
|
+
|
|
102
|
+
if (!isDraggingAnyBlocks || insertionPointIndex === null || !order.length) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let previousClientId = order[insertionPointIndex - 1];
|
|
107
|
+
let nextClientId = order[insertionPointIndex];
|
|
108
|
+
|
|
109
|
+
while (isBlockBeingDragged(previousClientId)) {
|
|
110
|
+
previousClientId = getPreviousBlockClientId(previousClientId);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
while (isBlockBeingDragged(nextClientId)) {
|
|
114
|
+
nextClientId = getNextBlockClientId(nextClientId);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const previousElement = previousClientId ? findBlockLayoutByClientId(blocksLayouts.current, previousClientId) : null;
|
|
118
|
+
const nextElement = nextClientId ? findBlockLayoutByClientId(blocksLayouts.current, nextClientId) : null;
|
|
119
|
+
const previousElementPosition = previousElement ? previousElement.y + previousElement.height : 0;
|
|
120
|
+
const nextElementPosition = nextElement ? nextElement.y : 0;
|
|
121
|
+
const elementsPositions = {
|
|
122
|
+
top: Math.floor(previousElement ? previousElementPosition : nextElementPosition),
|
|
123
|
+
bottom: Math.floor(nextElement ? nextElementPosition : previousElementPosition)
|
|
124
|
+
};
|
|
125
|
+
const nextPosition = elementsPositions.top !== elementsPositions.bottom ? getSelectedBlockIndicatorPosition(elementsPositions) : elementsPositions.top;
|
|
126
|
+
|
|
127
|
+
if (nextPosition && blockYPosition.value !== nextPosition) {
|
|
128
|
+
opacity.value = 0;
|
|
129
|
+
blockYPosition.value = nextPosition;
|
|
130
|
+
opacity.value = (0, _reactNativeReanimated.withTiming)(1);
|
|
131
|
+
(0, _reactNativeBridge.generateHapticFeedback)();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => targetBlockIndex.value, (value, previous) => {
|
|
136
|
+
if (value !== previous) {
|
|
137
|
+
(0, _reactNativeReanimated.runOnJS)(setIndicatorPosition)(value);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const animatedStyles = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
141
|
+
const translationY = blockYPosition.value - scroll.offsetY.value; // Prevents overflowing behind the header/footer
|
|
142
|
+
|
|
143
|
+
const shouldHideIndicator = translationY < 0 || translationY > maxHeight;
|
|
144
|
+
return {
|
|
145
|
+
opacity: shouldHideIndicator ? 0 : opacity.value,
|
|
146
|
+
transform: [{
|
|
147
|
+
translateY: translationY
|
|
148
|
+
}]
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
const insertionPointStyles = [_droppingInsertionPoint.default['dropping-insertion-point'], animatedStyles];
|
|
152
|
+
return (0, _element.createElement)(_reactNativeReanimated.default.View, {
|
|
153
|
+
pointerEvents: "none",
|
|
154
|
+
style: insertionPointStyles
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=dropping-insertion-point.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/dropping-insertion-point.native.js"],"names":["DroppingInsertionPoint","scroll","currentYPosition","isDragging","targetBlockIndex","getBlockOrder","isBlockBeingDragged","isDraggingBlocks","getPreviousBlockClientId","getNextBlockClientId","blockEditorStore","blocksLayouts","findBlockLayoutByClientId","top","bottom","height","safeAreaOffset","maxHeight","styles","blockYPosition","opacity","value","getSelectedBlockIndicatorPosition","positions","currentYPositionWithScroll","offsetY","midpoint","setIndicatorPosition","index","insertionPointIndex","order","isDraggingAnyBlocks","length","previousClientId","nextClientId","previousElement","current","nextElement","previousElementPosition","y","nextElementPosition","elementsPositions","Math","floor","nextPosition","previous","animatedStyles","translationY","shouldHideIndicator","transform","translateY","insertionPointStyles"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport Animated, {\n\tuseSharedValue,\n\tuseAnimatedStyle,\n\twithTiming,\n\tuseAnimatedReaction,\n\trunOnJS,\n} from 'react-native-reanimated';\nimport {\n\tuseSafeAreaInsets,\n\tuseSafeAreaFrame,\n} from 'react-native-safe-area-context';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { generateHapticFeedback } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockListContext } from '../block-list/block-list-context';\nimport styles from './dropping-insertion-point.scss';\n\n/**\n * Dropping zone indicator component.\n *\n * This component shows where a block can be dropped when it's being dragged.\n *\n * @param {Object} props Component props.\n * @param {Object} props.scroll Scroll offset object.\n * @param {Object} props.currentYPosition Current Y coordinate position when dragging.\n * @param {import('react-native-reanimated').SharedValue} props.isDragging Whether or not dragging has started.\n * @param {import('react-native-reanimated').SharedValue} props.targetBlockIndex Current block target index.\n *\n * @return {JSX.Element} The component to be rendered.\n */\nexport default function DroppingInsertionPoint( {\n\tscroll,\n\tcurrentYPosition,\n\tisDragging,\n\ttargetBlockIndex,\n} ) {\n\tconst {\n\t\tgetBlockOrder,\n\t\tisBlockBeingDragged,\n\t\tisDraggingBlocks,\n\t\tgetPreviousBlockClientId,\n\t\tgetNextBlockClientId,\n\t} = useSelect( blockEditorStore );\n\n\tconst { blocksLayouts, findBlockLayoutByClientId } = useBlockListContext();\n\tconst { top, bottom } = useSafeAreaInsets();\n\tconst { height } = useSafeAreaFrame();\n\tconst safeAreaOffset = top + bottom;\n\tconst maxHeight =\n\t\theight -\n\t\t( safeAreaOffset + styles[ 'dropping-insertion-point' ].height );\n\n\tconst blockYPosition = useSharedValue( 0 );\n\tconst opacity = useSharedValue( 0 );\n\n\tuseAnimatedReaction(\n\t\t() => isDragging.value,\n\t\t( value ) => {\n\t\t\tif ( ! value ) {\n\t\t\t\topacity.value = 0;\n\t\t\t\tblockYPosition.value = 0;\n\t\t\t}\n\t\t}\n\t);\n\n\tfunction getSelectedBlockIndicatorPosition( positions ) {\n\t\tconst currentYPositionWithScroll =\n\t\t\tcurrentYPosition.value + scroll.offsetY.value;\n\t\tconst midpoint = ( positions.top + positions.bottom ) / 2;\n\n\t\treturn midpoint < currentYPositionWithScroll\n\t\t\t? positions.bottom\n\t\t\t: positions.top;\n\t}\n\n\tfunction setIndicatorPosition( index ) {\n\t\tconst insertionPointIndex = index;\n\t\tconst order = getBlockOrder();\n\t\tconst isDraggingAnyBlocks = isDraggingBlocks();\n\n\t\tif (\n\t\t\t! isDraggingAnyBlocks ||\n\t\t\tinsertionPointIndex === null ||\n\t\t\t! order.length\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet previousClientId = order[ insertionPointIndex - 1 ];\n\t\tlet nextClientId = order[ insertionPointIndex ];\n\n\t\twhile ( isBlockBeingDragged( previousClientId ) ) {\n\t\t\tpreviousClientId = getPreviousBlockClientId( previousClientId );\n\t\t}\n\n\t\twhile ( isBlockBeingDragged( nextClientId ) ) {\n\t\t\tnextClientId = getNextBlockClientId( nextClientId );\n\t\t}\n\n\t\tconst previousElement = previousClientId\n\t\t\t? findBlockLayoutByClientId(\n\t\t\t\t\tblocksLayouts.current,\n\t\t\t\t\tpreviousClientId\n\t\t\t )\n\t\t\t: null;\n\t\tconst nextElement = nextClientId\n\t\t\t? findBlockLayoutByClientId( blocksLayouts.current, nextClientId )\n\t\t\t: null;\n\n\t\tconst previousElementPosition = previousElement\n\t\t\t? previousElement.y + previousElement.height\n\t\t\t: 0;\n\t\tconst nextElementPosition = nextElement ? nextElement.y : 0;\n\n\t\tconst elementsPositions = {\n\t\t\ttop: Math.floor(\n\t\t\t\tpreviousElement ? previousElementPosition : nextElementPosition\n\t\t\t),\n\t\t\tbottom: Math.floor(\n\t\t\t\tnextElement ? nextElementPosition : previousElementPosition\n\t\t\t),\n\t\t};\n\n\t\tconst nextPosition =\n\t\t\telementsPositions.top !== elementsPositions.bottom\n\t\t\t\t? getSelectedBlockIndicatorPosition( elementsPositions )\n\t\t\t\t: elementsPositions.top;\n\n\t\tif ( nextPosition && blockYPosition.value !== nextPosition ) {\n\t\t\topacity.value = 0;\n\t\t\tblockYPosition.value = nextPosition;\n\t\t\topacity.value = withTiming( 1 );\n\t\t\tgenerateHapticFeedback();\n\t\t}\n\t}\n\n\tuseAnimatedReaction(\n\t\t() => targetBlockIndex.value,\n\t\t( value, previous ) => {\n\t\t\tif ( value !== previous ) {\n\t\t\t\trunOnJS( setIndicatorPosition )( value );\n\t\t\t}\n\t\t}\n\t);\n\n\tconst animatedStyles = useAnimatedStyle( () => {\n\t\tconst translationY = blockYPosition.value - scroll.offsetY.value;\n\t\t// Prevents overflowing behind the header/footer\n\t\tconst shouldHideIndicator =\n\t\t\ttranslationY < 0 || translationY > maxHeight;\n\n\t\treturn {\n\t\t\topacity: shouldHideIndicator ? 0 : opacity.value,\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: translationY,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t} );\n\n\tconst insertionPointStyles = [\n\t\tstyles[ 'dropping-insertion-point' ],\n\t\tanimatedStyles,\n\t];\n\n\treturn (\n\t\t<Animated.View pointerEvents=\"none\" style={ insertionPointStyles } />\n\t);\n}\n"]}
|
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = exports.BlockDraggableWrapper = void 0;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _reactNative = require("react-native");
|
|
13
|
+
|
|
14
|
+
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
15
|
+
|
|
16
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
17
|
+
|
|
18
|
+
var _components = require("@wordpress/components");
|
|
19
|
+
|
|
20
|
+
var _data = require("@wordpress/data");
|
|
21
|
+
|
|
22
|
+
var _blocks = require("@wordpress/blocks");
|
|
23
|
+
|
|
24
|
+
var _reactNativeBridge = require("@wordpress/react-native-bridge");
|
|
25
|
+
|
|
26
|
+
var _reactNativeAztec = _interopRequireDefault(require("@wordpress/react-native-aztec"));
|
|
27
|
+
|
|
28
|
+
var _useScrollWhenDragging = _interopRequireDefault(require("./use-scroll-when-dragging"));
|
|
29
|
+
|
|
30
|
+
var _draggableChip = _interopRequireDefault(require("./draggable-chip"));
|
|
31
|
+
|
|
32
|
+
var _store = require("../../store");
|
|
33
|
+
|
|
34
|
+
var _blockListContext = require("../block-list/block-list-context");
|
|
35
|
+
|
|
36
|
+
var _droppingInsertionPoint = _interopRequireDefault(require("./dropping-insertion-point"));
|
|
37
|
+
|
|
38
|
+
var _useBlockDropZone = _interopRequireDefault(require("../use-block-drop-zone"));
|
|
39
|
+
|
|
40
|
+
var _style = _interopRequireDefault(require("./style.scss"));
|
|
41
|
+
|
|
42
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
|
+
|
|
44
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* External dependencies
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* WordPress dependencies
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Internal dependencies
|
|
56
|
+
*/
|
|
57
|
+
const CHIP_OFFSET_TO_TOUCH_POSITION = 32;
|
|
58
|
+
const BLOCK_OPACITY_ANIMATION_CONFIG = {
|
|
59
|
+
duration: 350
|
|
60
|
+
};
|
|
61
|
+
const BLOCK_OPACITY_ANIMATION_DELAY = 250;
|
|
62
|
+
const DEFAULT_LONG_PRESS_MIN_DURATION = 500;
|
|
63
|
+
const DEFAULT_IOS_LONG_PRESS_MIN_DURATION = DEFAULT_LONG_PRESS_MIN_DURATION - 50;
|
|
64
|
+
/**
|
|
65
|
+
* Block draggable wrapper component
|
|
66
|
+
*
|
|
67
|
+
* This component handles all the interactions for dragging blocks.
|
|
68
|
+
* It relies on the block list and its context for dragging, hence it
|
|
69
|
+
* should be rendered between the `BlockListProvider` component and the
|
|
70
|
+
* block list rendering. It also requires listening to scroll events,
|
|
71
|
+
* therefore for this purpose, it returns the `onScroll` event handler
|
|
72
|
+
* that should be attached to the list that renders the blocks.
|
|
73
|
+
*
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} props Component props.
|
|
76
|
+
* @param {JSX.Element} props.children Children to be rendered.
|
|
77
|
+
* @param {boolean} props.isRTL Check if current locale is RTL.
|
|
78
|
+
*
|
|
79
|
+
* @return {Function} Render function that passes `onScroll` event handler.
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
const BlockDraggableWrapper = _ref => {
|
|
83
|
+
let {
|
|
84
|
+
children,
|
|
85
|
+
isRTL
|
|
86
|
+
} = _ref;
|
|
87
|
+
const [draggedBlockIcon, setDraggedBlockIcon] = (0, _element.useState)();
|
|
88
|
+
const {
|
|
89
|
+
selectBlock,
|
|
90
|
+
startDraggingBlocks,
|
|
91
|
+
stopDraggingBlocks
|
|
92
|
+
} = (0, _data.useDispatch)(_store.store);
|
|
93
|
+
const {
|
|
94
|
+
scrollRef
|
|
95
|
+
} = (0, _blockListContext.useBlockListContext)();
|
|
96
|
+
const animatedScrollRef = (0, _reactNativeReanimated.useAnimatedRef)();
|
|
97
|
+
const {
|
|
98
|
+
left,
|
|
99
|
+
right
|
|
100
|
+
} = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
101
|
+
const {
|
|
102
|
+
width
|
|
103
|
+
} = (0, _reactNativeSafeAreaContext.useSafeAreaFrame)();
|
|
104
|
+
const safeAreaOffset = left + right;
|
|
105
|
+
const contentWidth = width - safeAreaOffset;
|
|
106
|
+
animatedScrollRef(scrollRef);
|
|
107
|
+
const scroll = {
|
|
108
|
+
offsetY: (0, _reactNativeReanimated.useSharedValue)(0)
|
|
109
|
+
};
|
|
110
|
+
const chip = {
|
|
111
|
+
x: (0, _reactNativeReanimated.useSharedValue)(0),
|
|
112
|
+
y: (0, _reactNativeReanimated.useSharedValue)(0),
|
|
113
|
+
width: (0, _reactNativeReanimated.useSharedValue)(0),
|
|
114
|
+
height: (0, _reactNativeReanimated.useSharedValue)(0)
|
|
115
|
+
};
|
|
116
|
+
const currentYPosition = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
117
|
+
const isDragging = (0, _reactNativeReanimated.useSharedValue)(false);
|
|
118
|
+
const [startScrolling, scrollOnDragOver, stopScrolling, draggingScrollHandler] = (0, _useScrollWhenDragging.default)();
|
|
119
|
+
|
|
120
|
+
const scrollHandler = event => {
|
|
121
|
+
'worklet';
|
|
122
|
+
|
|
123
|
+
const {
|
|
124
|
+
contentOffset
|
|
125
|
+
} = event;
|
|
126
|
+
scroll.offsetY.value = contentOffset.y;
|
|
127
|
+
draggingScrollHandler(event);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const {
|
|
131
|
+
onBlockDragOver,
|
|
132
|
+
onBlockDragEnd,
|
|
133
|
+
onBlockDrop,
|
|
134
|
+
targetBlockIndex
|
|
135
|
+
} = (0, _useBlockDropZone.default)(); // Stop dragging blocks if the block draggable is unmounted.
|
|
136
|
+
|
|
137
|
+
(0, _element.useEffect)(() => {
|
|
138
|
+
return () => {
|
|
139
|
+
if (isDragging.value) {
|
|
140
|
+
stopDraggingBlocks();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}, []);
|
|
144
|
+
|
|
145
|
+
const setDraggedBlockIconByClientId = clientId => {
|
|
146
|
+
var _getBlockType;
|
|
147
|
+
|
|
148
|
+
const blockName = (0, _data.select)(_store.store).getBlockName(clientId);
|
|
149
|
+
const blockIcon = (_getBlockType = (0, _blocks.getBlockType)(blockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon;
|
|
150
|
+
|
|
151
|
+
if (blockIcon) {
|
|
152
|
+
setDraggedBlockIcon(blockIcon);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const onStartDragging = _ref2 => {
|
|
157
|
+
let {
|
|
158
|
+
clientId,
|
|
159
|
+
position
|
|
160
|
+
} = _ref2;
|
|
161
|
+
|
|
162
|
+
if (clientId) {
|
|
163
|
+
startDraggingBlocks([clientId]);
|
|
164
|
+
setDraggedBlockIconByClientId(clientId);
|
|
165
|
+
(0, _reactNativeReanimated.runOnUI)(startScrolling)(position.y);
|
|
166
|
+
(0, _reactNativeBridge.generateHapticFeedback)();
|
|
167
|
+
} else {
|
|
168
|
+
// We stop dragging if no block is found.
|
|
169
|
+
(0, _reactNativeReanimated.runOnUI)(stopDragging)();
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const onStopDragging = _ref3 => {
|
|
174
|
+
let {
|
|
175
|
+
clientId
|
|
176
|
+
} = _ref3;
|
|
177
|
+
|
|
178
|
+
if (clientId) {
|
|
179
|
+
onBlockDrop({
|
|
180
|
+
// Dropping is only allowed at root level
|
|
181
|
+
srcRootClientId: '',
|
|
182
|
+
srcClientIds: [clientId],
|
|
183
|
+
type: 'block'
|
|
184
|
+
});
|
|
185
|
+
selectBlock(clientId);
|
|
186
|
+
setDraggedBlockIcon(undefined);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
onBlockDragEnd();
|
|
190
|
+
stopDraggingBlocks();
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const onChipLayout = _ref4 => {
|
|
194
|
+
let {
|
|
195
|
+
nativeEvent: {
|
|
196
|
+
layout
|
|
197
|
+
}
|
|
198
|
+
} = _ref4;
|
|
199
|
+
|
|
200
|
+
if (layout.width > 0) {
|
|
201
|
+
chip.width.value = layout.width;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (layout.height > 0) {
|
|
205
|
+
chip.height.value = layout.height;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const startDragging = _ref5 => {
|
|
210
|
+
'worklet';
|
|
211
|
+
|
|
212
|
+
let {
|
|
213
|
+
x,
|
|
214
|
+
y,
|
|
215
|
+
id
|
|
216
|
+
} = _ref5;
|
|
217
|
+
const dragPosition = {
|
|
218
|
+
x,
|
|
219
|
+
y
|
|
220
|
+
};
|
|
221
|
+
chip.x.value = dragPosition.x;
|
|
222
|
+
chip.y.value = dragPosition.y;
|
|
223
|
+
currentYPosition.value = dragPosition.y;
|
|
224
|
+
isDragging.value = true;
|
|
225
|
+
(0, _reactNativeReanimated.runOnJS)(onStartDragging)({
|
|
226
|
+
clientId: id,
|
|
227
|
+
position: dragPosition
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const updateDragging = _ref6 => {
|
|
232
|
+
'worklet';
|
|
233
|
+
|
|
234
|
+
let {
|
|
235
|
+
x,
|
|
236
|
+
y
|
|
237
|
+
} = _ref6;
|
|
238
|
+
const dragPosition = {
|
|
239
|
+
x,
|
|
240
|
+
y
|
|
241
|
+
};
|
|
242
|
+
chip.x.value = dragPosition.x;
|
|
243
|
+
chip.y.value = dragPosition.y;
|
|
244
|
+
currentYPosition.value = dragPosition.y;
|
|
245
|
+
(0, _reactNativeReanimated.runOnJS)(onBlockDragOver)({
|
|
246
|
+
x,
|
|
247
|
+
y: y + scroll.offsetY.value
|
|
248
|
+
}); // Update scrolling velocity
|
|
249
|
+
|
|
250
|
+
scrollOnDragOver(dragPosition.y);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const stopDragging = _ref7 => {
|
|
254
|
+
'worklet';
|
|
255
|
+
|
|
256
|
+
let {
|
|
257
|
+
id
|
|
258
|
+
} = _ref7;
|
|
259
|
+
isDragging.value = false;
|
|
260
|
+
stopScrolling();
|
|
261
|
+
(0, _reactNativeReanimated.runOnJS)(onStopDragging)({
|
|
262
|
+
clientId: id
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const chipDynamicStyles = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
267
|
+
const chipOffset = chip.width.value / 2;
|
|
268
|
+
const translateX = !isRTL ? chip.x.value - chipOffset : -(contentWidth - (chip.x.value + chipOffset));
|
|
269
|
+
return {
|
|
270
|
+
transform: [{
|
|
271
|
+
translateX
|
|
272
|
+
}, {
|
|
273
|
+
translateY: chip.y.value - chip.height.value - CHIP_OFFSET_TO_TOUCH_POSITION
|
|
274
|
+
}]
|
|
275
|
+
};
|
|
276
|
+
});
|
|
277
|
+
const chipStyles = [chipDynamicStyles, _style.default['draggable-chip__wrapper']];
|
|
278
|
+
|
|
279
|
+
const exitingAnimation = _ref8 => {
|
|
280
|
+
'worklet';
|
|
281
|
+
|
|
282
|
+
let {
|
|
283
|
+
currentHeight,
|
|
284
|
+
currentWidth
|
|
285
|
+
} = _ref8;
|
|
286
|
+
const translateX = !isRTL ? 0 : currentWidth * -1;
|
|
287
|
+
const duration = 150;
|
|
288
|
+
const animations = {
|
|
289
|
+
transform: [{
|
|
290
|
+
translateY: (0, _reactNativeReanimated.withTiming)(currentHeight, {
|
|
291
|
+
duration
|
|
292
|
+
})
|
|
293
|
+
}, {
|
|
294
|
+
translateX: (0, _reactNativeReanimated.withTiming)(translateX, {
|
|
295
|
+
duration
|
|
296
|
+
})
|
|
297
|
+
}, {
|
|
298
|
+
scale: (0, _reactNativeReanimated.withTiming)(0, {
|
|
299
|
+
duration
|
|
300
|
+
})
|
|
301
|
+
}]
|
|
302
|
+
};
|
|
303
|
+
const initialValues = {
|
|
304
|
+
transform: [{
|
|
305
|
+
translateY: 0
|
|
306
|
+
}, {
|
|
307
|
+
translateX
|
|
308
|
+
}, {
|
|
309
|
+
scale: 1
|
|
310
|
+
}]
|
|
311
|
+
};
|
|
312
|
+
return {
|
|
313
|
+
initialValues,
|
|
314
|
+
animations
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_droppingInsertionPoint.default, {
|
|
319
|
+
scroll: scroll,
|
|
320
|
+
currentYPosition: currentYPosition,
|
|
321
|
+
isDragging: isDragging,
|
|
322
|
+
targetBlockIndex: targetBlockIndex
|
|
323
|
+
}), (0, _element.createElement)(_components.Draggable, {
|
|
324
|
+
onDragStart: startDragging,
|
|
325
|
+
onDragOver: updateDragging,
|
|
326
|
+
onDragEnd: stopDragging,
|
|
327
|
+
testID: "block-draggable-wrapper"
|
|
328
|
+
}, children({
|
|
329
|
+
onScroll: scrollHandler
|
|
330
|
+
})), (0, _element.createElement)(_reactNativeReanimated.default.View, {
|
|
331
|
+
onLayout: onChipLayout,
|
|
332
|
+
style: chipStyles,
|
|
333
|
+
pointerEvents: "none"
|
|
334
|
+
}, draggedBlockIcon && (0, _element.createElement)(_reactNativeReanimated.default.View, {
|
|
335
|
+
entering: _reactNativeReanimated.ZoomInEasyDown.duration(200),
|
|
336
|
+
exiting: exitingAnimation
|
|
337
|
+
}, (0, _element.createElement)(_draggableChip.default, {
|
|
338
|
+
icon: draggedBlockIcon
|
|
339
|
+
}))));
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* Block draggable component
|
|
343
|
+
*
|
|
344
|
+
* This component serves for animating the block when it is being dragged.
|
|
345
|
+
* Hence, it should be wrapped around the rendering of a block.
|
|
346
|
+
*
|
|
347
|
+
* @param {Object} props Component props.
|
|
348
|
+
* @param {JSX.Element} props.children Children to be rendered.
|
|
349
|
+
* @param {string} props.clientId Client id of the block.
|
|
350
|
+
* @param {string} [props.draggingClientId] Client id to use for dragging. If not defined, the value from `clientId` will be used.
|
|
351
|
+
* @param {boolean} [props.enabled] Enables the draggable trigger.
|
|
352
|
+
* @param {string} [props.testID] Id used for querying the long-press gesture handler in tests.
|
|
353
|
+
*
|
|
354
|
+
* @return {Function} Render function which includes the parameter `isDraggable` to determine if the block can be dragged.
|
|
355
|
+
*/
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
exports.BlockDraggableWrapper = BlockDraggableWrapper;
|
|
359
|
+
|
|
360
|
+
const BlockDraggable = _ref9 => {
|
|
361
|
+
let {
|
|
362
|
+
clientId,
|
|
363
|
+
children,
|
|
364
|
+
draggingClientId,
|
|
365
|
+
enabled = true,
|
|
366
|
+
testID
|
|
367
|
+
} = _ref9;
|
|
368
|
+
const wasBeingDragged = (0, _element.useRef)(false);
|
|
369
|
+
const [isEditingText, setIsEditingText] = (0, _element.useState)(false);
|
|
370
|
+
const [isScreenReaderEnabled, setIsScreenReaderEnabled] = (0, _element.useState)(false);
|
|
371
|
+
const draggingAnimation = {
|
|
372
|
+
opacity: (0, _reactNativeReanimated.useSharedValue)(1)
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
const startDraggingBlock = () => {
|
|
376
|
+
draggingAnimation.opacity.value = (0, _reactNativeReanimated.withTiming)(0.4, BLOCK_OPACITY_ANIMATION_CONFIG);
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const stopDraggingBlock = () => {
|
|
380
|
+
draggingAnimation.opacity.value = (0, _reactNativeReanimated.withDelay)(BLOCK_OPACITY_ANIMATION_DELAY, (0, _reactNativeReanimated.withTiming)(1, BLOCK_OPACITY_ANIMATION_CONFIG));
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
const {
|
|
384
|
+
isDraggable,
|
|
385
|
+
isBeingDragged,
|
|
386
|
+
isBlockSelected
|
|
387
|
+
} = (0, _data.useSelect)(_select => {
|
|
388
|
+
const {
|
|
389
|
+
getBlockRootClientId,
|
|
390
|
+
getTemplateLock,
|
|
391
|
+
isBlockBeingDragged,
|
|
392
|
+
getSelectedBlockClientId
|
|
393
|
+
} = _select(_store.store);
|
|
394
|
+
|
|
395
|
+
const rootClientId = getBlockRootClientId(clientId);
|
|
396
|
+
const templateLock = rootClientId ? getTemplateLock(rootClientId) : null;
|
|
397
|
+
const selectedBlockClientId = getSelectedBlockClientId();
|
|
398
|
+
return {
|
|
399
|
+
isBeingDragged: isBlockBeingDragged(clientId),
|
|
400
|
+
isDraggable: 'all' !== templateLock,
|
|
401
|
+
isBlockSelected: selectedBlockClientId && selectedBlockClientId === clientId
|
|
402
|
+
};
|
|
403
|
+
}, [clientId]);
|
|
404
|
+
(0, _element.useEffect)(() => {
|
|
405
|
+
if (isBeingDragged !== wasBeingDragged.current) {
|
|
406
|
+
if (isBeingDragged) {
|
|
407
|
+
startDraggingBlock();
|
|
408
|
+
} else {
|
|
409
|
+
stopDraggingBlock();
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
wasBeingDragged.current = isBeingDragged;
|
|
414
|
+
}, [isBeingDragged]);
|
|
415
|
+
const onFocusChangeAztec = (0, _element.useCallback)(_ref10 => {
|
|
416
|
+
let {
|
|
417
|
+
isFocused
|
|
418
|
+
} = _ref10;
|
|
419
|
+
setIsEditingText(isFocused);
|
|
420
|
+
}, []);
|
|
421
|
+
(0, _element.useEffect)(() => {
|
|
422
|
+
let mounted = true;
|
|
423
|
+
|
|
424
|
+
const isAnyAztecInputFocused = _reactNativeAztec.default.InputState.isFocused();
|
|
425
|
+
|
|
426
|
+
if (isAnyAztecInputFocused) {
|
|
427
|
+
setIsEditingText(isAnyAztecInputFocused);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
_reactNativeAztec.default.InputState.addFocusChangeListener(onFocusChangeAztec);
|
|
431
|
+
|
|
432
|
+
const screenReaderChangedListener = _reactNative.AccessibilityInfo.addEventListener('screenReaderChanged', setIsScreenReaderEnabled);
|
|
433
|
+
|
|
434
|
+
_reactNative.AccessibilityInfo.isScreenReaderEnabled().then(screenReaderEnabled => {
|
|
435
|
+
if (mounted) {
|
|
436
|
+
setIsScreenReaderEnabled(screenReaderEnabled);
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
return () => {
|
|
441
|
+
mounted = false;
|
|
442
|
+
|
|
443
|
+
_reactNativeAztec.default.InputState.removeFocusChangeListener(onFocusChangeAztec);
|
|
444
|
+
|
|
445
|
+
screenReaderChangedListener.remove();
|
|
446
|
+
};
|
|
447
|
+
}, []);
|
|
448
|
+
const onLongPressDraggable = (0, _element.useCallback)(() => {
|
|
449
|
+
// Ensure that no text input is focused when starting the dragging gesture in order to prevent conflicts with text editing.
|
|
450
|
+
_reactNativeAztec.default.InputState.blurCurrentFocusedElement();
|
|
451
|
+
}, []);
|
|
452
|
+
const animatedWrapperStyles = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
453
|
+
return {
|
|
454
|
+
opacity: draggingAnimation.opacity.value
|
|
455
|
+
};
|
|
456
|
+
});
|
|
457
|
+
const wrapperStyles = [animatedWrapperStyles, _style.default['draggable-wrapper__container']];
|
|
458
|
+
const canDragBlock = enabled && !isScreenReaderEnabled && (!isBlockSelected || !isEditingText);
|
|
459
|
+
|
|
460
|
+
if (!isDraggable) {
|
|
461
|
+
return children({
|
|
462
|
+
isDraggable: false
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return (0, _element.createElement)(_components.DraggableTrigger, {
|
|
467
|
+
id: draggingClientId || clientId,
|
|
468
|
+
enabled: enabled && canDragBlock,
|
|
469
|
+
minDuration: _element.Platform.select({
|
|
470
|
+
// On iOS, using a lower min duration than the default
|
|
471
|
+
// value prevents the long-press gesture from being
|
|
472
|
+
// triggered in underneath elements. This is required to
|
|
473
|
+
// prevent enabling text editing when dragging is available.
|
|
474
|
+
ios: canDragBlock ? DEFAULT_IOS_LONG_PRESS_MIN_DURATION : DEFAULT_LONG_PRESS_MIN_DURATION,
|
|
475
|
+
android: DEFAULT_LONG_PRESS_MIN_DURATION
|
|
476
|
+
}),
|
|
477
|
+
onLongPress: onLongPressDraggable,
|
|
478
|
+
testID: testID
|
|
479
|
+
}, (0, _element.createElement)(_reactNativeReanimated.default.View, {
|
|
480
|
+
style: wrapperStyles
|
|
481
|
+
}, children({
|
|
482
|
+
isDraggable: true
|
|
483
|
+
})));
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
var _default = BlockDraggable;
|
|
487
|
+
exports.default = _default;
|
|
488
|
+
//# sourceMappingURL=index.native.js.map
|