@wordpress/block-editor 12.0.0 → 12.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/build/autocompleters/block.js +13 -5
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +6 -3
- package/build/components/block-breadcrumb/index.js.map +1 -1
- package/build/components/block-controls/slot.js +12 -4
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-controls/slot.native.js +10 -1
- package/build/components/block-controls/slot.native.js.map +1 -1
- package/build/components/block-draggable/index.js +11 -7
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/use-scroll-when-dragging.js +2 -2
- package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
- package/build/components/block-editing-mode/index.js +84 -0
- package/build/components/block-editing-mode/index.js.map +1 -0
- package/build/components/block-list/block-invalid-warning.native.js +15 -7
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block-list-block-context.js +15 -0
- package/build/components/block-list/block-list-block-context.js.map +1 -0
- package/build/components/block-list/block-list-item-cell.native.js +15 -2
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +158 -195
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +57 -0
- package/build/components/block-list/block-outline.native.js.map +1 -0
- package/build/components/block-list/block.js +29 -37
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +347 -311
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +260 -357
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/insertion-point.native.js +4 -2
- package/build/components/block-list/insertion-point.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +2 -2
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +7 -5
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js +15 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +19 -4
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +8 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +15 -4
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/preview-panel.js +1 -2
- package/build/components/block-styles/preview-panel.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +8 -0
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/block-variation-transformations.js +125 -0
- package/build/components/block-switcher/block-variation-transformations.js.map +1 -0
- package/build/components/block-switcher/index.js +34 -12
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +3 -3
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/index.js +9 -7
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +22 -65
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +11 -5
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +3 -8
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +7 -2
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.native.js +87 -3
- package/build/components/convert-to-group-buttons/index.native.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +23 -37
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +86 -0
- package/build/components/global-styles/advanced-panel.js.map +1 -0
- package/build/components/global-styles/color-panel.js +4 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +9 -8
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +24 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +1 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +27 -4
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +30 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +14 -7
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +24 -8
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/inner-blocks/index.js +2 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +7 -7
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +13 -5
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/index.js +3 -7
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -4
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +19 -6
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +5 -0
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/fill.js +1 -1
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +1 -1
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/slot.js +3 -6
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls/slot.native.js +1 -1
- package/build/components/inspector-controls/slot.native.js.map +1 -1
- package/build/components/line-height-control/index.js +7 -2
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +9 -8
- package/build/components/link-control/use-internal-input-value.js.map +1 -1
- package/build/components/list-view/appender.js +6 -1
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/list-view/block-contents.js +9 -2
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +2 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +25 -29
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +1 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +43 -22
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +27 -3
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +163 -11
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-placeholder/index.js +68 -7
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/multi-selection-inspector/index.js +2 -2
- package/build/components/multi-selection-inspector/index.js.map +1 -1
- package/build/components/preview-options/index.js +6 -1
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +0 -2
- package/build/components/publish-date-time-picker/index.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +4 -2
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +25 -15
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +8 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +13 -7
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/align.js +4 -8
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/behaviors.js +115 -0
- package/build/hooks/behaviors.js.map +1 -0
- package/build/hooks/border.js +1 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +8 -12
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +0 -30
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +5 -9
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout.js +10 -11
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +1 -1
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +1 -1
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/use-editor-wrapper-styles.native.js +255 -0
- package/build/hooks/use-editor-wrapper-styles.native.js.map +1 -0
- package/build/hooks/use-typography-props.js +14 -10
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/index.native.js +31 -0
- package/build/index.native.js.map +1 -0
- package/build/private-apis.js +4 -7
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +46 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +88 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +36 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +28 -18
- package/build/store/selectors.js.map +1 -1
- package/build/utils/order-inserter-block-items.js +41 -0
- package/build/utils/order-inserter-block-items.js.map +1 -0
- package/build/utils/use-should-contextual-toolbar-show.js +16 -12
- package/build/utils/use-should-contextual-toolbar-show.js.map +1 -1
- package/build-module/autocompleters/block.js +12 -5
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +5 -3
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- package/build-module/components/block-controls/slot.js +11 -4
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-controls/slot.native.js +9 -1
- package/build-module/components/block-controls/slot.native.js.map +1 -1
- package/build-module/components/block-draggable/index.js +10 -6
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/use-scroll-when-dragging.js +2 -2
- package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +72 -0
- package/build-module/components/block-editing-mode/index.js.map +1 -0
- package/build-module/components/block-list/block-invalid-warning.native.js +16 -8
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block-list-block-context.js +6 -0
- package/build-module/components/block-list/block-list-block-context.js.map +1 -0
- package/build-module/components/block-list/block-list-item-cell.native.js +13 -2
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +160 -190
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +44 -0
- package/build-module/components/block-list/block-outline.native.js.map +1 -0
- package/build-module/components/block-list/block.js +26 -34
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +345 -310
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +263 -355
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/insertion-point.native.js +4 -2
- package/build-module/components/block-list/insertion-point.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -1
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +6 -5
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +15 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -4
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +8 -9
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +13 -5
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/preview-panel.js +1 -2
- package/build-module/components/block-styles/preview-panel.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +7 -0
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/block-variation-transformations.js +108 -0
- package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -0
- package/build-module/components/block-switcher/index.js +33 -12
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -3
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +8 -7
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +22 -65
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +11 -5
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +3 -7
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +7 -2
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.native.js +76 -1
- package/build-module/components/convert-to-group-buttons/index.native.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +22 -36
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +74 -0
- package/build-module/components/global-styles/advanced-panel.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +5 -2
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +9 -8
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +1 -1
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +25 -4
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +25 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +15 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +24 -8
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +2 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +7 -6
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +13 -5
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -7
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -4
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +16 -6
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +4 -0
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +1 -1
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +1 -1
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +4 -7
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls/slot.native.js +1 -1
- package/build-module/components/inspector-controls/slot.native.js.map +1 -1
- package/build-module/components/line-height-control/index.js +7 -2
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +9 -8
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
- package/build-module/components/list-view/appender.js +6 -2
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +9 -3
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +2 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +24 -29
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +44 -23
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +26 -3
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +160 -11
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +66 -7
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/multi-selection-inspector/index.js +2 -2
- package/build-module/components/multi-selection-inspector/index.js.map +1 -1
- package/build-module/components/preview-options/index.js +7 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +0 -2
- package/build-module/components/publish-date-time-picker/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +4 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +25 -16
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +8 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +13 -7
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/align.js +4 -7
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/behaviors.js +97 -0
- package/build-module/hooks/behaviors.js.map +1 -0
- package/build-module/hooks/border.js +1 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +8 -11
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +0 -28
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -7
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout.js +9 -11
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +1 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +1 -1
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/use-editor-wrapper-styles.native.js +242 -0
- package/build-module/hooks/use-editor-wrapper-styles.native.js.map +1 -0
- package/build-module/hooks/use-typography-props.js +14 -10
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/index.native.js +6 -0
- package/build-module/index.native.js.map +1 -0
- package/build-module/private-apis.js +3 -5
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +42 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +79 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +34 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +26 -17
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/order-inserter-block-items.js +32 -0
- package/build-module/utils/order-inserter-block-items.js.map +1 -0
- package/build-module/utils/use-should-contextual-toolbar-show.js +16 -12
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -1
- package/build-style/content-rtl.css +32 -14
- package/build-style/content.css +32 -14
- package/build-style/default-editor-styles-rtl.css +1 -1
- package/build-style/default-editor-styles.css +1 -1
- package/build-style/style-rtl.css +56 -77
- package/build-style/style.css +57 -77
- package/package.json +32 -31
- package/src/autocompleters/block.js +15 -7
- package/src/components/block-breadcrumb/index.js +11 -3
- package/src/components/block-breadcrumb/style.scss +2 -1
- package/src/components/block-controls/slot.js +8 -4
- package/src/components/block-controls/slot.native.js +6 -1
- package/src/components/block-draggable/index.js +10 -6
- package/src/components/block-draggable/use-scroll-when-dragging.js +8 -2
- package/src/components/block-editing-mode/index.js +71 -0
- package/src/components/block-list/block-invalid-warning.native.js +17 -9
- package/src/components/block-list/block-list-block-context.js +6 -0
- package/src/components/block-list/block-list-item-cell.native.js +10 -1
- package/src/components/block-list/block-list-item.native.js +180 -208
- package/src/components/block-list/block-outline.native.js +58 -0
- package/src/components/block-list/block.js +38 -56
- package/src/components/block-list/block.native.js +531 -501
- package/src/components/block-list/content.scss +5 -6
- package/src/components/block-list/index.native.js +324 -382
- package/src/components/block-list/insertion-point.native.js +2 -2
- package/src/components/block-list/test/block-invalid-warning.native.js +48 -0
- package/src/components/block-list/test/index.native.js +205 -0
- package/src/components/block-list/use-block-props/index.js +1 -1
- package/src/components/block-list/use-in-between-inserter.js +7 -3
- package/src/components/block-list-appender/index.js +22 -4
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +26 -1
- package/src/components/block-mover/style.scss +1 -0
- package/src/components/block-pattern-setup/style.scss +1 -4
- package/src/components/block-patterns-list/style.scss +1 -4
- package/src/components/block-settings-menu/block-settings-dropdown.js +10 -17
- package/src/components/block-settings-menu-controls/index.js +24 -4
- package/src/components/block-styles/preview-panel.js +1 -3
- package/src/components/block-styles/style.scss +4 -4
- package/src/components/block-switcher/block-transformations-menu.js +12 -0
- package/src/components/block-switcher/block-variation-transformations.js +115 -0
- package/src/components/block-switcher/index.js +38 -5
- package/src/components/block-switcher/pattern-transformations-menu.js +5 -5
- package/src/components/block-switcher/style.scss +6 -5
- package/src/components/block-toolbar/index.js +10 -11
- package/src/components/block-tools/block-contextual-toolbar.js +32 -67
- package/src/components/block-tools/insertion-point.js +23 -9
- package/src/components/block-tools/selected-block-popover.js +3 -5
- package/src/components/block-tools/style.scss +8 -0
- package/src/components/button-block-appender/content.scss +22 -0
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +16 -2
- package/src/components/convert-to-group-buttons/index.js +9 -2
- package/src/components/convert-to-group-buttons/index.native.js +79 -1
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +32 -38
- package/src/components/global-styles/advanced-panel.js +82 -0
- package/src/components/global-styles/color-panel.js +6 -1
- package/src/components/global-styles/dimensions-panel.js +9 -8
- package/src/components/global-styles/hooks.js +1 -5
- package/src/components/global-styles/index.js +6 -1
- package/src/components/global-styles/style.scss +17 -0
- package/src/components/global-styles/test/utils.js +57 -1
- package/src/components/global-styles/typography-panel.js +1 -1
- package/src/components/global-styles/use-global-styles-output.js +21 -3
- package/src/components/global-styles/utils.js +27 -0
- package/src/components/iframe/index.js +22 -12
- package/src/components/image-editor/use-save-image.js +20 -9
- package/src/components/inner-blocks/README.md +5 -0
- package/src/components/inner-blocks/index.js +2 -0
- package/src/components/inner-blocks/index.native.js +16 -6
- package/src/components/inner-blocks/use-nested-settings-update.js +20 -3
- package/src/components/inserter/index.js +1 -9
- package/src/components/inserter/quick-inserter.js +0 -2
- package/src/components/inserter/search-results.js +32 -6
- package/src/components/inserter-draggable-blocks/index.js +4 -0
- package/src/components/inspector-controls/fill.js +1 -1
- package/src/components/inspector-controls/fill.native.js +1 -1
- package/src/components/inspector-controls/slot.js +4 -9
- package/src/components/inspector-controls/slot.native.js +1 -1
- package/src/components/line-height-control/index.js +7 -2
- package/src/components/line-height-control/stories/index.js +1 -1
- package/src/components/link-control/test/index.js +42 -0
- package/src/components/link-control/use-internal-input-value.js +8 -7
- package/src/components/list-view/appender.js +3 -2
- package/src/components/list-view/block-contents.js +32 -20
- package/src/components/list-view/block-select-button.js +5 -1
- package/src/components/list-view/block.js +34 -37
- package/src/components/list-view/branch.js +1 -7
- package/src/components/list-view/index.js +42 -17
- package/src/components/list-view/style.scss +7 -7
- package/src/components/list-view/test/use-list-view-drop-zone.js +88 -12
- package/src/components/list-view/use-list-view-client-ids.js +21 -4
- package/src/components/list-view/use-list-view-drop-zone.js +194 -11
- package/src/components/media-placeholder/index.js +74 -1
- package/src/components/multi-selection-inspector/index.js +2 -2
- package/src/components/preview-options/index.js +9 -2
- package/src/components/publish-date-time-picker/index.js +0 -2
- package/src/components/spacing-sizes-control/spacing-input-control.js +1 -0
- package/src/components/url-input/README.md +6 -0
- package/src/components/url-input/index.js +2 -2
- package/src/components/use-block-drop-zone/index.js +31 -17
- package/src/components/use-resize-canvas/index.js +9 -1
- package/src/components/writing-flow/test/index.js +15 -0
- package/src/components/writing-flow/use-arrow-nav.js +17 -4
- package/src/hooks/align.js +5 -12
- package/src/hooks/behaviors.js +104 -0
- package/src/hooks/border.js +2 -1
- package/src/hooks/color.js +2 -1
- package/src/hooks/content-lock-ui.js +3 -15
- package/src/hooks/dimensions.js +0 -40
- package/src/hooks/duotone.js +4 -11
- package/src/hooks/index.js +1 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.js +14 -20
- package/src/hooks/position.js +2 -1
- package/src/hooks/style.js +2 -1
- package/src/hooks/test/use-editor-wrapper-styles.native.js +282 -0
- package/src/hooks/test/use-typography-props.js +47 -2
- package/src/hooks/use-editor-wrapper-styles.native.js +250 -0
- package/src/hooks/use-editor-wrapper-styles.native.scss +11 -0
- package/src/hooks/use-typography-props.js +10 -11
- package/src/index.native.js +6 -0
- package/src/private-apis.js +2 -4
- package/src/store/private-actions.js +39 -0
- package/src/store/private-selectors.js +95 -0
- package/src/store/reducer.js +27 -0
- package/src/store/selectors.js +25 -15
- package/src/store/test/private-actions.js +32 -1
- package/src/store/test/private-selectors.js +158 -0
- package/src/store/test/reducer.js +48 -0
- package/src/style.scss +0 -3
- package/src/utils/order-inserter-block-items.js +26 -0
- package/src/utils/use-should-contextual-toolbar-show.js +19 -9
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-list/block-list-compact.native.js +0 -75
- package/build/components/block-list/block-list-compact.native.js.map +0 -1
- package/build/components/off-canvas-editor/appender.js +0 -125
- package/build/components/off-canvas-editor/appender.js.map +0 -1
- package/build/components/off-canvas-editor/block-contents.js +0 -141
- package/build/components/off-canvas-editor/block-contents.js.map +0 -1
- package/build/components/off-canvas-editor/block-select-button.js +0 -126
- package/build/components/off-canvas-editor/block-select-button.js.map +0 -1
- package/build/components/off-canvas-editor/block.js +0 -297
- package/build/components/off-canvas-editor/block.js.map +0 -1
- package/build/components/off-canvas-editor/branch.js +0 -197
- package/build/components/off-canvas-editor/branch.js.map +0 -1
- package/build/components/off-canvas-editor/context.js +0 -19
- package/build/components/off-canvas-editor/context.js.map +0 -1
- package/build/components/off-canvas-editor/drop-indicator.js +0 -118
- package/build/components/off-canvas-editor/drop-indicator.js.map +0 -1
- package/build/components/off-canvas-editor/expander.js +0 -41
- package/build/components/off-canvas-editor/expander.js.map +0 -1
- package/build/components/off-canvas-editor/index.js +0 -236
- package/build/components/off-canvas-editor/index.js.map +0 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +0 -146
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
- package/build/components/off-canvas-editor/leaf.js +0 -60
- package/build/components/off-canvas-editor/leaf.js.map +0 -1
- package/build/components/off-canvas-editor/link-ui.js +0 -186
- package/build/components/off-canvas-editor/link-ui.js.map +0 -1
- package/build/components/off-canvas-editor/update-attributes.js +0 -108
- package/build/components/off-canvas-editor/update-attributes.js.map +0 -1
- package/build/components/off-canvas-editor/use-block-selection.js +0 -139
- package/build/components/off-canvas-editor/use-block-selection.js.map +0 -1
- package/build/components/off-canvas-editor/use-inserted-block.js +0 -58
- package/build/components/off-canvas-editor/use-inserted-block.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +0 -33
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +0 -235
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -60
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
- package/build/components/off-canvas-editor/utils.js +0 -60
- package/build/components/off-canvas-editor/utils.js.map +0 -1
- package/build-module/components/block-list/block-list-compact.native.js +0 -60
- package/build-module/components/block-list/block-list-compact.native.js.map +0 -1
- package/build-module/components/off-canvas-editor/appender.js +0 -108
- package/build-module/components/off-canvas-editor/appender.js.map +0 -1
- package/build-module/components/off-canvas-editor/block-contents.js +0 -121
- package/build-module/components/off-canvas-editor/block-contents.js.map +0 -1
- package/build-module/components/off-canvas-editor/block-select-button.js +0 -107
- package/build-module/components/off-canvas-editor/block-select-button.js.map +0 -1
- package/build-module/components/off-canvas-editor/block.js +0 -273
- package/build-module/components/off-canvas-editor/block.js.map +0 -1
- package/build-module/components/off-canvas-editor/branch.js +0 -179
- package/build-module/components/off-canvas-editor/branch.js.map +0 -1
- package/build-module/components/off-canvas-editor/context.js +0 -7
- package/build-module/components/off-canvas-editor/context.js.map +0 -1
- package/build-module/components/off-canvas-editor/drop-indicator.js +0 -111
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +0 -1
- package/build-module/components/off-canvas-editor/expander.js +0 -32
- package/build-module/components/off-canvas-editor/expander.js.map +0 -1
- package/build-module/components/off-canvas-editor/index.js +0 -213
- package/build-module/components/off-canvas-editor/index.js.map +0 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +0 -128
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
- package/build-module/components/off-canvas-editor/leaf.js +0 -45
- package/build-module/components/off-canvas-editor/leaf.js.map +0 -1
- package/build-module/components/off-canvas-editor/link-ui.js +0 -166
- package/build-module/components/off-canvas-editor/link-ui.js.map +0 -1
- package/build-module/components/off-canvas-editor/update-attributes.js +0 -97
- package/build-module/components/off-canvas-editor/update-attributes.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-block-selection.js +0 -124
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-inserted-block.js +0 -47
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +0 -24
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +0 -220
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -50
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
- package/build-module/components/off-canvas-editor/utils.js +0 -44
- package/build-module/components/off-canvas-editor/utils.js.map +0 -1
- package/src/components/block-list/block-list-compact.native.js +0 -63
- package/src/components/off-canvas-editor/README.md +0 -5
- package/src/components/off-canvas-editor/appender.js +0 -124
- package/src/components/off-canvas-editor/block-contents.js +0 -156
- package/src/components/off-canvas-editor/block-select-button.js +0 -128
- package/src/components/off-canvas-editor/block.js +0 -347
- package/src/components/off-canvas-editor/branch.js +0 -238
- package/src/components/off-canvas-editor/context.js +0 -8
- package/src/components/off-canvas-editor/drop-indicator.js +0 -126
- package/src/components/off-canvas-editor/expander.js +0 -26
- package/src/components/off-canvas-editor/index.js +0 -271
- package/src/components/off-canvas-editor/leaf-more-menu.js +0 -157
- package/src/components/off-canvas-editor/leaf.js +0 -52
- package/src/components/off-canvas-editor/link-ui.js +0 -167
- package/src/components/off-canvas-editor/style.scss +0 -34
- package/src/components/off-canvas-editor/test/use-inserted-block.js +0 -108
- package/src/components/off-canvas-editor/test/utils.js +0 -50
- package/src/components/off-canvas-editor/update-attributes.js +0 -99
- package/src/components/off-canvas-editor/use-block-selection.js +0 -169
- package/src/components/off-canvas-editor/use-inserted-block.js +0 -47
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +0 -29
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +0 -260
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -58
- package/src/components/off-canvas-editor/utils.js +0 -58
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { Pressable, useWindowDimensions, View } from 'react-native';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { useCallback, useMemo, useRef, useState } from '@wordpress/element';
|
|
10
10
|
import {
|
|
11
11
|
GlobalStylesContext,
|
|
12
12
|
getMergedGlobalStyles,
|
|
@@ -14,51 +14,254 @@ import {
|
|
|
14
14
|
alignmentHelpers,
|
|
15
15
|
useGlobalStyles,
|
|
16
16
|
} from '@wordpress/components';
|
|
17
|
-
import { withDispatch, withSelect } from '@wordpress/data';
|
|
18
|
-
import { compose, withPreferredColorScheme } from '@wordpress/compose';
|
|
19
17
|
import {
|
|
20
|
-
getBlockType,
|
|
21
18
|
__experimentalGetAccessibleBlockLabel as getAccessibleBlockLabel,
|
|
22
|
-
|
|
19
|
+
getBlockType,
|
|
23
20
|
getDefaultBlockName,
|
|
24
21
|
isUnmodifiedBlock,
|
|
22
|
+
isUnmodifiedDefaultBlock,
|
|
23
|
+
switchToBlockType,
|
|
25
24
|
} from '@wordpress/blocks';
|
|
26
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
useDispatch,
|
|
27
|
+
useSelect,
|
|
28
|
+
withDispatch,
|
|
29
|
+
withSelect,
|
|
30
|
+
} from '@wordpress/data';
|
|
31
|
+
import { compose, ifCondition, pure } from '@wordpress/compose';
|
|
27
32
|
|
|
28
33
|
/**
|
|
29
34
|
* Internal dependencies
|
|
30
35
|
*/
|
|
31
|
-
import styles from './block.scss';
|
|
32
36
|
import BlockEdit from '../block-edit';
|
|
37
|
+
import BlockDraggable from '../block-draggable';
|
|
33
38
|
import BlockInvalidWarning from './block-invalid-warning';
|
|
34
39
|
import BlockMobileToolbar from '../block-mobile-toolbar';
|
|
40
|
+
import BlockOutline from './block-outline';
|
|
41
|
+
import styles from './block.scss';
|
|
35
42
|
import { store as blockEditorStore } from '../../store';
|
|
36
|
-
import BlockDraggable from '../block-draggable';
|
|
37
43
|
import { useLayout } from './layout';
|
|
44
|
+
import useSetting from '../use-setting';
|
|
38
45
|
|
|
39
46
|
const emptyArray = [];
|
|
40
|
-
|
|
47
|
+
|
|
48
|
+
// Helper function to memoize the wrapperProps since getEditWrapperProps always returns a new reference.
|
|
49
|
+
const wrapperPropsCache = new WeakMap();
|
|
50
|
+
const emptyObj = {};
|
|
51
|
+
function getWrapperProps( value, getWrapperPropsFunction ) {
|
|
52
|
+
if ( ! getWrapperPropsFunction ) {
|
|
53
|
+
return emptyObj;
|
|
54
|
+
}
|
|
55
|
+
const cachedValue = wrapperPropsCache.get( value );
|
|
56
|
+
if ( ! cachedValue ) {
|
|
57
|
+
const wrapperProps = getWrapperPropsFunction( value );
|
|
58
|
+
wrapperPropsCache.set( value, wrapperProps );
|
|
59
|
+
return wrapperProps;
|
|
60
|
+
}
|
|
61
|
+
return cachedValue;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function BlockWrapper( {
|
|
65
|
+
accessibilityLabel,
|
|
66
|
+
align,
|
|
67
|
+
blockWidth,
|
|
68
|
+
children,
|
|
69
|
+
clientId,
|
|
70
|
+
draggingClientId,
|
|
71
|
+
draggingEnabled,
|
|
72
|
+
isDescendentBlockSelected,
|
|
73
|
+
isParentSelected,
|
|
74
|
+
isSelected,
|
|
75
|
+
isStackedHorizontally,
|
|
76
|
+
isTouchable,
|
|
77
|
+
marginHorizontal,
|
|
78
|
+
marginVertical,
|
|
79
|
+
onDeleteBlock,
|
|
80
|
+
onFocus,
|
|
81
|
+
} ) {
|
|
82
|
+
const { width: screenWidth } = useWindowDimensions();
|
|
83
|
+
const anchorNodeRef = useRef();
|
|
84
|
+
const { isFullWidth } = alignmentHelpers;
|
|
85
|
+
const isScreenWidthEqual = blockWidth === screenWidth;
|
|
86
|
+
const isFullWidthToolbar = isFullWidth( align ) || isScreenWidthEqual;
|
|
87
|
+
const blockWrapperStyles = { flex: 1 };
|
|
88
|
+
const blockWrapperStyle = [
|
|
89
|
+
blockWrapperStyles,
|
|
90
|
+
{
|
|
91
|
+
marginVertical,
|
|
92
|
+
marginHorizontal,
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
const accessible = ! ( isSelected || isDescendentBlockSelected );
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Pressable
|
|
99
|
+
accessibilityLabel={ accessibilityLabel }
|
|
100
|
+
accessibilityRole="button"
|
|
101
|
+
accessible={ accessible }
|
|
102
|
+
disabled={ ! isTouchable }
|
|
103
|
+
onPress={ onFocus }
|
|
104
|
+
style={ blockWrapperStyle }
|
|
105
|
+
>
|
|
106
|
+
<BlockOutline
|
|
107
|
+
isSelected={ isSelected }
|
|
108
|
+
isParentSelected={ isParentSelected }
|
|
109
|
+
screenWidth={ screenWidth }
|
|
110
|
+
/>
|
|
111
|
+
<BlockDraggable
|
|
112
|
+
clientId={ clientId }
|
|
113
|
+
draggingClientId={ draggingClientId }
|
|
114
|
+
enabled={ draggingEnabled }
|
|
115
|
+
testID="draggable-trigger-content"
|
|
116
|
+
>
|
|
117
|
+
{ children }
|
|
118
|
+
</BlockDraggable>
|
|
119
|
+
<View style={ styles.neutralToolbar } ref={ anchorNodeRef }>
|
|
120
|
+
{ isSelected && (
|
|
121
|
+
<BlockMobileToolbar
|
|
122
|
+
anchorNodeRef={ anchorNodeRef.current }
|
|
123
|
+
blockWidth={ blockWidth }
|
|
124
|
+
clientId={ clientId }
|
|
125
|
+
draggingClientId={ draggingClientId }
|
|
126
|
+
isFullWidth={ isFullWidthToolbar }
|
|
127
|
+
isStackedHorizontally={ isStackedHorizontally }
|
|
128
|
+
onDelete={ onDeleteBlock }
|
|
129
|
+
/>
|
|
130
|
+
) }
|
|
131
|
+
</View>
|
|
132
|
+
</Pressable>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function BlockListBlock( {
|
|
41
137
|
attributes,
|
|
138
|
+
blockWidth: blockWrapperWidth,
|
|
139
|
+
canRemove,
|
|
42
140
|
clientId,
|
|
43
141
|
contentStyle,
|
|
44
|
-
|
|
45
|
-
insertBlocksAfter,
|
|
142
|
+
isLocked,
|
|
46
143
|
isSelected,
|
|
47
|
-
|
|
144
|
+
isSelectionEnabled,
|
|
145
|
+
isStackedHorizontally,
|
|
146
|
+
isValid,
|
|
147
|
+
marginHorizontal,
|
|
148
|
+
marginVertical,
|
|
48
149
|
name,
|
|
49
|
-
onBlockFocus,
|
|
50
|
-
onChange,
|
|
51
150
|
onDeleteBlock,
|
|
151
|
+
onInsertBlocksAfter,
|
|
152
|
+
onMerge,
|
|
52
153
|
onReplace,
|
|
53
|
-
parentWidth,
|
|
54
154
|
parentBlockAlignment,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
155
|
+
parentWidth,
|
|
156
|
+
rootClientId,
|
|
157
|
+
setAttributes,
|
|
158
|
+
toggleSelection,
|
|
58
159
|
} ) {
|
|
160
|
+
const {
|
|
161
|
+
baseGlobalStyles,
|
|
162
|
+
blockType,
|
|
163
|
+
draggingClientId,
|
|
164
|
+
draggingEnabled,
|
|
165
|
+
isDescendantOfParentSelected,
|
|
166
|
+
isDescendentBlockSelected,
|
|
167
|
+
isParentSelected,
|
|
168
|
+
order,
|
|
169
|
+
} = useSelect(
|
|
170
|
+
( select ) => {
|
|
171
|
+
const {
|
|
172
|
+
getBlockCount,
|
|
173
|
+
getBlockHierarchyRootClientId,
|
|
174
|
+
getBlockIndex,
|
|
175
|
+
getBlockParents,
|
|
176
|
+
getSelectedBlockClientId,
|
|
177
|
+
getSettings,
|
|
178
|
+
hasSelectedInnerBlock,
|
|
179
|
+
} = select( blockEditorStore );
|
|
180
|
+
const currentBlockType = getBlockType( name || 'core/missing' );
|
|
181
|
+
const blockOrder = getBlockIndex( clientId );
|
|
182
|
+
const descendentBlockSelected = hasSelectedInnerBlock(
|
|
183
|
+
clientId,
|
|
184
|
+
true
|
|
185
|
+
);
|
|
186
|
+
const selectedBlockClientId = getSelectedBlockClientId();
|
|
187
|
+
|
|
188
|
+
const parents = getBlockParents( clientId, true );
|
|
189
|
+
const parentSelected =
|
|
190
|
+
// Set false as a default value to prevent re-render when it's changed from null to false.
|
|
191
|
+
( selectedBlockClientId || false ) &&
|
|
192
|
+
selectedBlockClientId === rootClientId;
|
|
193
|
+
|
|
194
|
+
const selectedParents = clientId ? parents : [];
|
|
195
|
+
const descendantOfParentSelected =
|
|
196
|
+
selectedParents.includes( rootClientId );
|
|
197
|
+
const hasInnerBlocks = getBlockCount( clientId ) > 0;
|
|
198
|
+
|
|
199
|
+
// For blocks with inner blocks, we only enable the dragging in the nested
|
|
200
|
+
// blocks if any of them are selected. This way we prevent the long-press
|
|
201
|
+
// gesture from being disabled for elements within the block UI.
|
|
202
|
+
const isDraggingEnabled =
|
|
203
|
+
! hasInnerBlocks || isSelected || ! descendentBlockSelected;
|
|
204
|
+
// Dragging nested blocks is not supported yet. For this reason, the block to be dragged
|
|
205
|
+
// will be the top in the hierarchy.
|
|
206
|
+
const currentDraggingClientId =
|
|
207
|
+
getBlockHierarchyRootClientId( clientId );
|
|
208
|
+
|
|
209
|
+
const globalStylesBaseStyles =
|
|
210
|
+
getSettings()?.__experimentalGlobalStylesBaseStyles;
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
baseGlobalStyles: globalStylesBaseStyles,
|
|
214
|
+
blockType: currentBlockType,
|
|
215
|
+
draggingClientId: currentDraggingClientId,
|
|
216
|
+
draggingEnabled: isDraggingEnabled,
|
|
217
|
+
isDescendantOfParentSelected: descendantOfParentSelected,
|
|
218
|
+
isDescendentBlockSelected: descendentBlockSelected,
|
|
219
|
+
isParentSelected: parentSelected,
|
|
220
|
+
order: blockOrder,
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
[ clientId, isSelected, name, rootClientId ]
|
|
224
|
+
);
|
|
225
|
+
const { removeBlock, selectBlock } = useDispatch( blockEditorStore );
|
|
226
|
+
const initialBlockWidth = blockWrapperWidth - 2 * marginHorizontal;
|
|
227
|
+
const [ blockWidth, setBlockWidth ] = useState( initialBlockWidth );
|
|
228
|
+
const parentLayout = useLayout() || {};
|
|
59
229
|
const defaultColors = useMobileGlobalStylesColors();
|
|
60
|
-
const fontSizes = useSetting( 'typography.fontSizes' ) || emptyArray;
|
|
61
230
|
const globalStyle = useGlobalStyles();
|
|
231
|
+
const fontSizes = useSetting( 'typography.fontSizes' ) || emptyArray;
|
|
232
|
+
|
|
233
|
+
const onRemove = useCallback(
|
|
234
|
+
() => removeBlock( clientId ),
|
|
235
|
+
[ clientId, removeBlock ]
|
|
236
|
+
);
|
|
237
|
+
const onFocus = useCallback( () => {
|
|
238
|
+
if ( ! isSelected ) {
|
|
239
|
+
selectBlock( clientId );
|
|
240
|
+
}
|
|
241
|
+
}, [ selectBlock, clientId, isSelected ] );
|
|
242
|
+
|
|
243
|
+
const onLayout = useCallback(
|
|
244
|
+
( { nativeEvent } ) => {
|
|
245
|
+
const layoutWidth = Math.floor( nativeEvent.layout.width );
|
|
246
|
+
|
|
247
|
+
if ( ! blockWidth || ! layoutWidth ) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if ( blockWidth !== layoutWidth ) {
|
|
252
|
+
setBlockWidth( layoutWidth );
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
[ blockWidth, setBlockWidth ]
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
// Block level styles.
|
|
259
|
+
const wrapperProps = getWrapperProps(
|
|
260
|
+
attributes,
|
|
261
|
+
blockType.getEditWrapperProps
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
// Inherited styles merged with block level styles.
|
|
62
265
|
const mergedStyle = useMemo( () => {
|
|
63
266
|
return getMergedGlobalStyles(
|
|
64
267
|
baseGlobalStyles,
|
|
@@ -69,12 +272,20 @@ function BlockForType( {
|
|
|
69
272
|
name,
|
|
70
273
|
fontSizes
|
|
71
274
|
);
|
|
275
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
276
|
}, [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
//
|
|
277
|
+
// It is crucial to keep the dependencies array minimal to prevent unnecessary calls that could negatively impact performance.
|
|
278
|
+
// JSON.stringify is used for the following purposes:
|
|
279
|
+
// 1. To create a single, comparable value from the globalStyle, wrapperProps.style, and attributes objects. This allows useMemo to
|
|
280
|
+
// efficiently determine if a change has occurred in any of these objects.
|
|
281
|
+
// 2. To filter the attributes object, ensuring that only the relevant attributes (included in
|
|
282
|
+
// GlobalStylesContext.BLOCK_STYLE_ATTRIBUTES) are considered as dependencies. This reduces the likelihood of
|
|
283
|
+
// unnecessary useMemo calls when other, unrelated attributes change.
|
|
284
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
285
|
+
JSON.stringify( globalStyle ),
|
|
286
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
287
|
JSON.stringify( wrapperProps.style ),
|
|
288
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
289
|
JSON.stringify(
|
|
79
290
|
Object.fromEntries(
|
|
80
291
|
Object.entries( attributes ?? {} ).filter( ( [ key ] ) =>
|
|
@@ -84,386 +295,193 @@ function BlockForType( {
|
|
|
84
295
|
),
|
|
85
296
|
] );
|
|
86
297
|
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
mergeBlocks={ onMerge }
|
|
100
|
-
// Block level styles.
|
|
101
|
-
wrapperProps={ wrapperProps }
|
|
102
|
-
// Inherited styles merged with block level styles.
|
|
103
|
-
style={ mergedStyle }
|
|
104
|
-
clientId={ clientId }
|
|
105
|
-
parentWidth={ parentWidth }
|
|
106
|
-
contentStyle={ contentStyle }
|
|
107
|
-
onDeleteBlock={ onDeleteBlock }
|
|
108
|
-
blockWidth={ blockWidth }
|
|
109
|
-
parentBlockAlignment={ parentBlockAlignment }
|
|
110
|
-
__unstableParentLayout={ parentLayout }
|
|
111
|
-
/>
|
|
112
|
-
<View onLayout={ getBlockWidth } />
|
|
113
|
-
</GlobalStylesContext.Provider>
|
|
298
|
+
const { align } = attributes;
|
|
299
|
+
const isFocused = isSelected || isDescendentBlockSelected;
|
|
300
|
+
const isTouchable =
|
|
301
|
+
isSelected ||
|
|
302
|
+
isDescendantOfParentSelected ||
|
|
303
|
+
isParentSelected ||
|
|
304
|
+
! rootClientId;
|
|
305
|
+
|
|
306
|
+
const accessibilityLabel = getAccessibleBlockLabel(
|
|
307
|
+
blockType,
|
|
308
|
+
attributes,
|
|
309
|
+
order + 1
|
|
114
310
|
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
class BlockListBlock extends Component {
|
|
118
|
-
constructor() {
|
|
119
|
-
super( ...arguments );
|
|
120
|
-
|
|
121
|
-
this.insertBlocksAfter = this.insertBlocksAfter.bind( this );
|
|
122
|
-
this.onFocus = this.onFocus.bind( this );
|
|
123
|
-
this.getBlockWidth = this.getBlockWidth.bind( this );
|
|
124
|
-
|
|
125
|
-
this.state = {
|
|
126
|
-
blockWidth: this.props.blockWidth - 2 * this.props.marginHorizontal,
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
this.anchorNodeRef = createRef();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
onFocus() {
|
|
133
|
-
const { firstToSelectId, isSelected, onSelect } = this.props;
|
|
134
|
-
if ( ! isSelected ) {
|
|
135
|
-
onSelect( firstToSelectId );
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
insertBlocksAfter( blocks ) {
|
|
140
|
-
this.props.onInsertBlocks( blocks, this.props.order + 1 );
|
|
141
|
-
|
|
142
|
-
if ( blocks[ 0 ] ) {
|
|
143
|
-
// Focus on the first block inserted.
|
|
144
|
-
this.props.onSelect( blocks[ 0 ].clientId );
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
getBlockWidth( { nativeEvent } ) {
|
|
149
|
-
const { layout } = nativeEvent;
|
|
150
|
-
const { blockWidth } = this.state;
|
|
151
|
-
const layoutWidth = Math.floor( layout.width );
|
|
152
|
-
|
|
153
|
-
if ( ! blockWidth || ! layoutWidth ) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
311
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const {
|
|
185
|
-
attributes,
|
|
186
|
-
blockType,
|
|
187
|
-
clientId,
|
|
188
|
-
icon,
|
|
189
|
-
isSelected,
|
|
190
|
-
isValid,
|
|
191
|
-
order,
|
|
192
|
-
title,
|
|
193
|
-
isDimmed,
|
|
194
|
-
isTouchable,
|
|
195
|
-
onDeleteBlock,
|
|
196
|
-
isStackedHorizontally,
|
|
197
|
-
isParentSelected,
|
|
198
|
-
getStylesFromColorScheme,
|
|
199
|
-
marginVertical,
|
|
200
|
-
marginHorizontal,
|
|
201
|
-
isInnerBlockSelected,
|
|
202
|
-
name,
|
|
203
|
-
draggingEnabled,
|
|
204
|
-
draggingClientId,
|
|
205
|
-
} = this.props;
|
|
206
|
-
|
|
207
|
-
if ( ! attributes || ! blockType ) {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
const { blockWidth } = this.state;
|
|
211
|
-
const { align } = attributes;
|
|
212
|
-
const accessibilityLabel = getAccessibleBlockLabel(
|
|
213
|
-
blockType,
|
|
214
|
-
attributes,
|
|
215
|
-
order + 1
|
|
216
|
-
);
|
|
217
|
-
const { isFullWidth, isContainerRelated } = alignmentHelpers;
|
|
218
|
-
const accessible = ! ( isSelected || isInnerBlockSelected );
|
|
219
|
-
const screenWidth = Math.floor( Dimensions.get( 'window' ).width );
|
|
220
|
-
const isScreenWidthEqual = blockWidth === screenWidth;
|
|
221
|
-
const isScreenWidthWider = blockWidth < screenWidth;
|
|
222
|
-
const isFullWidthToolbar = isFullWidth( align ) || isScreenWidthEqual;
|
|
223
|
-
|
|
224
|
-
return (
|
|
225
|
-
<TouchableWithoutFeedback
|
|
226
|
-
onPress={ this.onFocus }
|
|
227
|
-
accessible={ accessible }
|
|
228
|
-
accessibilityRole={ 'button' }
|
|
229
|
-
>
|
|
230
|
-
<View
|
|
231
|
-
style={ { flex: 1 } }
|
|
232
|
-
accessibilityLabel={ accessibilityLabel }
|
|
233
|
-
>
|
|
234
|
-
<View
|
|
235
|
-
pointerEvents={ isTouchable ? 'auto' : 'box-only' }
|
|
236
|
-
accessibilityLabel={ accessibilityLabel }
|
|
237
|
-
style={ [
|
|
238
|
-
{ marginVertical, marginHorizontal, flex: 1 },
|
|
239
|
-
isDimmed && styles.dimmed,
|
|
240
|
-
] }
|
|
241
|
-
>
|
|
242
|
-
{ isSelected && (
|
|
243
|
-
<View
|
|
244
|
-
pointerEvents="box-none"
|
|
245
|
-
style={ [
|
|
246
|
-
styles.solidBorder,
|
|
247
|
-
isFullWidth( align ) &&
|
|
248
|
-
isScreenWidthWider &&
|
|
249
|
-
styles.borderFullWidth,
|
|
250
|
-
isFullWidth( align ) &&
|
|
251
|
-
isContainerRelated( name ) &&
|
|
252
|
-
isScreenWidthWider &&
|
|
253
|
-
styles.containerBorderFullWidth,
|
|
254
|
-
getStylesFromColorScheme(
|
|
255
|
-
styles.solidBorderColor,
|
|
256
|
-
styles.solidBorderColorDark
|
|
257
|
-
),
|
|
258
|
-
] }
|
|
259
|
-
/>
|
|
260
|
-
) }
|
|
261
|
-
{ isParentSelected && (
|
|
262
|
-
<View
|
|
263
|
-
style={ [
|
|
264
|
-
styles.dashedBorder,
|
|
265
|
-
getStylesFromColorScheme(
|
|
266
|
-
styles.dashedBorderColor,
|
|
267
|
-
styles.dashedBorderColorDark
|
|
268
|
-
),
|
|
269
|
-
] }
|
|
270
|
-
/>
|
|
271
|
-
) }
|
|
272
|
-
<BlockDraggable
|
|
312
|
+
return (
|
|
313
|
+
<BlockWrapper
|
|
314
|
+
accessibilityLabel={ accessibilityLabel }
|
|
315
|
+
align={ align }
|
|
316
|
+
blockWidth={ blockWidth }
|
|
317
|
+
clientId={ clientId }
|
|
318
|
+
draggingClientId={ draggingClientId }
|
|
319
|
+
draggingEnabled={ draggingEnabled }
|
|
320
|
+
isFocused={ isFocused }
|
|
321
|
+
isDescendentBlockSelected={ isDescendentBlockSelected }
|
|
322
|
+
isParentSelected={ isParentSelected }
|
|
323
|
+
isSelected={ isSelected }
|
|
324
|
+
isStackedHorizontally={ isStackedHorizontally }
|
|
325
|
+
isTouchable={ isTouchable }
|
|
326
|
+
marginHorizontal={ marginHorizontal }
|
|
327
|
+
marginVertical={ marginVertical }
|
|
328
|
+
onDeleteBlock={ onDeleteBlock }
|
|
329
|
+
onFocus={ onFocus }
|
|
330
|
+
>
|
|
331
|
+
{ () =>
|
|
332
|
+
! isValid ? (
|
|
333
|
+
<BlockInvalidWarning clientId={ clientId } />
|
|
334
|
+
) : (
|
|
335
|
+
<GlobalStylesContext.Provider value={ mergedStyle }>
|
|
336
|
+
<BlockEdit
|
|
337
|
+
attributes={ attributes }
|
|
338
|
+
blockWidth={ blockWidth }
|
|
273
339
|
clientId={ clientId }
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
>
|
|
278
|
-
{ () =>
|
|
279
|
-
isValid ? (
|
|
280
|
-
this.getBlockForType()
|
|
281
|
-
) : (
|
|
282
|
-
<BlockInvalidWarning
|
|
283
|
-
blockTitle={ title }
|
|
284
|
-
icon={ icon }
|
|
285
|
-
clientId={ clientId }
|
|
286
|
-
/>
|
|
287
|
-
)
|
|
340
|
+
contentStyle={ contentStyle }
|
|
341
|
+
insertBlocksAfter={
|
|
342
|
+
isLocked ? undefined : onInsertBlocksAfter
|
|
288
343
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
{
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
// Helper function to memoize the wrapperProps since getEditWrapperProps always returns a new reference.
|
|
316
|
-
const wrapperPropsCache = new WeakMap();
|
|
317
|
-
const emptyObj = {};
|
|
318
|
-
function getWrapperProps( value, getWrapperPropsFunction ) {
|
|
319
|
-
if ( ! getWrapperPropsFunction ) {
|
|
320
|
-
return emptyObj;
|
|
321
|
-
}
|
|
322
|
-
const cachedValue = wrapperPropsCache.get( value );
|
|
323
|
-
if ( ! cachedValue ) {
|
|
324
|
-
const wrapperProps = getWrapperPropsFunction( value );
|
|
325
|
-
wrapperPropsCache.set( value, wrapperProps );
|
|
326
|
-
return wrapperProps;
|
|
327
|
-
}
|
|
328
|
-
return cachedValue;
|
|
344
|
+
isSelected={ isSelected }
|
|
345
|
+
isSelectionEnabled={ isSelectionEnabled }
|
|
346
|
+
mergeBlocks={ canRemove ? onMerge : undefined }
|
|
347
|
+
name={ name }
|
|
348
|
+
onFocus={ onFocus }
|
|
349
|
+
onRemove={ canRemove ? onRemove : undefined }
|
|
350
|
+
onReplace={ canRemove ? onReplace : undefined }
|
|
351
|
+
parentBlockAlignment={ parentBlockAlignment }
|
|
352
|
+
parentWidth={ parentWidth }
|
|
353
|
+
setAttributes={ setAttributes }
|
|
354
|
+
style={ mergedStyle }
|
|
355
|
+
toggleSelection={ toggleSelection }
|
|
356
|
+
__unstableParentLayout={
|
|
357
|
+
Object.keys( parentLayout ).length
|
|
358
|
+
? parentLayout
|
|
359
|
+
: undefined
|
|
360
|
+
}
|
|
361
|
+
wrapperProps={ wrapperProps }
|
|
362
|
+
/>
|
|
363
|
+
<View onLayout={ onLayout } />
|
|
364
|
+
</GlobalStylesContext.Provider>
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
</BlockWrapper>
|
|
368
|
+
);
|
|
329
369
|
}
|
|
330
370
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Moves the block with clientId up one level. If the block type
|
|
448
|
-
* cannot be inserted at the new location, it will be attempted to
|
|
449
|
-
* convert to the default block type.
|
|
450
|
-
*
|
|
451
|
-
* @param {string} _clientId The block to move.
|
|
452
|
-
* @param {boolean} changeSelection Whether to change the selection
|
|
453
|
-
* to the moved block.
|
|
454
|
-
*/
|
|
455
|
-
function moveFirstItemUp( _clientId, changeSelection = true ) {
|
|
456
|
-
const targetRootClientId =
|
|
457
|
-
getBlockRootClientId( _clientId );
|
|
458
|
-
const blockOrder = getBlockOrder( _clientId );
|
|
459
|
-
const [ firstClientId ] = blockOrder;
|
|
460
|
-
|
|
461
|
-
if (
|
|
462
|
-
blockOrder.length === 1 &&
|
|
463
|
-
isUnmodifiedBlock( getBlock( firstClientId ) )
|
|
464
|
-
) {
|
|
465
|
-
removeBlock( _clientId );
|
|
466
|
-
} else {
|
|
371
|
+
const applyWithSelect = withSelect( ( select, { clientId, rootClientId } ) => {
|
|
372
|
+
const {
|
|
373
|
+
isBlockSelected,
|
|
374
|
+
getBlockMode,
|
|
375
|
+
isSelectionEnabled,
|
|
376
|
+
getTemplateLock,
|
|
377
|
+
__unstableGetBlockWithoutInnerBlocks,
|
|
378
|
+
canRemoveBlock,
|
|
379
|
+
canMoveBlock,
|
|
380
|
+
} = select( blockEditorStore );
|
|
381
|
+
const block = __unstableGetBlockWithoutInnerBlocks( clientId );
|
|
382
|
+
const isSelected = isBlockSelected( clientId );
|
|
383
|
+
const templateLock = getTemplateLock( rootClientId );
|
|
384
|
+
const canRemove = canRemoveBlock( clientId, rootClientId );
|
|
385
|
+
const canMove = canMoveBlock( clientId, rootClientId );
|
|
386
|
+
|
|
387
|
+
// The fallback to `{}` is a temporary fix.
|
|
388
|
+
// This function should never be called when a block is not present in
|
|
389
|
+
// the state. It happens now because the order in withSelect rendering
|
|
390
|
+
// is not correct.
|
|
391
|
+
const { name, attributes, isValid } = block || {};
|
|
392
|
+
|
|
393
|
+
// Do not add new properties here, use `useSelect` instead to avoid
|
|
394
|
+
// leaking new props to the public API (editor.BlockListBlock filter).
|
|
395
|
+
return {
|
|
396
|
+
mode: getBlockMode( clientId ),
|
|
397
|
+
isSelectionEnabled: isSelectionEnabled(),
|
|
398
|
+
isLocked: !! templateLock,
|
|
399
|
+
canRemove,
|
|
400
|
+
canMove,
|
|
401
|
+
// Users of the editor.BlockListBlock filter used to be able to
|
|
402
|
+
// access the block prop.
|
|
403
|
+
// Ideally these blocks would rely on the clientId prop only.
|
|
404
|
+
// This is kept for backward compatibility reasons.
|
|
405
|
+
block,
|
|
406
|
+
name,
|
|
407
|
+
attributes,
|
|
408
|
+
isValid,
|
|
409
|
+
isSelected,
|
|
410
|
+
};
|
|
411
|
+
} );
|
|
412
|
+
|
|
413
|
+
const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
414
|
+
const {
|
|
415
|
+
updateBlockAttributes,
|
|
416
|
+
insertBlocks,
|
|
417
|
+
mergeBlocks,
|
|
418
|
+
replaceBlocks,
|
|
419
|
+
toggleSelection,
|
|
420
|
+
__unstableMarkLastChangeAsPersistent,
|
|
421
|
+
moveBlocksToPosition,
|
|
422
|
+
removeBlock,
|
|
423
|
+
} = dispatch( blockEditorStore );
|
|
424
|
+
|
|
425
|
+
// Do not add new properties here, use `useDispatch` instead to avoid
|
|
426
|
+
// leaking new props to the public API (editor.BlockListBlock filter).
|
|
427
|
+
return {
|
|
428
|
+
setAttributes( newAttributes ) {
|
|
429
|
+
const { getMultiSelectedBlockClientIds } =
|
|
430
|
+
registry.select( blockEditorStore );
|
|
431
|
+
const multiSelectedBlockClientIds =
|
|
432
|
+
getMultiSelectedBlockClientIds();
|
|
433
|
+
const { clientId } = ownProps;
|
|
434
|
+
const clientIds = multiSelectedBlockClientIds.length
|
|
435
|
+
? multiSelectedBlockClientIds
|
|
436
|
+
: [ clientId ];
|
|
437
|
+
|
|
438
|
+
updateBlockAttributes( clientIds, newAttributes );
|
|
439
|
+
},
|
|
440
|
+
onInsertBlocks( blocks, index ) {
|
|
441
|
+
const { rootClientId } = ownProps;
|
|
442
|
+
insertBlocks( blocks, index, rootClientId );
|
|
443
|
+
},
|
|
444
|
+
onInsertBlocksAfter( blocks ) {
|
|
445
|
+
const { clientId, rootClientId } = ownProps;
|
|
446
|
+
const { getBlockIndex } = registry.select( blockEditorStore );
|
|
447
|
+
const index = getBlockIndex( clientId );
|
|
448
|
+
insertBlocks( blocks, index + 1, rootClientId );
|
|
449
|
+
},
|
|
450
|
+
onMerge( forward ) {
|
|
451
|
+
const { clientId, rootClientId } = ownProps;
|
|
452
|
+
const {
|
|
453
|
+
getPreviousBlockClientId,
|
|
454
|
+
getNextBlockClientId,
|
|
455
|
+
getBlock,
|
|
456
|
+
getBlockAttributes,
|
|
457
|
+
getBlockName,
|
|
458
|
+
getBlockOrder,
|
|
459
|
+
getBlockIndex,
|
|
460
|
+
getBlockRootClientId,
|
|
461
|
+
canInsertBlockType,
|
|
462
|
+
} = registry.select( blockEditorStore );
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Moves the block with clientId up one level. If the block type
|
|
466
|
+
* cannot be inserted at the new location, it will be attempted to
|
|
467
|
+
* convert to the default block type.
|
|
468
|
+
*
|
|
469
|
+
* @param {string} _clientId The block to move.
|
|
470
|
+
* @param {boolean} changeSelection Whether to change the selection
|
|
471
|
+
* to the moved block.
|
|
472
|
+
*/
|
|
473
|
+
function moveFirstItemUp( _clientId, changeSelection = true ) {
|
|
474
|
+
const targetRootClientId = getBlockRootClientId( _clientId );
|
|
475
|
+
const blockOrder = getBlockOrder( _clientId );
|
|
476
|
+
const [ firstClientId ] = blockOrder;
|
|
477
|
+
|
|
478
|
+
if (
|
|
479
|
+
blockOrder.length === 1 &&
|
|
480
|
+
isUnmodifiedBlock( getBlock( firstClientId ) )
|
|
481
|
+
) {
|
|
482
|
+
removeBlock( _clientId );
|
|
483
|
+
} else {
|
|
484
|
+
registry.batch( () => {
|
|
467
485
|
if (
|
|
468
486
|
canInsertBlockType(
|
|
469
487
|
getBlockName( firstClientId ),
|
|
@@ -483,15 +501,13 @@ export default compose( [
|
|
|
483
501
|
);
|
|
484
502
|
|
|
485
503
|
if ( replacement && replacement.length ) {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
removeBlock( firstClientId, false );
|
|
494
|
-
} );
|
|
504
|
+
insertBlocks(
|
|
505
|
+
replacement,
|
|
506
|
+
getBlockIndex( _clientId ),
|
|
507
|
+
targetRootClientId,
|
|
508
|
+
changeSelection
|
|
509
|
+
);
|
|
510
|
+
removeBlock( firstClientId, false );
|
|
495
511
|
}
|
|
496
512
|
}
|
|
497
513
|
|
|
@@ -501,85 +517,29 @@ export default compose( [
|
|
|
501
517
|
) {
|
|
502
518
|
removeBlock( _clientId, false );
|
|
503
519
|
}
|
|
504
|
-
}
|
|
520
|
+
} );
|
|
505
521
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
getBlockName( rootClientId ) ===
|
|
520
|
-
getBlockName( nextRootClientId )
|
|
521
|
-
) {
|
|
522
|
-
const rootAttributes =
|
|
523
|
-
getBlockAttributes( rootClientId );
|
|
524
|
-
const previousRootAttributes =
|
|
525
|
-
getBlockAttributes( nextRootClientId );
|
|
526
|
-
|
|
527
|
-
if (
|
|
528
|
-
Object.keys( rootAttributes ).every(
|
|
529
|
-
( key ) =>
|
|
530
|
-
rootAttributes[ key ] ===
|
|
531
|
-
previousRootAttributes[ key ]
|
|
532
|
-
)
|
|
533
|
-
) {
|
|
534
|
-
registry.batch( () => {
|
|
535
|
-
moveBlocksToPosition(
|
|
536
|
-
getBlockOrder( nextRootClientId ),
|
|
537
|
-
nextRootClientId,
|
|
538
|
-
rootClientId
|
|
539
|
-
);
|
|
540
|
-
removeBlock( nextRootClientId, false );
|
|
541
|
-
} );
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
} else {
|
|
545
|
-
mergeBlocks( rootClientId, nextRootClientId );
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
const nextBlockClientId = getNextBlockClientId( clientId );
|
|
552
|
-
|
|
553
|
-
if ( ! nextBlockClientId ) {
|
|
554
|
-
return;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
if ( getBlockOrder( nextBlockClientId ).length ) {
|
|
558
|
-
moveFirstItemUp( nextBlockClientId, false );
|
|
559
|
-
} else {
|
|
560
|
-
mergeBlocks( clientId, nextBlockClientId );
|
|
561
|
-
}
|
|
562
|
-
} else {
|
|
563
|
-
const previousBlockClientId =
|
|
564
|
-
getPreviousBlockClientId( clientId );
|
|
565
|
-
|
|
566
|
-
if ( previousBlockClientId ) {
|
|
567
|
-
mergeBlocks( previousBlockClientId, clientId );
|
|
568
|
-
} else if ( rootClientId ) {
|
|
569
|
-
const previousRootClientId =
|
|
570
|
-
getPreviousBlockClientId( rootClientId );
|
|
571
|
-
|
|
572
|
-
// If there is a preceding block with the same parent block
|
|
573
|
-
// name and the same attributes, merge the inner blocks.
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// For `Delete` or forward merge, we should do the exact same thing
|
|
525
|
+
// as `Backspace`, but from the other block.
|
|
526
|
+
if ( forward ) {
|
|
527
|
+
if ( rootClientId ) {
|
|
528
|
+
const nextRootClientId =
|
|
529
|
+
getNextBlockClientId( rootClientId );
|
|
530
|
+
|
|
531
|
+
if ( nextRootClientId ) {
|
|
532
|
+
// If there is a block that follows with the same parent
|
|
533
|
+
// block name and the same attributes, merge the inner
|
|
534
|
+
// blocks.
|
|
574
535
|
if (
|
|
575
|
-
previousRootClientId &&
|
|
576
536
|
getBlockName( rootClientId ) ===
|
|
577
|
-
|
|
537
|
+
getBlockName( nextRootClientId )
|
|
578
538
|
) {
|
|
579
539
|
const rootAttributes =
|
|
580
540
|
getBlockAttributes( rootClientId );
|
|
581
541
|
const previousRootAttributes =
|
|
582
|
-
getBlockAttributes(
|
|
542
|
+
getBlockAttributes( nextRootClientId );
|
|
583
543
|
|
|
584
544
|
if (
|
|
585
545
|
Object.keys( rootAttributes ).every(
|
|
@@ -590,33 +550,103 @@ export default compose( [
|
|
|
590
550
|
) {
|
|
591
551
|
registry.batch( () => {
|
|
592
552
|
moveBlocksToPosition(
|
|
593
|
-
getBlockOrder(
|
|
594
|
-
|
|
595
|
-
|
|
553
|
+
getBlockOrder( nextRootClientId ),
|
|
554
|
+
nextRootClientId,
|
|
555
|
+
rootClientId
|
|
596
556
|
);
|
|
597
|
-
removeBlock(
|
|
557
|
+
removeBlock( nextRootClientId, false );
|
|
598
558
|
} );
|
|
599
559
|
return;
|
|
600
560
|
}
|
|
561
|
+
} else {
|
|
562
|
+
mergeBlocks( rootClientId, nextRootClientId );
|
|
563
|
+
return;
|
|
601
564
|
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
const nextBlockClientId = getNextBlockClientId( clientId );
|
|
569
|
+
|
|
570
|
+
if ( ! nextBlockClientId ) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
602
573
|
|
|
603
|
-
|
|
574
|
+
if ( getBlockOrder( nextBlockClientId ).length ) {
|
|
575
|
+
moveFirstItemUp( nextBlockClientId, false );
|
|
576
|
+
} else {
|
|
577
|
+
mergeBlocks( clientId, nextBlockClientId );
|
|
578
|
+
}
|
|
579
|
+
} else {
|
|
580
|
+
const previousBlockClientId =
|
|
581
|
+
getPreviousBlockClientId( clientId );
|
|
582
|
+
|
|
583
|
+
if ( previousBlockClientId ) {
|
|
584
|
+
mergeBlocks( previousBlockClientId, clientId );
|
|
585
|
+
} else if ( rootClientId ) {
|
|
586
|
+
const previousRootClientId =
|
|
587
|
+
getPreviousBlockClientId( rootClientId );
|
|
588
|
+
|
|
589
|
+
// If there is a preceding block with the same parent block
|
|
590
|
+
// name and the same attributes, merge the inner blocks.
|
|
591
|
+
if (
|
|
592
|
+
previousRootClientId &&
|
|
593
|
+
getBlockName( rootClientId ) ===
|
|
594
|
+
getBlockName( previousRootClientId )
|
|
595
|
+
) {
|
|
596
|
+
const rootAttributes =
|
|
597
|
+
getBlockAttributes( rootClientId );
|
|
598
|
+
const previousRootAttributes =
|
|
599
|
+
getBlockAttributes( previousRootClientId );
|
|
600
|
+
|
|
601
|
+
if (
|
|
602
|
+
Object.keys( rootAttributes ).every(
|
|
603
|
+
( key ) =>
|
|
604
|
+
rootAttributes[ key ] ===
|
|
605
|
+
previousRootAttributes[ key ]
|
|
606
|
+
)
|
|
607
|
+
) {
|
|
608
|
+
registry.batch( () => {
|
|
609
|
+
moveBlocksToPosition(
|
|
610
|
+
getBlockOrder( rootClientId ),
|
|
611
|
+
rootClientId,
|
|
612
|
+
previousRootClientId
|
|
613
|
+
);
|
|
614
|
+
removeBlock( rootClientId, false );
|
|
615
|
+
} );
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
604
618
|
}
|
|
619
|
+
|
|
620
|
+
moveFirstItemUp( rootClientId );
|
|
605
621
|
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
onReplace( blocks, indexToSelect, initialPosition ) {
|
|
625
|
+
if (
|
|
626
|
+
blocks.length &&
|
|
627
|
+
! isUnmodifiedDefaultBlock( blocks[ blocks.length - 1 ] )
|
|
628
|
+
) {
|
|
629
|
+
__unstableMarkLastChangeAsPersistent();
|
|
630
|
+
}
|
|
631
|
+
replaceBlocks(
|
|
632
|
+
[ ownProps.clientId ],
|
|
633
|
+
blocks,
|
|
634
|
+
indexToSelect,
|
|
635
|
+
initialPosition
|
|
636
|
+
);
|
|
637
|
+
},
|
|
638
|
+
toggleSelection( selectionEnabled ) {
|
|
639
|
+
toggleSelection( selectionEnabled );
|
|
640
|
+
},
|
|
641
|
+
};
|
|
642
|
+
} );
|
|
643
|
+
|
|
644
|
+
export default compose(
|
|
645
|
+
pure,
|
|
646
|
+
applyWithSelect,
|
|
647
|
+
applyWithDispatch,
|
|
648
|
+
// Block is sometimes not mounted at the right time, causing it be undefined
|
|
649
|
+
// see issue for more info
|
|
650
|
+
// https://github.com/WordPress/gutenberg/issues/17013
|
|
651
|
+
ifCondition( ( { block } ) => !! block )
|
|
652
|
+
)( BlockListBlock );
|