@wordpress/block-editor 12.15.0 → 12.16.1-next.79a6196f.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 +2 -0
- package/LICENSE.md +1 -1
- package/README.md +12 -10
- package/build/components/block-canvas/index.js +21 -7
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-card/index.js +2 -2
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-controls/hook.js +3 -23
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.js +6 -1
- package/build/components/block-draggable/draggable-chip.js.map +1 -1
- package/build/components/block-draggable/index.js +76 -6
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +0 -6
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
- package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -1
- package/build/components/block-edit/context.js +5 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +18 -9
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-editing-mode/index.js +2 -3
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-info-slot-fill/index.js +3 -4
- package/build/components/block-info-slot-fill/index.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-item-cell.native.js +1 -0
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
- package/build/components/block-list/block.js +257 -95
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +58 -23
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +3 -5
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/private-block-context.js +14 -0
- package/build/components/block-list/private-block-context.js.map +1 -0
- package/build/components/block-list/use-block-props/index.js +49 -69
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -2
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list/use-scroll-upon-insertion.native.js +41 -0
- package/build/components/block-list/use-scroll-upon-insertion.native.js.map +1 -0
- package/build/components/block-lock/toolbar.js +21 -27
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/index.js +2 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +5 -5
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -9
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-rename/modal.js +3 -0
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-settings/container.native.js +6 -4
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +1 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/index.native.js +3 -2
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-switcher/index.js +4 -4
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +90 -29
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +49 -0
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build/components/block-tools/block-toolbar-popover.js +84 -0
- package/build/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build/components/block-tools/index.js +27 -24
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +4 -3
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/block-variation-picker/index.native.js +2 -1
- package/build/components/block-variation-picker/index.native.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +29 -2
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +1 -1
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/colors/utils.js +10 -2
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors/with-colors.js +6 -2
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +28 -17
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -4
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/utils.js +10 -2
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +24 -21
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +4 -3
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +2 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +6 -3
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +192 -0
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -0
- package/build/components/global-styles/hooks.js +3 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +7 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/index.js +7 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +43 -36
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +22 -8
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +8 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/height-control/index.js +6 -2
- package/build/components/height-control/index.js.map +1 -1
- package/build/components/image-link-destinations/index.native.js +118 -0
- package/build/components/image-link-destinations/index.native.js.map +1 -0
- package/build/components/image-size-control/index.js +2 -2
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.native.js +14 -5
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +61 -22
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +18 -4
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +5 -6
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +5 -9
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +10 -9
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js +10 -10
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +9 -9
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/utils.js +10 -14
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +4 -14
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/index.js +1 -2
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/library.js +3 -7
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +2 -2
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/menu.js +26 -33
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +2 -2
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/tabs.js +21 -21
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-button/index.native.js +98 -0
- package/build/components/inserter-button/index.native.js.map +1 -0
- package/build/components/inserter-button/sparkles.js +23 -0
- package/build/components/inserter-button/sparkles.js.map +1 -0
- package/build/components/inserter-draggable-blocks/index.js +8 -4
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inserter-list-item/index.js +2 -4
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +3 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +3 -3
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +3 -3
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +34 -23
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +4 -0
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +57 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/media-upload-progress/constants.js +19 -0
- package/build/components/media-upload-progress/constants.js.map +1 -0
- package/build/components/media-upload-progress/index.native.js +42 -17
- package/build/components/media-upload-progress/index.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +11 -16
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +8 -3
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +6 -62
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +7 -1
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/content.js +26 -23
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +2 -1
- package/build/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build/components/rich-text/index.js +19 -37
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +9 -16
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +22 -57
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +7 -3
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/use-mark-persistent.js +1 -1
- package/build/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build/components/rich-text/with-deprecations.js +50 -0
- package/build/components/rich-text/with-deprecations.js.map +1 -0
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +9 -6
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +14 -18
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +108 -17
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +100 -92
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +9 -12
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +4 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +14 -0
- package/build/components/use-settings/index.js.map +1 -1
- package/build/components/writing-flow/index.js +0 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js +15 -4
- package/build/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +73 -27
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +7 -4
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +21 -69
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +11 -1
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +14 -30
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/aria-label.js +9 -1
- package/build/hooks/aria-label.js.map +1 -1
- package/build/hooks/background.js +198 -36
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +24 -32
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-renaming.js +18 -22
- package/build/hooks/block-renaming.js.map +1 -1
- package/build/hooks/border.js +53 -80
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +79 -90
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +29 -29
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +13 -30
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +9 -1
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +13 -14
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +31 -61
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js +23 -28
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +52 -120
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +27 -16
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +15 -6
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout-child.js +68 -0
- package/build/hooks/layout-child.js.map +1 -0
- package/build/hooks/layout.js +25 -104
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/padding.js +2 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/position.js +40 -62
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +52 -89
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +25 -10
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/typography.native.js +43 -18
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/use-typography-props.js +10 -2
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/hooks/utils.js +200 -10
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +2 -6
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +0 -2
- package/build/private-apis.native.js.map +1 -1
- package/build/store/actions.js +0 -16
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +54 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +46 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +18 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +11 -73
- package/build/store/selectors.js.map +1 -1
- package/build/store/undo-ignore.js +12 -0
- package/build/store/undo-ignore.js.map +1 -0
- package/build/store/utils.js +66 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/get-px-from-css-unit.js +16 -0
- package/build/utils/get-px-from-css-unit.js.map +1 -0
- package/build/utils/index.js +2 -2
- package/build/utils/index.js.map +1 -1
- package/build/utils/object.js +38 -99
- package/build/utils/object.js.map +1 -1
- package/build/utils/selection.js +9 -1
- package/build/utils/selection.js.map +1 -1
- package/build/utils/use-can-block-toolbar-be-focused.js +46 -0
- package/build/utils/use-can-block-toolbar-be-focused.js.map +1 -0
- package/build-module/components/block-canvas/index.js +22 -8
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-card/index.js +2 -2
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-controls/hook.js +4 -24
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.js +6 -1
- package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
- package/build-module/components/block-draggable/index.js +76 -6
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +1 -7
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -1
- package/build-module/components/block-edit/context.js +2 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +19 -10
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +3 -4
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-info-slot-fill/index.js +3 -3
- package/build-module/components/block-info-slot-fill/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-item-cell.native.js +1 -0
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
- package/build-module/components/block-list/block.js +261 -99
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +60 -25
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +3 -5
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/private-block-context.js +6 -0
- package/build-module/components/block-list/private-block-context.js.map +1 -0
- package/build-module/components/block-list/use-block-props/index.js +50 -70
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +3 -2
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list/use-scroll-upon-insertion.native.js +33 -0
- package/build-module/components/block-list/use-scroll-upon-insertion.native.js.map +1 -0
- package/build-module/components/block-lock/toolbar.js +22 -28
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/index.js +2 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +6 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -10
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +3 -0
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +4 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/index.native.js +3 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-switcher/index.js +4 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +89 -27
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +41 -0
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build-module/components/block-tools/block-toolbar-popover.js +74 -0
- package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build-module/components/block-tools/index.js +27 -24
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +2 -1
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +30 -3
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +1 -1
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/colors/utils.js +9 -1
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -1
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +29 -18
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -4
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +9 -1
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +26 -23
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +5 -4
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +3 -2
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +8 -5
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +184 -0
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +3 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +7 -1
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +45 -38
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +15 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +7 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/height-control/index.js +6 -2
- package/build-module/components/height-control/index.js.map +1 -1
- package/build-module/components/image-link-destinations/index.native.js +109 -0
- package/build-module/components/image-link-destinations/index.native.js.map +1 -0
- package/build-module/components/image-size-control/index.js +2 -2
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.native.js +3 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +62 -23
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +18 -4
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +5 -6
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +6 -10
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +11 -10
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +11 -11
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +11 -11
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/utils.js +7 -11
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +4 -14
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +2 -2
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.js +1 -2
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/library.js +3 -7
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +26 -33
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +2 -2
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/tabs.js +22 -22
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-button/index.native.js +89 -0
- package/build-module/components/inserter-button/index.native.js.map +1 -0
- package/build-module/components/inserter-button/sparkles.js +15 -0
- package/build-module/components/inserter-button/sparkles.js.map +1 -0
- package/build-module/components/inserter-draggable-blocks/index.js +9 -5
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +2 -4
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +3 -3
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +3 -3
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +35 -24
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +4 -0
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +58 -4
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/media-upload-progress/constants.js +7 -0
- package/build-module/components/media-upload-progress/constants.js.map +1 -0
- package/build-module/components/media-upload-progress/index.native.js +37 -8
- package/build-module/components/media-upload-progress/index.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +11 -16
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +6 -1
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +6 -62
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +7 -1
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/content.js +25 -21
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +2 -1
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build-module/components/rich-text/index.js +21 -39
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +10 -18
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +22 -56
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +7 -3
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/use-mark-persistent.js +1 -1
- package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build-module/components/rich-text/with-deprecations.js +42 -0
- package/build-module/components/rich-text/with-deprecations.js.map +1 -0
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +9 -6
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +14 -18
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +107 -18
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +102 -94
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +9 -12
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +4 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +13 -1
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +0 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js +15 -4
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +73 -27
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +7 -4
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +20 -67
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +1 -0
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +12 -27
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/aria-label.js +7 -1
- package/build-module/hooks/aria-label.js.map +1 -1
- package/build-module/hooks/background.js +197 -37
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +22 -30
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-renaming.js +17 -21
- package/build-module/hooks/block-renaming.js.map +1 -1
- package/build-module/hooks/border.js +52 -79
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +78 -88
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +27 -27
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +12 -28
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +7 -1
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +15 -16
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +30 -61
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-family.js +20 -25
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +50 -120
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +20 -16
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +10 -6
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout-child.js +60 -0
- package/build-module/hooks/layout-child.js.map +1 -0
- package/build-module/hooks/layout.js +21 -100
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/padding.js +2 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/position.js +38 -59
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +52 -85
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +26 -11
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/typography.native.js +43 -17
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +9 -1
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/hooks/utils.js +194 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +2 -6
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +0 -2
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/actions.js +0 -15
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +52 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +44 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +18 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +4 -65
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/undo-ignore.js +5 -0
- package/build-module/store/undo-ignore.js.map +1 -0
- package/build-module/store/utils.js +56 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/get-px-from-css-unit.js +9 -0
- package/build-module/utils/get-px-from-css-unit.js.map +1 -0
- package/build-module/utils/index.js +1 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/object.js +37 -97
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/selection.js +9 -1
- package/build-module/utils/selection.js.map +1 -1
- package/build-module/utils/use-can-block-toolbar-be-focused.js +40 -0
- package/build-module/utils/use-can-block-toolbar-be-focused.js.map +1 -0
- package/build-style/content-rtl.css +7 -6
- package/build-style/content.css +7 -6
- package/build-style/style-rtl.css +164 -301
- package/build-style/style.css +164 -301
- package/package.json +31 -31
- package/src/components/alignment-control/README.md +0 -5
- package/src/components/block-alignment-control/README.md +0 -5
- package/src/components/block-alignment-matrix-control/README.md +0 -10
- package/src/components/block-breadcrumb/README.md +0 -5
- package/src/components/block-canvas/index.js +29 -17
- package/src/components/block-canvas/style.scss +6 -0
- package/src/components/block-caption/README.md +2 -7
- package/src/components/block-card/README.md +0 -5
- package/src/components/block-card/index.js +6 -4
- package/src/components/block-card/style.scss +7 -3
- package/src/components/block-controls/hook.js +8 -30
- package/src/components/block-controls/test/index.js +3 -3
- package/src/components/block-draggable/draggable-chip.js +11 -1
- package/src/components/block-draggable/index.js +116 -4
- package/src/components/block-draggable/index.native.js +0 -5
- package/src/components/block-draggable/style.scss +35 -0
- package/src/components/block-draggable/test/helpers.native.js +8 -7
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +36 -10
- package/src/components/block-editing-mode/index.js +3 -3
- package/src/components/block-icon/README.md +0 -5
- package/src/components/block-info-slot-fill/index.js +6 -3
- package/src/components/block-inspector/README.md +0 -5
- package/src/components/block-inspector/index.js +3 -1
- package/src/components/block-inspector/style.scss +0 -4
- package/src/components/block-list/block-list-item-cell.native.js +5 -1
- package/src/components/block-list/block.js +309 -104
- package/src/components/block-list/block.native.js +69 -21
- package/src/components/block-list/content.scss +14 -10
- package/src/components/block-list/index.native.js +3 -5
- package/src/components/block-list/{block-list-block-context.js → private-block-context.js} +1 -1
- package/src/components/block-list/use-block-props/index.js +43 -86
- package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -34
- package/src/components/block-list/use-block-props/use-is-hovered.js +2 -13
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +1 -5
- package/src/components/block-list/use-in-between-inserter.js +4 -1
- package/src/components/block-list/use-scroll-upon-insertion.native.js +52 -0
- package/src/components/block-lock/toolbar.js +23 -34
- package/src/components/block-mover/README.md +0 -5
- package/src/components/block-mover/index.js +1 -1
- package/src/components/block-parent-selector/README.md +0 -5
- package/src/components/block-patterns-list/README.md +0 -5
- package/src/components/block-patterns-list/index.js +9 -6
- package/src/components/block-removal-warning-modal/index.js +7 -14
- package/src/components/block-rename/modal.js +7 -1
- package/src/components/block-settings/container.native.js +3 -5
- package/src/components/block-styles/index.js +1 -1
- package/src/components/block-styles/index.native.js +4 -2
- package/src/components/block-styles/style.scss +0 -11
- package/src/components/block-switcher/index.js +49 -59
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +3 -1
- package/src/components/block-toolbar/README.md +0 -5
- package/src/components/block-toolbar/index.js +179 -95
- package/src/components/block-toolbar/style.scss +50 -66
- package/src/components/block-tools/block-toolbar-breadcrumb.js +46 -0
- package/src/components/block-tools/block-toolbar-popover.js +84 -0
- package/src/components/block-tools/index.js +42 -29
- package/src/components/block-tools/style.scss +60 -172
- package/src/components/block-types-list/README.md +0 -5
- package/src/components/block-types-list/index.native.js +2 -1
- package/src/components/block-variation-picker/README.md +0 -5
- package/src/components/block-variation-picker/index.native.js +1 -1
- package/src/components/block-variation-transforms/README.md +0 -5
- package/src/components/block-variation-transforms/index.js +49 -3
- package/src/components/border-radius-control/linked-button.js +1 -1
- package/src/components/caption/README.md +0 -5
- package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -1
- package/src/components/colors/utils.js +8 -1
- package/src/components/colors/with-colors.js +3 -1
- package/src/components/colors-gradients/control.js +49 -30
- package/src/components/colors-gradients/style.scss +0 -7
- package/src/components/contrast-checker/README.md +0 -4
- package/src/components/copy-handler/README.md +0 -10
- package/src/components/duotone-control/index.js +2 -5
- package/src/components/duotone-control/style.scss +1 -6
- package/src/components/font-sizes/utils.js +7 -1
- package/src/components/global-styles/border-panel.js +2 -1
- package/src/components/global-styles/color-panel.js +36 -26
- package/src/components/global-styles/dimensions-panel.js +4 -3
- package/src/components/global-styles/effects-panel.js +2 -1
- package/src/components/global-styles/filters-panel.js +6 -5
- package/src/components/global-styles/get-global-styles-changes.js +210 -0
- package/src/components/global-styles/hooks.js +5 -0
- package/src/components/global-styles/image-settings-panel.js +6 -0
- package/src/components/global-styles/index.js +1 -0
- package/src/components/global-styles/test/get-global-styles-changes.js +234 -0
- package/src/components/global-styles/typography-panel.js +60 -47
- package/src/components/global-styles/use-global-styles-output.js +9 -5
- package/src/components/global-styles/utils.js +7 -0
- package/src/components/height-control/README.md +2 -7
- package/src/components/height-control/index.js +4 -0
- package/src/components/image-link-destinations/index.native.js +152 -0
- package/src/components/image-link-destinations/style.native.scss +16 -0
- package/src/components/image-size-control/index.js +5 -2
- package/src/components/index.native.js +3 -2
- package/src/components/inner-blocks/README.md +13 -2
- package/src/components/inner-blocks/index.js +68 -29
- package/src/components/inner-blocks/index.native.js +19 -7
- package/src/components/inner-blocks/use-inner-block-template-sync.js +5 -7
- package/src/components/inner-blocks/use-nested-settings-update.js +6 -13
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +15 -15
- package/src/components/inserter/block-patterns-tab/patterns-filter.js +15 -13
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +15 -18
- package/src/components/inserter/block-patterns-tab/utils.js +11 -12
- package/src/components/inserter/hooks/use-block-types-state.js +9 -11
- package/src/components/inserter/hooks/use-patterns-state.js +2 -2
- package/src/components/inserter/index.js +0 -1
- package/src/components/inserter/library.js +2 -8
- package/src/components/inserter/media-tab/media-panel.js +1 -1
- package/src/components/inserter/menu.js +26 -36
- package/src/components/inserter/preview-panel.js +2 -2
- package/src/components/inserter/style.scss +21 -21
- package/src/components/inserter/tabs.js +34 -25
- package/src/components/inserter-button/README.md +62 -0
- package/src/components/inserter-button/index.native.js +116 -0
- package/src/components/inserter-button/sparkles.js +15 -0
- package/src/components/inserter-button/style.native.scss +72 -0
- package/src/components/inserter-draggable-blocks/index.js +18 -5
- package/src/components/inserter-list-item/index.js +6 -6
- package/src/components/inspector-controls/block-support-tools-panel.js +2 -0
- package/src/components/inspector-controls/fill.js +6 -3
- package/src/components/inspector-controls/fill.native.js +6 -3
- package/src/components/inspector-controls-tabs/index.js +39 -28
- package/src/components/inspector-controls-tabs/style.scss +3 -2
- package/src/components/letter-spacing-control/README.md +0 -5
- package/src/components/line-height-control/README.md +0 -5
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/list-view/README.md +0 -5
- package/src/components/list-view/block-select-button.js +4 -0
- package/src/components/list-view/block.js +73 -2
- package/src/components/list-view/style.scss +6 -0
- package/src/components/media-upload-progress/constants.js +6 -0
- package/src/components/media-upload-progress/index.native.js +66 -14
- package/src/components/media-upload-progress/test/index.native.js +2 -2
- package/src/components/multi-selection-inspector/README.md +0 -5
- package/src/components/navigable-toolbar/README.md +2 -0
- package/src/components/navigable-toolbar/index.js +15 -13
- package/src/components/plain-text/index.native.js +6 -1
- package/src/components/preview-options/index.js +6 -86
- package/src/components/provider/index.js +1 -1
- package/src/components/provider/test/use-block-sync.js +20 -17
- package/src/components/provider/use-block-sync.js +6 -0
- package/src/components/rich-text/content.js +27 -20
- package/src/components/rich-text/get-rich-text-values.js +6 -1
- package/src/components/rich-text/index.js +23 -52
- package/src/components/rich-text/index.native.js +8 -25
- package/src/components/rich-text/native/get-format-colors.native.js +33 -40
- package/src/components/rich-text/native/index.native.js +22 -71
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +3 -3
- package/src/components/rich-text/native/test/index.native.js +72 -5
- package/src/components/rich-text/use-input-rules.js +8 -3
- package/src/components/rich-text/use-mark-persistent.js +1 -2
- package/src/components/rich-text/with-deprecations.js +51 -0
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/src/components/text-decoration-control/README.md +40 -0
- package/src/components/text-transform-control/README.md +0 -4
- package/src/components/ungroup-button/README.md +0 -5
- package/src/components/unit-control/README.md +0 -4
- package/src/components/url-input/index.js +11 -11
- package/src/components/use-block-commands/index.js +18 -21
- package/src/components/use-block-drop-zone/index.js +181 -30
- package/src/components/use-moving-animation/index.js +107 -103
- package/src/components/use-on-block-drop/index.js +9 -24
- package/src/components/use-on-block-drop/test/index.js +12 -26
- package/src/components/use-resize-canvas/README.md +3 -7
- package/src/components/use-resize-canvas/index.js +4 -1
- package/src/components/use-settings/README.md +0 -4
- package/src/components/use-settings/index.js +15 -1
- package/src/components/writing-flow/index.js +0 -1
- package/src/components/writing-flow/use-drag-selection.js +18 -4
- package/src/components/writing-flow/use-selection-observer.js +99 -37
- package/src/components/writing-flow/use-tab-nav.js +7 -7
- package/src/hooks/align.js +16 -81
- package/src/hooks/align.native.js +1 -0
- package/src/hooks/anchor.js +14 -38
- package/src/hooks/aria-label.js +8 -5
- package/src/hooks/background.js +269 -32
- package/src/hooks/block-hooks.js +22 -51
- package/src/hooks/block-renaming.js +23 -37
- package/src/hooks/border.js +62 -124
- package/src/hooks/color.js +111 -138
- package/src/hooks/content-lock-ui.js +110 -122
- package/src/hooks/custom-class-name.js +9 -45
- package/src/hooks/custom-class-name.native.js +8 -5
- package/src/hooks/dimensions.js +14 -16
- package/src/hooks/duotone.js +70 -127
- package/src/hooks/font-family.js +14 -36
- package/src/hooks/font-size.js +67 -168
- package/src/hooks/index.js +58 -16
- package/src/hooks/index.native.js +22 -6
- package/src/hooks/layout-child.js +53 -0
- package/src/hooks/layout.js +17 -103
- package/src/hooks/padding.js +2 -2
- package/src/hooks/position.js +50 -90
- package/src/hooks/style.js +118 -193
- package/src/hooks/test/align.js +1 -178
- package/src/hooks/test/anchor.js +4 -9
- package/src/hooks/test/custom-class-name.js +3 -8
- package/src/hooks/test/style.js +4 -14
- package/src/hooks/typography.js +14 -16
- package/src/hooks/typography.native.js +31 -33
- package/src/hooks/use-typography-props.js +7 -1
- package/src/hooks/utils.js +261 -10
- package/src/private-apis.js +2 -6
- package/src/private-apis.native.js +0 -2
- package/src/store/actions.js +0 -15
- package/src/store/private-actions.js +48 -0
- package/src/store/private-selectors.js +56 -0
- package/src/store/reducer.js +20 -1
- package/src/store/selectors.js +10 -82
- package/src/store/undo-ignore.js +4 -0
- package/src/store/utils.js +74 -0
- package/src/style.scss +1 -2
- package/src/utils/get-px-from-css-unit.js +8 -0
- package/src/utils/index.js +1 -1
- package/src/utils/object.js +34 -104
- package/src/utils/selection.js +9 -2
- package/src/utils/test/object.js +1 -96
- package/src/utils/use-can-block-toolbar-be-focused.js +48 -0
- package/build/components/block-list/block-list-block-context.js +0 -14
- package/build/components/block-list/block-list-block-context.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +0 -67
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js +0 -46
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-default-class-name.js +0 -37
- package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build/components/block-tools/back-compat.js +0 -45
- package/build/components/block-tools/back-compat.js.map +0 -1
- package/build/components/block-tools/block-contextual-toolbar.js +0 -91
- package/build/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build/components/block-tools/selected-block-tools.js +0 -113
- package/build/components/block-tools/selected-block-tools.js.map +0 -1
- package/build/components/inserter/hooks/use-debounced-input.js +0 -22
- package/build/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build/components/use-display-block-controls/index.js +0 -39
- package/build/components/use-display-block-controls/index.js.map +0 -1
- package/build/components/use-display-block-controls/index.native.js +0 -39
- package/build/components/use-display-block-controls/index.native.js.map +0 -1
- package/build/hooks/custom-fields.js +0 -120
- package/build/hooks/custom-fields.js.map +0 -1
- package/build/utils/parse-css-unit-to-px.js +0 -302
- package/build/utils/parse-css-unit-to-px.js.map +0 -1
- package/build/utils/use-should-contextual-toolbar-show.js +0 -63
- package/build/utils/use-should-contextual-toolbar-show.js.map +0 -1
- package/build-module/components/block-list/block-list-block-context.js +0 -6
- package/build-module/components/block-list/block-list-block-context.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +0 -60
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +0 -40
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +0 -31
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build-module/components/block-tools/back-compat.js +0 -35
- package/build-module/components/block-tools/back-compat.js.map +0 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +0 -83
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build-module/components/block-tools/selected-block-tools.js +0 -105
- package/build-module/components/block-tools/selected-block-tools.js.map +0 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +0 -15
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.js +0 -32
- package/build-module/components/use-display-block-controls/index.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.native.js +0 -32
- package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
- package/build-module/hooks/custom-fields.js +0 -118
- package/build-module/hooks/custom-fields.js.map +0 -1
- package/build-module/utils/parse-css-unit-to-px.js +0 -294
- package/build-module/utils/parse-css-unit-to-px.js.map +0 -1
- package/build-module/utils/use-should-contextual-toolbar-show.js +0 -57
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +0 -1
- package/src/components/block-list/use-block-props/use-block-class-names.js +0 -66
- package/src/components/block-list/use-block-props/use-block-custom-class-name.js +0 -44
- package/src/components/block-list/use-block-props/use-block-default-class-name.js +0 -35
- package/src/components/block-parent-selector/style.scss +0 -11
- package/src/components/block-tools/back-compat.js +0 -35
- package/src/components/block-tools/block-contextual-toolbar.js +0 -100
- package/src/components/block-tools/selected-block-tools.js +0 -127
- package/src/components/inserter/hooks/use-debounced-input.js +0 -18
- package/src/components/preview-options/README.md +0 -94
- package/src/components/preview-options/style.scss +0 -64
- package/src/components/use-display-block-controls/index.js +0 -36
- package/src/components/use-display-block-controls/index.native.js +0 -37
- package/src/hooks/custom-fields.js +0 -142
- package/src/hooks/test/color.js +0 -112
- package/src/utils/parse-css-unit-to-px.js +0 -329
- package/src/utils/test/parse-css-unit-to-px.js +0 -172
- package/src/utils/use-should-contextual-toolbar-show.js +0 -85
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["groups","useBlockEditContext","mayDisplayControlsKey","mayDisplayParentControlsKey","useBlockControlsFill","group","shareWithChildBlocks","context","Fill","parent"],"sources":["@wordpress/block-editor/src/components/block-controls/hook.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\n\n/**\n * Internal dependencies\n */\nimport groups from './groups';\nimport {\n\tuseBlockEditContext,\n\tmayDisplayControlsKey,\n\tmayDisplayParentControlsKey,\n} from '../block-edit/context';\n\nexport default function useBlockControlsFill( group, shareWithChildBlocks ) {\n\tconst context = useBlockEditContext();\n\tif ( context[ mayDisplayControlsKey ] ) {\n\t\treturn groups[ group ]?.Fill;\n\t}\n\tif ( context[ mayDisplayParentControlsKey ] && shareWithChildBlocks ) {\n\t\treturn groups.parent.Fill;\n\t}\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,UAAU;AAC7B,SACCC,mBAAmB,EACnBC,qBAAqB,EACrBC,2BAA2B,QACrB,uBAAuB;AAE9B,eAAe,SAASC,oBAAoBA,CAAEC,KAAK,EAAEC,oBAAoB,EAAG;EAC3E,MAAMC,OAAO,GAAGN,mBAAmB,CAAC,CAAC;EACrC,IAAKM,OAAO,CAAEL,qBAAqB,CAAE,EAAG;IACvC,OAAOF,MAAM,CAAEK,KAAK,CAAE,EAAEG,IAAI;EAC7B;EACA,IAAKD,OAAO,CAAEJ,2BAA2B,CAAE,IAAIG,oBAAoB,EAAG;IACrE,OAAON,MAAM,CAACS,MAAM,CAACD,IAAI;EAC1B;EACA,OAAO,IAAI;AACZ"}
|
|
@@ -13,7 +13,8 @@ import BlockIcon from '../block-icon';
|
|
|
13
13
|
export default function BlockDraggableChip({
|
|
14
14
|
count,
|
|
15
15
|
icon,
|
|
16
|
-
isPattern
|
|
16
|
+
isPattern,
|
|
17
|
+
fadeWhenDisabled
|
|
17
18
|
}) {
|
|
18
19
|
const patternLabel = isPattern && __('Pattern');
|
|
19
20
|
return createElement("div", {
|
|
@@ -29,6 +30,10 @@ export default function BlockDraggableChip({
|
|
|
29
30
|
}) : patternLabel || sprintf( /* translators: %d: Number of blocks. */
|
|
30
31
|
_n('%d block', '%d blocks', count), count)), createElement(FlexItem, null, createElement(BlockIcon, {
|
|
31
32
|
icon: dragHandle
|
|
33
|
+
})), fadeWhenDisabled && createElement(FlexItem, {
|
|
34
|
+
className: "block-editor-block-draggable-chip__disabled"
|
|
35
|
+
}, createElement("span", {
|
|
36
|
+
className: "block-editor-block-draggable-chip__disabled-icon"
|
|
32
37
|
})))));
|
|
33
38
|
}
|
|
34
39
|
//# sourceMappingURL=draggable-chip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","_n","sprintf","Flex","FlexItem","dragHandle","BlockIcon","BlockDraggableChip","count","icon","isPattern","patternLabel","createElement","className","justify"],"sources":["@wordpress/block-editor/src/components/block-draggable/draggable-chip.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { Flex, FlexItem } from '@wordpress/components';\nimport { dragHandle } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\n\nexport default function BlockDraggableChip( {
|
|
1
|
+
{"version":3,"names":["__","_n","sprintf","Flex","FlexItem","dragHandle","BlockIcon","BlockDraggableChip","count","icon","isPattern","fadeWhenDisabled","patternLabel","createElement","className","justify"],"sources":["@wordpress/block-editor/src/components/block-draggable/draggable-chip.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { Flex, FlexItem } from '@wordpress/components';\nimport { dragHandle } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\n\nexport default function BlockDraggableChip( {\n\tcount,\n\ticon,\n\tisPattern,\n\tfadeWhenDisabled,\n} ) {\n\tconst patternLabel = isPattern && __( 'Pattern' );\n\treturn (\n\t\t<div className=\"block-editor-block-draggable-chip-wrapper\">\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-block-draggable-chip\"\n\t\t\t\tdata-testid=\"block-draggable-chip\"\n\t\t\t>\n\t\t\t\t<Flex\n\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\tclassName=\"block-editor-block-draggable-chip__content\"\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t{ icon ? (\n\t\t\t\t\t\t\t<BlockIcon icon={ icon } />\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tpatternLabel ||\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %d: Number of blocks. */\n\t\t\t\t\t\t\t\t_n( '%d block', '%d blocks', count ),\n\t\t\t\t\t\t\t\tcount\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<BlockIcon icon={ dragHandle } />\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t{ fadeWhenDisabled && (\n\t\t\t\t\t\t<FlexItem className=\"block-editor-block-draggable-chip__disabled\">\n\t\t\t\t\t\t\t<span className=\"block-editor-block-draggable-chip__disabled-icon\"></span>\n\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t) }\n\t\t\t\t</Flex>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,IAAI,EAAEC,QAAQ,QAAQ,uBAAuB;AACtD,SAASC,UAAU,QAAQ,kBAAkB;;AAE7C;AACA;AACA;AACA,OAAOC,SAAS,MAAM,eAAe;AAErC,eAAe,SAASC,kBAAkBA,CAAE;EAC3CC,KAAK;EACLC,IAAI;EACJC,SAAS;EACTC;AACD,CAAC,EAAG;EACH,MAAMC,YAAY,GAAGF,SAAS,IAAIV,EAAE,CAAE,SAAU,CAAC;EACjD,OACCa,aAAA;IAAKC,SAAS,EAAC;EAA2C,GACzDD,aAAA;IACCC,SAAS,EAAC,mCAAmC;IAC7C,eAAY;EAAsB,GAElCD,aAAA,CAACV,IAAI;IACJY,OAAO,EAAC,QAAQ;IAChBD,SAAS,EAAC;EAA4C,GAEtDD,aAAA,CAACT,QAAQ,QACNK,IAAI,GACLI,aAAA,CAACP,SAAS;IAACG,IAAI,EAAGA;EAAM,CAAE,CAAC,GAE3BG,YAAY,IACZV,OAAO,EACN;EACAD,EAAE,CAAE,UAAU,EAAE,WAAW,EAAEO,KAAM,CAAC,EACpCA,KACD,CAEQ,CAAC,EACXK,aAAA,CAACT,QAAQ,QACRS,aAAA,CAACP,SAAS;IAACG,IAAI,EAAGJ;EAAY,CAAE,CACvB,CAAC,EACTM,gBAAgB,IACjBE,aAAA,CAACT,QAAQ;IAACU,SAAS,EAAC;EAA6C,GAChED,aAAA;IAAMC,SAAS,EAAC;EAAkD,CAAO,CAChE,CAEN,CACF,CACD,CAAC;AAER"}
|
|
@@ -6,6 +6,7 @@ import { store as blocksStore } from '@wordpress/blocks';
|
|
|
6
6
|
import { Draggable } from '@wordpress/components';
|
|
7
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
8
|
import { useEffect, useRef } from '@wordpress/element';
|
|
9
|
+
import { throttle } from '@wordpress/compose';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
@@ -13,26 +14,32 @@ import { useEffect, useRef } from '@wordpress/element';
|
|
|
13
14
|
import BlockDraggableChip from './draggable-chip';
|
|
14
15
|
import useScrollWhenDragging from './use-scroll-when-dragging';
|
|
15
16
|
import { store as blockEditorStore } from '../../store';
|
|
17
|
+
import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
|
|
18
|
+
import { isDropTargetValid } from '../use-block-drop-zone';
|
|
16
19
|
const BlockDraggable = ({
|
|
17
20
|
children,
|
|
18
21
|
clientIds,
|
|
19
22
|
cloneClassname,
|
|
20
23
|
onDragStart,
|
|
21
|
-
onDragEnd
|
|
24
|
+
onDragEnd,
|
|
25
|
+
fadeWhenDisabled = false
|
|
22
26
|
}) => {
|
|
23
27
|
const {
|
|
24
28
|
srcRootClientId,
|
|
25
29
|
isDraggable,
|
|
26
|
-
icon
|
|
30
|
+
icon,
|
|
31
|
+
visibleInserter,
|
|
32
|
+
getBlockType
|
|
27
33
|
} = useSelect(select => {
|
|
28
34
|
const {
|
|
29
35
|
canMoveBlocks,
|
|
30
36
|
getBlockRootClientId,
|
|
31
37
|
getBlockName,
|
|
32
|
-
getBlockAttributes
|
|
38
|
+
getBlockAttributes,
|
|
39
|
+
isBlockInsertionPointVisible
|
|
33
40
|
} = select(blockEditorStore);
|
|
34
41
|
const {
|
|
35
|
-
getBlockType,
|
|
42
|
+
getBlockType: _getBlockType,
|
|
36
43
|
getActiveBlockVariation
|
|
37
44
|
} = select(blocksStore);
|
|
38
45
|
const rootClientId = getBlockRootClientId(clientIds[0]);
|
|
@@ -41,11 +48,18 @@ const BlockDraggable = ({
|
|
|
41
48
|
return {
|
|
42
49
|
srcRootClientId: rootClientId,
|
|
43
50
|
isDraggable: canMoveBlocks(clientIds, rootClientId),
|
|
44
|
-
icon: variation?.icon ||
|
|
51
|
+
icon: variation?.icon || _getBlockType(blockName)?.icon,
|
|
52
|
+
visibleInserter: isBlockInsertionPointVisible(),
|
|
53
|
+
getBlockType: _getBlockType
|
|
45
54
|
};
|
|
46
55
|
}, [clientIds]);
|
|
47
56
|
const isDragging = useRef(false);
|
|
48
57
|
const [startScrolling, scrollOnDragOver, stopScrolling] = useScrollWhenDragging();
|
|
58
|
+
const {
|
|
59
|
+
getAllowedBlocks,
|
|
60
|
+
getBlockNamesByClientId,
|
|
61
|
+
getBlockRootClientId
|
|
62
|
+
} = useSelect(blockEditorStore);
|
|
49
63
|
const {
|
|
50
64
|
startDraggingBlocks,
|
|
51
65
|
stopDraggingBlocks
|
|
@@ -59,6 +73,61 @@ const BlockDraggable = ({
|
|
|
59
73
|
}
|
|
60
74
|
};
|
|
61
75
|
}, []);
|
|
76
|
+
|
|
77
|
+
// Find the root of the editor iframe.
|
|
78
|
+
const blockRef = useBlockRef(clientIds[0]);
|
|
79
|
+
const editorRoot = blockRef.current?.closest('body');
|
|
80
|
+
|
|
81
|
+
/*
|
|
82
|
+
* Add a dragover event listener to the editor root to track the blocks being dragged over.
|
|
83
|
+
* The listener has to be inside the editor iframe otherwise the target isn't accessible.
|
|
84
|
+
*/
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (!editorRoot || !fadeWhenDisabled) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const onDragOver = event => {
|
|
90
|
+
if (!event.target.closest('[data-block]')) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const draggedBlockNames = getBlockNamesByClientId(clientIds);
|
|
94
|
+
const targetClientId = event.target.closest('[data-block]').getAttribute('data-block');
|
|
95
|
+
const allowedBlocks = getAllowedBlocks(targetClientId);
|
|
96
|
+
const targetBlockName = getBlockNamesByClientId([targetClientId])[0];
|
|
97
|
+
|
|
98
|
+
/*
|
|
99
|
+
* Check if the target is valid to drop in.
|
|
100
|
+
* If the target's allowedBlocks is an empty array,
|
|
101
|
+
* it isn't a container block, in which case we check
|
|
102
|
+
* its parent's validity instead.
|
|
103
|
+
*/
|
|
104
|
+
let dropTargetValid;
|
|
105
|
+
if (allowedBlocks?.length === 0) {
|
|
106
|
+
const targetRootClientId = getBlockRootClientId(targetClientId);
|
|
107
|
+
const targetRootBlockName = getBlockNamesByClientId([targetRootClientId])[0];
|
|
108
|
+
const rootAllowedBlocks = getAllowedBlocks(targetRootClientId);
|
|
109
|
+
dropTargetValid = isDropTargetValid(getBlockType, rootAllowedBlocks, draggedBlockNames, targetRootBlockName);
|
|
110
|
+
} else {
|
|
111
|
+
dropTargetValid = isDropTargetValid(getBlockType, allowedBlocks, draggedBlockNames, targetBlockName);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
* Update the body class to reflect if drop target is valid.
|
|
116
|
+
* This has to be done on the document body because the draggable
|
|
117
|
+
* chip is rendered outside of the editor iframe.
|
|
118
|
+
*/
|
|
119
|
+
if (!dropTargetValid && !visibleInserter) {
|
|
120
|
+
window?.document?.body?.classList?.add('block-draggable-invalid-drag-token');
|
|
121
|
+
} else {
|
|
122
|
+
window?.document?.body?.classList?.remove('block-draggable-invalid-drag-token');
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const throttledOnDragOver = throttle(onDragOver, 200);
|
|
126
|
+
editorRoot.addEventListener('dragover', throttledOnDragOver);
|
|
127
|
+
return () => {
|
|
128
|
+
editorRoot.removeEventListener('dragover', throttledOnDragOver);
|
|
129
|
+
};
|
|
130
|
+
}, [clientIds, editorRoot, fadeWhenDisabled, getAllowedBlocks, getBlockNamesByClientId, getBlockRootClientId, getBlockType, visibleInserter]);
|
|
62
131
|
if (!isDraggable) {
|
|
63
132
|
return children({
|
|
64
133
|
draggable: false
|
|
@@ -96,7 +165,8 @@ const BlockDraggable = ({
|
|
|
96
165
|
},
|
|
97
166
|
__experimentalDragComponent: createElement(BlockDraggableChip, {
|
|
98
167
|
count: clientIds.length,
|
|
99
|
-
icon: icon
|
|
168
|
+
icon: icon,
|
|
169
|
+
fadeWhenDisabled: true
|
|
100
170
|
})
|
|
101
171
|
}, ({
|
|
102
172
|
onDraggableStart,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","blocksStore","Draggable","useSelect","useDispatch","useEffect","useRef","BlockDraggableChip","useScrollWhenDragging","blockEditorStore","BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","srcRootClientId","isDraggable","icon","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","getBlockType","getActiveBlockVariation","rootClientId","blockName","variation","isDragging","startScrolling","scrollOnDragOver","stopScrolling","startDraggingBlocks","stopDraggingBlocks","current","draggable","transferData","type","srcClientIds","createElement","__experimentalTransferDataType","event","window","requestAnimationFrame","onDragOver","__experimentalDragComponent","count","length","onDraggableStart","onDraggableEnd"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\n\nconst BlockDraggable = ( {\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\tonDragStart,\n\tonDragEnd,\n} ) => {\n\tconst { srcRootClientId, isDraggable, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds, rootClientId ),\n\t\t\t\ticon: variation?.icon || getBlockType( blockName )?.icon,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip count={ clientIds.length } icon={ icon } />\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;;AAEtD;AACA;AACA;AACA,OAAOC,kBAAkB,MAAM,kBAAkB;AACjD,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,SAASR,KAAK,IAAIS,gBAAgB,QAAQ,aAAa;AAEvD,MAAMC,cAAc,GAAGA,CAAE;EACxBC,QAAQ;EACRC,SAAS;EACTC,cAAc;EACdC,WAAW;EACXC;AACD,CAAC,KAAM;EACN,MAAM;IAAEC,eAAe;IAAEC,WAAW;IAAEC;EAAK,CAAC,GAAGf,SAAS,CACrDgB,MAAM,IAAM;IACb,MAAM;MACLC,aAAa;MACbC,oBAAoB;MACpBC,YAAY;MACZC;IACD,CAAC,GAAGJ,MAAM,CAAEV,gBAAiB,CAAC;IAC9B,MAAM;MAAEe,YAAY;MAAEC;IAAwB,CAAC,GAC9CN,MAAM,CAAElB,WAAY,CAAC;IACtB,MAAMyB,YAAY,GAAGL,oBAAoB,CAAET,SAAS,CAAE,CAAC,CAAG,CAAC;IAC3D,MAAMe,SAAS,GAAGL,YAAY,CAAEV,SAAS,CAAE,CAAC,CAAG,CAAC;IAChD,MAAMgB,SAAS,GAAGH,uBAAuB,CACxCE,SAAS,EACTJ,kBAAkB,CAAEX,SAAS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J,CAAG;IACH+B,UAAU,EAAGd,gBAAkB;IAC/BhB,SAAS,EAAGA,CAAA,KAAM;MACjBmB,kBAAkB,CAAC,CAAC;MACpBL,UAAU,CAACM,OAAO,GAAG,KAAK;MAE1BH,aAAa,CAAC,CAAC;MAEf,IAAKjB,SAAS,EAAG;QAChBA,SAAS,CAAC,CAAC;MACZ;IACD,CAAG;IACH+B,2BAA2B,EAC1BN,aAAA,CAACjC,kBAAkB;MAACwC,KAAK,EAAGnC,SAAS,CAACoC,MAAQ;MAAC9B,IAAI,EAAGA;IAAM,CAAE;EAC9D,GAEC,CAAE;IAAE+B,gBAAgB;IAAEC;EAAe,CAAC,KAAM;IAC7C,OAAOvC,QAAQ,CAAE;MAChByB,SAAS,EAAE,IAAI;MACftB,WAAW,EAAEmC,gBAAgB;MAC7BlC,SAAS,EAAEmC;IACZ,CAAE,CAAC;EACJ,CACU,CAAC;AAEd,CAAC;AAED,eAAexC,cAAc"}
|
|
1
|
+
{"version":3,"names":["store","blocksStore","Draggable","useSelect","useDispatch","useEffect","useRef","throttle","BlockDraggableChip","useScrollWhenDragging","blockEditorStore","__unstableUseBlockRef","useBlockRef","isDropTargetValid","BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","fadeWhenDisabled","srcRootClientId","isDraggable","icon","visibleInserter","getBlockType","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","isBlockInsertionPointVisible","_getBlockType","getActiveBlockVariation","rootClientId","blockName","variation","isDragging","startScrolling","scrollOnDragOver","stopScrolling","getAllowedBlocks","getBlockNamesByClientId","startDraggingBlocks","stopDraggingBlocks","current","blockRef","editorRoot","closest","onDragOver","event","target","draggedBlockNames","targetClientId","getAttribute","allowedBlocks","targetBlockName","dropTargetValid","length","targetRootClientId","targetRootBlockName","rootAllowedBlocks","window","document","body","classList","add","remove","throttledOnDragOver","addEventListener","removeEventListener","draggable","transferData","type","srcClientIds","createElement","__experimentalTransferDataType","requestAnimationFrame","__experimentalDragComponent","count","onDraggableStart","onDraggableEnd"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\nimport { throttle } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';\nimport { isDropTargetValid } from '../use-block-drop-zone';\n\nconst BlockDraggable = ( {\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\tonDragStart,\n\tonDragEnd,\n\tfadeWhenDisabled = false,\n} ) => {\n\tconst {\n\t\tsrcRootClientId,\n\t\tisDraggable,\n\t\ticon,\n\t\tvisibleInserter,\n\t\tgetBlockType,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType: _getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds, rootClientId ),\n\t\t\t\ticon: variation?.icon || _getBlockType( blockName )?.icon,\n\t\t\t\tvisibleInserter: isBlockInsertionPointVisible(),\n\t\t\t\tgetBlockType: _getBlockType,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { getAllowedBlocks, getBlockNamesByClientId, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\t// Find the root of the editor iframe.\n\tconst blockRef = useBlockRef( clientIds[ 0 ] );\n\tconst editorRoot = blockRef.current?.closest( 'body' );\n\n\t/*\n\t * Add a dragover event listener to the editor root to track the blocks being dragged over.\n\t * The listener has to be inside the editor iframe otherwise the target isn't accessible.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! editorRoot || ! fadeWhenDisabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst onDragOver = ( event ) => {\n\t\t\tif ( ! event.target.closest( '[data-block]' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst draggedBlockNames = getBlockNamesByClientId( clientIds );\n\t\t\tconst targetClientId = event.target\n\t\t\t\t.closest( '[data-block]' )\n\t\t\t\t.getAttribute( 'data-block' );\n\n\t\t\tconst allowedBlocks = getAllowedBlocks( targetClientId );\n\t\t\tconst targetBlockName = getBlockNamesByClientId( [\n\t\t\t\ttargetClientId,\n\t\t\t] )[ 0 ];\n\n\t\t\t/*\n\t\t\t * Check if the target is valid to drop in.\n\t\t\t * If the target's allowedBlocks is an empty array,\n\t\t\t * it isn't a container block, in which case we check\n\t\t\t * its parent's validity instead.\n\t\t\t */\n\t\t\tlet dropTargetValid;\n\t\t\tif ( allowedBlocks?.length === 0 ) {\n\t\t\t\tconst targetRootClientId =\n\t\t\t\t\tgetBlockRootClientId( targetClientId );\n\t\t\t\tconst targetRootBlockName = getBlockNamesByClientId( [\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t] )[ 0 ];\n\t\t\t\tconst rootAllowedBlocks =\n\t\t\t\t\tgetAllowedBlocks( targetRootClientId );\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\trootAllowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetRootBlockName\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tdropTargetValid = isDropTargetValid(\n\t\t\t\t\tgetBlockType,\n\t\t\t\t\tallowedBlocks,\n\t\t\t\t\tdraggedBlockNames,\n\t\t\t\t\ttargetBlockName\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Update the body class to reflect if drop target is valid.\n\t\t\t * This has to be done on the document body because the draggable\n\t\t\t * chip is rendered outside of the editor iframe.\n\t\t\t */\n\t\t\tif ( ! dropTargetValid && ! visibleInserter ) {\n\t\t\t\twindow?.document?.body?.classList?.add(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\twindow?.document?.body?.classList?.remove(\n\t\t\t\t\t'block-draggable-invalid-drag-token'\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\n\t\tconst throttledOnDragOver = throttle( onDragOver, 200 );\n\n\t\teditorRoot.addEventListener( 'dragover', throttledOnDragOver );\n\n\t\treturn () => {\n\t\t\teditorRoot.removeEventListener( 'dragover', throttledOnDragOver );\n\t\t};\n\t}, [\n\t\tclientIds,\n\t\teditorRoot,\n\t\tfadeWhenDisabled,\n\t\tgetAllowedBlocks,\n\t\tgetBlockNamesByClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockType,\n\t\tvisibleInserter,\n\t] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip\n\t\t\t\t\tcount={ clientIds.length }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tfadeWhenDisabled\n\t\t\t\t/>\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB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
|
|
6
6
|
import { useSafeAreaInsets, useSafeAreaFrame } from 'react-native-safe-area-context';
|
|
7
|
-
import Animated, { runOnJS, runOnUI,
|
|
7
|
+
import Animated, { runOnJS, runOnUI, useAnimatedStyle, useSharedValue, withDelay, withTiming, ZoomInEasyDown } from 'react-native-reanimated';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* WordPress dependencies
|
|
@@ -22,7 +22,6 @@ import RCTAztecView from '@wordpress/react-native-aztec';
|
|
|
22
22
|
import useScrollWhenDragging from './use-scroll-when-dragging';
|
|
23
23
|
import DraggableChip from './draggable-chip';
|
|
24
24
|
import { store as blockEditorStore } from '../../store';
|
|
25
|
-
import { useBlockListContext } from '../block-list/block-list-context';
|
|
26
25
|
import DroppingInsertionPoint from './dropping-insertion-point';
|
|
27
26
|
import useBlockDropZone from '../use-block-drop-zone';
|
|
28
27
|
import styles from './style.scss';
|
|
@@ -61,10 +60,6 @@ const BlockDraggableWrapper = ({
|
|
|
61
60
|
startDraggingBlocks,
|
|
62
61
|
stopDraggingBlocks
|
|
63
62
|
} = useDispatch(blockEditorStore);
|
|
64
|
-
const {
|
|
65
|
-
scrollRef
|
|
66
|
-
} = useBlockListContext();
|
|
67
|
-
const animatedScrollRef = useAnimatedRef();
|
|
68
63
|
const {
|
|
69
64
|
left,
|
|
70
65
|
right
|
|
@@ -74,7 +69,6 @@ const BlockDraggableWrapper = ({
|
|
|
74
69
|
} = useSafeAreaFrame();
|
|
75
70
|
const safeAreaOffset = left + right;
|
|
76
71
|
const contentWidth = width - safeAreaOffset;
|
|
77
|
-
animatedScrollRef(scrollRef);
|
|
78
72
|
const scroll = {
|
|
79
73
|
offsetY: useSharedValue(0)
|
|
80
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AccessibilityInfo","useSafeAreaInsets","useSafeAreaFrame","Animated","runOnJS","runOnUI","useAnimatedRef","useAnimatedStyle","useSharedValue","withDelay","withTiming","ZoomInEasyDown","Draggable","DraggableTrigger","select","useSelect","useDispatch","useCallback","useEffect","useRef","useState","Platform","getBlockType","generateHapticFeedback","RCTAztecView","useScrollWhenDragging","DraggableChip","store","blockEditorStore","useBlockListContext","DroppingInsertionPoint","useBlockDropZone","styles","CHIP_OFFSET_TO_TOUCH_POSITION","BLOCK_OPACITY_ANIMATION_CONFIG","duration","BLOCK_OPACITY_ANIMATION_DELAY","DEFAULT_LONG_PRESS_MIN_DURATION","DEFAULT_IOS_LONG_PRESS_MIN_DURATION","BlockDraggableWrapper","children","isRTL","draggedBlockIcon","setDraggedBlockIcon","selectBlock","startDraggingBlocks","stopDraggingBlocks","scrollRef","animatedScrollRef","left","right","width","safeAreaOffset","contentWidth","scroll","offsetY","chip","x","y","height","currentYPosition","isDragging","startScrolling","scrollOnDragOver","stopScrolling","draggingScrollHandler","scrollHandler","event","contentOffset","value","onBlockDragOverWorklet","onBlockDragEnd","onBlockDrop","targetBlockIndex","setDraggedBlockIconByClientId","clientId","blockName","getBlockName","blockIcon","icon","onStartDragging","position","stopDragging","onStopDragging","srcRootClientId","srcClientIds","type","undefined","onChipLayout","nativeEvent","layout","startDragging","id","dragPosition","updateDragging","chipDynamicStyles","chipOffset","translateX","transform","translateY","chipStyles","exitingAnimation","currentHeight","currentWidth","animations","scale","initialValues","createElement","Fragment","onDragStart","onDragOver","onDragEnd","testID","onScroll","View","onLayout","style","pointerEvents","entering","exiting","useIsScreenReaderEnabled","isScreenReaderEnabled","setIsScreenReaderEnabled","mounted","changeListener","addEventListener","enabled","then","screenReaderEnabled","remove","useIsEditingText","isEditingText","setIsEditingText","InputState","isFocused","onFocusChangeAztec","addFocusChangeListener","removeFocusChangeListener","BlockDraggable","draggingClientId","wasBeingDragged","draggingAnimation","opacity","startDraggingBlock","stopDraggingBlock","isDraggable","isBeingDragged","isBlockSelected","_select","getBlockRootClientId","getTemplateLock","isBlockBeingDragged","getSelectedBlockClientId","rootClientId","templateLock","selectedBlockClientId","current","onLongPressDraggable","blurCurrentFocusedElement","animatedWrapperStyles","wrapperStyles","canDragBlock","minDuration","ios","android","onLongPress"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo } from 'react-native';\nimport {\n\tuseSafeAreaInsets,\n\tuseSafeAreaFrame,\n} from 'react-native-safe-area-context';\nimport Animated, {\n\trunOnJS,\n\trunOnUI,\n\tuseAnimatedRef,\n\tuseAnimatedStyle,\n\tuseSharedValue,\n\twithDelay,\n\twithTiming,\n\tZoomInEasyDown,\n} from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport { Draggable, DraggableTrigger } from '@wordpress/components';\nimport { select, useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tPlatform,\n} from '@wordpress/element';\nimport { getBlockType } from '@wordpress/blocks';\nimport { generateHapticFeedback } from '@wordpress/react-native-bridge';\nimport RCTAztecView from '@wordpress/react-native-aztec';\n\n/**\n * Internal dependencies\n */\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport DraggableChip from './draggable-chip';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockListContext } from '../block-list/block-list-context';\nimport DroppingInsertionPoint from './dropping-insertion-point';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport styles from './style.scss';\n\nconst CHIP_OFFSET_TO_TOUCH_POSITION = 32;\nconst BLOCK_OPACITY_ANIMATION_CONFIG = { duration: 350 };\nconst BLOCK_OPACITY_ANIMATION_DELAY = 250;\nconst DEFAULT_LONG_PRESS_MIN_DURATION = 500;\nconst DEFAULT_IOS_LONG_PRESS_MIN_DURATION =\n\tDEFAULT_LONG_PRESS_MIN_DURATION - 50;\n\n/**\n * Block draggable wrapper component\n *\n * This component handles all the interactions for dragging blocks.\n * It relies on the block list and its context for dragging, hence it\n * should be rendered between the `BlockListProvider` component and the\n * block list rendering. It also requires listening to scroll events,\n * therefore for this purpose, it returns the `onScroll` event handler\n * that should be attached to the list that renders the blocks.\n *\n *\n * @param {Object} props Component props.\n * @param {JSX.Element} props.children Children to be rendered.\n * @param {boolean} props.isRTL Check if current locale is RTL.\n *\n * @return {Function} Render function that passes `onScroll` event handler.\n */\nconst BlockDraggableWrapper = ( { children, isRTL } ) => {\n\tconst [ draggedBlockIcon, setDraggedBlockIcon ] = useState();\n\n\tconst { selectBlock, startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { scrollRef } = useBlockListContext();\n\tconst animatedScrollRef = useAnimatedRef();\n\tconst { left, right } = useSafeAreaInsets();\n\tconst { width } = useSafeAreaFrame();\n\tconst safeAreaOffset = left + right;\n\tconst contentWidth = width - safeAreaOffset;\n\tanimatedScrollRef( scrollRef );\n\n\tconst scroll = {\n\t\toffsetY: useSharedValue( 0 ),\n\t};\n\tconst chip = {\n\t\tx: useSharedValue( 0 ),\n\t\ty: useSharedValue( 0 ),\n\t\twidth: useSharedValue( 0 ),\n\t\theight: useSharedValue( 0 ),\n\t};\n\tconst currentYPosition = useSharedValue( 0 );\n\tconst isDragging = useSharedValue( false );\n\n\tconst [\n\t\tstartScrolling,\n\t\tscrollOnDragOver,\n\t\tstopScrolling,\n\t\tdraggingScrollHandler,\n\t] = useScrollWhenDragging();\n\n\tconst scrollHandler = ( event ) => {\n\t\t'worklet';\n\t\tconst { contentOffset } = event;\n\t\tscroll.offsetY.value = contentOffset.y;\n\n\t\tdraggingScrollHandler( event );\n\t};\n\n\tconst {\n\t\tonBlockDragOverWorklet,\n\t\tonBlockDragEnd,\n\t\tonBlockDrop,\n\t\ttargetBlockIndex,\n\t} = useBlockDropZone();\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.value ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tconst setDraggedBlockIconByClientId = ( clientId ) => {\n\t\tconst blockName = select( blockEditorStore ).getBlockName( clientId );\n\t\tconst blockIcon = getBlockType( blockName )?.icon;\n\t\tif ( blockIcon ) {\n\t\t\tsetDraggedBlockIcon( blockIcon );\n\t\t}\n\t};\n\n\tconst onStartDragging = ( { clientId, position } ) => {\n\t\tif ( clientId ) {\n\t\t\tstartDraggingBlocks( [ clientId ] );\n\t\t\tsetDraggedBlockIconByClientId( clientId );\n\t\t\trunOnUI( startScrolling )( position.y );\n\t\t\tgenerateHapticFeedback();\n\t\t} else {\n\t\t\t// We stop dragging if no block is found.\n\t\t\trunOnUI( stopDragging )();\n\t\t}\n\t};\n\n\tconst onStopDragging = ( { clientId } ) => {\n\t\tif ( clientId ) {\n\t\t\tonBlockDrop( {\n\t\t\t\t// Dropping is only allowed at root level\n\t\t\t\tsrcRootClientId: '',\n\t\t\t\tsrcClientIds: [ clientId ],\n\t\t\t\ttype: 'block',\n\t\t\t} );\n\t\t\tselectBlock( clientId );\n\t\t\tsetDraggedBlockIcon( undefined );\n\t\t}\n\t\tonBlockDragEnd();\n\t\tstopDraggingBlocks();\n\t};\n\n\tconst onChipLayout = ( { nativeEvent: { layout } } ) => {\n\t\tif ( layout.width > 0 ) {\n\t\t\tchip.width.value = layout.width;\n\t\t}\n\t\tif ( layout.height > 0 ) {\n\t\t\tchip.height.value = layout.height;\n\t\t}\n\t};\n\n\tconst startDragging = ( { x, y, id } ) => {\n\t\t'worklet';\n\t\tconst dragPosition = { x, y };\n\t\tchip.x.value = dragPosition.x;\n\t\tchip.y.value = dragPosition.y;\n\t\tcurrentYPosition.value = dragPosition.y;\n\n\t\tisDragging.value = true;\n\n\t\trunOnJS( onStartDragging )( { clientId: id, position: dragPosition } );\n\t};\n\n\tconst updateDragging = ( { x, y } ) => {\n\t\t'worklet';\n\t\tconst dragPosition = { x, y };\n\t\tchip.x.value = dragPosition.x;\n\t\tchip.y.value = dragPosition.y;\n\t\tcurrentYPosition.value = dragPosition.y;\n\n\t\tonBlockDragOverWorklet( { x, y: y + scroll.offsetY.value } );\n\n\t\t// Update scrolling velocity\n\t\tscrollOnDragOver( dragPosition.y );\n\t};\n\n\tconst stopDragging = ( { id } ) => {\n\t\t'worklet';\n\t\tisDragging.value = false;\n\n\t\tstopScrolling();\n\t\trunOnJS( onStopDragging )( { clientId: id } );\n\t};\n\n\tconst chipDynamicStyles = useAnimatedStyle( () => {\n\t\tconst chipOffset = chip.width.value / 2;\n\t\tconst translateX = ! isRTL\n\t\t\t? chip.x.value - chipOffset\n\t\t\t: -( contentWidth - ( chip.x.value + chipOffset ) );\n\n\t\treturn {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateX,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttranslateY:\n\t\t\t\t\t\tchip.y.value -\n\t\t\t\t\t\tchip.height.value -\n\t\t\t\t\t\tCHIP_OFFSET_TO_TOUCH_POSITION,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t} );\n\tconst chipStyles = [\n\t\tchipDynamicStyles,\n\t\tstyles[ 'draggable-chip__wrapper' ],\n\t];\n\n\tconst exitingAnimation = ( { currentHeight, currentWidth } ) => {\n\t\t'worklet';\n\t\tconst translateX = ! isRTL ? 0 : currentWidth * -1;\n\t\tconst duration = 150;\n\t\tconst animations = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: withTiming( currentHeight, {\n\t\t\t\t\t\tduration,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttranslateX: withTiming( translateX, {\n\t\t\t\t\t\tduration,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\t{ scale: withTiming( 0, { duration } ) },\n\t\t\t],\n\t\t};\n\t\tconst initialValues = {\n\t\t\ttransform: [ { translateY: 0 }, { translateX }, { scale: 1 } ],\n\t\t};\n\t\treturn {\n\t\t\tinitialValues,\n\t\t\tanimations,\n\t\t};\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<DroppingInsertionPoint\n\t\t\t\tscroll={ scroll }\n\t\t\t\tcurrentYPosition={ currentYPosition }\n\t\t\t\tisDragging={ isDragging }\n\t\t\t\ttargetBlockIndex={ targetBlockIndex }\n\t\t\t/>\n\t\t\t<Draggable\n\t\t\t\tonDragStart={ startDragging }\n\t\t\t\tonDragOver={ updateDragging }\n\t\t\t\tonDragEnd={ stopDragging }\n\t\t\t\ttestID=\"block-draggable-wrapper\"\n\t\t\t>\n\t\t\t\t{ children( { onScroll: scrollHandler } ) }\n\t\t\t</Draggable>\n\t\t\t<Animated.View\n\t\t\t\tonLayout={ onChipLayout }\n\t\t\t\tstyle={ chipStyles }\n\t\t\t\tpointerEvents=\"none\"\n\t\t\t>\n\t\t\t\t{ draggedBlockIcon && (\n\t\t\t\t\t<Animated.View\n\t\t\t\t\t\tentering={ ZoomInEasyDown.duration( 200 ) }\n\t\t\t\t\t\texiting={ exitingAnimation }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DraggableChip icon={ draggedBlockIcon } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t) }\n\t\t\t</Animated.View>\n\t\t</>\n\t);\n};\n\nfunction useIsScreenReaderEnabled() {\n\tconst [ isScreenReaderEnabled, setIsScreenReaderEnabled ] =\n\t\tuseState( false );\n\n\tuseEffect( () => {\n\t\tlet mounted = true;\n\n\t\tconst changeListener = AccessibilityInfo.addEventListener(\n\t\t\t'screenReaderChanged',\n\t\t\t( enabled ) => setIsScreenReaderEnabled( enabled )\n\t\t);\n\n\t\tAccessibilityInfo.isScreenReaderEnabled().then(\n\t\t\t( screenReaderEnabled ) => {\n\t\t\t\tif ( mounted && screenReaderEnabled ) {\n\t\t\t\t\tsetIsScreenReaderEnabled( screenReaderEnabled );\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tmounted = false;\n\n\t\t\tchangeListener.remove();\n\t\t};\n\t}, [] );\n\n\treturn isScreenReaderEnabled;\n}\n\nfunction useIsEditingText() {\n\tconst [ isEditingText, setIsEditingText ] = useState( () =>\n\t\tRCTAztecView.InputState.isFocused()\n\t);\n\n\tuseEffect( () => {\n\t\tconst onFocusChangeAztec = ( { isFocused } ) => {\n\t\t\tsetIsEditingText( isFocused );\n\t\t};\n\n\t\tRCTAztecView.InputState.addFocusChangeListener( onFocusChangeAztec );\n\n\t\treturn () => {\n\t\t\tRCTAztecView.InputState.removeFocusChangeListener(\n\t\t\t\tonFocusChangeAztec\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\treturn isEditingText;\n}\n\n/**\n * Block draggable component\n *\n * This component serves for animating the block when it is being dragged.\n * Hence, it should be wrapped around the rendering of a block.\n *\n * @param {Object} props Component props.\n * @param {JSX.Element} props.children Children to be rendered.\n * @param {string} props.clientId Client id of the block.\n * @param {string} [props.draggingClientId] Client id to use for dragging. If not defined, the value from `clientId` will be used.\n * @param {boolean} [props.enabled] Enables the draggable trigger.\n * @param {string} [props.testID] Id used for querying the long-press gesture handler in tests.\n *\n * @return {Function} Render function which includes the parameter `isDraggable` to determine if the block can be dragged.\n */\nconst BlockDraggable = ( {\n\tclientId,\n\tchildren,\n\tdraggingClientId,\n\tenabled = true,\n\ttestID,\n} ) => {\n\tconst wasBeingDragged = useRef( false );\n\tconst isEditingText = useIsEditingText();\n\tconst isScreenReaderEnabled = useIsScreenReaderEnabled();\n\n\tconst draggingAnimation = {\n\t\topacity: useSharedValue( 1 ),\n\t};\n\n\tconst startDraggingBlock = () => {\n\t\tdraggingAnimation.opacity.value = withTiming(\n\t\t\t0.4,\n\t\t\tBLOCK_OPACITY_ANIMATION_CONFIG\n\t\t);\n\t};\n\n\tconst stopDraggingBlock = () => {\n\t\tdraggingAnimation.opacity.value = withDelay(\n\t\t\tBLOCK_OPACITY_ANIMATION_DELAY,\n\t\t\twithTiming( 1, BLOCK_OPACITY_ANIMATION_CONFIG )\n\t\t);\n\t};\n\n\tconst { isDraggable, isBeingDragged, isBlockSelected } = useSelect(\n\t\t( _select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tisBlockBeingDragged,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t} = _select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst templateLock = rootClientId\n\t\t\t\t? getTemplateLock( rootClientId )\n\t\t\t\t: null;\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\treturn {\n\t\t\t\tisBeingDragged: isBlockBeingDragged( clientId ),\n\t\t\t\tisDraggable: 'all' !== templateLock,\n\t\t\t\tisBlockSelected:\n\t\t\t\t\tselectedBlockClientId && selectedBlockClientId === clientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( isBeingDragged !== wasBeingDragged.current ) {\n\t\t\tif ( isBeingDragged ) {\n\t\t\t\tstartDraggingBlock();\n\t\t\t} else {\n\t\t\t\tstopDraggingBlock();\n\t\t\t}\n\t\t}\n\t\twasBeingDragged.current = isBeingDragged;\n\t}, [ isBeingDragged ] );\n\n\tconst onLongPressDraggable = useCallback( () => {\n\t\t// Ensure that no text input is focused when starting the dragging gesture in order to prevent conflicts with text editing.\n\t\tRCTAztecView.InputState.blurCurrentFocusedElement();\n\t}, [] );\n\n\tconst animatedWrapperStyles = useAnimatedStyle( () => {\n\t\treturn {\n\t\t\topacity: draggingAnimation.opacity.value,\n\t\t};\n\t} );\n\tconst wrapperStyles = [\n\t\tanimatedWrapperStyles,\n\t\tstyles[ 'draggable-wrapper__container' ],\n\t];\n\n\tconst canDragBlock =\n\t\tenabled &&\n\t\t! isScreenReaderEnabled &&\n\t\t( ! isBlockSelected || ! isEditingText );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { isDraggable: false } );\n\t}\n\n\treturn (\n\t\t<DraggableTrigger\n\t\t\tid={ draggingClientId || clientId }\n\t\t\tenabled={ enabled && canDragBlock }\n\t\t\tminDuration={ Platform.select( {\n\t\t\t\t// On iOS, using a lower min duration than the default\n\t\t\t\t// value prevents the long-press gesture from being\n\t\t\t\t// triggered in underneath elements. This is required to\n\t\t\t\t// prevent enabling text editing when dragging is available.\n\t\t\t\tios: canDragBlock\n\t\t\t\t\t? DEFAULT_IOS_LONG_PRESS_MIN_DURATION\n\t\t\t\t\t: DEFAULT_LONG_PRESS_MIN_DURATION,\n\t\t\t\tandroid: DEFAULT_LONG_PRESS_MIN_DURATION,\n\t\t\t} ) }\n\t\t\tonLongPress={ onLongPressDraggable }\n\t\t\ttestID={ testID }\n\t\t>\n\t\t\t<Animated.View style={ wrapperStyles }>\n\t\t\t\t{ children( { isDraggable: true } ) }\n\t\t\t</Animated.View>\n\t\t</DraggableTrigger>\n\t);\n};\n\nexport { BlockDraggableWrapper };\nexport default BlockDraggable;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,iBAAiB,QAAQ,cAAc;AAChD,SACCC,iBAAiB,EACjBC,gBAAgB,QACV,gCAAgC;AACvC,OAAOC,QAAQ,IACdC,OAAO,EACPC,OAAO,EACPC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,EACTC,UAAU,EACVC,cAAc,QACR,yBAAyB;;AAEhC;AACA;AACA;AACA,SAASC,SAAS,EAAEC,gBAAgB,QAAQ,uBAAuB;AACnE,SAASC,MAAM,EAAEC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AAChE,SACCC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,EACRC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,sBAAsB,QAAQ,gCAAgC;AACvE,OAAOC,YAAY,MAAM,+BAA+B;;AAExD;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,OAAOC,sBAAsB,M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a,CAAE;EAEzC,IAAK,CAAEc,WAAW,EAAG;IACpB,OAAOzG,QAAQ,CAAE;MAAEyG,WAAW,EAAE;IAAM,CAAE,CAAC;EAC1C;EAEA,OACCtC,aAAA,CAAC9F,gBAAgB;IAChB+E,EAAE,EAAG+C,gBAAgB,IAAIhE,QAAU;IACnCmD,OAAO,EAAGA,OAAO,IAAImC,YAAc;IACnCC,WAAW,EAAG7I,QAAQ,CAACP,MAAM,CAAE;MAC9B;MACA;MACA;MACA;MACAqJ,GAAG,EAAEF,YAAY,GACd3H,mCAAmC,GACnCD,+BAA+B;MAClC+H,OAAO,EAAE/H;IACV,CAAE,CAAG;IACLgI,WAAW,EAAGR,oBAAsB;IACpC7C,MAAM,EAAGA;EAAQ,GAEjBL,aAAA,CAACxG,QAAQ,CAAC+G,IAAI;IAACE,KAAK,EAAG4C;EAAe,GACnCxH,QAAQ,CAAE;IAAEyG,WAAW,EAAE;EAAK,CAAE,CACpB,CACE,CAAC;AAErB,CAAC;AAED,SAAS1G,qBAAqB;AAC9B,eAAemG,cAAc"}
|
|
1
|
+
{"version":3,"names":["AccessibilityInfo","useSafeAreaInsets","useSafeAreaFrame","Animated","runOnJS","runOnUI","useAnimatedStyle","useSharedValue","withDelay","withTiming","ZoomInEasyDown","Draggable","DraggableTrigger","select","useSelect","useDispatch","useCallback","useEffect","useRef","useState","Platform","getBlockType","generateHapticFeedback","RCTAztecView","useScrollWhenDragging","DraggableChip","store","blockEditorStore","DroppingInsertionPoint","useBlockDropZone","styles","CHIP_OFFSET_TO_TOUCH_POSITION","BLOCK_OPACITY_ANIMATION_CONFIG","duration","BLOCK_OPACITY_ANIMATION_DELAY","DEFAULT_LONG_PRESS_MIN_DURATION","DEFAULT_IOS_LONG_PRESS_MIN_DURATION","BlockDraggableWrapper","children","isRTL","draggedBlockIcon","setDraggedBlockIcon","selectBlock","startDraggingBlocks","stopDraggingBlocks","left","right","width","safeAreaOffset","contentWidth","scroll","offsetY","chip","x","y","height","currentYPosition","isDragging","startScrolling","scrollOnDragOver","stopScrolling","draggingScrollHandler","scrollHandler","event","contentOffset","value","onBlockDragOverWorklet","onBlockDragEnd","onBlockDrop","targetBlockIndex","setDraggedBlockIconByClientId","clientId","blockName","getBlockName","blockIcon","icon","onStartDragging","position","stopDragging","onStopDragging","srcRootClientId","srcClientIds","type","undefined","onChipLayout","nativeEvent","layout","startDragging","id","dragPosition","updateDragging","chipDynamicStyles","chipOffset","translateX","transform","translateY","chipStyles","exitingAnimation","currentHeight","currentWidth","animations","scale","initialValues","createElement","Fragment","onDragStart","onDragOver","onDragEnd","testID","onScroll","View","onLayout","style","pointerEvents","entering","exiting","useIsScreenReaderEnabled","isScreenReaderEnabled","setIsScreenReaderEnabled","mounted","changeListener","addEventListener","enabled","then","screenReaderEnabled","remove","useIsEditingText","isEditingText","setIsEditingText","InputState","isFocused","onFocusChangeAztec","addFocusChangeListener","removeFocusChangeListener","BlockDraggable","draggingClientId","wasBeingDragged","draggingAnimation","opacity","startDraggingBlock","stopDraggingBlock","isDraggable","isBeingDragged","isBlockSelected","_select","getBlockRootClientId","getTemplateLock","isBlockBeingDragged","getSelectedBlockClientId","rootClientId","templateLock","selectedBlockClientId","current","onLongPressDraggable","blurCurrentFocusedElement","animatedWrapperStyles","wrapperStyles","canDragBlock","minDuration","ios","android","onLongPress"],"sources":["@wordpress/block-editor/src/components/block-draggable/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo } from 'react-native';\nimport {\n\tuseSafeAreaInsets,\n\tuseSafeAreaFrame,\n} from 'react-native-safe-area-context';\nimport Animated, {\n\trunOnJS,\n\trunOnUI,\n\tuseAnimatedStyle,\n\tuseSharedValue,\n\twithDelay,\n\twithTiming,\n\tZoomInEasyDown,\n} from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport { Draggable, DraggableTrigger } from '@wordpress/components';\nimport { select, useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tPlatform,\n} from '@wordpress/element';\nimport { getBlockType } from '@wordpress/blocks';\nimport { generateHapticFeedback } from '@wordpress/react-native-bridge';\nimport RCTAztecView from '@wordpress/react-native-aztec';\n\n/**\n * Internal dependencies\n */\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport DraggableChip from './draggable-chip';\nimport { store as blockEditorStore } from '../../store';\nimport DroppingInsertionPoint from './dropping-insertion-point';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport styles from './style.scss';\n\nconst CHIP_OFFSET_TO_TOUCH_POSITION = 32;\nconst BLOCK_OPACITY_ANIMATION_CONFIG = { duration: 350 };\nconst BLOCK_OPACITY_ANIMATION_DELAY = 250;\nconst DEFAULT_LONG_PRESS_MIN_DURATION = 500;\nconst DEFAULT_IOS_LONG_PRESS_MIN_DURATION =\n\tDEFAULT_LONG_PRESS_MIN_DURATION - 50;\n\n/**\n * Block draggable wrapper component\n *\n * This component handles all the interactions for dragging blocks.\n * It relies on the block list and its context for dragging, hence it\n * should be rendered between the `BlockListProvider` component and the\n * block list rendering. It also requires listening to scroll events,\n * therefore for this purpose, it returns the `onScroll` event handler\n * that should be attached to the list that renders the blocks.\n *\n *\n * @param {Object} props Component props.\n * @param {JSX.Element} props.children Children to be rendered.\n * @param {boolean} props.isRTL Check if current locale is RTL.\n *\n * @return {Function} Render function that passes `onScroll` event handler.\n */\nconst BlockDraggableWrapper = ( { children, isRTL } ) => {\n\tconst [ draggedBlockIcon, setDraggedBlockIcon ] = useState();\n\n\tconst { selectBlock, startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { left, right } = useSafeAreaInsets();\n\tconst { width } = useSafeAreaFrame();\n\tconst safeAreaOffset = left + right;\n\tconst contentWidth = width - safeAreaOffset;\n\n\tconst scroll = {\n\t\toffsetY: useSharedValue( 0 ),\n\t};\n\tconst chip = {\n\t\tx: useSharedValue( 0 ),\n\t\ty: useSharedValue( 0 ),\n\t\twidth: useSharedValue( 0 ),\n\t\theight: useSharedValue( 0 ),\n\t};\n\tconst currentYPosition = useSharedValue( 0 );\n\tconst isDragging = useSharedValue( false );\n\n\tconst [\n\t\tstartScrolling,\n\t\tscrollOnDragOver,\n\t\tstopScrolling,\n\t\tdraggingScrollHandler,\n\t] = useScrollWhenDragging();\n\n\tconst scrollHandler = ( event ) => {\n\t\t'worklet';\n\t\tconst { contentOffset } = event;\n\t\tscroll.offsetY.value = contentOffset.y;\n\n\t\tdraggingScrollHandler( event );\n\t};\n\n\tconst {\n\t\tonBlockDragOverWorklet,\n\t\tonBlockDragEnd,\n\t\tonBlockDrop,\n\t\ttargetBlockIndex,\n\t} = useBlockDropZone();\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.value ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tconst setDraggedBlockIconByClientId = ( clientId ) => {\n\t\tconst blockName = select( blockEditorStore ).getBlockName( clientId );\n\t\tconst blockIcon = getBlockType( blockName )?.icon;\n\t\tif ( blockIcon ) {\n\t\t\tsetDraggedBlockIcon( blockIcon );\n\t\t}\n\t};\n\n\tconst onStartDragging = ( { clientId, position } ) => {\n\t\tif ( clientId ) {\n\t\t\tstartDraggingBlocks( [ clientId ] );\n\t\t\tsetDraggedBlockIconByClientId( clientId );\n\t\t\trunOnUI( startScrolling )( position.y );\n\t\t\tgenerateHapticFeedback();\n\t\t} else {\n\t\t\t// We stop dragging if no block is found.\n\t\t\trunOnUI( stopDragging )();\n\t\t}\n\t};\n\n\tconst onStopDragging = ( { clientId } ) => {\n\t\tif ( clientId ) {\n\t\t\tonBlockDrop( {\n\t\t\t\t// Dropping is only allowed at root level\n\t\t\t\tsrcRootClientId: '',\n\t\t\t\tsrcClientIds: [ clientId ],\n\t\t\t\ttype: 'block',\n\t\t\t} );\n\t\t\tselectBlock( clientId );\n\t\t\tsetDraggedBlockIcon( undefined );\n\t\t}\n\t\tonBlockDragEnd();\n\t\tstopDraggingBlocks();\n\t};\n\n\tconst onChipLayout = ( { nativeEvent: { layout } } ) => {\n\t\tif ( layout.width > 0 ) {\n\t\t\tchip.width.value = layout.width;\n\t\t}\n\t\tif ( layout.height > 0 ) {\n\t\t\tchip.height.value = layout.height;\n\t\t}\n\t};\n\n\tconst startDragging = ( { x, y, id } ) => {\n\t\t'worklet';\n\t\tconst dragPosition = { x, y };\n\t\tchip.x.value = dragPosition.x;\n\t\tchip.y.value = dragPosition.y;\n\t\tcurrentYPosition.value = dragPosition.y;\n\n\t\tisDragging.value = true;\n\n\t\trunOnJS( onStartDragging )( { clientId: id, position: dragPosition } );\n\t};\n\n\tconst updateDragging = ( { x, y } ) => {\n\t\t'worklet';\n\t\tconst dragPosition = { x, y };\n\t\tchip.x.value = dragPosition.x;\n\t\tchip.y.value = dragPosition.y;\n\t\tcurrentYPosition.value = dragPosition.y;\n\n\t\tonBlockDragOverWorklet( { x, y: y + scroll.offsetY.value } );\n\n\t\t// Update scrolling velocity\n\t\tscrollOnDragOver( dragPosition.y );\n\t};\n\n\tconst stopDragging = ( { id } ) => {\n\t\t'worklet';\n\t\tisDragging.value = false;\n\n\t\tstopScrolling();\n\t\trunOnJS( onStopDragging )( { clientId: id } );\n\t};\n\n\tconst chipDynamicStyles = useAnimatedStyle( () => {\n\t\tconst chipOffset = chip.width.value / 2;\n\t\tconst translateX = ! isRTL\n\t\t\t? chip.x.value - chipOffset\n\t\t\t: -( contentWidth - ( chip.x.value + chipOffset ) );\n\n\t\treturn {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateX,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttranslateY:\n\t\t\t\t\t\tchip.y.value -\n\t\t\t\t\t\tchip.height.value -\n\t\t\t\t\t\tCHIP_OFFSET_TO_TOUCH_POSITION,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t} );\n\tconst chipStyles = [\n\t\tchipDynamicStyles,\n\t\tstyles[ 'draggable-chip__wrapper' ],\n\t];\n\n\tconst exitingAnimation = ( { currentHeight, currentWidth } ) => {\n\t\t'worklet';\n\t\tconst translateX = ! isRTL ? 0 : currentWidth * -1;\n\t\tconst duration = 150;\n\t\tconst animations = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: withTiming( currentHeight, {\n\t\t\t\t\t\tduration,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttranslateX: withTiming( translateX, {\n\t\t\t\t\t\tduration,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\t{ scale: withTiming( 0, { duration } ) },\n\t\t\t],\n\t\t};\n\t\tconst initialValues = {\n\t\t\ttransform: [ { translateY: 0 }, { translateX }, { scale: 1 } ],\n\t\t};\n\t\treturn {\n\t\t\tinitialValues,\n\t\t\tanimations,\n\t\t};\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<DroppingInsertionPoint\n\t\t\t\tscroll={ scroll }\n\t\t\t\tcurrentYPosition={ currentYPosition }\n\t\t\t\tisDragging={ isDragging }\n\t\t\t\ttargetBlockIndex={ targetBlockIndex }\n\t\t\t/>\n\t\t\t<Draggable\n\t\t\t\tonDragStart={ startDragging }\n\t\t\t\tonDragOver={ updateDragging }\n\t\t\t\tonDragEnd={ stopDragging }\n\t\t\t\ttestID=\"block-draggable-wrapper\"\n\t\t\t>\n\t\t\t\t{ children( { onScroll: scrollHandler } ) }\n\t\t\t</Draggable>\n\t\t\t<Animated.View\n\t\t\t\tonLayout={ onChipLayout }\n\t\t\t\tstyle={ chipStyles }\n\t\t\t\tpointerEvents=\"none\"\n\t\t\t>\n\t\t\t\t{ draggedBlockIcon && (\n\t\t\t\t\t<Animated.View\n\t\t\t\t\t\tentering={ ZoomInEasyDown.duration( 200 ) }\n\t\t\t\t\t\texiting={ exitingAnimation }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DraggableChip icon={ draggedBlockIcon } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t) }\n\t\t\t</Animated.View>\n\t\t</>\n\t);\n};\n\nfunction useIsScreenReaderEnabled() {\n\tconst [ isScreenReaderEnabled, setIsScreenReaderEnabled ] =\n\t\tuseState( false );\n\n\tuseEffect( () => {\n\t\tlet mounted = true;\n\n\t\tconst changeListener = AccessibilityInfo.addEventListener(\n\t\t\t'screenReaderChanged',\n\t\t\t( enabled ) => setIsScreenReaderEnabled( enabled )\n\t\t);\n\n\t\tAccessibilityInfo.isScreenReaderEnabled().then(\n\t\t\t( screenReaderEnabled ) => {\n\t\t\t\tif ( mounted && screenReaderEnabled ) {\n\t\t\t\t\tsetIsScreenReaderEnabled( screenReaderEnabled );\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tmounted = false;\n\n\t\t\tchangeListener.remove();\n\t\t};\n\t}, [] );\n\n\treturn isScreenReaderEnabled;\n}\n\nfunction useIsEditingText() {\n\tconst [ isEditingText, setIsEditingText ] = useState( () =>\n\t\tRCTAztecView.InputState.isFocused()\n\t);\n\n\tuseEffect( () => {\n\t\tconst onFocusChangeAztec = ( { isFocused } ) => {\n\t\t\tsetIsEditingText( isFocused );\n\t\t};\n\n\t\tRCTAztecView.InputState.addFocusChangeListener( onFocusChangeAztec );\n\n\t\treturn () => {\n\t\t\tRCTAztecView.InputState.removeFocusChangeListener(\n\t\t\t\tonFocusChangeAztec\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\treturn isEditingText;\n}\n\n/**\n * Block draggable component\n *\n * This component serves for animating the block when it is being dragged.\n * Hence, it should be wrapped around the rendering of a block.\n *\n * @param {Object} props Component props.\n * @param {JSX.Element} props.children Children to be rendered.\n * @param {string} props.clientId Client id of the block.\n * @param {string} [props.draggingClientId] Client id to use for dragging. If not defined, the value from `clientId` will be used.\n * @param {boolean} [props.enabled] Enables the draggable trigger.\n * @param {string} [props.testID] Id used for querying the long-press gesture handler in tests.\n *\n * @return {Function} Render function which includes the parameter `isDraggable` to determine if the block can be dragged.\n */\nconst BlockDraggable = ( {\n\tclientId,\n\tchildren,\n\tdraggingClientId,\n\tenabled = true,\n\ttestID,\n} ) => {\n\tconst wasBeingDragged = useRef( false );\n\tconst isEditingText = useIsEditingText();\n\tconst isScreenReaderEnabled = useIsScreenReaderEnabled();\n\n\tconst draggingAnimation = {\n\t\topacity: useSharedValue( 1 ),\n\t};\n\n\tconst startDraggingBlock = () => {\n\t\tdraggingAnimation.opacity.value = withTiming(\n\t\t\t0.4,\n\t\t\tBLOCK_OPACITY_ANIMATION_CONFIG\n\t\t);\n\t};\n\n\tconst stopDraggingBlock = () => {\n\t\tdraggingAnimation.opacity.value = withDelay(\n\t\t\tBLOCK_OPACITY_ANIMATION_DELAY,\n\t\t\twithTiming( 1, BLOCK_OPACITY_ANIMATION_CONFIG )\n\t\t);\n\t};\n\n\tconst { isDraggable, isBeingDragged, isBlockSelected } = useSelect(\n\t\t( _select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tisBlockBeingDragged,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t} = _select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst templateLock = rootClientId\n\t\t\t\t? getTemplateLock( rootClientId )\n\t\t\t\t: null;\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\treturn {\n\t\t\t\tisBeingDragged: isBlockBeingDragged( clientId ),\n\t\t\t\tisDraggable: 'all' !== templateLock,\n\t\t\t\tisBlockSelected:\n\t\t\t\t\tselectedBlockClientId && selectedBlockClientId === clientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( isBeingDragged !== wasBeingDragged.current ) {\n\t\t\tif ( isBeingDragged ) {\n\t\t\t\tstartDraggingBlock();\n\t\t\t} else {\n\t\t\t\tstopDraggingBlock();\n\t\t\t}\n\t\t}\n\t\twasBeingDragged.current = isBeingDragged;\n\t}, [ isBeingDragged ] );\n\n\tconst onLongPressDraggable = useCallback( () => {\n\t\t// Ensure that no text input is focused when starting the dragging gesture in order to prevent conflicts with text editing.\n\t\tRCTAztecView.InputState.blurCurrentFocusedElement();\n\t}, [] );\n\n\tconst animatedWrapperStyles = useAnimatedStyle( () => {\n\t\treturn {\n\t\t\topacity: draggingAnimation.opacity.value,\n\t\t};\n\t} );\n\tconst wrapperStyles = [\n\t\tanimatedWrapperStyles,\n\t\tstyles[ 'draggable-wrapper__container' ],\n\t];\n\n\tconst canDragBlock =\n\t\tenabled &&\n\t\t! isScreenReaderEnabled &&\n\t\t( ! isBlockSelected || ! isEditingText );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { isDraggable: false } );\n\t}\n\n\treturn (\n\t\t<DraggableTrigger\n\t\t\tid={ draggingClientId || clientId }\n\t\t\tenabled={ enabled && canDragBlock }\n\t\t\tminDuration={ Platform.select( {\n\t\t\t\t// On iOS, using a lower min duration than the default\n\t\t\t\t// value prevents the long-press gesture from being\n\t\t\t\t// triggered in underneath elements. This is required to\n\t\t\t\t// prevent enabling text editing when dragging is available.\n\t\t\t\tios: canDragBlock\n\t\t\t\t\t? DEFAULT_IOS_LONG_PRESS_MIN_DURATION\n\t\t\t\t\t: DEFAULT_LONG_PRESS_MIN_DURATION,\n\t\t\t\tandroid: DEFAULT_LONG_PRESS_MIN_DURATION,\n\t\t\t} ) }\n\t\t\tonLongPress={ onLongPressDraggable }\n\t\t\ttestID={ testID }\n\t\t>\n\t\t\t<Animated.View style={ wrapperStyles }>\n\t\t\t\t{ children( { isDraggable: true } ) }\n\t\t\t</Animated.View>\n\t\t</DraggableTrigger>\n\t);\n};\n\nexport { BlockDraggableWrapper };\nexport default BlockDraggable;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,iBAAiB,QAAQ,cAAc;AAChD,SACCC,iBAAiB,EACjBC,gBAAgB,QACV,gCAAgC;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MW,oBAAoB,GAAGzI,WAAW,CAAE,MAAM;IAC/C;IACAO,YAAY,CAAC0G,UAAU,CAACyB,yBAAyB,CAAC,CAAC;EACpD,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMC,qBAAqB,GAAGrJ,gBAAgB,CAAE,MAAM;IACrD,OAAO;MACNoI,OAAO,EAAED,iBAAiB,CAACC,OAAO,CAACzE;IACpC,CAAC;EACF,CAAE,CAAC;EACH,MAAM2F,aAAa,GAAG,CACrBD,qBAAqB,EACrB7H,MAAM,CAAE,8BAA8B,CAAE,CACxC;EAED,MAAM+H,YAAY,GACjBnC,OAAO,IACP,CAAEL,qBAAqB,KACrB,CAAE0B,eAAe,IAAI,CAAEhB,aAAa,CAAE;EAEzC,IAAK,CAAEc,WAAW,EAAG;IACpB,OAAOvG,QAAQ,CAAE;MAAEuG,WAAW,EAAE;IAAM,CAAE,CAAC;EAC1C;EAEA,OACCtC,aAAA,CAAC3F,gBAAgB;IAChB4E,EAAE,EAAG+C,gBAAgB,IAAIhE,QAAU;IACnCmD,OAAO,EAAGA,OAAO,IAAImC,YAAc;IACnCC,WAAW,EAAG1I,QAAQ,CAACP,MAAM,CAAE;MAC9B;MACA;MACA;MACA;MACAkJ,GAAG,EAAEF,YAAY,GACdzH,mCAAmC,GACnCD,+BAA+B;MAClC6H,OAAO,EAAE7H;IACV,CAAE,CAAG;IACL8H,WAAW,EAAGR,oBAAsB;IACpC7C,MAAM,EAAGA;EAAQ,GAEjBL,aAAA,CAACpG,QAAQ,CAAC2G,IAAI;IAACE,KAAK,EAAG4C;EAAe,GACnCtH,QAAQ,CAAE;IAAEuG,WAAW,EAAE;EAAK,CAAE,CACpB,CACE,CAAC;AAErB,CAAC;AAED,SAASxG,qBAAqB;AAC9B,eAAeiG,cAAc"}
|
|
@@ -26,7 +26,7 @@ export default function useScrollWhenDragging() {
|
|
|
26
26
|
scrollRef
|
|
27
27
|
} = useBlockListContext();
|
|
28
28
|
const animatedScrollRef = useAnimatedRef();
|
|
29
|
-
animatedScrollRef(scrollRef);
|
|
29
|
+
animatedScrollRef(scrollRef?.scrollViewRef);
|
|
30
30
|
const {
|
|
31
31
|
height: windowHeight
|
|
32
32
|
} = useWindowDimensions();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useWindowDimensions","useSharedValue","useAnimatedRef","scrollTo","useAnimatedReaction","withTiming","withRepeat","cancelAnimation","Easing","useBlockListContext","SCROLL_INACTIVE_DISTANCE_PX","SCROLL_INTERVAL_MS","VELOCITY_MULTIPLIER","useScrollWhenDragging","scrollRef","animatedScrollRef","height","windowHeight","velocityY","offsetY","dragStartY","animationTimer","isAnimationTimerActive","isScrollActive","scroll","maxOffsetY","scrollHandler","event","contentSize","contentOffset","layoutMeasurement","value","y","stopScrolling","startScrolling","duration","easing","linear","scrollOnDragOver","dragDistance","Math","max","abs","distancePercentage","previous","delta","newOffset","min"],"sources":["@wordpress/block-editor/src/components/block-draggable/use-scroll-when-dragging.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useWindowDimensions } from 'react-native';\nimport {\n\tuseSharedValue,\n\tuseAnimatedRef,\n\tscrollTo,\n\tuseAnimatedReaction,\n\twithTiming,\n\twithRepeat,\n\tcancelAnimation,\n\tEasing,\n} from 'react-native-reanimated';\n\n/**\n * Internal dependencies\n */\nimport { useBlockListContext } from '../block-list/block-list-context';\n\nconst SCROLL_INACTIVE_DISTANCE_PX = 50;\nconst SCROLL_INTERVAL_MS = 1000;\nconst VELOCITY_MULTIPLIER = 5000;\n\n/**\n * React hook that scrolls the scroll container when a block is being dragged.\n *\n * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`\n * functions to be called in `onDragStart`, `onDragOver`\n * and `onDragEnd` events respectively. Additionally,\n * \t\t\t\t\t\t`scrollHandler` function is returned which should be\n * \t\t\t\t\t\tcalled in the `onScroll` event of the block list.\n */\nexport default function useScrollWhenDragging() {\n\tconst { scrollRef } = useBlockListContext();\n\tconst animatedScrollRef = useAnimatedRef();\n\tanimatedScrollRef( scrollRef );\n\n\tconst { height: windowHeight } = useWindowDimensions();\n\n\tconst velocityY = useSharedValue( 0 );\n\tconst offsetY = useSharedValue( 0 );\n\tconst dragStartY = useSharedValue( 0 );\n\tconst animationTimer = useSharedValue( 0 );\n\tconst isAnimationTimerActive = useSharedValue( false );\n\tconst isScrollActive = useSharedValue( false );\n\n\tconst scroll = {\n\t\toffsetY: useSharedValue( 0 ),\n\t\tmaxOffsetY: useSharedValue( 0 ),\n\t};\n\tconst scrollHandler = ( event ) => {\n\t\t'worklet';\n\t\tconst { contentSize, contentOffset, layoutMeasurement } = event;\n\t\tscroll.offsetY.value = contentOffset.y;\n\t\tscroll.maxOffsetY.value = contentSize.height - layoutMeasurement.height;\n\t};\n\n\tconst stopScrolling = () => {\n\t\t'worklet';\n\t\tcancelAnimation( animationTimer );\n\n\t\tisAnimationTimerActive.value = false;\n\t\tisScrollActive.value = false;\n\t\tvelocityY.value = 0;\n\t};\n\n\tconst startScrolling = ( y ) => {\n\t\t'worklet';\n\t\tstopScrolling();\n\t\toffsetY.value = scroll.offsetY.value;\n\t\tdragStartY.value = y;\n\n\t\tanimationTimer.value = 0;\n\t\tanimationTimer.value = withRepeat(\n\t\t\twithTiming( 1, {\n\t\t\t\tduration: SCROLL_INTERVAL_MS,\n\t\t\t\teasing: Easing.linear,\n\t\t\t} ),\n\t\t\t-1,\n\t\t\ttrue\n\t\t);\n\t\tisAnimationTimerActive.value = true;\n\t};\n\n\tconst scrollOnDragOver = ( y ) => {\n\t\t'worklet';\n\t\tconst dragDistance = Math.max(\n\t\t\tMath.abs( y - dragStartY.value ) - SCROLL_INACTIVE_DISTANCE_PX,\n\t\t\t0\n\t\t);\n\t\tconst distancePercentage = dragDistance / windowHeight;\n\n\t\tif ( ! isScrollActive.value ) {\n\t\t\tisScrollActive.value = dragDistance > 0;\n\t\t} else if ( y > dragStartY.value ) {\n\t\t\t// User is dragging downwards.\n\t\t\tvelocityY.value = VELOCITY_MULTIPLIER * distancePercentage;\n\t\t} else if ( y < dragStartY.value ) {\n\t\t\t// User is dragging upwards.\n\t\t\tvelocityY.value = -VELOCITY_MULTIPLIER * distancePercentage;\n\t\t} else {\n\t\t\tvelocityY.value = 0;\n\t\t}\n\t};\n\n\tuseAnimatedReaction(\n\t\t() => animationTimer.value,\n\t\t( value, previous ) => {\n\t\t\tif ( velocityY.value === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst delta = Math.abs( value - previous );\n\t\t\tlet newOffset = offsetY.value + delta * velocityY.value;\n\n\t\t\tif ( scroll.maxOffsetY.value !== 0 ) {\n\t\t\t\tnewOffset = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\tMath.min( scroll.maxOffsetY.value, newOffset )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Scroll values are empty until receiving the first scroll event.\n\t\t\t\t// In that case, the max offset is unknown and we can't clamp the\n\t\t\t\t// new offset value.\n\t\t\t\tnewOffset = Math.max( 0, newOffset );\n\t\t\t}\n\n\t\t\toffsetY.value = newOffset;\n\t\t\tscrollTo( animatedScrollRef, 0, offsetY.value, false );\n\t\t}\n\t);\n\n\treturn [ startScrolling, scrollOnDragOver, stopScrolling, scrollHandler ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAClD,SACCC,cAAc,EACdC,cAAc,EACdC,QAAQ,EACRC,mBAAmB,EACnBC,UAAU,EACVC,UAAU,EACVC,eAAe,EACfC,MAAM,QACA,yBAAyB;;AAEhC;AACA;AACA;AACA,SAASC,mBAAmB,QAAQ,kCAAkC;AAEtE,MAAMC,2BAA2B,GAAG,EAAE;AACtC,MAAMC,kBAAkB,GAAG,IAAI;AAC/B,MAAMC,mBAAmB,GAAG,IAAI;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAEC;EAAU,CAAC,GAAGL,mBAAmB,CAAC,CAAC;EAC3C,MAAMM,iBAAiB,GAAGb,cAAc,CAAC,CAAC;EAC1Ca,iBAAiB,CAAED,
|
|
1
|
+
{"version":3,"names":["useWindowDimensions","useSharedValue","useAnimatedRef","scrollTo","useAnimatedReaction","withTiming","withRepeat","cancelAnimation","Easing","useBlockListContext","SCROLL_INACTIVE_DISTANCE_PX","SCROLL_INTERVAL_MS","VELOCITY_MULTIPLIER","useScrollWhenDragging","scrollRef","animatedScrollRef","scrollViewRef","height","windowHeight","velocityY","offsetY","dragStartY","animationTimer","isAnimationTimerActive","isScrollActive","scroll","maxOffsetY","scrollHandler","event","contentSize","contentOffset","layoutMeasurement","value","y","stopScrolling","startScrolling","duration","easing","linear","scrollOnDragOver","dragDistance","Math","max","abs","distancePercentage","previous","delta","newOffset","min"],"sources":["@wordpress/block-editor/src/components/block-draggable/use-scroll-when-dragging.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useWindowDimensions } from 'react-native';\nimport {\n\tuseSharedValue,\n\tuseAnimatedRef,\n\tscrollTo,\n\tuseAnimatedReaction,\n\twithTiming,\n\twithRepeat,\n\tcancelAnimation,\n\tEasing,\n} from 'react-native-reanimated';\n\n/**\n * Internal dependencies\n */\nimport { useBlockListContext } from '../block-list/block-list-context';\n\nconst SCROLL_INACTIVE_DISTANCE_PX = 50;\nconst SCROLL_INTERVAL_MS = 1000;\nconst VELOCITY_MULTIPLIER = 5000;\n\n/**\n * React hook that scrolls the scroll container when a block is being dragged.\n *\n * @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`\n * functions to be called in `onDragStart`, `onDragOver`\n * and `onDragEnd` events respectively. Additionally,\n * \t\t\t\t\t\t`scrollHandler` function is returned which should be\n * \t\t\t\t\t\tcalled in the `onScroll` event of the block list.\n */\nexport default function useScrollWhenDragging() {\n\tconst { scrollRef } = useBlockListContext();\n\tconst animatedScrollRef = useAnimatedRef();\n\tanimatedScrollRef( scrollRef?.scrollViewRef );\n\n\tconst { height: windowHeight } = useWindowDimensions();\n\n\tconst velocityY = useSharedValue( 0 );\n\tconst offsetY = useSharedValue( 0 );\n\tconst dragStartY = useSharedValue( 0 );\n\tconst animationTimer = useSharedValue( 0 );\n\tconst isAnimationTimerActive = useSharedValue( false );\n\tconst isScrollActive = useSharedValue( false );\n\n\tconst scroll = {\n\t\toffsetY: useSharedValue( 0 ),\n\t\tmaxOffsetY: useSharedValue( 0 ),\n\t};\n\tconst scrollHandler = ( event ) => {\n\t\t'worklet';\n\t\tconst { contentSize, contentOffset, layoutMeasurement } = event;\n\t\tscroll.offsetY.value = contentOffset.y;\n\t\tscroll.maxOffsetY.value = contentSize.height - layoutMeasurement.height;\n\t};\n\n\tconst stopScrolling = () => {\n\t\t'worklet';\n\t\tcancelAnimation( animationTimer );\n\n\t\tisAnimationTimerActive.value = false;\n\t\tisScrollActive.value = false;\n\t\tvelocityY.value = 0;\n\t};\n\n\tconst startScrolling = ( y ) => {\n\t\t'worklet';\n\t\tstopScrolling();\n\t\toffsetY.value = scroll.offsetY.value;\n\t\tdragStartY.value = y;\n\n\t\tanimationTimer.value = 0;\n\t\tanimationTimer.value = withRepeat(\n\t\t\twithTiming( 1, {\n\t\t\t\tduration: SCROLL_INTERVAL_MS,\n\t\t\t\teasing: Easing.linear,\n\t\t\t} ),\n\t\t\t-1,\n\t\t\ttrue\n\t\t);\n\t\tisAnimationTimerActive.value = true;\n\t};\n\n\tconst scrollOnDragOver = ( y ) => {\n\t\t'worklet';\n\t\tconst dragDistance = Math.max(\n\t\t\tMath.abs( y - dragStartY.value ) - SCROLL_INACTIVE_DISTANCE_PX,\n\t\t\t0\n\t\t);\n\t\tconst distancePercentage = dragDistance / windowHeight;\n\n\t\tif ( ! isScrollActive.value ) {\n\t\t\tisScrollActive.value = dragDistance > 0;\n\t\t} else if ( y > dragStartY.value ) {\n\t\t\t// User is dragging downwards.\n\t\t\tvelocityY.value = VELOCITY_MULTIPLIER * distancePercentage;\n\t\t} else if ( y < dragStartY.value ) {\n\t\t\t// User is dragging upwards.\n\t\t\tvelocityY.value = -VELOCITY_MULTIPLIER * distancePercentage;\n\t\t} else {\n\t\t\tvelocityY.value = 0;\n\t\t}\n\t};\n\n\tuseAnimatedReaction(\n\t\t() => animationTimer.value,\n\t\t( value, previous ) => {\n\t\t\tif ( velocityY.value === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst delta = Math.abs( value - previous );\n\t\t\tlet newOffset = offsetY.value + delta * velocityY.value;\n\n\t\t\tif ( scroll.maxOffsetY.value !== 0 ) {\n\t\t\t\tnewOffset = Math.max(\n\t\t\t\t\t0,\n\t\t\t\t\tMath.min( scroll.maxOffsetY.value, newOffset )\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// Scroll values are empty until receiving the first scroll event.\n\t\t\t\t// In that case, the max offset is unknown and we can't clamp the\n\t\t\t\t// new offset value.\n\t\t\t\tnewOffset = Math.max( 0, newOffset );\n\t\t\t}\n\n\t\t\toffsetY.value = newOffset;\n\t\t\tscrollTo( animatedScrollRef, 0, offsetY.value, false );\n\t\t}\n\t);\n\n\treturn [ startScrolling, scrollOnDragOver, stopScrolling, scrollHandler ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAClD,SACCC,cAAc,EACdC,cAAc,EACdC,QAAQ,EACRC,mBAAmB,EACnBC,UAAU,EACVC,UAAU,EACVC,eAAe,EACfC,MAAM,QACA,yBAAyB;;AAEhC;AACA;AACA;AACA,SAASC,mBAAmB,QAAQ,kCAAkC;AAEtE,MAAMC,2BAA2B,GAAG,EAAE;AACtC,MAAMC,kBAAkB,GAAG,IAAI;AAC/B,MAAMC,mBAAmB,GAAG,IAAI;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAA,EAAG;EAC/C,MAAM;IAAEC;EAAU,CAAC,GAAGL,mBAAmB,CAAC,CAAC;EAC3C,MAAM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KAAK,GAAGa,QAAS,CAAC;IAC1C,IAAIE,SAAS,GAAG3B,OAAO,CAACY,KAAK,GAAGc,KAAK,GAAG3B,SAAS,CAACa,KAAK;IAEvD,IAAKP,MAAM,CAACC,UAAU,CAACM,KAAK,KAAK,CAAC,EAAG;MACpCe,SAAS,GAAGN,IAAI,CAACC,GAAG,CACnB,CAAC,EACDD,IAAI,CAACO,GAAG,CAAEvB,MAAM,CAACC,UAAU,CAACM,KAAK,EAAEe,SAAU,CAC9C,CAAC;IACF,CAAC,MAAM;MACN;MACA;MACA;MACAA,SAAS,GAAGN,IAAI,CAACC,GAAG,CAAE,CAAC,EAAEK,SAAU,CAAC;IACrC;IAEA3B,OAAO,CAACY,KAAK,GAAGe,SAAS;IACzB5C,QAAQ,CAAEY,iBAAiB,EAAE,CAAC,EAAEK,OAAO,CAACY,KAAK,EAAE,KAAM,CAAC;EACvD,CACD,CAAC;EAED,OAAO,CAAEG,cAAc,EAAEI,gBAAgB,EAAEL,aAAa,EAAEP,aAAa,CAAE;AAC1E"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { createContext, useContext } from '@wordpress/element';
|
|
5
|
+
export const mayDisplayControlsKey = Symbol('mayDisplayControls');
|
|
6
|
+
export const mayDisplayParentControlsKey = Symbol('mayDisplayParentControls');
|
|
5
7
|
export const DEFAULT_BLOCK_EDIT_CONTEXT = {
|
|
6
8
|
name: '',
|
|
7
9
|
isSelected: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","DEFAULT_BLOCK_EDIT_CONTEXT","name","isSelected","Context","Provider","BlockEditContextProvider","useBlockEditContext"],"sources":["@wordpress/block-editor/src/components/block-edit/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\nexport const DEFAULT_BLOCK_EDIT_CONTEXT = {\n\tname: '',\n\tisSelected: false,\n};\n\nconst Context = createContext( DEFAULT_BLOCK_EDIT_CONTEXT );\nconst { Provider } = Context;\n\nexport { Provider as BlockEditContextProvider };\n\n/**\n * A hook that returns the block edit context.\n *\n * @return {Object} Block edit context\n */\nexport function useBlockEditContext() {\n\treturn useContext( Context );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAE9D,OAAO,MAAMC,0BAA0B,GAAG;EACzCC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACb,CAAC;AAED,MAAMC,OAAO,
|
|
1
|
+
{"version":3,"names":["createContext","useContext","mayDisplayControlsKey","Symbol","mayDisplayParentControlsKey","DEFAULT_BLOCK_EDIT_CONTEXT","name","isSelected","Context","Provider","BlockEditContextProvider","useBlockEditContext"],"sources":["@wordpress/block-editor/src/components/block-edit/context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\nexport const mayDisplayControlsKey = Symbol( 'mayDisplayControls' );\nexport const mayDisplayParentControlsKey = Symbol( 'mayDisplayParentControls' );\n\nexport const DEFAULT_BLOCK_EDIT_CONTEXT = {\n\tname: '',\n\tisSelected: false,\n};\n\nconst Context = createContext( DEFAULT_BLOCK_EDIT_CONTEXT );\nconst { Provider } = Context;\n\nexport { Provider as BlockEditContextProvider };\n\n/**\n * A hook that returns the block edit context.\n *\n * @return {Object} Block edit context\n */\nexport function useBlockEditContext() {\n\treturn useContext( Context );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAQ,oBAAoB;AAE9D,OAAO,MAAMC,qBAAqB,GAAGC,MAAM,CAAE,oBAAqB,CAAC;AACnE,OAAO,MAAMC,2BAA2B,GAAGD,MAAM,CAAE,0BAA2B,CAAC;AAE/E,OAAO,MAAME,0BAA0B,GAAG;EACzCC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE;AACb,CAAC;AAED,MAAMC,OAAO,GAAGR,aAAa,CAAEK,0BAA2B,CAAC;AAC3D,MAAM;EAAEI;AAAS,CAAC,GAAGD,OAAO;AAE5B,SAASC,QAAQ,IAAIC,wBAAwB;;AAE7C;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAA,EAAG;EACrC,OAAOV,UAAU,CAAEO,OAAQ,CAAC;AAC7B"}
|
|
@@ -8,7 +8,7 @@ import { hasBlockSupport } from '@wordpress/blocks';
|
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import Edit from './edit';
|
|
11
|
-
import { BlockEditContextProvider, useBlockEditContext } from './context';
|
|
11
|
+
import { BlockEditContextProvider, useBlockEditContext, mayDisplayControlsKey, mayDisplayParentControlsKey } from './context';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The `useBlockEditContext` hook provides information about the block this hook is being used in.
|
|
@@ -19,7 +19,13 @@ import { BlockEditContextProvider, useBlockEditContext } from './context';
|
|
|
19
19
|
* @return {Object} Block edit context
|
|
20
20
|
*/
|
|
21
21
|
export { useBlockEditContext };
|
|
22
|
-
export default function BlockEdit(
|
|
22
|
+
export default function BlockEdit({
|
|
23
|
+
mayDisplayControls,
|
|
24
|
+
mayDisplayParentControls,
|
|
25
|
+
// The remaining props are passed through the BlockEdit filters and are thus
|
|
26
|
+
// public API!
|
|
27
|
+
...props
|
|
28
|
+
}) {
|
|
23
29
|
const {
|
|
24
30
|
name,
|
|
25
31
|
isSelected,
|
|
@@ -31,19 +37,22 @@ export default function BlockEdit(props) {
|
|
|
31
37
|
layout = null
|
|
32
38
|
} = attributes;
|
|
33
39
|
const layoutSupport = hasBlockSupport(name, 'layout', false) || hasBlockSupport(name, '__experimentalLayout', false);
|
|
34
|
-
const context = {
|
|
35
|
-
name,
|
|
36
|
-
isSelected,
|
|
37
|
-
clientId,
|
|
38
|
-
layout: layoutSupport ? layout : null,
|
|
39
|
-
__unstableLayoutClassNames
|
|
40
|
-
};
|
|
41
40
|
return createElement(BlockEditContextProvider
|
|
42
41
|
// It is important to return the same object if props haven't
|
|
43
42
|
// changed to avoid unnecessary rerenders.
|
|
44
43
|
// See https://reactjs.org/docs/context.html#caveats.
|
|
45
44
|
, {
|
|
46
|
-
value: useMemo(() =>
|
|
45
|
+
value: useMemo(() => ({
|
|
46
|
+
name,
|
|
47
|
+
isSelected,
|
|
48
|
+
clientId,
|
|
49
|
+
layout: layoutSupport ? layout : null,
|
|
50
|
+
__unstableLayoutClassNames,
|
|
51
|
+
// We use symbols in favour of an __unstable prefix to avoid
|
|
52
|
+
// usage outside of the package (this context is exposed).
|
|
53
|
+
[mayDisplayControlsKey]: mayDisplayControls,
|
|
54
|
+
[mayDisplayParentControlsKey]: mayDisplayParentControls
|
|
55
|
+
}), [name, isSelected, clientId, layoutSupport, layout, __unstableLayoutClassNames, mayDisplayControls, mayDisplayParentControls])
|
|
47
56
|
}, createElement(Edit, {
|
|
48
57
|
...props
|
|
49
58
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","hasBlockSupport","Edit","BlockEditContextProvider","useBlockEditContext","BlockEdit","props","name","isSelected","clientId","attributes","__unstableLayoutClassNames","layout","layoutSupport","
|
|
1
|
+
{"version":3,"names":["useMemo","hasBlockSupport","Edit","BlockEditContextProvider","useBlockEditContext","mayDisplayControlsKey","mayDisplayParentControlsKey","BlockEdit","mayDisplayControls","mayDisplayParentControls","props","name","isSelected","clientId","attributes","__unstableLayoutClassNames","layout","layoutSupport","createElement","value"],"sources":["@wordpress/block-editor/src/components/block-edit/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\nimport { hasBlockSupport } from '@wordpress/blocks';\n/**\n * Internal dependencies\n */\nimport Edit from './edit';\nimport {\n\tBlockEditContextProvider,\n\tuseBlockEditContext,\n\tmayDisplayControlsKey,\n\tmayDisplayParentControlsKey,\n} from './context';\n\n/**\n * The `useBlockEditContext` hook provides information about the block this hook is being used in.\n * It returns an object with the `name`, `isSelected` state, and the `clientId` of the block.\n * It is useful if you want to create custom hooks that need access to the current blocks clientId\n * but don't want to rely on the data getting passed in as a parameter.\n *\n * @return {Object} Block edit context\n */\nexport { useBlockEditContext };\n\nexport default function BlockEdit( {\n\tmayDisplayControls,\n\tmayDisplayParentControls,\n\t// The remaining props are passed through the BlockEdit filters and are thus\n\t// public API!\n\t...props\n} ) {\n\tconst {\n\t\tname,\n\t\tisSelected,\n\t\tclientId,\n\t\tattributes = {},\n\t\t__unstableLayoutClassNames,\n\t} = props;\n\tconst { layout = null } = attributes;\n\tconst layoutSupport =\n\t\thasBlockSupport( name, 'layout', false ) ||\n\t\thasBlockSupport( name, '__experimentalLayout', false );\n\treturn (\n\t\t<BlockEditContextProvider\n\t\t\t// It is important to return the same object if props haven't\n\t\t\t// changed to avoid unnecessary rerenders.\n\t\t\t// See https://reactjs.org/docs/context.html#caveats.\n\t\t\tvalue={ useMemo(\n\t\t\t\t() => ( {\n\t\t\t\t\tname,\n\t\t\t\t\tisSelected,\n\t\t\t\t\tclientId,\n\t\t\t\t\tlayout: layoutSupport ? layout : null,\n\t\t\t\t\t__unstableLayoutClassNames,\n\t\t\t\t\t// We use symbols in favour of an __unstable prefix to avoid\n\t\t\t\t\t// usage outside of the package (this context is exposed).\n\t\t\t\t\t[ mayDisplayControlsKey ]: mayDisplayControls,\n\t\t\t\t\t[ mayDisplayParentControlsKey ]: mayDisplayParentControls,\n\t\t\t\t} ),\n\t\t\t\t[\n\t\t\t\t\tname,\n\t\t\t\t\tisSelected,\n\t\t\t\t\tclientId,\n\t\t\t\t\tlayoutSupport,\n\t\t\t\t\tlayout,\n\t\t\t\t\t__unstableLayoutClassNames,\n\t\t\t\t\tmayDisplayControls,\n\t\t\t\t\tmayDisplayParentControls,\n\t\t\t\t]\n\t\t\t) }\n\t\t>\n\t\t\t<Edit { ...props } />\n\t\t</BlockEditContextProvider>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAE5C,SAASC,eAAe,QAAQ,mBAAmB;AACnD;AACA;AACA;AACA,OAAOC,IAAI,MAAM,QAAQ;AACzB,SACCC,wBAAwB,EACxBC,mBAAmB,EACnBC,qBAAqB,EACrBC,2BAA2B,QACrB,WAAW;;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASF,mBAAmB;AAE5B,eAAe,SAASG,SAASA,CAAE;EAClCC,kBAAkB;EAClBC,wBAAwB;EACxB;EACA;EACA,GAAGC;AACJ,CAAC,EAAG;EACH,MAAM;IACLC,IAAI;IACJC,UAAU;IACVC,QAAQ;IACRC,UAAU,GAAG,CAAC,CAAC;IACfC;EACD,CAAC,GAAGL,KAAK;EACT,MAAM;IAAEM,MAAM,GAAG;EAAK,CAAC,GAAGF,UAAU;EACpC,MAAMG,aAAa,GAClBhB,eAAe,CAAEU,IAAI,EAAE,QAAQ,EAAE,KAAM,CAAC,IACxCV,eAAe,CAAEU,IAAI,EAAE,sBAAsB,EAAE,KAAM,CAAC;EACvD,OACCO,aAAA,CAACf;EACA;EACA;EACA;EAAA;IACAgB,KAAK,EAAGnB,OAAO,CACd,OAAQ;MACPW,IAAI;MACJC,UAAU;MACVC,QAAQ;MACRG,MAAM,EAAEC,aAAa,GAAGD,MAAM,GAAG,IAAI;MACrCD,0BAA0B;MAC1B;MACA;MACA,CAAEV,qBAAqB,GAAIG,kBAAkB;MAC7C,CAAEF,2BAA2B,GAAIG;IAClC,CAAC,CAAE,EACH,CACCE,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRI,aAAa,EACbD,MAAM,EACND,0BAA0B,EAC1BP,kBAAkB,EAClBC,wBAAwB,CAE1B;EAAG,GAEHS,aAAA,CAAChB,IAAI;IAAA,GAAMQ;EAAK,CAAI,CACK,CAAC;AAE7B"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
-
import {
|
|
5
|
+
import { useEffect } from '@wordpress/element';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { store as blockEditorStore } from '../../store';
|
|
11
|
-
import {
|
|
11
|
+
import { useBlockEditContext } from '../block-edit/context';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @typedef {'disabled'|'contentOnly'|'default'} BlockEditingMode
|
|
@@ -45,10 +45,9 @@ import { BlockListBlockContext } from '../block-list/block-list-block-context';
|
|
|
45
45
|
* @return {BlockEditingMode} The current editing mode.
|
|
46
46
|
*/
|
|
47
47
|
export function useBlockEditingMode(mode) {
|
|
48
|
-
var _useContext;
|
|
49
48
|
const {
|
|
50
49
|
clientId = ''
|
|
51
|
-
} = (
|
|
50
|
+
} = useBlockEditContext();
|
|
52
51
|
const blockEditingMode = useSelect(select => select(blockEditorStore).getBlockEditingMode(clientId), [clientId]);
|
|
53
52
|
const {
|
|
54
53
|
setBlockEditingMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","useEffect","store","blockEditorStore","useBlockEditContext","useBlockEditingMode","mode","clientId","blockEditingMode","select","getBlockEditingMode","setBlockEditingMode","unsetBlockEditingMode"],"sources":["@wordpress/block-editor/src/components/block-editing-mode/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockEditContext } from '../block-edit/context';\n\n/**\n * @typedef {'disabled'|'contentOnly'|'default'} BlockEditingMode\n */\n\n/**\n * Allows a block to restrict the user interface that is displayed for editing\n * that block and its inner blocks.\n *\n * @example\n * ```js\n * function MyBlock( { attributes, setAttributes } ) {\n * useBlockEditingMode( 'disabled' );\n * return <div { ...useBlockProps() }></div>;\n * }\n * ```\n *\n * `mode` can be one of three options:\n *\n * - `'disabled'`: Prevents editing the block entirely, i.e. it cannot be\n * selected.\n * - `'contentOnly'`: Hides all non-content UI, e.g. auxiliary controls in the\n * toolbar, the block movers, block settings.\n * - `'default'`: Allows editing the block as normal.\n *\n * The mode is inherited by all of the block's inner blocks, unless they have\n * their own mode.\n *\n * If called outside of a block context, the mode is applied to all blocks.\n *\n * @param {?BlockEditingMode} mode The editing mode to apply. If undefined, the\n * current editing mode is not changed.\n *\n * @return {BlockEditingMode} The current editing mode.\n */\nexport function useBlockEditingMode( mode ) {\n\tconst { clientId = '' } = useBlockEditContext();\n\tconst blockEditingMode = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getBlockEditingMode( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\tuseEffect( () => {\n\t\tif ( mode ) {\n\t\t\tsetBlockEditingMode( clientId, mode );\n\t\t}\n\t\treturn () => {\n\t\t\tif ( mode ) {\n\t\t\t\tunsetBlockEditingMode( clientId );\n\t\t\t}\n\t\t};\n\t}, [ clientId, mode, setBlockEditingMode, unsetBlockEditingMode ] );\n\treturn blockEditingMode;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,mBAAmB,QAAQ,uBAAuB;;AAE3D;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAEC,IAAI,EAAG;EAC3C,MAAM;IAAEC,QAAQ,GAAG;EAAG,CAAC,GAAGH,mBAAmB,CAAC,CAAC;EAC/C,MAAMI,gBAAgB,GAAGT,SAAS,CAC/BU,MAAM,IACPA,MAAM,CAAEN,gBAAiB,CAAC,CAACO,mBAAmB,CAAEH,QAAS,CAAC,EAC3D,CAAEA,QAAQ,CACX,CAAC;EACD,MAAM;IAAEI,mBAAmB;IAAEC;EAAsB,CAAC,GACnDZ,WAAW,CAAEG,gBAAiB,CAAC;EAChCF,SAAS,CAAE,MAAM;IAChB,IAAKK,IAAI,EAAG;MACXK,mBAAmB,CAAEJ,QAAQ,EAAED,IAAK,CAAC;IACtC;IACA,OAAO,MAAM;MACZ,IAAKA,IAAI,EAAG;QACXM,qBAAqB,CAAEL,QAAS,CAAC;MAClC;IACD,CAAC;EACF,CAAC,EAAE,CAAEA,QAAQ,EAAED,IAAI,EAAEK,mBAAmB,EAAEC,qBAAqB,CAAG,CAAC;EACnE,OAAOJ,gBAAgB;AACxB"}
|