@wordpress/block-editor 15.20.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 +18 -0
- package/build/components/block-compare/index.cjs +2 -2
- package/build/components/block-compare/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/index.cjs +1 -1
- package/build/components/block-list/use-block-props/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/child-layout-control/index.cjs +10 -5
- package/build/components/child-layout-control/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 +5 -4
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/iframe/index.cjs +3 -0
- package/build/components/iframe/index.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/media-tab/utils.cjs +1 -1
- package/build/components/inserter/media-tab/utils.cjs.map +2 -2
- 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 +29 -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-list/use-block-props/index.mjs +1 -1
- package/build-module/components/block-list/use-block-props/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/child-layout-control/index.mjs +10 -5
- package/build-module/components/child-layout-control/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 +9 -6
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/iframe/index.mjs +3 -0
- package/build-module/components/iframe/index.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/media-tab/utils.mjs +1 -1
- package/build-module/components/inserter/media-tab/utils.mjs.map +2 -2
- 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 +26 -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 +51 -48
- 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-list/use-block-props/index.js +1 -1
- 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/child-layout-control/index.js +15 -8
- package/src/components/child-layout-control/test/index.js +126 -0
- package/src/components/colors/test/with-colors.js +1 -1
- 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 +23 -16
- package/src/components/iframe/index.js +3 -0
- 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/media-tab/utils.js +1 -1
- 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 +59 -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/private-selectors.js +53 -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
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useWindowDimensions } from 'react-native';
|
|
5
|
-
import {
|
|
6
|
-
useSharedValue,
|
|
7
|
-
useAnimatedRef,
|
|
8
|
-
scrollTo,
|
|
9
|
-
useAnimatedReaction,
|
|
10
|
-
withTiming,
|
|
11
|
-
withRepeat,
|
|
12
|
-
cancelAnimation,
|
|
13
|
-
Easing,
|
|
14
|
-
} from 'react-native-reanimated';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
import { useBlockListContext } from '../block-list/block-list-context';
|
|
20
|
-
|
|
21
|
-
const SCROLL_INACTIVE_DISTANCE_PX = 50;
|
|
22
|
-
const SCROLL_INTERVAL_MS = 1000;
|
|
23
|
-
const VELOCITY_MULTIPLIER = 5000;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* React hook that scrolls the scroll container when a block is being dragged.
|
|
27
|
-
*
|
|
28
|
-
* @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`
|
|
29
|
-
* functions to be called in `onDragStart`, `onDragOver`
|
|
30
|
-
* and `onDragEnd` events respectively. Additionally,
|
|
31
|
-
* `scrollHandler` function is returned which should be
|
|
32
|
-
* called in the `onScroll` event of the block list.
|
|
33
|
-
*/
|
|
34
|
-
export default function useScrollWhenDragging() {
|
|
35
|
-
const { scrollRef } = useBlockListContext();
|
|
36
|
-
const animatedScrollRef = useAnimatedRef();
|
|
37
|
-
animatedScrollRef( scrollRef?.scrollViewRef );
|
|
38
|
-
|
|
39
|
-
const { height: windowHeight } = useWindowDimensions();
|
|
40
|
-
|
|
41
|
-
const velocityY = useSharedValue( 0 );
|
|
42
|
-
const offsetY = useSharedValue( 0 );
|
|
43
|
-
const dragStartY = useSharedValue( 0 );
|
|
44
|
-
const animationTimer = useSharedValue( 0 );
|
|
45
|
-
const isAnimationTimerActive = useSharedValue( false );
|
|
46
|
-
const isScrollActive = useSharedValue( false );
|
|
47
|
-
|
|
48
|
-
const scroll = {
|
|
49
|
-
offsetY: useSharedValue( 0 ),
|
|
50
|
-
maxOffsetY: useSharedValue( 0 ),
|
|
51
|
-
};
|
|
52
|
-
const scrollHandler = ( event ) => {
|
|
53
|
-
'worklet';
|
|
54
|
-
const { contentSize, contentOffset, layoutMeasurement } = event;
|
|
55
|
-
scroll.offsetY.value = contentOffset.y;
|
|
56
|
-
scroll.maxOffsetY.value = contentSize.height - layoutMeasurement.height;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const stopScrolling = () => {
|
|
60
|
-
'worklet';
|
|
61
|
-
cancelAnimation( animationTimer );
|
|
62
|
-
|
|
63
|
-
isAnimationTimerActive.value = false;
|
|
64
|
-
isScrollActive.value = false;
|
|
65
|
-
velocityY.value = 0;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const startScrolling = ( y ) => {
|
|
69
|
-
'worklet';
|
|
70
|
-
stopScrolling();
|
|
71
|
-
offsetY.value = scroll.offsetY.value;
|
|
72
|
-
dragStartY.value = y;
|
|
73
|
-
|
|
74
|
-
animationTimer.value = 0;
|
|
75
|
-
animationTimer.value = withRepeat(
|
|
76
|
-
withTiming( 1, {
|
|
77
|
-
duration: SCROLL_INTERVAL_MS,
|
|
78
|
-
easing: Easing.linear,
|
|
79
|
-
} ),
|
|
80
|
-
-1,
|
|
81
|
-
true
|
|
82
|
-
);
|
|
83
|
-
isAnimationTimerActive.value = true;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const scrollOnDragOver = ( y ) => {
|
|
87
|
-
'worklet';
|
|
88
|
-
const dragDistance = Math.max(
|
|
89
|
-
Math.abs( y - dragStartY.value ) - SCROLL_INACTIVE_DISTANCE_PX,
|
|
90
|
-
0
|
|
91
|
-
);
|
|
92
|
-
const distancePercentage = dragDistance / windowHeight;
|
|
93
|
-
|
|
94
|
-
if ( ! isScrollActive.value ) {
|
|
95
|
-
isScrollActive.value = dragDistance > 0;
|
|
96
|
-
} else if ( y > dragStartY.value ) {
|
|
97
|
-
// User is dragging downwards.
|
|
98
|
-
velocityY.value = VELOCITY_MULTIPLIER * distancePercentage;
|
|
99
|
-
} else if ( y < dragStartY.value ) {
|
|
100
|
-
// User is dragging upwards.
|
|
101
|
-
velocityY.value = -VELOCITY_MULTIPLIER * distancePercentage;
|
|
102
|
-
} else {
|
|
103
|
-
velocityY.value = 0;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
useAnimatedReaction(
|
|
108
|
-
() => animationTimer.value,
|
|
109
|
-
( value, previous ) => {
|
|
110
|
-
if ( velocityY.value === 0 ) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const delta = Math.abs( value - previous );
|
|
115
|
-
let newOffset = offsetY.value + delta * velocityY.value;
|
|
116
|
-
|
|
117
|
-
if ( scroll.maxOffsetY.value !== 0 ) {
|
|
118
|
-
newOffset = Math.max(
|
|
119
|
-
0,
|
|
120
|
-
Math.min( scroll.maxOffsetY.value, newOffset )
|
|
121
|
-
);
|
|
122
|
-
} else {
|
|
123
|
-
// Scroll values are empty until receiving the first scroll event.
|
|
124
|
-
// In that case, the max offset is unknown and we can't clamp the
|
|
125
|
-
// new offset value.
|
|
126
|
-
newOffset = Math.max( 0, newOffset );
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
offsetY.value = newOffset;
|
|
130
|
-
scrollTo( animatedScrollRef, 0, offsetY.value, false );
|
|
131
|
-
}
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
return [ startScrolling, scrollOnDragOver, stopScrolling, scrollHandler ];
|
|
135
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { withFilters } from '@wordpress/components';
|
|
5
|
-
import { getBlockType } from '@wordpress/blocks';
|
|
6
|
-
import { useContext, useMemo } from '@wordpress/element';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
import BlockContext from '../block-context';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Default value used for blocks which do not define their own context needs,
|
|
15
|
-
* used to guarantee that a block's `context` prop will always be an object. It
|
|
16
|
-
* is assigned as a constant since it is always expected to be an empty object,
|
|
17
|
-
* and in order to avoid unnecessary React reconciliations of a changing object.
|
|
18
|
-
*
|
|
19
|
-
* @type {{}}
|
|
20
|
-
*/
|
|
21
|
-
const DEFAULT_BLOCK_CONTEXT = {};
|
|
22
|
-
|
|
23
|
-
export const Edit = ( props ) => {
|
|
24
|
-
const { name } = props;
|
|
25
|
-
const blockType = getBlockType( name );
|
|
26
|
-
|
|
27
|
-
const blockContext = useContext( BlockContext );
|
|
28
|
-
|
|
29
|
-
// Assign context values using the block type's declared context needs.
|
|
30
|
-
const context = useMemo( () => {
|
|
31
|
-
return blockType && blockType.usesContext
|
|
32
|
-
? Object.fromEntries(
|
|
33
|
-
Object.entries( blockContext ).filter( ( [ key ] ) =>
|
|
34
|
-
blockType.usesContext.includes( key )
|
|
35
|
-
)
|
|
36
|
-
)
|
|
37
|
-
: DEFAULT_BLOCK_CONTEXT;
|
|
38
|
-
}, [ blockType, blockContext ] );
|
|
39
|
-
|
|
40
|
-
if ( ! blockType ) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const Component = blockType.edit;
|
|
45
|
-
|
|
46
|
-
return <Component { ...props } context={ context } />;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default withFilters( 'editor.BlockEdit' )( Edit );
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { render } from 'test/helpers';
|
|
5
|
-
import { Text } from 'react-native';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import {
|
|
11
|
-
registerBlockType,
|
|
12
|
-
unregisterBlockType,
|
|
13
|
-
getBlockTypes,
|
|
14
|
-
} from '@wordpress/blocks';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
import { Edit } from '../edit';
|
|
20
|
-
import { BlockContextProvider } from '../../block-context';
|
|
21
|
-
|
|
22
|
-
describe( 'Edit', () => {
|
|
23
|
-
afterEach( () => {
|
|
24
|
-
getBlockTypes().forEach( ( block ) => {
|
|
25
|
-
unregisterBlockType( block.name );
|
|
26
|
-
} );
|
|
27
|
-
} );
|
|
28
|
-
|
|
29
|
-
it( 'should return null if block type not defined', () => {
|
|
30
|
-
const screen = render( <Edit name="core/test-block" /> );
|
|
31
|
-
|
|
32
|
-
expect( screen.toJSON() ).toBe( null );
|
|
33
|
-
} );
|
|
34
|
-
|
|
35
|
-
it( 'should use edit implementation of block', () => {
|
|
36
|
-
const edit = () => <Text>core/test-block</Text>;
|
|
37
|
-
registerBlockType( 'core/test-block', {
|
|
38
|
-
category: 'text',
|
|
39
|
-
title: 'block title',
|
|
40
|
-
edit,
|
|
41
|
-
} );
|
|
42
|
-
|
|
43
|
-
const screen = render( <Edit name="core/test-block" /> );
|
|
44
|
-
|
|
45
|
-
expect( screen.getByText( 'core/test-block' ) ).toBeDefined();
|
|
46
|
-
} );
|
|
47
|
-
|
|
48
|
-
it( 'should assign context', () => {
|
|
49
|
-
const edit = ( { context } ) => <Text>{ context.value }</Text>;
|
|
50
|
-
registerBlockType( 'core/test-block', {
|
|
51
|
-
category: 'text',
|
|
52
|
-
title: 'block title',
|
|
53
|
-
usesContext: [ 'value' ],
|
|
54
|
-
edit,
|
|
55
|
-
} );
|
|
56
|
-
|
|
57
|
-
const screen = render(
|
|
58
|
-
<BlockContextProvider value={ { value: 'Ok' } }>
|
|
59
|
-
<Edit name="core/test-block" />
|
|
60
|
-
</BlockContextProvider>
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
expect( screen.getByText( 'Ok' ) ).toBeDefined();
|
|
64
|
-
} );
|
|
65
|
-
} );
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
-
import { DropdownMenu } from '@wordpress/components';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import HeadingLevelIcon from './heading-level-icon';
|
|
11
|
-
|
|
12
|
-
const HEADING_LEVELS = [ 1, 2, 3, 4, 5, 6 ];
|
|
13
|
-
|
|
14
|
-
/** @typedef {React.ComponentType} ComponentType */
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* HeadingLevelDropdown props.
|
|
18
|
-
*
|
|
19
|
-
* @typedef WPHeadingLevelDropdownProps
|
|
20
|
-
*
|
|
21
|
-
* @property {number} value The chosen heading level.
|
|
22
|
-
* @property {number[]} options An array of supported heading levels.
|
|
23
|
-
* @property {()=>number} onChange Function called with
|
|
24
|
-
* the selected value changes.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Dropdown for selecting a heading level (1 through 6).
|
|
29
|
-
*
|
|
30
|
-
* @param {WPHeadingLevelDropdownProps} props Component props.
|
|
31
|
-
*
|
|
32
|
-
* @return {ComponentType} The toolbar.
|
|
33
|
-
*/
|
|
34
|
-
export default function HeadingLevelDropdown( {
|
|
35
|
-
options = HEADING_LEVELS,
|
|
36
|
-
value,
|
|
37
|
-
onChange,
|
|
38
|
-
} ) {
|
|
39
|
-
const createLevelControl = (
|
|
40
|
-
targetLevel,
|
|
41
|
-
currentLevel,
|
|
42
|
-
onChangeCallback
|
|
43
|
-
) => {
|
|
44
|
-
const isActive = targetLevel === currentLevel;
|
|
45
|
-
return {
|
|
46
|
-
icon: (
|
|
47
|
-
<HeadingLevelIcon
|
|
48
|
-
level={ targetLevel }
|
|
49
|
-
isPressed={ isActive }
|
|
50
|
-
/>
|
|
51
|
-
),
|
|
52
|
-
// translators: %d: heading level e.g: "1", "2", "3"
|
|
53
|
-
title: sprintf( __( 'Heading %d' ), targetLevel ),
|
|
54
|
-
isActive,
|
|
55
|
-
onClick: () => onChangeCallback( targetLevel ),
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<DropdownMenu
|
|
61
|
-
icon={ <HeadingLevelIcon level={ value } /> }
|
|
62
|
-
controls={ options.map( ( index ) =>
|
|
63
|
-
createLevelControl( index, value, onChange )
|
|
64
|
-
) }
|
|
65
|
-
label={ __( 'Change level' ) }
|
|
66
|
-
/>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { View } from 'react-native';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { Icon as WCIcon } from '@wordpress/components';
|
|
10
|
-
import { blockDefault } from '@wordpress/icons';
|
|
11
|
-
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import styles from './style.scss';
|
|
17
|
-
|
|
18
|
-
export function BlockIcon( { icon, fill, size, showColors = false } ) {
|
|
19
|
-
if ( icon?.src === 'block-default' ) {
|
|
20
|
-
icon = {
|
|
21
|
-
src: blockDefault,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const defaultFill = usePreferredColorSchemeStyle(
|
|
26
|
-
styles.iconPlaceholder,
|
|
27
|
-
styles.iconPlaceholderDark
|
|
28
|
-
)?.fill;
|
|
29
|
-
const iconForeground = showColors ? icon?.foreground : undefined;
|
|
30
|
-
|
|
31
|
-
const renderedIcon = (
|
|
32
|
-
<WCIcon
|
|
33
|
-
icon={ icon && icon.src ? icon.src : icon }
|
|
34
|
-
fill={ fill || iconForeground || defaultFill }
|
|
35
|
-
{ ...( size && { size } ) }
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
const style = showColors
|
|
39
|
-
? {
|
|
40
|
-
backgroundColor: icon && icon.background,
|
|
41
|
-
}
|
|
42
|
-
: {};
|
|
43
|
-
|
|
44
|
-
return <View style={ style }>{ renderedIcon }</View>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default BlockIcon;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { Component } from '@wordpress/element';
|
|
5
|
-
import { logException } from '@wordpress/react-native-bridge';
|
|
6
|
-
|
|
7
|
-
class BlockCrashBoundary extends Component {
|
|
8
|
-
constructor() {
|
|
9
|
-
super( ...arguments );
|
|
10
|
-
|
|
11
|
-
this.state = {
|
|
12
|
-
error: null,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static getDerivedStateFromError( error ) {
|
|
17
|
-
return { error };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
componentDidCatch( error ) {
|
|
21
|
-
const { blockName } = this.props;
|
|
22
|
-
|
|
23
|
-
logException( error, {
|
|
24
|
-
context: {
|
|
25
|
-
component_stack: error.componentStack,
|
|
26
|
-
block_name: blockName,
|
|
27
|
-
},
|
|
28
|
-
isHandled: true,
|
|
29
|
-
handledBy: 'Block-level Error Boundary',
|
|
30
|
-
} );
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
render() {
|
|
34
|
-
const { error } = this.state;
|
|
35
|
-
if ( ! error ) {
|
|
36
|
-
return this.props.children;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return this.props.fallback;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default BlockCrashBoundary;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import Warning from '../warning';
|
|
10
|
-
|
|
11
|
-
const warning = (
|
|
12
|
-
<Warning
|
|
13
|
-
message={ __(
|
|
14
|
-
'This block has encountered an error and cannot be previewed.'
|
|
15
|
-
) }
|
|
16
|
-
/>
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export default function BlockCrashWarning() {
|
|
20
|
-
return warning;
|
|
21
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { TouchableWithoutFeedback } from 'react-native';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
10
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
11
|
-
import { createBlock, getBlockType } from '@wordpress/blocks';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import Warning from '../warning';
|
|
17
|
-
import { store as blockEditorStore } from '../../store';
|
|
18
|
-
|
|
19
|
-
export default function BlockInvalidWarning( { clientId } ) {
|
|
20
|
-
const selector = ( select ) => {
|
|
21
|
-
const { getBlock } = select( blockEditorStore );
|
|
22
|
-
const block = getBlock( clientId );
|
|
23
|
-
const { name } = block || {};
|
|
24
|
-
|
|
25
|
-
const blockType = getBlockType( name || 'core/missing' );
|
|
26
|
-
const title = blockType?.title;
|
|
27
|
-
const blockIcon = blockType?.icon;
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
block,
|
|
31
|
-
blockTitle: title,
|
|
32
|
-
icon: blockIcon,
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const { block, blockTitle, icon } = useSelect( selector, [ clientId ] );
|
|
37
|
-
|
|
38
|
-
const accessibilityLabel = sprintf(
|
|
39
|
-
/* translators: accessibility text for blocks with invalid content. %s: localized block title */
|
|
40
|
-
__( '%s block. This block has invalid content' ),
|
|
41
|
-
blockTitle
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const { replaceBlock } = useDispatch( blockEditorStore );
|
|
45
|
-
|
|
46
|
-
const recoverBlock = ( { name, attributes, innerBlocks } ) =>
|
|
47
|
-
createBlock( name, attributes, innerBlocks );
|
|
48
|
-
|
|
49
|
-
const attemptBlockRecovery = () => {
|
|
50
|
-
replaceBlock( block.clientId, recoverBlock( block ) );
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<TouchableWithoutFeedback
|
|
55
|
-
onPress={ attemptBlockRecovery }
|
|
56
|
-
accessible
|
|
57
|
-
accessibilityRole="button"
|
|
58
|
-
>
|
|
59
|
-
<Warning
|
|
60
|
-
title={ blockTitle }
|
|
61
|
-
// eslint-disable-next-line @wordpress/i18n-no-collapsible-whitespace
|
|
62
|
-
message={ __(
|
|
63
|
-
'Problem displaying block. \nTap to attempt block recovery.'
|
|
64
|
-
) }
|
|
65
|
-
icon={ icon }
|
|
66
|
-
accessibilityLabel={ accessibilityLabel }
|
|
67
|
-
/>
|
|
68
|
-
</TouchableWithoutFeedback>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createContext, useContext } from '@wordpress/element';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { orderBy } from '../../utils/sorting';
|
|
10
|
-
|
|
11
|
-
export const DEFAULT_BLOCK_LIST_CONTEXT = {
|
|
12
|
-
scrollRef: null,
|
|
13
|
-
blocksLayouts: { current: {} },
|
|
14
|
-
findBlockLayoutByClientId,
|
|
15
|
-
getBlockLayoutsOrderedByYCoord,
|
|
16
|
-
findBlockLayoutByPosition,
|
|
17
|
-
updateBlocksLayouts,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const Context = createContext( DEFAULT_BLOCK_LIST_CONTEXT );
|
|
21
|
-
const { Provider, Consumer } = Context;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Finds a block's layout data by position.
|
|
25
|
-
*
|
|
26
|
-
* @param {Object} data Blocks layouts object.
|
|
27
|
-
* @param {Object} position Position to use for finding the block.
|
|
28
|
-
* @param {number} position.x X coordinate.
|
|
29
|
-
* @param {number} position.y Y coordinate.
|
|
30
|
-
*
|
|
31
|
-
* @return {Object|undefined} Found block layout data that matches the provided position. If none is found, `undefined` will be returned.
|
|
32
|
-
*/
|
|
33
|
-
function findBlockLayoutByPosition( data, position ) {
|
|
34
|
-
// Only enabled for root level blocks
|
|
35
|
-
return Object.values( data ).find( ( block ) => {
|
|
36
|
-
return (
|
|
37
|
-
position.x >= block.x &&
|
|
38
|
-
position.x <= block.x + block.width &&
|
|
39
|
-
position.y >= block.y &&
|
|
40
|
-
position.y <= block.y + block.height
|
|
41
|
-
);
|
|
42
|
-
} );
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Finds a block's layout data by its client Id.
|
|
47
|
-
*
|
|
48
|
-
* @param {Object} data Blocks layouts object.
|
|
49
|
-
* @param {string} clientId Block's clientId.
|
|
50
|
-
*
|
|
51
|
-
* @return {Object} Found block layout data.
|
|
52
|
-
*/
|
|
53
|
-
function findBlockLayoutByClientId( data, clientId ) {
|
|
54
|
-
return Object.entries( data ).reduce( ( acc, entry ) => {
|
|
55
|
-
const item = entry[ 1 ];
|
|
56
|
-
if ( acc ) {
|
|
57
|
-
return acc;
|
|
58
|
-
}
|
|
59
|
-
if ( item?.clientId === clientId ) {
|
|
60
|
-
return item;
|
|
61
|
-
}
|
|
62
|
-
if ( item?.innerBlocks && Object.keys( item.innerBlocks ).length > 0 ) {
|
|
63
|
-
return findBlockLayoutByClientId( item.innerBlocks, clientId );
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}, null );
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Deletes the layout data of a block by its client Id.
|
|
71
|
-
*
|
|
72
|
-
* @param {Object} data Blocks layouts object.
|
|
73
|
-
* @param {string} clientId Block's clientsId.
|
|
74
|
-
*
|
|
75
|
-
* @return {Object} Updated data object.
|
|
76
|
-
*/
|
|
77
|
-
export function deleteBlockLayoutByClientId( data, clientId ) {
|
|
78
|
-
return Object.keys( data ).reduce( ( acc, key ) => {
|
|
79
|
-
if ( key !== clientId ) {
|
|
80
|
-
acc[ key ] = data[ key ];
|
|
81
|
-
}
|
|
82
|
-
if (
|
|
83
|
-
data[ key ]?.innerBlocks &&
|
|
84
|
-
Object.keys( data[ key ].innerBlocks ).length > 0
|
|
85
|
-
) {
|
|
86
|
-
if ( acc[ key ] ) {
|
|
87
|
-
acc[ key ].innerBlocks = deleteBlockLayoutByClientId(
|
|
88
|
-
data[ key ].innerBlocks,
|
|
89
|
-
clientId
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return acc;
|
|
94
|
-
}, {} );
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Orders the block's layout data by its Y coordinate.
|
|
99
|
-
*
|
|
100
|
-
* @param {Object} data Blocks layouts object.
|
|
101
|
-
*
|
|
102
|
-
* @return {Object} Blocks layouts object ordered by its Y coordinate.
|
|
103
|
-
*/
|
|
104
|
-
function getBlockLayoutsOrderedByYCoord( data ) {
|
|
105
|
-
// Only enabled for root level blocks.
|
|
106
|
-
return orderBy( Object.values( data ), 'y' );
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Updates or deletes a block's layout data in the blocksLayouts object,
|
|
111
|
-
* in case of deletion, the layout data is not required.
|
|
112
|
-
*
|
|
113
|
-
* @param {Object} blocksLayouts Blocks layouts object.
|
|
114
|
-
* @param {Object} blockData Block's layout data to add or remove to/from the blockLayouts object.
|
|
115
|
-
* @param {string} blockData.clientId Block's clientId.
|
|
116
|
-
* @param {?string} blockData.rootClientId Optional. Block's rootClientId.
|
|
117
|
-
* @param {?boolean} blockData.shouldRemove Optional. Flag to remove it from the blocksLayout list.
|
|
118
|
-
* @param {number} blockData.width Block's width.
|
|
119
|
-
* @param {number} blockData.height Block's height.
|
|
120
|
-
* @param {number} blockData.x Block's x coordinate (relative to the parent).
|
|
121
|
-
* @param {number} blockData.y Block's y coordinate (relative to the parent).
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
function updateBlocksLayouts( blocksLayouts, blockData ) {
|
|
125
|
-
const { clientId, rootClientId, shouldRemove, ...layoutProps } = blockData;
|
|
126
|
-
|
|
127
|
-
if ( clientId && shouldRemove ) {
|
|
128
|
-
blocksLayouts.current = deleteBlockLayoutByClientId(
|
|
129
|
-
blocksLayouts.current,
|
|
130
|
-
clientId
|
|
131
|
-
);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if ( clientId && ! rootClientId ) {
|
|
136
|
-
blocksLayouts.current[ clientId ] = {
|
|
137
|
-
clientId,
|
|
138
|
-
rootClientId,
|
|
139
|
-
...layoutProps,
|
|
140
|
-
innerBlocks: {
|
|
141
|
-
...blocksLayouts.current[ clientId ]?.innerBlocks,
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
} else if ( clientId && rootClientId ) {
|
|
145
|
-
const block = findBlockLayoutByClientId(
|
|
146
|
-
blocksLayouts.current,
|
|
147
|
-
rootClientId
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
if ( block ) {
|
|
151
|
-
block.innerBlocks[ clientId ] = {
|
|
152
|
-
clientId,
|
|
153
|
-
rootClientId,
|
|
154
|
-
...layoutProps,
|
|
155
|
-
innerBlocks: {
|
|
156
|
-
...block.innerBlocks[ clientId ]?.innerBlocks,
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export { Provider as BlockListProvider, Consumer as BlockListConsumer };
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Hook that returns the block list context.
|
|
167
|
-
*
|
|
168
|
-
* @return {Object} Block list context
|
|
169
|
-
*/
|
|
170
|
-
export const useBlockListContext = () => {
|
|
171
|
-
return useContext( Context );
|
|
172
|
-
};
|