@wordpress/block-editor 15.21.0 → 15.21.1
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 +17 -1
- package/build/components/block-compare/index.cjs +2 -2
- package/build/components/block-compare/index.cjs.map +2 -2
- package/build/components/block-patterns-list/index.cjs +1 -1
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-switcher/block-transformations-menu.cjs +16 -15
- package/build/components/block-switcher/block-transformations-menu.cjs.map +2 -2
- package/build/components/block-switcher/index.cjs +4 -4
- package/build/components/block-switcher/index.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +23 -15
- package/build/components/global-styles/advanced-panel.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +2 -2
- package/build/components/global-styles/background-panel.cjs.map +2 -2
- package/build/components/global-styles/border-panel.cjs +2 -0
- package/build/components/global-styles/border-panel.cjs.map +2 -2
- package/build/components/global-styles/dimensions-panel.cjs +1 -1
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/inner-blocks/use-inner-block-template-sync.cjs +3 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.cjs.map +2 -2
- package/build/components/inserter/hooks/use-patterns-state.cjs +1 -1
- package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
- package/build/components/inserter/index.cjs +179 -220
- package/build/components/inserter/index.cjs.map +3 -3
- package/build/components/inserter/search-results.cjs +1 -1
- package/build/components/inserter/search-results.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +10 -12
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +2 -1
- package/build/components/list-view/block.cjs.map +2 -2
- package/build/components/provider/use-block-sync.cjs +11 -2
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/before-input-rules.cjs +4 -4
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/delete.cjs +4 -4
- package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/enter.cjs +7 -2
- package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/input-events.cjs +4 -4
- package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/input-rules.cjs +17 -4
- package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +4 -4
- package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +4 -4
- package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/shortcuts.cjs +4 -4
- package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +4 -4
- package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
- package/build/components/rich-text/index.cjs +1 -23
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs +5 -5
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/hooks/anchor.cjs +11 -15
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/border.cjs +0 -3
- package/build/hooks/border.cjs.map +2 -2
- package/build/hooks/color.cjs +1 -4
- package/build/hooks/color.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +0 -3
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/fit-text.cjs +11 -0
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/position.cjs +19 -22
- package/build/hooks/position.cjs.map +2 -2
- package/build/hooks/supports.cjs +0 -7
- package/build/hooks/supports.cjs.map +2 -2
- package/build/store/actions.cjs +7 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/private-actions.cjs +1 -2
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-selectors.cjs +23 -0
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +14 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +60 -41
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/block-compare/index.mjs +1 -1
- package/build-module/components/block-compare/index.mjs.map +2 -2
- package/build-module/components/block-patterns-list/index.mjs +1 -1
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-switcher/block-transformations-menu.mjs +16 -15
- package/build-module/components/block-switcher/block-transformations-menu.mjs.map +2 -2
- package/build-module/components/block-switcher/index.mjs +4 -4
- package/build-module/components/block-switcher/index.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +23 -15
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +3 -3
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/border-panel.mjs +2 -0
- package/build-module/components/global-styles/border-panel.mjs.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs +2 -2
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs +3 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs.map +2 -2
- package/build-module/components/inserter/hooks/use-patterns-state.mjs +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +185 -222
- package/build-module/components/inserter/index.mjs.map +3 -3
- package/build-module/components/inserter/search-results.mjs +1 -1
- package/build-module/components/inserter/search-results.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +10 -12
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +2 -1
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +11 -2
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/delete.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs +7 -2
- package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-events.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/input-rules.mjs +17 -4
- package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +4 -4
- package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +1 -23
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +5 -5
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/hooks/anchor.mjs +11 -15
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/border.mjs +1 -4
- package/build-module/hooks/border.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -5
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +1 -4
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/fit-text.mjs +11 -0
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/position.mjs +20 -23
- package/build-module/hooks/position.mjs.map +2 -2
- package/build-module/hooks/supports.mjs +0 -7
- package/build-module/hooks/supports.mjs.map +2 -2
- package/build-module/store/actions.mjs +7 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +1 -2
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +21 -0
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +14 -6
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +62 -42
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/content-rtl.css +12 -0
- package/build-style/content.css +12 -0
- package/build-style/style-rtl.css +26 -8
- package/build-style/style.css +26 -8
- package/package.json +49 -46
- package/src/components/block-breadcrumb/README.md +2 -2
- package/src/components/block-compare/README.md +6 -6
- package/src/components/block-compare/index.js +1 -3
- package/src/components/block-patterns-list/index.js +1 -1
- package/src/components/block-preview/README.md +1 -1
- package/src/components/block-switcher/block-transformations-menu.js +16 -18
- package/src/components/block-switcher/index.js +4 -4
- package/src/components/block-types-list/README.md +0 -19
- package/src/components/global-styles/advanced-panel.js +5 -1
- package/src/components/global-styles/background-panel.js +3 -3
- package/src/components/global-styles/border-panel.js +2 -0
- package/src/components/global-styles/dimensions-panel.js +12 -13
- package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -1
- package/src/components/inserter/hooks/use-patterns-state.js +1 -1
- package/src/components/inserter/index.js +257 -288
- package/src/components/inserter/search-results.js +1 -3
- package/src/components/justify-content-control/README.md +1 -1
- package/src/components/list-view/block-select-button.js +9 -13
- package/src/components/list-view/block.js +1 -0
- package/src/components/media-placeholder/README.md +1 -29
- package/src/components/media-upload/README.md +0 -19
- package/src/components/provider/test/use-block-sync.js +40 -0
- package/src/components/provider/use-block-sync.js +12 -2
- package/src/components/rich-text/event-listeners/before-input-rules.js +5 -4
- package/src/components/rich-text/event-listeners/delete.js +9 -4
- package/src/components/rich-text/event-listeners/enter.js +9 -2
- package/src/components/rich-text/event-listeners/input-events.js +13 -4
- package/src/components/rich-text/event-listeners/input-rules.js +20 -4
- package/src/components/rich-text/event-listeners/insert-replacement-text.js +9 -4
- package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +9 -4
- package/src/components/rich-text/event-listeners/shortcuts.js +13 -4
- package/src/components/rich-text/event-listeners/undo-automatic-change.js +5 -4
- package/src/components/rich-text/index.js +1 -33
- package/src/components/unit-control/README.md +1 -1
- package/src/components/url-popover/README.md +1 -1
- package/src/components/use-block-commands/index.js +5 -5
- package/src/hooks/anchor.js +9 -17
- package/src/hooks/border.js +1 -5
- package/src/hooks/color.js +1 -6
- package/src/hooks/dimensions.js +1 -5
- package/src/hooks/fit-text.js +16 -0
- package/src/hooks/position.js +23 -27
- package/src/hooks/supports.js +0 -9
- package/src/store/actions.js +13 -3
- package/src/store/private-actions.js +1 -4
- package/src/store/private-selectors.js +42 -0
- package/src/store/reducer.js +19 -7
- package/src/store/selectors.js +91 -53
- package/src/store/test/actions.js +21 -0
- package/src/store/test/reducer.js +46 -0
- package/src/store/test/selectors.js +77 -0
- package/build/components/media-upload-progress/constants.cjs +0 -46
- package/build/components/media-upload-progress/constants.cjs.map +0 -7
- package/build/components/rich-text/native/format-edit.cjs +0 -60
- package/build/components/rich-text/native/format-edit.cjs.map +0 -7
- package/build/components/rich-text/native/index.cjs +0 -28
- package/build/components/rich-text/native/index.cjs.map +0 -7
- package/build/components/rich-text/native/use-format-types.cjs +0 -139
- package/build/components/rich-text/native/use-format-types.cjs.map +0 -7
- package/build-module/components/media-upload-progress/constants.mjs +0 -16
- package/build-module/components/media-upload-progress/constants.mjs.map +0 -7
- package/build-module/components/rich-text/native/format-edit.mjs +0 -39
- package/build-module/components/rich-text/native/format-edit.mjs.map +0 -7
- package/build-module/components/rich-text/native/index.mjs +0 -7
- package/build-module/components/rich-text/native/index.mjs.map +0 -7
- package/build-module/components/rich-text/native/use-format-types.mjs +0 -114
- package/build-module/components/rich-text/native/use-format-types.mjs.map +0 -7
- package/src/components/audio-player/audio-url-parser.native.js +0 -20
- package/src/components/audio-player/index.native.js +0 -225
- package/src/components/audio-player/styles.native.scss +0 -114
- package/src/components/audio-player/test/audio-url-parser.native.js +0 -53
- package/src/components/block-alignment-control/test/index.native.js +0 -37
- package/src/components/block-alignment-control/ui.native.js +0 -86
- package/src/components/block-caption/README.md +0 -104
- package/src/components/block-caption/index.native.js +0 -89
- package/src/components/block-caption/styles.native.scss +0 -7
- package/src/components/block-controls/slot.native.js +0 -33
- package/src/components/block-draggable/draggable-chip.native.js +0 -49
- package/src/components/block-draggable/dropping-insertion-point.native.js +0 -181
- package/src/components/block-draggable/dropping-insertion-point.native.scss +0 -8
- package/src/components/block-draggable/index.native.js +0 -467
- package/src/components/block-draggable/style.native.scss +0 -19
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +0 -73
- package/src/components/block-draggable/test/helpers.native.js +0 -182
- package/src/components/block-draggable/test/index.native.js +0 -419
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +0 -135
- package/src/components/block-edit/edit.native.js +0 -49
- package/src/components/block-edit/test/edit.native.js +0 -65
- package/src/components/block-heading-level-dropdown/index.native.js +0 -68
- package/src/components/block-icon/index.native.js +0 -47
- package/src/components/block-icon/style.native.scss +0 -7
- package/src/components/block-list/block-crash-boundary.native.js +0 -43
- package/src/components/block-list/block-crash-warning.native.js +0 -21
- package/src/components/block-list/block-invalid-warning.native.js +0 -70
- package/src/components/block-list/block-list-context.native.js +0 -172
- package/src/components/block-list/block-list-item-cell.native.js +0 -62
- package/src/components/block-list/block-list-item.native.js +0 -209
- package/src/components/block-list/block-list-item.native.scss +0 -16
- package/src/components/block-list/block-outline.native.js +0 -77
- package/src/components/block-list/block-selection-button.native.js +0 -100
- package/src/components/block-list/block-selection-button.native.scss +0 -34
- package/src/components/block-list/block.native.js +0 -716
- package/src/components/block-list/block.native.scss +0 -62
- package/src/components/block-list/grid-item.native.js +0 -58
- package/src/components/block-list/index.native.js +0 -437
- package/src/components/block-list/insertion-point.native.js +0 -36
- package/src/components/block-list/style.native.scss +0 -117
- package/src/components/block-list/test/block-invalid-warning.native.js +0 -62
- package/src/components/block-list/test/block-list-context.native.js +0 -243
- package/src/components/block-list/test/block-outline.native.js +0 -255
- package/src/components/block-list/test/fixtures/block-list-context.native.js +0 -79
- package/src/components/block-list/test/index.native.js +0 -205
- package/src/components/block-list/use-block-props/index.native.js +0 -10
- package/src/components/block-list/use-scroll-upon-insertion.native.js +0 -52
- package/src/components/block-list-appender/index.native.js +0 -70
- package/src/components/block-list-appender/style.native.scss +0 -8
- package/src/components/block-media-update-progress/README.md +0 -100
- package/src/components/block-media-update-progress/index.native.js +0 -299
- package/src/components/block-media-update-progress/styles.native.scss +0 -9
- package/src/components/block-media-update-progress/test/index.native.js +0 -543
- package/src/components/block-mover/index.native.js +0 -193
- package/src/components/block-mover/mover-description.native.js +0 -155
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -218
- package/src/components/block-mover/test/index.native.js +0 -186
- package/src/components/block-settings/button.native.js +0 -41
- package/src/components/block-settings/container.native.js +0 -91
- package/src/components/block-settings/container.native.scss +0 -4
- package/src/components/block-settings/index.native.js +0 -5
- package/src/components/block-styles/index.native.js +0 -94
- package/src/components/block-styles/preview.native.js +0 -109
- package/src/components/block-styles/style.native.scss +0 -64
- package/src/components/block-switcher/block-transformations-menu.native.js +0 -91
- package/src/components/block-toolbar/block-toolbar-menu.native.js +0 -477
- package/src/components/block-toolbar/index.native.js +0 -126
- package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +0 -125
- package/src/components/block-toolbar/test/block-toolbar-menu.native.js +0 -405
- package/src/components/block-toolbar/test/index.native.js +0 -36
- package/src/components/block-types-list/index.native.js +0 -175
- package/src/components/block-types-list/style.native.scss +0 -25
- package/src/components/block-variation-picker/index.native.js +0 -107
- package/src/components/block-variation-picker/style.native.scss +0 -32
- package/src/components/button-block-appender/index.native.js +0 -92
- package/src/components/button-block-appender/styles.native.scss +0 -43
- package/src/components/caption/README.md +0 -44
- package/src/components/caption/index.native.js +0 -61
- package/src/components/colors-gradients/panel-color-gradient-settings.native.js +0 -59
- package/src/components/contrast-checker/index.native.js +0 -113
- package/src/components/contrast-checker/style.native.scss +0 -26
- package/src/components/convert-to-group-buttons/index.native.js +0 -79
- package/src/components/default-block-appender/index.native.js +0 -113
- package/src/components/default-block-appender/style.native.scss +0 -18
- package/src/components/floating-toolbar/floatingToolbar.android.scss +0 -4
- package/src/components/floating-toolbar/floatingToolbar.ios.scss +0 -3
- package/src/components/floating-toolbar/index.native.js +0 -141
- package/src/components/floating-toolbar/styles.native.scss +0 -43
- package/src/components/font-sizes/index.native.js +0 -7
- package/src/components/global-styles/color-panel.native.js +0 -207
- package/src/components/global-styles/test/use-global-styles-context.native.js +0 -435
- package/src/components/global-styles/use-global-styles-context.native.js +0 -592
- package/src/components/gradients/index.native.js +0 -2
- package/src/components/image-link-destinations/index.native.js +0 -152
- package/src/components/image-link-destinations/style.native.scss +0 -16
- package/src/components/index.native.js +0 -108
- package/src/components/inner-blocks/constants.native.js +0 -5
- package/src/components/inner-blocks/index.native.js +0 -221
- package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +0 -124
- package/src/components/inserter/block-types-tab.native.js +0 -76
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +0 -47
- package/src/components/inserter/hooks/use-clipboard-block.native.js +0 -40
- package/src/components/inserter/index.native.js +0 -424
- package/src/components/inserter/menu.native.js +0 -237
- package/src/components/inserter/no-results.native.js +0 -49
- package/src/components/inserter/reusable-blocks-tab.native.js +0 -45
- package/src/components/inserter/search-results.native.js +0 -67
- package/src/components/inserter/style.native.scss +0 -83
- package/src/components/inserter/tabs.native.js +0 -152
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +0 -117
- package/src/components/inserter/test/fixtures/index.native.js +0 -12
- package/src/components/inserter/test/index.native.js +0 -273
- package/src/components/inserter/test/reusable-blocks-tab.native.js +0 -62
- package/src/components/inserter/test/utils.native.js +0 -37
- package/src/components/inserter/utils.native.js +0 -46
- package/src/components/inserter-button/index.native.js +0 -108
- package/src/components/inserter-button/style.native.scss +0 -72
- package/src/components/inspector-controls/fill.native.js +0 -62
- package/src/components/inspector-controls/slot.native.js +0 -35
- package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +0 -31
- package/src/components/line-height-control/index.native.js +0 -28
- package/src/components/media-placeholder/index.native.js +0 -258
- package/src/components/media-placeholder/styles.native.scss +0 -108
- package/src/components/media-replace-flow/index.native.js +0 -12
- package/src/components/media-upload/constants.native.js +0 -14
- package/src/components/media-upload/index.native.js +0 -356
- package/src/components/media-upload/style.native.scss +0 -4
- package/src/components/media-upload/test/index.native.js +0 -172
- package/src/components/media-upload-progress/README.md +0 -100
- package/src/components/media-upload-progress/constants.js +0 -6
- package/src/components/media-upload-progress/index.native.js +0 -233
- package/src/components/media-upload-progress/styles.native.scss +0 -15
- package/src/components/media-upload-progress/test/index.native.js +0 -220
- package/src/components/plain-text/index.native.js +0 -164
- package/src/components/plain-text/style.native.scss +0 -10
- package/src/components/provider/index.native.js +0 -32
- package/src/components/rich-text/embed-handler-picker.native.js +0 -65
- package/src/components/rich-text/file-paste-handler.native.js +0 -3
- package/src/components/rich-text/format-toolbar/index.native.js +0 -21
- package/src/components/rich-text/format-toolbar-container.native.js +0 -16
- package/src/components/rich-text/index.native.js +0 -701
- package/src/components/rich-text/input-event.native.js +0 -10
- package/src/components/rich-text/native/format-edit.js +0 -44
- package/src/components/rich-text/native/get-format-colors.native.js +0 -47
- package/src/components/rich-text/native/index.js +0 -1
- package/src/components/rich-text/native/index.native.js +0 -1389
- package/src/components/rich-text/native/style.native.scss +0 -28
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +0 -79
- package/src/components/rich-text/native/test/index.native.js +0 -345
- package/src/components/rich-text/native/test/performance/rich-text.native.js +0 -44
- package/src/components/rich-text/native/toolbar-button-with-options.native.js +0 -61
- package/src/components/rich-text/native/use-format-types.js +0 -146
- package/src/components/rich-text/remove-browser-shortcuts.native.js +0 -1
- package/src/components/rich-text/shortcut.native.js +0 -10
- package/src/components/ungroup-button/README.md +0 -23
- package/src/components/ungroup-button/index.native.js +0 -77
- package/src/components/unsupported-block-details/index.native.js +0 -187
- package/src/components/unsupported-block-details/style.native.scss +0 -56
- package/src/components/url-input/index.native.js +0 -33
- package/src/components/use-block-drop-zone/index.native.js +0 -207
- package/src/components/use-on-block-drop/index.native.js +0 -115
- package/src/components/use-unsupported-block-editor/index.native.js +0 -59
- package/src/components/video-player/gridicon-play.native.js +0 -13
- package/src/components/video-player/index.native.js +0 -133
- package/src/components/video-player/styles.native.scss +0 -29
- package/src/components/warning/index.native.js +0 -64
- package/src/components/warning/style.native.scss +0 -47
- package/src/hooks/align.native.js +0 -49
- package/src/hooks/custom-class-name.native.js +0 -70
- package/src/hooks/index.native.js +0 -36
- package/src/hooks/layout.native.js +0 -23
- package/src/hooks/test/__snapshots__/align.native.js.snap +0 -73
- package/src/hooks/test/__snapshots__/anchor.native.js.snap +0 -7
- package/src/hooks/test/align.native.js +0 -134
- package/src/hooks/test/anchor.native.js +0 -32
- package/src/hooks/test/use-editor-wrapper-styles.native.js +0 -282
- package/src/hooks/typography.native.js +0 -60
- package/src/hooks/use-editor-wrapper-styles.native.js +0 -250
- package/src/hooks/use-editor-wrapper-styles.native.scss +0 -12
- package/src/index.native.js +0 -6
- package/src/private-apis.native.js +0 -21
- package/src/store/defaults.native.js +0 -23
|
@@ -9,10 +9,13 @@ import clsx from 'clsx';
|
|
|
9
9
|
import { speak } from '@wordpress/a11y';
|
|
10
10
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
11
11
|
import { Dropdown, Button } from '@wordpress/components';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
|
+
import {
|
|
14
|
+
createBlock,
|
|
15
|
+
store as blocksStore,
|
|
16
|
+
__experimentalGetBlockLabel as getBlockLabel,
|
|
17
|
+
} from '@wordpress/blocks';
|
|
18
|
+
import { forwardRef } from '@wordpress/element';
|
|
16
19
|
import { plus } from '@wordpress/icons';
|
|
17
20
|
|
|
18
21
|
/**
|
|
@@ -23,15 +26,18 @@ import QuickInserter from './quick-inserter';
|
|
|
23
26
|
import { store as blockEditorStore } from '../../store';
|
|
24
27
|
import { getAppenderLabel } from './get-appender-label';
|
|
25
28
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const UnforwardedInserterToggle = (
|
|
30
|
+
{
|
|
31
|
+
onToggle,
|
|
32
|
+
disabled,
|
|
33
|
+
isOpen,
|
|
34
|
+
blockTitle,
|
|
35
|
+
hasSingleBlockType,
|
|
36
|
+
appenderLabel,
|
|
37
|
+
toggleProps = {},
|
|
38
|
+
},
|
|
39
|
+
ref
|
|
40
|
+
) => {
|
|
35
41
|
const {
|
|
36
42
|
as: Wrapper = Button,
|
|
37
43
|
label: labelProp,
|
|
@@ -65,6 +71,7 @@ const defaultRenderToggle = ( {
|
|
|
65
71
|
|
|
66
72
|
return (
|
|
67
73
|
<Wrapper
|
|
74
|
+
ref={ ref }
|
|
68
75
|
__next40pxDefaultSize={ toggleProps.as ? undefined : true }
|
|
69
76
|
icon={ plus }
|
|
70
77
|
label={ label }
|
|
@@ -80,78 +87,236 @@ const defaultRenderToggle = ( {
|
|
|
80
87
|
);
|
|
81
88
|
};
|
|
82
89
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
const InserterToggle = forwardRef( UnforwardedInserterToggle );
|
|
91
|
+
|
|
92
|
+
const UnforwardedInserter = (
|
|
93
|
+
{
|
|
94
|
+
clientId,
|
|
95
|
+
rootClientId,
|
|
96
|
+
disabled,
|
|
97
|
+
isAppender,
|
|
98
|
+
position,
|
|
99
|
+
selectBlockOnInsert,
|
|
100
|
+
shouldDirectInsert = true,
|
|
101
|
+
showInserterHelpPanel,
|
|
102
|
+
// This prop is experimental to give some time for the quick inserter to mature
|
|
103
|
+
// Feel free to make them stable after a few releases.
|
|
104
|
+
__experimentalIsQuick: isQuick,
|
|
105
|
+
onSelectOrClose,
|
|
106
|
+
onToggle,
|
|
107
|
+
renderToggle: renderToggleProp,
|
|
108
|
+
toggleProps,
|
|
109
|
+
},
|
|
110
|
+
ref
|
|
111
|
+
) => {
|
|
112
|
+
const {
|
|
113
|
+
hasItems,
|
|
114
|
+
hasSingleBlockType,
|
|
115
|
+
blockTitle,
|
|
116
|
+
allowedBlockType,
|
|
117
|
+
blockToInsert,
|
|
118
|
+
appenderLabel,
|
|
119
|
+
targetRootClientId,
|
|
120
|
+
} = useSelect(
|
|
121
|
+
( select ) => {
|
|
122
|
+
const {
|
|
123
|
+
getBlockRootClientId,
|
|
124
|
+
hasInserterItems,
|
|
125
|
+
getAllowedBlocks,
|
|
126
|
+
getDirectInsertBlock,
|
|
127
|
+
getBlockListSettings,
|
|
128
|
+
} = select( blockEditorStore );
|
|
129
|
+
const { getBlockVariations, getBlockType } = select( blocksStore );
|
|
86
130
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
131
|
+
const _targetRootClientId =
|
|
132
|
+
rootClientId || getBlockRootClientId( clientId ) || undefined;
|
|
133
|
+
|
|
134
|
+
const allowedBlocks = getAllowedBlocks( _targetRootClientId );
|
|
135
|
+
const directInsertBlock =
|
|
136
|
+
shouldDirectInsert &&
|
|
137
|
+
getDirectInsertBlock( _targetRootClientId );
|
|
138
|
+
const { defaultBlock } =
|
|
139
|
+
getBlockListSettings( _targetRootClientId ) ?? {};
|
|
140
|
+
|
|
141
|
+
const _hasSingleBlockType =
|
|
142
|
+
allowedBlocks?.length === 1 &&
|
|
143
|
+
getBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )
|
|
144
|
+
?.length === 0;
|
|
145
|
+
const _allowedBlockType = _hasSingleBlockType
|
|
146
|
+
? allowedBlocks[ 0 ]
|
|
147
|
+
: null;
|
|
148
|
+
|
|
149
|
+
// Single-block-type parents get adjacent-attribute copying
|
|
150
|
+
// without needing to set `directInsert: true`.
|
|
151
|
+
let _blockToInsert = directInsertBlock || null;
|
|
152
|
+
if (
|
|
153
|
+
! _blockToInsert &&
|
|
154
|
+
_hasSingleBlockType &&
|
|
155
|
+
defaultBlock?.name === _allowedBlockType.name
|
|
156
|
+
) {
|
|
157
|
+
_blockToInsert = defaultBlock;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const defaultBlockType = directInsertBlock
|
|
161
|
+
? getBlockType( directInsertBlock.name )
|
|
162
|
+
: null;
|
|
163
|
+
return {
|
|
164
|
+
hasItems: hasInserterItems( _targetRootClientId ),
|
|
165
|
+
hasSingleBlockType: _hasSingleBlockType,
|
|
166
|
+
blockTitle: _allowedBlockType ? _allowedBlockType.title : '',
|
|
167
|
+
allowedBlockType: _allowedBlockType,
|
|
168
|
+
blockToInsert: _blockToInsert,
|
|
169
|
+
appenderLabel: getAppenderLabel(
|
|
170
|
+
directInsertBlock,
|
|
171
|
+
defaultBlockType
|
|
172
|
+
),
|
|
173
|
+
targetRootClientId: _targetRootClientId,
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
[ rootClientId, clientId, shouldDirectInsert ]
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
const { insertBlock } = useDispatch( blockEditorStore );
|
|
180
|
+
const {
|
|
181
|
+
getBlock,
|
|
182
|
+
getBlockIndex,
|
|
183
|
+
getBlockOrder,
|
|
184
|
+
getBlockRootClientId,
|
|
185
|
+
getBlockSelectionEnd,
|
|
186
|
+
getPreviousBlockClientId,
|
|
187
|
+
} = useSelect( blockEditorStore );
|
|
188
|
+
const { getActiveBlockVariation, getBlockType } = useSelect( blocksStore );
|
|
189
|
+
|
|
190
|
+
// The global inserter (no isAppender, no rootClientId, no clientId) should
|
|
191
|
+
// always render, even with no items.
|
|
192
|
+
if ( ! hasItems && ( isAppender || targetRootClientId || clientId ) ) {
|
|
193
|
+
return null;
|
|
90
194
|
}
|
|
91
195
|
|
|
92
|
-
|
|
93
|
-
const
|
|
196
|
+
function insertOnlyAllowedBlock() {
|
|
197
|
+
const blockName = blockToInsert?.name ?? allowedBlockType.name;
|
|
94
198
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
199
|
+
function getAdjacentBlockAttributes( attributesToCopy ) {
|
|
200
|
+
if ( ! attributesToCopy?.length ) {
|
|
201
|
+
return {};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Find the adjacent block of the same type whose attributes
|
|
205
|
+
// should be copied: previous sibling when inserting next to
|
|
206
|
+
// an existing block, otherwise the last child of the root.
|
|
207
|
+
let adjacentAttributes;
|
|
208
|
+
if ( clientId ) {
|
|
209
|
+
const currentBlock = getBlock( clientId );
|
|
210
|
+
const previousBlock = getBlock(
|
|
211
|
+
getPreviousBlockClientId( clientId )
|
|
212
|
+
);
|
|
213
|
+
if ( currentBlock?.name === previousBlock?.name ) {
|
|
214
|
+
adjacentAttributes = previousBlock?.attributes;
|
|
215
|
+
}
|
|
216
|
+
} else if ( targetRootClientId ) {
|
|
217
|
+
const lastInnerBlock =
|
|
218
|
+
getBlock( targetRootClientId )?.innerBlocks?.at( -1 );
|
|
219
|
+
if ( lastInnerBlock?.name === blockName ) {
|
|
220
|
+
adjacentAttributes = lastInnerBlock.attributes;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if ( ! adjacentAttributes ) {
|
|
225
|
+
return {};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return Object.fromEntries(
|
|
229
|
+
attributesToCopy
|
|
230
|
+
.filter( ( attr ) => attr in adjacentAttributes )
|
|
231
|
+
.map( ( attr ) => [ attr, adjacentAttributes[ attr ] ] )
|
|
232
|
+
);
|
|
98
233
|
}
|
|
99
|
-
}
|
|
100
234
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
appenderLabel,
|
|
117
|
-
toggleProps,
|
|
118
|
-
hasItems,
|
|
119
|
-
renderToggle = defaultRenderToggle,
|
|
120
|
-
} = this.props;
|
|
235
|
+
function getInsertionIndex() {
|
|
236
|
+
// If the clientId is defined, we insert at the position of the block.
|
|
237
|
+
if ( clientId ) {
|
|
238
|
+
return getBlockIndex( clientId );
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// If there a selected block, we insert after the selected block.
|
|
242
|
+
const end = getBlockSelectionEnd();
|
|
243
|
+
if (
|
|
244
|
+
! isAppender &&
|
|
245
|
+
end &&
|
|
246
|
+
getBlockRootClientId( end ) === targetRootClientId
|
|
247
|
+
) {
|
|
248
|
+
return getBlockIndex( end ) + 1;
|
|
249
|
+
}
|
|
121
250
|
|
|
122
|
-
|
|
123
|
-
|
|
251
|
+
// Otherwise, we insert at the end of the current rootClientId.
|
|
252
|
+
return getBlockOrder( targetRootClientId ).length;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Attempt to augment the inserted block with attributes from an adjacent block.
|
|
256
|
+
// This ensures styling from nearby blocks is preserved in the newly inserted block.
|
|
257
|
+
// See: https://github.com/WordPress/gutenberg/issues/37904
|
|
258
|
+
const newAttributes = getAdjacentBlockAttributes(
|
|
259
|
+
blockToInsert?.attributesToCopy
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
const newBlock = createBlock( blockName, {
|
|
263
|
+
...blockToInsert?.attributes,
|
|
264
|
+
...newAttributes,
|
|
265
|
+
} );
|
|
266
|
+
|
|
267
|
+
insertBlock(
|
|
268
|
+
newBlock,
|
|
269
|
+
getInsertionIndex(),
|
|
270
|
+
targetRootClientId,
|
|
271
|
+
selectBlockOnInsert
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
onSelectOrClose?.( newBlock );
|
|
275
|
+
|
|
276
|
+
const blockTypeToInsert = getBlockType( blockName );
|
|
277
|
+
let blockLabelToInsert;
|
|
278
|
+
if ( blockTypeToInsert ) {
|
|
279
|
+
blockLabelToInsert = getBlockLabel(
|
|
280
|
+
blockTypeToInsert,
|
|
281
|
+
newBlock.attributes
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
if ( blockLabelToInsert === blockTypeToInsert.title ) {
|
|
285
|
+
blockLabelToInsert =
|
|
286
|
+
getActiveBlockVariation( blockName, newBlock.attributes )
|
|
287
|
+
?.title || blockLabelToInsert;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if ( blockLabelToInsert ) {
|
|
292
|
+
const message = sprintf(
|
|
293
|
+
// translators: %s: the name of the block that has been added
|
|
294
|
+
__( '%s block added' ),
|
|
295
|
+
blockLabelToInsert
|
|
296
|
+
);
|
|
297
|
+
speak( message );
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function renderToggle( { onToggle: dropdownOnToggle, isOpen } ) {
|
|
302
|
+
const toggleArgs = {
|
|
303
|
+
onToggle: dropdownOnToggle,
|
|
124
304
|
isOpen,
|
|
125
305
|
disabled: disabled || ! hasItems,
|
|
126
306
|
blockTitle,
|
|
127
307
|
hasSingleBlockType,
|
|
128
308
|
appenderLabel,
|
|
129
309
|
toggleProps,
|
|
130
|
-
}
|
|
131
|
-
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
if ( renderToggleProp ) {
|
|
313
|
+
return renderToggleProp( toggleArgs );
|
|
314
|
+
}
|
|
132
315
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
*
|
|
136
|
-
* @param {Object} options
|
|
137
|
-
* @param {Function} options.onClose Callback to invoke when dropdown is
|
|
138
|
-
* closed.
|
|
139
|
-
*
|
|
140
|
-
* @return {Element} Dropdown content element.
|
|
141
|
-
*/
|
|
142
|
-
renderContent( { onClose } ) {
|
|
143
|
-
const {
|
|
144
|
-
rootClientId,
|
|
145
|
-
clientId,
|
|
146
|
-
isAppender,
|
|
147
|
-
showInserterHelpPanel,
|
|
148
|
-
// This prop is experimental to give some time for the quick inserter to mature
|
|
149
|
-
// Feel free to make them stable after a few releases.
|
|
150
|
-
__experimentalIsQuick: isQuick,
|
|
151
|
-
onSelectOrClose,
|
|
152
|
-
selectBlockOnInsert,
|
|
153
|
-
} = this.props;
|
|
316
|
+
return <InserterToggle ref={ ref } { ...toggleArgs } />;
|
|
317
|
+
}
|
|
154
318
|
|
|
319
|
+
function renderContent( { onClose } ) {
|
|
155
320
|
if ( isQuick ) {
|
|
156
321
|
return (
|
|
157
322
|
<QuickInserter
|
|
@@ -168,7 +333,7 @@ class Inserter extends Component {
|
|
|
168
333
|
}
|
|
169
334
|
onClose();
|
|
170
335
|
} }
|
|
171
|
-
rootClientId={
|
|
336
|
+
rootClientId={ targetRootClientId }
|
|
172
337
|
clientId={ clientId }
|
|
173
338
|
isAppender={ isAppender }
|
|
174
339
|
selectBlockOnInsert={ selectBlockOnInsert }
|
|
@@ -182,7 +347,7 @@ class Inserter extends Component {
|
|
|
182
347
|
onClose();
|
|
183
348
|
} }
|
|
184
349
|
onClose={ onClose }
|
|
185
|
-
rootClientId={
|
|
350
|
+
rootClientId={ targetRootClientId }
|
|
186
351
|
clientId={ clientId }
|
|
187
352
|
isAppender={ isAppender }
|
|
188
353
|
showInserterHelpPanel={ showInserterHelpPanel }
|
|
@@ -190,223 +355,27 @@ class Inserter extends Component {
|
|
|
190
355
|
);
|
|
191
356
|
}
|
|
192
357
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
position,
|
|
196
|
-
hasSingleBlockType,
|
|
197
|
-
blockToInsert,
|
|
198
|
-
insertOnlyAllowedBlock,
|
|
199
|
-
__experimentalIsQuick: isQuick,
|
|
200
|
-
onSelectOrClose,
|
|
201
|
-
} = this.props;
|
|
202
|
-
|
|
203
|
-
if ( hasSingleBlockType || blockToInsert ) {
|
|
204
|
-
return this.renderToggle( { onToggle: insertOnlyAllowedBlock } );
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return (
|
|
208
|
-
<Dropdown
|
|
209
|
-
className="block-editor-inserter"
|
|
210
|
-
contentClassName={ clsx( 'block-editor-inserter__popover', {
|
|
211
|
-
'is-quick': isQuick,
|
|
212
|
-
} ) }
|
|
213
|
-
popoverProps={ { position, shift: true } }
|
|
214
|
-
onToggle={ this.onToggle }
|
|
215
|
-
expandOnMobile
|
|
216
|
-
headerTitle={ __( 'Add a block' ) }
|
|
217
|
-
renderToggle={ this.renderToggle }
|
|
218
|
-
renderContent={ this.renderContent }
|
|
219
|
-
onClose={ onSelectOrClose }
|
|
220
|
-
/>
|
|
221
|
-
);
|
|
358
|
+
if ( hasSingleBlockType || blockToInsert ) {
|
|
359
|
+
return renderToggle( { onToggle: insertOnlyAllowedBlock } );
|
|
222
360
|
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
export default compose( [
|
|
226
|
-
withSelect(
|
|
227
|
-
( select, { clientId, rootClientId, shouldDirectInsert = true } ) => {
|
|
228
|
-
const {
|
|
229
|
-
getBlockRootClientId,
|
|
230
|
-
hasInserterItems,
|
|
231
|
-
getAllowedBlocks,
|
|
232
|
-
getDirectInsertBlock,
|
|
233
|
-
getBlockListSettings,
|
|
234
|
-
} = select( blockEditorStore );
|
|
235
|
-
const { getBlockVariations, getBlockType } = select( blocksStore );
|
|
236
|
-
|
|
237
|
-
rootClientId =
|
|
238
|
-
rootClientId || getBlockRootClientId( clientId ) || undefined;
|
|
239
|
-
|
|
240
|
-
const allowedBlocks = getAllowedBlocks( rootClientId );
|
|
241
|
-
const directInsertBlock =
|
|
242
|
-
shouldDirectInsert && getDirectInsertBlock( rootClientId );
|
|
243
|
-
const { defaultBlock } = getBlockListSettings( rootClientId ) ?? {};
|
|
244
|
-
|
|
245
|
-
const hasSingleBlockType =
|
|
246
|
-
allowedBlocks?.length === 1 &&
|
|
247
|
-
getBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )
|
|
248
|
-
?.length === 0;
|
|
249
|
-
const allowedBlockType = hasSingleBlockType
|
|
250
|
-
? allowedBlocks[ 0 ]
|
|
251
|
-
: null;
|
|
252
361
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
defaultBlockType
|
|
270
|
-
);
|
|
271
|
-
|
|
272
|
-
return {
|
|
273
|
-
hasItems: hasInserterItems( rootClientId ),
|
|
274
|
-
hasSingleBlockType,
|
|
275
|
-
blockTitle: allowedBlockType ? allowedBlockType.title : '',
|
|
276
|
-
allowedBlockType,
|
|
277
|
-
blockToInsert,
|
|
278
|
-
appenderLabel,
|
|
279
|
-
rootClientId,
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
),
|
|
283
|
-
withDispatch( ( dispatch, ownProps, { select } ) => {
|
|
284
|
-
return {
|
|
285
|
-
insertOnlyAllowedBlock() {
|
|
286
|
-
const {
|
|
287
|
-
rootClientId,
|
|
288
|
-
clientId,
|
|
289
|
-
isAppender,
|
|
290
|
-
hasSingleBlockType,
|
|
291
|
-
allowedBlockType,
|
|
292
|
-
blockToInsert,
|
|
293
|
-
onSelectOrClose,
|
|
294
|
-
selectBlockOnInsert,
|
|
295
|
-
} = ownProps;
|
|
296
|
-
|
|
297
|
-
if ( ! hasSingleBlockType && ! blockToInsert ) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
const blockName = blockToInsert?.name ?? allowedBlockType.name;
|
|
302
|
-
|
|
303
|
-
function getAdjacentBlockAttributes( attributesToCopy ) {
|
|
304
|
-
if ( ! attributesToCopy?.length ) {
|
|
305
|
-
return {};
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const { getBlock, getPreviousBlockClientId } =
|
|
309
|
-
select( blockEditorStore );
|
|
310
|
-
|
|
311
|
-
// Find the adjacent block of the same type whose attributes
|
|
312
|
-
// should be copied: previous sibling when inserting next to
|
|
313
|
-
// an existing block, otherwise the last child of the root.
|
|
314
|
-
let adjacentAttributes;
|
|
315
|
-
if ( clientId ) {
|
|
316
|
-
const currentBlock = getBlock( clientId );
|
|
317
|
-
const previousBlock = getBlock(
|
|
318
|
-
getPreviousBlockClientId( clientId )
|
|
319
|
-
);
|
|
320
|
-
if ( currentBlock?.name === previousBlock?.name ) {
|
|
321
|
-
adjacentAttributes = previousBlock?.attributes;
|
|
322
|
-
}
|
|
323
|
-
} else if ( rootClientId ) {
|
|
324
|
-
const lastInnerBlock =
|
|
325
|
-
getBlock( rootClientId )?.innerBlocks?.at( -1 );
|
|
326
|
-
if ( lastInnerBlock?.name === blockName ) {
|
|
327
|
-
adjacentAttributes = lastInnerBlock.attributes;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
if ( ! adjacentAttributes ) {
|
|
332
|
-
return {};
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
return Object.fromEntries(
|
|
336
|
-
attributesToCopy
|
|
337
|
-
.filter( ( attr ) => attr in adjacentAttributes )
|
|
338
|
-
.map( ( attr ) => [
|
|
339
|
-
attr,
|
|
340
|
-
adjacentAttributes[ attr ],
|
|
341
|
-
] )
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function getInsertionIndex() {
|
|
346
|
-
const {
|
|
347
|
-
getBlockIndex,
|
|
348
|
-
getBlockSelectionEnd,
|
|
349
|
-
getBlockOrder,
|
|
350
|
-
getBlockRootClientId,
|
|
351
|
-
} = select( blockEditorStore );
|
|
352
|
-
|
|
353
|
-
// If the clientId is defined, we insert at the position of the block.
|
|
354
|
-
if ( clientId ) {
|
|
355
|
-
return getBlockIndex( clientId );
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// If there a selected block, we insert after the selected block.
|
|
359
|
-
const end = getBlockSelectionEnd();
|
|
360
|
-
if (
|
|
361
|
-
! isAppender &&
|
|
362
|
-
end &&
|
|
363
|
-
getBlockRootClientId( end ) === rootClientId
|
|
364
|
-
) {
|
|
365
|
-
return getBlockIndex( end ) + 1;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// Otherwise, we insert at the end of the current rootClientId.
|
|
369
|
-
return getBlockOrder( rootClientId ).length;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
const { insertBlock } = dispatch( blockEditorStore );
|
|
373
|
-
|
|
374
|
-
// Attempt to augment the inserted block with attributes from an adjacent block.
|
|
375
|
-
// This ensures styling from nearby blocks is preserved in the newly inserted block.
|
|
376
|
-
// See: https://github.com/WordPress/gutenberg/issues/37904
|
|
377
|
-
const newAttributes = getAdjacentBlockAttributes(
|
|
378
|
-
blockToInsert?.attributesToCopy
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
const newBlock = createBlock( blockName, {
|
|
382
|
-
...( blockToInsert?.attributes || {} ),
|
|
383
|
-
...newAttributes,
|
|
384
|
-
} );
|
|
385
|
-
|
|
386
|
-
insertBlock(
|
|
387
|
-
newBlock,
|
|
388
|
-
getInsertionIndex(),
|
|
389
|
-
rootClientId,
|
|
390
|
-
selectBlockOnInsert
|
|
391
|
-
);
|
|
362
|
+
return (
|
|
363
|
+
<Dropdown
|
|
364
|
+
className="block-editor-inserter"
|
|
365
|
+
contentClassName={ clsx( 'block-editor-inserter__popover', {
|
|
366
|
+
'is-quick': isQuick,
|
|
367
|
+
} ) }
|
|
368
|
+
popoverProps={ { position, shift: true } }
|
|
369
|
+
onToggle={ onToggle }
|
|
370
|
+
expandOnMobile
|
|
371
|
+
headerTitle={ __( 'Add a block' ) }
|
|
372
|
+
renderToggle={ renderToggle }
|
|
373
|
+
renderContent={ renderContent }
|
|
374
|
+
onClose={ onSelectOrClose }
|
|
375
|
+
/>
|
|
376
|
+
);
|
|
377
|
+
};
|
|
392
378
|
|
|
393
|
-
|
|
394
|
-
onSelectOrClose( newBlock );
|
|
395
|
-
}
|
|
379
|
+
const Inserter = forwardRef( UnforwardedInserter );
|
|
396
380
|
|
|
397
|
-
|
|
398
|
-
// translators: %s: the name of the block that has been added
|
|
399
|
-
__( '%s block added' ),
|
|
400
|
-
allowedBlockType.title
|
|
401
|
-
);
|
|
402
|
-
speak( message );
|
|
403
|
-
},
|
|
404
|
-
};
|
|
405
|
-
} ),
|
|
406
|
-
// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as
|
|
407
|
-
// a way to detect the global Inserter.
|
|
408
|
-
ifCondition(
|
|
409
|
-
( { hasItems, isAppender, rootClientId, clientId } ) =>
|
|
410
|
-
hasItems || ( ! isAppender && ! rootClientId && ! clientId )
|
|
411
|
-
),
|
|
412
|
-
] )( Inserter );
|
|
381
|
+
export default Inserter;
|
|
@@ -181,9 +181,7 @@ function InserterSearchResults( {
|
|
|
181
181
|
|
|
182
182
|
const patternsUI = !! filteredBlockPatterns.length && (
|
|
183
183
|
<InserterPanel
|
|
184
|
-
title={
|
|
185
|
-
<VisuallyHidden>{ __( 'Block patterns' ) }</VisuallyHidden>
|
|
186
|
-
}
|
|
184
|
+
title={ <VisuallyHidden>{ __( 'Patterns' ) }</VisuallyHidden> }
|
|
187
185
|
>
|
|
188
186
|
<div className="block-editor-inserter__quick-inserter-patterns">
|
|
189
187
|
<BlockPatternsList
|
|
@@ -27,7 +27,7 @@ const MyJustifyToolbar = ( { attributes, setAttributes } ) => (
|
|
|
27
27
|
);
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
**NOTE:** The
|
|
30
|
+
**NOTE:** The justify toolbar does not add any classes to your component, you must do this using the `setAttributes` function. The toolbar does define the following classnames you should use:
|
|
31
31
|
|
|
32
32
|
items-justified-left
|
|
33
33
|
items-justified-center
|
|
@@ -36,7 +36,6 @@ import { useBlockLock } from '../block-lock';
|
|
|
36
36
|
import useListViewImages from './use-list-view-images';
|
|
37
37
|
import { store as blockEditorStore } from '../../store';
|
|
38
38
|
import { unlock } from '../../lock-unlock';
|
|
39
|
-
import { getBlockVisibilityLabel } from '../block-visibility';
|
|
40
39
|
|
|
41
40
|
const { Badge: WCBadge } = unlock( componentsPrivateApis );
|
|
42
41
|
|
|
@@ -55,6 +54,7 @@ function ListViewBlockSelectButton(
|
|
|
55
54
|
draggable,
|
|
56
55
|
isExpanded,
|
|
57
56
|
ariaDescribedBy,
|
|
57
|
+
visibilityLabel,
|
|
58
58
|
},
|
|
59
59
|
ref
|
|
60
60
|
) {
|
|
@@ -64,14 +64,10 @@ function ListViewBlockSelectButton(
|
|
|
64
64
|
context: 'list-view',
|
|
65
65
|
} );
|
|
66
66
|
const { isLocked } = useBlockLock( clientId );
|
|
67
|
-
const
|
|
67
|
+
const hasPatternName = useSelect(
|
|
68
68
|
( select ) => {
|
|
69
69
|
const { getBlockAttributes } = unlock( select( blockEditorStore ) );
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
hasPatternName: !! attributes?.metadata?.patternName,
|
|
73
|
-
blockVisibility: attributes?.metadata?.blockVisibility,
|
|
74
|
-
};
|
|
70
|
+
return !! getBlockAttributes( clientId )?.metadata?.patternName;
|
|
75
71
|
},
|
|
76
72
|
[ clientId ]
|
|
77
73
|
);
|
|
@@ -80,9 +76,6 @@ function ListViewBlockSelectButton(
|
|
|
80
76
|
const isSticky = blockInformation?.positionType === 'sticky';
|
|
81
77
|
const images = useListViewImages( { clientId, isExpanded } );
|
|
82
78
|
|
|
83
|
-
// Determine visibility label from blockVisibility metadata
|
|
84
|
-
const visibilityLabel = getBlockVisibilityLabel( blockVisibility );
|
|
85
|
-
|
|
86
79
|
// The `href` attribute triggers the browser's native HTML drag operations.
|
|
87
80
|
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
88
81
|
// We need to clear any HTML drag data to prevent `pasteHandler` from firing
|
|
@@ -166,9 +159,12 @@ function ListViewBlockSelectButton(
|
|
|
166
159
|
</span>
|
|
167
160
|
) : null }
|
|
168
161
|
{ !! visibilityLabel && (
|
|
169
|
-
//
|
|
170
|
-
//
|
|
171
|
-
// `
|
|
162
|
+
// The tooltip below is a sighted-hover affordance for
|
|
163
|
+
// the (decorative) visibility icon. The same
|
|
164
|
+
// `visibilityLabel` is exposed to assistive technology
|
|
165
|
+
// via the row's `aria-describedby`, which references the
|
|
166
|
+
// hidden `AriaReferencedText` rendered by the parent
|
|
167
|
+
// `ListViewBlock`.
|
|
172
168
|
<Tooltip.Root>
|
|
173
169
|
<Tooltip.Trigger
|
|
174
170
|
render={
|
|
@@ -630,6 +630,7 @@ function ListViewBlock( {
|
|
|
630
630
|
isExpanded={ canEditBlock ? isExpanded : undefined }
|
|
631
631
|
selectedClientIds={ selectedClientIds }
|
|
632
632
|
ariaDescribedBy={ descriptionId }
|
|
633
|
+
visibilityLabel={ blockVisibilityDescription }
|
|
633
634
|
/>
|
|
634
635
|
<AriaReferencedText id={ descriptionId }>
|
|
635
636
|
{ [
|