@wordpress/block-editor 10.4.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +0 -1
- package/build/autocompleters/block.js +2 -6
- package/build/autocompleters/block.js.map +1 -1
- package/build/autocompleters/link.js +2 -0
- package/build/autocompleters/link.js.map +1 -1
- package/build/components/block-card/index.js +51 -3
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +46 -39
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +4 -3
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-edit/edit.native.js +4 -7
- package/build/components/block-edit/edit.native.js.map +1 -1
- package/build/components/block-inspector/index.js +35 -33
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-context.native.js +5 -8
- package/build/components/block-list/block-list-context.native.js.map +1 -1
- package/build/components/block-list/block.js +55 -24
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +61 -28
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-lock/menu-item.js +1 -1
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +16 -9
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +12 -4
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +3 -2
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +33 -11
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +9 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +5 -9
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/utils.js +3 -3
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/index.js +19 -4
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +8 -49
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +27 -4
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-variation-picker/index.js +1 -2
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/colors/with-colors.js +4 -3
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +24 -40
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +7 -5
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/height-control/index.js +115 -0
- package/build/components/height-control/index.js.map +1 -0
- package/build/components/iframe/index.js +11 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +2 -0
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/zoom-dropdown.js +1 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +25 -9
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +25 -10
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +25 -46
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +3 -1
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +27 -0
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build/components/inserter/index.js +8 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +3 -4
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +103 -0
- package/build/components/inserter/media-tab/hooks.js.map +1 -0
- package/build/components/inserter/media-tab/index.js +32 -0
- package/build/components/inserter/media-tab/index.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +100 -0
- package/build/components/inserter/media-tab/media-list.js.map +1 -0
- package/build/components/inserter/media-tab/media-panel.js +96 -0
- package/build/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build/components/inserter/media-tab/media-tab.js +120 -0
- package/build/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build/components/inserter/media-tab/utils.js +54 -0
- package/build/components/inserter/media-tab/utils.js.map +1 -0
- package/build/components/inserter/menu.js +35 -12
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +70 -0
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build/components/inserter/quick-inserter.js +1 -0
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter/search-results.js +3 -1
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +16 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-list-item/index.js +4 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/index.js +71 -0
- package/build/components/inspector-controls-tabs/index.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +28 -0
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/styles-tab.js +61 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +97 -0
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +18 -0
- package/build/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build/components/inspector-controls-tabs/utils.js +37 -0
- package/build/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build/components/link-control/index.js +19 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -2
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +26 -0
- package/build/components/link-control/use-internal-input-value.js.map +1 -0
- package/build/components/list-view/block.js +10 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +22 -15
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-upload/index.native.js +2 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +104 -0
- package/build/components/off-canvas-editor/appender.js.map +1 -0
- package/build/components/off-canvas-editor/block-contents.js +100 -0
- package/build/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build/components/off-canvas-editor/block-edit-button.js +50 -0
- package/build/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build/components/off-canvas-editor/block-select-button.js +119 -0
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build/components/off-canvas-editor/block.js +324 -0
- package/build/components/off-canvas-editor/block.js.map +1 -0
- package/build/components/off-canvas-editor/branch.js +179 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -0
- package/build/components/off-canvas-editor/context.js +19 -0
- package/build/components/off-canvas-editor/context.js.map +1 -0
- package/build/components/off-canvas-editor/drop-indicator.js +118 -0
- package/build/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build/components/off-canvas-editor/expander.js +41 -0
- package/build/components/off-canvas-editor/expander.js.map +1 -0
- package/build/components/off-canvas-editor/index.js +213 -0
- package/build/components/off-canvas-editor/index.js.map +1 -0
- package/build/components/off-canvas-editor/leaf.js +60 -0
- package/build/components/off-canvas-editor/leaf.js.map +1 -0
- package/build/components/off-canvas-editor/link-ui.js +185 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build/components/off-canvas-editor/update-attributes.js +108 -0
- package/build/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build/components/off-canvas-editor/use-block-selection.js +139 -0
- package/build/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +33 -0
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +235 -0
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +60 -0
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build/components/off-canvas-editor/utils.js +60 -0
- package/build/components/off-canvas-editor/utils.js.map +1 -0
- package/build/components/rich-text/format-toolbar/index.js +8 -4
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +3 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-insert-replacement-text.js +43 -0
- package/build/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build/components/rich-text/utils.js +1 -19
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/ungroup-button/index.native.js +4 -2
- package/build/components/ungroup-button/index.native.js.map +1 -1
- package/build/components/url-input/index.js +46 -43
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/index.js +31 -2
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +8 -4
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +10 -2
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/child-layout.js +209 -0
- package/build/hooks/child-layout.js.map +1 -0
- package/build/hooks/color-panel.js +17 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +14 -7
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/dimensions.js +65 -16
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout.js +59 -3
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +4 -2
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/min-height.js +139 -0
- package/build/hooks/min-height.js.map +1 -0
- package/build/hooks/padding.js +4 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +3 -2
- package/build/hooks/style.js.map +1 -1
- package/build/layouts/flex.js +22 -21
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +26 -0
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +420 -265
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +73 -49
- package/build/store/selectors.js.map +1 -1
- package/build/utils/sorting.js +63 -0
- package/build/utils/sorting.js.map +1 -0
- package/build-module/autocompleters/block.js +2 -6
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/autocompleters/link.js +2 -0
- package/build-module/autocompleters/link.js.map +1 -1
- package/build-module/components/block-card/index.js +45 -3
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +40 -31
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +4 -2
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-edit/edit.native.js +4 -6
- package/build-module/components/block-edit/edit.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +32 -30
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-context.native.js +5 -8
- package/build-module/components/block-list/block-list-context.native.js.map +1 -1
- package/build-module/components/block-list/block.js +55 -25
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +61 -28
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +2 -2
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +17 -10
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +13 -6
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +3 -2
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +35 -13
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +9 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +5 -8
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/utils.js +3 -3
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/index.js +19 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +6 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +8 -49
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +27 -5
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -2
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +24 -40
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +8 -6
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/height-control/index.js +103 -0
- package/build-module/components/height-control/index.js.map +1 -0
- package/build-module/components/iframe/index.js +11 -8
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/zoom-dropdown.js +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -1
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +27 -11
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +23 -10
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +27 -49
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -2
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +18 -0
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -0
- package/build-module/components/inserter/index.js +8 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +3 -5
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +89 -0
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -0
- package/build-module/components/inserter/media-tab/index.js +4 -0
- package/build-module/components/inserter/media-tab/index.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +86 -0
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-panel.js +77 -0
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-tab.js +100 -0
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -0
- package/build-module/components/inserter/media-tab/utils.js +45 -0
- package/build-module/components/inserter/media-tab/utils.js.map +1 -0
- package/build-module/components/inserter/menu.js +33 -12
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +61 -0
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -0
- package/build-module/components/inserter/quick-inserter.js +1 -0
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter/search-results.js +3 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +15 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +5 -2
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +32 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/index.js +56 -0
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +17 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js +46 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +81 -0
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +8 -0
- package/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/utils.js +26 -0
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -0
- package/build-module/components/link-control/index.js +18 -34
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -2
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +18 -0
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -0
- package/build-module/components/list-view/block.js +10 -5
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +21 -14
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +2 -4
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +89 -0
- package/build-module/components/off-canvas-editor/appender.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-contents.js +85 -0
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js +35 -0
- package/build-module/components/off-canvas-editor/block-edit-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block-select-button.js +101 -0
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -0
- package/build-module/components/off-canvas-editor/block.js +298 -0
- package/build-module/components/off-canvas-editor/block.js.map +1 -0
- package/build-module/components/off-canvas-editor/branch.js +164 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -0
- package/build-module/components/off-canvas-editor/context.js +7 -0
- package/build-module/components/off-canvas-editor/context.js.map +1 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js +111 -0
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +1 -0
- package/build-module/components/off-canvas-editor/expander.js +32 -0
- package/build-module/components/off-canvas-editor/expander.js.map +1 -0
- package/build-module/components/off-canvas-editor/index.js +189 -0
- package/build-module/components/off-canvas-editor/index.js.map +1 -0
- package/build-module/components/off-canvas-editor/leaf.js +45 -0
- package/build-module/components/off-canvas-editor/leaf.js.map +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js +165 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -0
- package/build-module/components/off-canvas-editor/update-attributes.js +97 -0
- package/build-module/components/off-canvas-editor/update-attributes.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js +124 -0
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +24 -0
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +220 -0
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +50 -0
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +1 -0
- package/build-module/components/off-canvas-editor/utils.js +44 -0
- package/build-module/components/off-canvas-editor/utils.js.map +1 -0
- package/build-module/components/rich-text/format-toolbar/index.js +6 -2
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -2
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-insert-replacement-text.js +33 -0
- package/build-module/components/rich-text/use-insert-replacement-text.js.map +1 -0
- package/build-module/components/rich-text/use-undo-automatic-change.js +9 -1
- package/build-module/components/rich-text/use-undo-automatic-change.js.map +1 -1
- package/build-module/components/rich-text/utils.js +1 -16
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +12 -3
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/ungroup-button/index.native.js +3 -2
- package/build-module/components/ungroup-button/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +46 -43
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/index.js +30 -3
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +9 -5
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +9 -2
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/child-layout.js +189 -0
- package/build-module/hooks/child-layout.js.map +1 -0
- package/build-module/hooks/color-panel.js +17 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +16 -9
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/dimensions.js +60 -16
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout.js +57 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -2
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/min-height.js +116 -0
- package/build-module/hooks/min-height.js.map +1 -0
- package/build-module/hooks/padding.js +4 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +4 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/layouts/flex.js +23 -22
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +22 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +415 -265
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +66 -48
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/sorting.js +56 -0
- package/build-module/utils/sorting.js.map +1 -0
- package/build-style/content-rtl.css +701 -0
- package/build-style/content.css +701 -0
- package/build-style/default-editor-styles-rtl.css +14 -0
- package/build-style/default-editor-styles.css +14 -0
- package/build-style/style-rtl.css +305 -668
- package/build-style/style.css +305 -668
- package/package.json +32 -30
- package/src/autocompleters/block.js +2 -6
- package/src/autocompleters/link.js +2 -0
- package/src/components/alignment-control/README.md +1 -1
- package/src/components/alignment-control/test/index.js +4 -1
- package/src/components/block-alignment-control/test/index.js +4 -1
- package/src/components/block-alignment-control/test/index.native.js +4 -4
- package/src/components/block-card/index.js +46 -2
- package/src/components/block-card/style.scss +4 -0
- package/src/components/block-content-overlay/{style.scss → content.scss} +7 -1
- package/src/components/block-draggable/content.scss +20 -0
- package/src/components/block-draggable/index.native.js +54 -40
- package/src/components/block-draggable/style.scss +0 -21
- package/src/components/block-draggable/test/helpers.native.js +7 -9
- package/src/components/block-draggable/test/index.native.js +35 -45
- package/src/components/block-edit/edit.js +5 -2
- package/src/components/block-edit/edit.native.js +5 -6
- package/src/components/block-inspector/index.js +96 -81
- package/src/components/block-inspector/style.scss +9 -1
- package/src/components/block-list/block-list-context.native.js +5 -8
- package/src/components/block-list/block.js +74 -23
- package/src/components/block-list/block.native.js +78 -23
- package/src/components/block-list/{style.scss → content.scss} +11 -20
- package/src/components/block-list-appender/{style.scss → content.scss} +0 -0
- package/src/components/block-lock/menu-item.js +5 -2
- package/src/components/block-lock/modal.js +19 -36
- package/src/components/block-lock/style.scss +8 -17
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +24 -6
- package/src/components/block-mover/style.scss +0 -1
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -2
- package/src/components/block-pattern-setup/index.js +2 -1
- package/src/components/block-patterns-list/index.js +47 -24
- package/src/components/block-popover/style.scss +1 -1
- package/src/components/block-preview/README.md +15 -10
- package/src/components/block-preview/auto.js +7 -1
- package/src/components/block-preview/content.scss +4 -0
- package/src/components/block-preview/index.js +7 -12
- package/src/components/block-preview/style.scss +0 -7
- package/src/components/block-preview/test/index.js +18 -35
- package/src/components/block-selection-clearer/test/index.js +12 -12
- package/src/components/block-settings-menu/block-settings-dropdown.js +32 -20
- package/src/components/block-styles/utils.js +3 -3
- package/src/components/block-switcher/index.js +19 -4
- package/src/components/block-switcher/test/index.js +4 -0
- package/src/components/block-toolbar/index.js +12 -5
- package/src/components/block-toolbar/style.scss +10 -0
- package/src/components/block-tools/insertion-point.js +3 -47
- package/src/components/block-tools/selected-block-popover.js +80 -34
- package/src/components/block-tools/style.scss +27 -5
- package/src/components/block-variation-picker/index.js +1 -4
- package/src/components/block-vertical-alignment-control/test/index.js +4 -1
- package/src/components/colors/with-colors.js +13 -23
- package/src/components/default-block-appender/{style.scss → content.scss} +1 -0
- package/src/components/font-sizes/fluid-utils.js +37 -64
- package/src/components/font-sizes/test/fluid-utils.js +5 -5
- package/src/components/font-sizes/with-font-sizes.js +14 -11
- package/src/components/height-control/index.js +123 -0
- package/src/components/height-control/stories/index.js +21 -0
- package/src/components/height-control/style.scss +5 -0
- package/src/components/iframe/index.js +25 -18
- package/src/components/image-editor/use-save-image.js +2 -0
- package/src/components/image-editor/zoom-dropdown.js +1 -0
- package/src/components/index.js +2 -0
- package/src/components/inner-blocks/{style.scss → content.scss} +0 -0
- package/src/components/inner-blocks/index.js +30 -10
- package/src/components/inner-blocks/use-inner-block-template-sync.js +28 -10
- package/src/components/inserter/block-patterns-explorer/sidebar.js +1 -0
- package/src/components/inserter/block-patterns-tab.js +28 -71
- package/src/components/inserter/block-types-tab.js +3 -2
- package/src/components/inserter/hooks/use-debounced-input.js +17 -0
- package/src/components/inserter/index.js +10 -2
- package/src/components/inserter/index.native.js +1 -1
- package/src/components/inserter/media-tab/hooks.js +88 -0
- package/src/components/inserter/media-tab/index.js +3 -0
- package/src/components/inserter/media-tab/media-list.js +93 -0
- package/src/components/inserter/media-tab/media-panel.js +83 -0
- package/src/components/inserter/media-tab/media-tab.js +135 -0
- package/src/components/inserter/media-tab/utils.js +37 -0
- package/src/components/inserter/menu.js +55 -13
- package/src/components/inserter/mobile-tab-navigation.js +85 -0
- package/src/components/inserter/quick-inserter.js +1 -0
- package/src/components/inserter/reusable-blocks-tab.js +4 -2
- package/src/components/inserter/search-results.js +3 -2
- package/src/components/inserter/stories/index.js +1 -1
- package/src/components/inserter/stories/{fixtures.js → utils/fixtures.js} +0 -0
- package/src/components/inserter/style.scss +184 -18
- package/src/components/inserter/tabs.js +12 -1
- package/src/components/inserter/test/reusable-blocks-tab.js +14 -57
- package/src/components/inserter-list-item/index.js +11 -1
- package/src/components/inserter-list-item/style.scss +26 -0
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/advanced-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/index.js +62 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +18 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +51 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +89 -0
- package/src/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js +9 -0
- package/src/components/inspector-controls-tabs/utils.js +28 -0
- package/src/components/line-height-control/test/index.js +5 -5
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/index.js +24 -39
- package/src/components/link-control/search-input.js +1 -2
- package/src/components/link-control/test/index.js +400 -582
- package/src/components/link-control/use-internal-input-value.js +22 -0
- package/src/components/list-view/block.js +7 -3
- package/src/components/list-view/branch.js +21 -14
- package/src/components/list-view/style.scss +20 -9
- package/src/components/media-placeholder/{style.scss → content.scss} +0 -0
- package/src/components/media-replace-flow/test/index.js +37 -9
- package/src/components/media-upload/test/index.native.js +2 -0
- package/src/components/off-canvas-editor/README.md +5 -0
- package/src/components/off-canvas-editor/appender.js +93 -0
- package/src/components/off-canvas-editor/block-contents.js +89 -0
- package/src/components/off-canvas-editor/block-edit-button.js +27 -0
- package/src/components/off-canvas-editor/block-select-button.js +113 -0
- package/src/components/off-canvas-editor/block.js +401 -0
- package/src/components/off-canvas-editor/branch.js +208 -0
- package/src/components/off-canvas-editor/context.js +8 -0
- package/src/components/off-canvas-editor/drop-indicator.js +126 -0
- package/src/components/off-canvas-editor/expander.js +26 -0
- package/src/components/off-canvas-editor/index.js +242 -0
- package/src/components/off-canvas-editor/leaf.js +52 -0
- package/src/components/off-canvas-editor/link-ui.js +166 -0
- package/src/components/off-canvas-editor/style.scss +26 -0
- package/src/components/off-canvas-editor/test/utils.js +50 -0
- package/src/components/off-canvas-editor/update-attributes.js +99 -0
- package/src/components/off-canvas-editor/use-block-selection.js +169 -0
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +29 -0
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +260 -0
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +58 -0
- package/src/components/off-canvas-editor/utils.js +58 -0
- package/src/components/plain-text/{style.scss → content.scss} +0 -0
- package/src/components/recursion-provider/test/index.js +27 -29
- package/src/components/responsive-block-control/test/index.js +69 -92
- package/src/components/rich-text/content.scss +42 -0
- package/src/components/rich-text/format-toolbar/index.js +6 -4
- package/src/components/rich-text/index.js +2 -2
- package/src/components/rich-text/index.native.js +0 -2
- package/src/components/rich-text/style.scss +0 -43
- package/src/components/rich-text/use-insert-replacement-text.js +31 -0
- package/src/components/rich-text/use-undo-automatic-change.js +7 -1
- package/src/components/rich-text/utils.js +2 -21
- package/src/components/spacing-sizes-control/spacing-input-control.js +9 -0
- package/src/components/ungroup-button/index.native.js +6 -2
- package/src/components/url-input/index.js +57 -73
- package/src/components/url-popover/README.md +12 -3
- package/src/components/url-popover/index.js +33 -3
- package/src/components/url-popover/test/__snapshots__/index.js.snap +8 -6
- package/src/components/url-popover/test/index.js +21 -9
- package/src/components/use-block-display-information/index.js +14 -5
- package/src/components/use-setting/index.js +20 -2
- package/src/components/use-setting/test/index.js +99 -0
- package/src/content.scss +10 -0
- package/src/hooks/child-layout.js +190 -0
- package/src/hooks/color-panel.js +13 -1
- package/src/hooks/color.js +2 -0
- package/src/hooks/content-lock-ui.js +47 -35
- package/src/hooks/dimensions.js +119 -21
- package/src/hooks/layout.js +62 -3
- package/src/hooks/margin.js +4 -3
- package/src/hooks/min-height.js +104 -0
- package/src/hooks/padding.js +4 -3
- package/src/hooks/style.js +10 -2
- package/src/hooks/test/style.js +4 -0
- package/src/hooks/test/use-typography-props.js +1 -1
- package/src/layouts/flex.js +43 -38
- package/src/store/actions.js +22 -0
- package/src/store/reducer.js +480 -434
- package/src/store/selectors.js +70 -64
- package/src/store/test/actions.js +18 -0
- package/src/store/test/performance.js +71 -0
- package/src/store/test/reducer.js +662 -490
- package/src/store/test/selectors.js +1839 -1306
- package/src/style.scss +4 -7
- package/src/utils/sorting.js +54 -0
- package/src/utils/test/sorting.js +49 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-preview/live.js +0 -30
- package/build/components/block-preview/live.js.map +0 -1
- package/build-module/components/block-preview/live.js +0 -20
- package/build-module/components/block-preview/live.js.map +0 -1
- package/src/components/block-preview/live.js +0 -19
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.orderBy = orderBy;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Recursive stable sorting comparator function.
|
|
10
|
+
*
|
|
11
|
+
* @param {string|Function} field Field to sort by.
|
|
12
|
+
* @param {Array} items Items to sort.
|
|
13
|
+
* @param {string} order Order, 'asc' or 'desc'.
|
|
14
|
+
* @return {Function} Comparison function to be used in a `.sort()`.
|
|
15
|
+
*/
|
|
16
|
+
const comparator = (field, items, order) => {
|
|
17
|
+
return (a, b) => {
|
|
18
|
+
let cmpA, cmpB;
|
|
19
|
+
|
|
20
|
+
if (typeof field === 'function') {
|
|
21
|
+
cmpA = field(a);
|
|
22
|
+
cmpB = field(b);
|
|
23
|
+
} else {
|
|
24
|
+
cmpA = a[field];
|
|
25
|
+
cmpB = b[field];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (cmpA > cmpB) {
|
|
29
|
+
return order === 'asc' ? 1 : -1;
|
|
30
|
+
} else if (cmpB > cmpA) {
|
|
31
|
+
return order === 'asc' ? -1 : 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const orderA = items.findIndex(item => item === a);
|
|
35
|
+
const orderB = items.findIndex(item => item === b); // Stable sort: maintaining original array order
|
|
36
|
+
|
|
37
|
+
if (orderA > orderB) {
|
|
38
|
+
return 1;
|
|
39
|
+
} else if (orderB > orderA) {
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return 0;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Order items by a certain key.
|
|
48
|
+
* Supports decorator functions that allow complex picking of a comparison field.
|
|
49
|
+
* Sorts in ascending order by default, but supports descending as well.
|
|
50
|
+
* Stable sort - maintains original order of equal items.
|
|
51
|
+
*
|
|
52
|
+
* @param {Array} items Items to order.
|
|
53
|
+
* @param {string|Function} field Field to order by.
|
|
54
|
+
* @param {string} order Sorting order, `asc` or `desc`.
|
|
55
|
+
* @return {Array} Sorted items.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
function orderBy(items, field) {
|
|
60
|
+
let order = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'asc';
|
|
61
|
+
return items.concat().sort(comparator(field, items, order));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=sorting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/utils/sorting.js"],"names":["comparator","field","items","order","a","b","cmpA","cmpB","orderA","findIndex","item","orderB","orderBy","concat","sort"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,UAAU,GAAG,CAAEC,KAAF,EAASC,KAAT,EAAgBC,KAAhB,KAA2B;AAC7C,SAAO,CAAEC,CAAF,EAAKC,CAAL,KAAY;AAClB,QAAIC,IAAJ,EAAUC,IAAV;;AAEA,QAAK,OAAON,KAAP,KAAiB,UAAtB,EAAmC;AAClCK,MAAAA,IAAI,GAAGL,KAAK,CAAEG,CAAF,CAAZ;AACAG,MAAAA,IAAI,GAAGN,KAAK,CAAEI,CAAF,CAAZ;AACA,KAHD,MAGO;AACNC,MAAAA,IAAI,GAAGF,CAAC,CAAEH,KAAF,CAAR;AACAM,MAAAA,IAAI,GAAGF,CAAC,CAAEJ,KAAF,CAAR;AACA;;AAED,QAAKK,IAAI,GAAGC,IAAZ,EAAmB;AAClB,aAAOJ,KAAK,KAAK,KAAV,GAAkB,CAAlB,GAAsB,CAAC,CAA9B;AACA,KAFD,MAEO,IAAKI,IAAI,GAAGD,IAAZ,EAAmB;AACzB,aAAOH,KAAK,KAAK,KAAV,GAAkB,CAAC,CAAnB,GAAuB,CAA9B;AACA;;AAED,UAAMK,MAAM,GAAGN,KAAK,CAACO,SAAN,CAAmBC,IAAF,IAAYA,IAAI,KAAKN,CAAtC,CAAf;AACA,UAAMO,MAAM,GAAGT,KAAK,CAACO,SAAN,CAAmBC,IAAF,IAAYA,IAAI,KAAKL,CAAtC,CAAf,CAlBkB,CAoBlB;;AACA,QAAKG,MAAM,GAAGG,MAAd,EAAuB;AACtB,aAAO,CAAP;AACA,KAFD,MAEO,IAAKA,MAAM,GAAGH,MAAd,EAAuB;AAC7B,aAAO,CAAC,CAAR;AACA;;AAED,WAAO,CAAP;AACA,GA5BD;AA6BA,CA9BD;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,OAAT,CAAkBV,KAAlB,EAAyBD,KAAzB,EAAgD;AAAA,MAAhBE,KAAgB,uEAAR,KAAQ;AACtD,SAAOD,KAAK,CAACW,MAAN,GAAeC,IAAf,CAAqBd,UAAU,CAAEC,KAAF,EAASC,KAAT,EAAgBC,KAAhB,CAA/B,CAAP;AACA","sourcesContent":["/**\n * Recursive stable sorting comparator function.\n *\n * @param {string|Function} field Field to sort by.\n * @param {Array} items Items to sort.\n * @param {string} order Order, 'asc' or 'desc'.\n * @return {Function} Comparison function to be used in a `.sort()`.\n */\nconst comparator = ( field, items, order ) => {\n\treturn ( a, b ) => {\n\t\tlet cmpA, cmpB;\n\n\t\tif ( typeof field === 'function' ) {\n\t\t\tcmpA = field( a );\n\t\t\tcmpB = field( b );\n\t\t} else {\n\t\t\tcmpA = a[ field ];\n\t\t\tcmpB = b[ field ];\n\t\t}\n\n\t\tif ( cmpA > cmpB ) {\n\t\t\treturn order === 'asc' ? 1 : -1;\n\t\t} else if ( cmpB > cmpA ) {\n\t\t\treturn order === 'asc' ? -1 : 1;\n\t\t}\n\n\t\tconst orderA = items.findIndex( ( item ) => item === a );\n\t\tconst orderB = items.findIndex( ( item ) => item === b );\n\n\t\t// Stable sort: maintaining original array order\n\t\tif ( orderA > orderB ) {\n\t\t\treturn 1;\n\t\t} else if ( orderB > orderA ) {\n\t\t\treturn -1;\n\t\t}\n\n\t\treturn 0;\n\t};\n};\n\n/**\n * Order items by a certain key.\n * Supports decorator functions that allow complex picking of a comparison field.\n * Sorts in ascending order by default, but supports descending as well.\n * Stable sort - maintains original order of equal items.\n *\n * @param {Array} items Items to order.\n * @param {string|Function} field Field to order by.\n * @param {string} order Sorting order, `asc` or `desc`.\n * @return {Array} Sorted items.\n */\nexport function orderBy( items, field, order = 'asc' ) {\n\treturn items.concat().sort( comparator( field, items, order ) );\n}\n"]}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { createElement, Fragment } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { orderBy } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import { useSelect } from '@wordpress/data';
|
|
12
7
|
import { createBlock, createBlocksFromInnerBlocksTemplate } from '@wordpress/blocks';
|
|
13
8
|
import { useMemo } from '@wordpress/element';
|
|
@@ -19,6 +14,7 @@ import { searchBlockItems } from '../components/inserter/search-items';
|
|
|
19
14
|
import useBlockTypesState from '../components/inserter/hooks/use-block-types-state';
|
|
20
15
|
import BlockIcon from '../components/block-icon';
|
|
21
16
|
import { store as blockEditorStore } from '../store';
|
|
17
|
+
import { orderBy } from '../utils/sorting';
|
|
22
18
|
|
|
23
19
|
const noop = () => {};
|
|
24
20
|
|
|
@@ -55,7 +51,7 @@ function createBlockCompleter() {
|
|
|
55
51
|
}, []);
|
|
56
52
|
const [items, categories, collections] = useBlockTypesState(rootClientId, noop);
|
|
57
53
|
const filteredItems = useMemo(() => {
|
|
58
|
-
const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : orderBy(items,
|
|
54
|
+
const initialFilteredItems = !!filterValue.trim() ? searchBlockItems(items, categories, collections, filterValue) : orderBy(items, 'frecency', 'desc');
|
|
59
55
|
return initialFilteredItems.filter(item => item.name !== selectedBlockName).slice(0, SHOWN_BLOCK_TYPES);
|
|
60
56
|
}, [filterValue, selectedBlockName, items, categories, collections]);
|
|
61
57
|
const options = useMemo(() => filteredItems.map(blockItem => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/autocompleters/block.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/autocompleters/block.js"],"names":["useSelect","createBlock","createBlocksFromInnerBlocksTemplate","useMemo","searchBlockItems","useBlockTypesState","BlockIcon","store","blockEditorStore","orderBy","noop","SHOWN_BLOCK_TYPES","createBlockCompleter","name","className","triggerPrefix","useItems","filterValue","rootClientId","selectedBlockName","select","getSelectedBlockClientId","getBlockName","getBlockInsertionPoint","selectedBlockClientId","items","categories","collections","filteredItems","initialFilteredItems","trim","filter","item","slice","options","map","blockItem","title","icon","isDisabled","key","id","value","label","allowContext","before","after","test","getOptionCompletion","inserterItem","initialAttributes","innerBlocks","action"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SACCC,WADD,EAECC,mCAFD,QAGO,mB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,EAAEzC,WAAW,CACjBY,IADiB,EAEjBqC,iBAFiB,EAGjBhD,mCAAmC,CAAEiD,WAAF,CAHlB;AAFZ,OAAP;AAQA;;AAvFK,GAAP;AAyFA;AAED;AACA;AACA;AACA;AACA;;;AACA,eAAevC,oBAAoB,EAAnC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n} from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { searchBlockItems } from '../components/inserter/search-items';\nimport useBlockTypesState from '../components/inserter/hooks/use-block-types-state';\nimport BlockIcon from '../components/block-icon';\nimport { store as blockEditorStore } from '../store';\nimport { orderBy } from '../utils/sorting';\n\nconst noop = () => {};\nconst SHOWN_BLOCK_TYPES = 9;\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nfunction createBlockCompleter() {\n\treturn {\n\t\tname: 'blocks',\n\t\tclassName: 'block-editor-autocompleters__block',\n\t\ttriggerPrefix: '/',\n\n\t\tuseItems( filterValue ) {\n\t\t\tconst { rootClientId, selectedBlockName } = useSelect(\n\t\t\t\t( select ) => {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\t\t\tgetBlockName,\n\t\t\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\t\t} = select( blockEditorStore );\n\t\t\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\t\t\t\treturn {\n\t\t\t\t\t\tselectedBlockName: selectedBlockClientId\n\t\t\t\t\t\t\t? getBlockName( selectedBlockClientId )\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\trootClientId: getBlockInsertionPoint().rootClientId,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t[]\n\t\t\t);\n\t\t\tconst [ items, categories, collections ] = useBlockTypesState(\n\t\t\t\trootClientId,\n\t\t\t\tnoop\n\t\t\t);\n\n\t\t\tconst filteredItems = useMemo( () => {\n\t\t\t\tconst initialFilteredItems = !! filterValue.trim()\n\t\t\t\t\t? searchBlockItems(\n\t\t\t\t\t\t\titems,\n\t\t\t\t\t\t\tcategories,\n\t\t\t\t\t\t\tcollections,\n\t\t\t\t\t\t\tfilterValue\n\t\t\t\t\t )\n\t\t\t\t\t: orderBy( items, 'frecency', 'desc' );\n\n\t\t\t\treturn initialFilteredItems\n\t\t\t\t\t.filter( ( item ) => item.name !== selectedBlockName )\n\t\t\t\t\t.slice( 0, SHOWN_BLOCK_TYPES );\n\t\t\t}, [\n\t\t\t\tfilterValue,\n\t\t\t\tselectedBlockName,\n\t\t\t\titems,\n\t\t\t\tcategories,\n\t\t\t\tcollections,\n\t\t\t] );\n\n\t\t\tconst options = useMemo(\n\t\t\t\t() =>\n\t\t\t\t\tfilteredItems.map( ( blockItem ) => {\n\t\t\t\t\t\tconst { title, icon, isDisabled } = blockItem;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tkey: `block-${ blockItem.id }`,\n\t\t\t\t\t\t\tvalue: blockItem,\n\t\t\t\t\t\t\tlabel: (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<BlockIcon\n\t\t\t\t\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t\t\tshowColors\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tisDisabled,\n\t\t\t\t\t\t};\n\t\t\t\t\t} ),\n\t\t\t\t[ filteredItems ]\n\t\t\t);\n\n\t\t\treturn [ options ];\n\t\t},\n\t\tallowContext( before, after ) {\n\t\t\treturn ! ( /\\S/.test( before ) || /\\S/.test( after ) );\n\t\t},\n\t\tgetOptionCompletion( inserterItem ) {\n\t\t\tconst { name, initialAttributes, innerBlocks } = inserterItem;\n\t\t\treturn {\n\t\t\t\taction: 'replace',\n\t\t\t\tvalue: createBlock(\n\t\t\t\t\tname,\n\t\t\t\t\tinitialAttributes,\n\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate( innerBlocks )\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t};\n}\n\n/**\n * Creates a blocks repeater for replacing the current block with a selected block type.\n *\n * @return {WPCompleter} A blocks completer.\n */\nexport default createBlockCompleter();\n"]}
|
|
@@ -3,6 +3,8 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
+
// Disable Reason: Needs to be refactored.
|
|
7
|
+
// eslint-disable-next-line no-restricted-imports
|
|
6
8
|
import apiFetch from '@wordpress/api-fetch';
|
|
7
9
|
import { addQueryArgs } from '@wordpress/url';
|
|
8
10
|
import { Icon, page, post } from '@wordpress/icons';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/autocompleters/link.js"],"names":["apiFetch","addQueryArgs","Icon","page","post","SHOWN_SUGGESTIONS","createLinkCompleter","name","className","triggerPrefix","options","letters","path","per_page","search","type","order_by","filter","option","title","getOptionKeywords","item","expansionWords","split","getOptionLabel","subtype","getOptionCompletion","url"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,IAAT,EAAeC,IAAf,EAAqBC,IAArB,QAAiC,kBAAjC;AAEA,MAAMC,iBAAiB,GAAG,EAA1B;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AACA,SAASC,mBAAT,GAA+B;AAC9B,SAAO;AACNC,IAAAA,IAAI,EAAE,OADA;AAENC,IAAAA,SAAS,EAAE,mCAFL;AAGNC,IAAAA,aAAa,EAAE,IAHT;AAINC,IAAAA,OAAO,EAAE,MAAQC,OAAR,IAAqB;AAC7B,UAAID,OAAO,GAAG,MAAMV,QAAQ,CAAE;AAC7BY,QAAAA,IAAI,EAAEX,YAAY,CAAE,eAAF,EAAmB;AACpCY,UAAAA,QAAQ,EAAER,iBAD0B;AAEpCS,UAAAA,MAAM,EAAEH,OAF4B;AAGpCI,UAAAA,IAAI,EAAE,MAH8B;AAIpCC,UAAAA,QAAQ,EAAE;AAJ0B,SAAnB;AADW,OAAF,CAA5B;AASAN,MAAAA,OAAO,GAAGA,OAAO,CAACO,MAAR,CAAkBC,MAAF,IAAcA,MAAM,CAACC,KAAP,KAAiB,EAA/C,CAAV;AAEA,aAAOT,OAAP;AACA,KAjBK;;AAkBNU,IAAAA,iBAAiB,CAAEC,IAAF,EAAS;AACzB,YAAMC,cAAc,GAAGD,IAAI,CAACF,KAAL,CAAWI,KAAX,CAAkB,KAAlB,CAAvB;AACA,aAAO,CAAE,GAAGD,cAAL,CAAP;AACA,KArBK;;AAsBNE,IAAAA,cAAc,CAAEH,IAAF,EAAS;AACtB,aACC,8BACC,cAAC,IAAD;AACC,QAAA,GAAG,EAAC,MADL;AAEC,QAAA,IAAI,EAAGA,IAAI,CAACI,OAAL,KAAiB,MAAjB,GAA0BtB,IAA1B,GAAiCC;AAFzC,QADD,EAKGiB,IAAI,CAACF,KALR,CADD;AASA,KAhCK;;AAiCNO,IAAAA,mBAAmB,CAAEL,IAAF,EAAS;AAC3B,aAAO;AAAG,QAAA,IAAI,EAAGA,IAAI,CAACM;AAAf,SAAuBN,IAAI,CAACF,KAA5B,CAAP;AACA;;AAnCK,GAAP;AAqCA;AAED;AACA;AACA;AACA;AACA;;;AACA,eAAeb,mBAAmB,EAAlC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { Icon, page, post } from '@wordpress/icons';\n\nconst SHOWN_SUGGESTIONS = 10;\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\n/**\n * Creates a suggestion list for links to posts or pages.\n *\n * @return {WPCompleter} A links completer.\n */\nfunction createLinkCompleter() {\n\treturn {\n\t\tname: 'links',\n\t\tclassName: 'block-editor-autocompleters__link',\n\t\ttriggerPrefix: '[[',\n\t\toptions: async ( letters ) => {\n\t\t\tlet options = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tper_page: SHOWN_SUGGESTIONS,\n\t\t\t\t\tsearch: letters,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\torder_by: 'menu_order',\n\t\t\t\t} ),\n\t\t\t} );\n\n\t\t\toptions = options.filter( ( option ) => option.title !== '' );\n\n\t\t\treturn options;\n\t\t},\n\t\tgetOptionKeywords( item ) {\n\t\t\tconst expansionWords = item.title.split( /\\s+/ );\n\t\t\treturn [ ...expansionWords ];\n\t\t},\n\t\tgetOptionLabel( item ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\ticon={ item.subtype === 'page' ? page : post }\n\t\t\t\t\t/>\n\t\t\t\t\t{ item.title }\n\t\t\t\t</>\n\t\t\t);\n\t\t},\n\t\tgetOptionCompletion( item ) {\n\t\t\treturn <a href={ item.url }>{ item.title }</a>;\n\t\t},\n\t};\n}\n\n/**\n * Creates a suggestion list for links to posts or pages..\n *\n * @return {WPCompleter} A link completer.\n */\nexport default createLinkCompleter();\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/autocompleters/link.js"],"names":["apiFetch","addQueryArgs","Icon","page","post","SHOWN_SUGGESTIONS","createLinkCompleter","name","className","triggerPrefix","options","letters","path","per_page","search","type","order_by","filter","option","title","getOptionKeywords","item","expansionWords","split","getOptionLabel","subtype","getOptionCompletion","url"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,OAAOA,QAAP,MAAqB,sBAArB;AACA,SAASC,YAAT,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AAf,SAAuBN,IAAI,CAACF,KAA5B,CAAP;AACA;;AAnCK,GAAP;AAqCA;AAED;AACA;AACA;AACA;AACA;;;AACA,eAAeb,mBAAmB,EAAlC","sourcesContent":["/**\n * WordPress dependencies\n */\n// Disable Reason: Needs to be refactored.\n// eslint-disable-next-line no-restricted-imports\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { Icon, page, post } from '@wordpress/icons';\n\nconst SHOWN_SUGGESTIONS = 10;\n\n/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */\n\n/**\n * Creates a suggestion list for links to posts or pages.\n *\n * @return {WPCompleter} A links completer.\n */\nfunction createLinkCompleter() {\n\treturn {\n\t\tname: 'links',\n\t\tclassName: 'block-editor-autocompleters__link',\n\t\ttriggerPrefix: '[[',\n\t\toptions: async ( letters ) => {\n\t\t\tlet options = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tper_page: SHOWN_SUGGESTIONS,\n\t\t\t\t\tsearch: letters,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\torder_by: 'menu_order',\n\t\t\t\t} ),\n\t\t\t} );\n\n\t\t\toptions = options.filter( ( option ) => option.title !== '' );\n\n\t\t\treturn options;\n\t\t},\n\t\tgetOptionKeywords( item ) {\n\t\t\tconst expansionWords = item.title.split( /\\s+/ );\n\t\t\treturn [ ...expansionWords ];\n\t\t},\n\t\tgetOptionLabel( item ) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tkey=\"icon\"\n\t\t\t\t\t\ticon={ item.subtype === 'page' ? page : post }\n\t\t\t\t\t/>\n\t\t\t\t\t{ item.title }\n\t\t\t\t</>\n\t\t\t);\n\t\t},\n\t\tgetOptionCompletion( item ) {\n\t\t\treturn <a href={ item.url }>{ item.title }</a>;\n\t\t},\n\t};\n}\n\n/**\n * Creates a suggestion list for links to posts or pages..\n *\n * @return {WPCompleter} A link completer.\n */\nexport default createLinkCompleter();\n"]}
|
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import classnames from 'classnames';
|
|
3
7
|
/**
|
|
4
8
|
* WordPress dependencies
|
|
5
9
|
*/
|
|
10
|
+
|
|
6
11
|
import deprecated from '@wordpress/deprecated';
|
|
12
|
+
import { Button } from '@wordpress/components';
|
|
13
|
+
import { chevronLeft, chevronRight } from '@wordpress/icons';
|
|
14
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
15
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
16
|
/**
|
|
8
17
|
* Internal dependencies
|
|
9
18
|
*/
|
|
10
19
|
|
|
11
20
|
import BlockIcon from '../block-icon';
|
|
21
|
+
import { store as blockEditorStore } from '../../store';
|
|
12
22
|
|
|
13
23
|
function BlockCard(_ref) {
|
|
24
|
+
var _window;
|
|
25
|
+
|
|
14
26
|
let {
|
|
15
27
|
title,
|
|
16
28
|
icon,
|
|
17
29
|
description,
|
|
18
|
-
blockType
|
|
30
|
+
blockType,
|
|
31
|
+
className
|
|
19
32
|
} = _ref;
|
|
20
33
|
|
|
21
34
|
if (blockType) {
|
|
@@ -30,9 +43,38 @@ function BlockCard(_ref) {
|
|
|
30
43
|
} = blockType);
|
|
31
44
|
}
|
|
32
45
|
|
|
46
|
+
const isOffCanvasNavigationEditorEnabled = ((_window = window) === null || _window === void 0 ? void 0 : _window.__experimentalEnableOffCanvasNavigationEditor) === true;
|
|
47
|
+
const {
|
|
48
|
+
parentNavBlockClientId
|
|
49
|
+
} = useSelect(select => {
|
|
50
|
+
const {
|
|
51
|
+
getSelectedBlockClientId,
|
|
52
|
+
getBlockParentsByBlockName
|
|
53
|
+
} = select(blockEditorStore);
|
|
54
|
+
|
|
55
|
+
const _selectedBlockClientId = getSelectedBlockClientId();
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
parentNavBlockClientId: getBlockParentsByBlockName(_selectedBlockClientId, 'core/navigation', true)[0]
|
|
59
|
+
};
|
|
60
|
+
}, []);
|
|
61
|
+
const {
|
|
62
|
+
selectBlock
|
|
63
|
+
} = useDispatch(blockEditorStore);
|
|
33
64
|
return createElement("div", {
|
|
34
|
-
className:
|
|
35
|
-
}, createElement(
|
|
65
|
+
className: classnames('block-editor-block-card', className)
|
|
66
|
+
}, isOffCanvasNavigationEditorEnabled && parentNavBlockClientId && createElement(Button, {
|
|
67
|
+
onClick: () => selectBlock(parentNavBlockClientId),
|
|
68
|
+
label: __('Go to parent Navigation block'),
|
|
69
|
+
style: // TODO: This style override is also used in ToolsPanelHeader.
|
|
70
|
+
// It should be supported out-of-the-box by Button.
|
|
71
|
+
{
|
|
72
|
+
minWidth: 24,
|
|
73
|
+
padding: 0
|
|
74
|
+
},
|
|
75
|
+
icon: isRTL() ? chevronRight : chevronLeft,
|
|
76
|
+
isSmall: true
|
|
77
|
+
}), createElement(BlockIcon, {
|
|
36
78
|
icon: icon,
|
|
37
79
|
showColors: true
|
|
38
80
|
}), createElement("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-card/index.js"],"names":["deprecated","BlockIcon","BlockCard","title","icon","description","blockType","since","alternative"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;;AAEA,SAASC,SAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-card/index.js"],"names":["classnames","deprecated","Button","chevronLeft","chevronRight","__","isRTL","useSelect","useDispatch","BlockIcon","store","blockEditorStore","BlockCard","title","icon","description","blockType","className","since","alternative","isOffCanvasNavigationEditorEnabled","window","__experimentalEnableOffCanvasNavigationEditor","parentNavBlockClientId","select","getSelectedBlockClientId","getBlockParentsByBlockName","_selectedBlockCl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AbyC,CAA5C;AAeA,QAAM;AAAEC,IAAAA;AAAF,MAAkBpB,WAAW,CAAEG,gBAAF,CAAnC;AAEA,SACC;AAAK,IAAA,SAAS,EAAGX,UAAU,CAAE,yBAAF,EAA6BiB,SAA7B;AAA3B,KACGG,kCAAkC,IAAIG,sBAAtC,IACD,cAAC,MAAD;AACC,IAAA,OAAO,EAAG,MAAMK,WAAW,CAAEL,sBAAF,CAD5B;AAEC,IAAA,KAAK,EAAGlB,EAAE,CAAE,+BAAF,CAFX;AAGC,IAAA,KAAK,EACJ;AACA;AACA;AAAEwB,MAAAA,QAAQ,EAAE,EAAZ;AAAgBC,MAAAA,OAAO,EAAE;AAAzB,KANF;AAQC,IAAA,IAAI,EAAGxB,KAAK,KAAKF,YAAL,GAAoBD,WARjC;AASC,IAAA,OAAO;AATR,IAFF,EAcC,cAAC,SAAD;AAAW,IAAA,IAAI,EAAGW,IAAlB;AAAyB,IAAA,UAAU;AAAnC,IAdD,EAeC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAI,IAAA,SAAS,EAAC;AAAd,KAAiDD,KAAjD,CADD,EAEC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGE,WADH,CAFD,CAfD,CADD;AAwBA;;AAED,eAAeH,SAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { Button } from '@wordpress/components';\nimport { chevronLeft, chevronRight } from '@wordpress/icons';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockCard( { title, icon, description, blockType, className } ) {\n\tif ( blockType ) {\n\t\tdeprecated( '`blockType` property in `BlockCard component`', {\n\t\t\tsince: '5.7',\n\t\t\talternative: '`title, icon and description` properties',\n\t\t} );\n\t\t( { title, icon, description } = blockType );\n\t}\n\n\tconst isOffCanvasNavigationEditorEnabled =\n\t\twindow?.__experimentalEnableOffCanvasNavigationEditor === true;\n\n\tconst { parentNavBlockClientId } = useSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientId, getBlockParentsByBlockName } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst _selectedBlockClientId = getSelectedBlockClientId();\n\n\t\treturn {\n\t\t\tparentNavBlockClientId: getBlockParentsByBlockName(\n\t\t\t\t_selectedBlockClientId,\n\t\t\t\t'core/navigation',\n\t\t\t\ttrue\n\t\t\t)[ 0 ],\n\t\t};\n\t}, [] );\n\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<div className={ classnames( 'block-editor-block-card', className ) }>\n\t\t\t{ isOffCanvasNavigationEditorEnabled && parentNavBlockClientId && (\n\t\t\t\t<Button\n\t\t\t\t\tonClick={ () => selectBlock( parentNavBlockClientId ) }\n\t\t\t\t\tlabel={ __( 'Go to parent Navigation block' ) }\n\t\t\t\t\tstyle={\n\t\t\t\t\t\t// TODO: This style override is also used in ToolsPanelHeader.\n\t\t\t\t\t\t// It should be supported out-of-the-box by Button.\n\t\t\t\t\t\t{ minWidth: 24, padding: 0 }\n\t\t\t\t\t}\n\t\t\t\t\ticon={ isRTL() ? chevronRight : chevronLeft }\n\t\t\t\t\tisSmall\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<BlockIcon icon={ icon } showColors />\n\t\t\t<div className=\"block-editor-block-card__content\">\n\t\t\t\t<h2 className=\"block-editor-block-card__title\">{ title }</h2>\n\t\t\t\t<span className=\"block-editor-block-card__description\">\n\t\t\t\t\t{ description }\n\t\t\t\t</span>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default BlockCard;\n"]}
|
|
@@ -311,6 +311,42 @@ const BlockDraggableWrapper = _ref => {
|
|
|
311
311
|
icon: draggedBlockIcon
|
|
312
312
|
}))));
|
|
313
313
|
};
|
|
314
|
+
|
|
315
|
+
function useIsScreenReaderEnabled() {
|
|
316
|
+
const [isScreenReaderEnabled, setIsScreenReaderEnabled] = useState(false);
|
|
317
|
+
useEffect(() => {
|
|
318
|
+
let mounted = true;
|
|
319
|
+
const changeListener = AccessibilityInfo.addEventListener('screenReaderChanged', enabled => setIsScreenReaderEnabled(enabled));
|
|
320
|
+
AccessibilityInfo.isScreenReaderEnabled().then(screenReaderEnabled => {
|
|
321
|
+
if (mounted && screenReaderEnabled) {
|
|
322
|
+
setIsScreenReaderEnabled(screenReaderEnabled);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
return () => {
|
|
326
|
+
mounted = false;
|
|
327
|
+
changeListener.remove();
|
|
328
|
+
};
|
|
329
|
+
}, []);
|
|
330
|
+
return isScreenReaderEnabled;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function useIsEditingText() {
|
|
334
|
+
const [isEditingText, setIsEditingText] = useState(() => RCTAztecView.InputState.isFocused());
|
|
335
|
+
useEffect(() => {
|
|
336
|
+
const onFocusChangeAztec = _ref9 => {
|
|
337
|
+
let {
|
|
338
|
+
isFocused
|
|
339
|
+
} = _ref9;
|
|
340
|
+
setIsEditingText(isFocused);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
RCTAztecView.InputState.addFocusChangeListener(onFocusChangeAztec);
|
|
344
|
+
return () => {
|
|
345
|
+
RCTAztecView.InputState.removeFocusChangeListener(onFocusChangeAztec);
|
|
346
|
+
};
|
|
347
|
+
}, []);
|
|
348
|
+
return isEditingText;
|
|
349
|
+
}
|
|
314
350
|
/**
|
|
315
351
|
* Block draggable component
|
|
316
352
|
*
|
|
@@ -328,17 +364,17 @@ const BlockDraggableWrapper = _ref => {
|
|
|
328
364
|
*/
|
|
329
365
|
|
|
330
366
|
|
|
331
|
-
const BlockDraggable =
|
|
367
|
+
const BlockDraggable = _ref10 => {
|
|
332
368
|
let {
|
|
333
369
|
clientId,
|
|
334
370
|
children,
|
|
335
371
|
draggingClientId,
|
|
336
372
|
enabled = true,
|
|
337
373
|
testID
|
|
338
|
-
} =
|
|
374
|
+
} = _ref10;
|
|
339
375
|
const wasBeingDragged = useRef(false);
|
|
340
|
-
const
|
|
341
|
-
const
|
|
376
|
+
const isEditingText = useIsEditingText();
|
|
377
|
+
const isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
342
378
|
const draggingAnimation = {
|
|
343
379
|
opacity: useSharedValue(1)
|
|
344
380
|
};
|
|
@@ -383,33 +419,6 @@ const BlockDraggable = _ref9 => {
|
|
|
383
419
|
|
|
384
420
|
wasBeingDragged.current = isBeingDragged;
|
|
385
421
|
}, [isBeingDragged]);
|
|
386
|
-
const onFocusChangeAztec = useCallback(_ref10 => {
|
|
387
|
-
let {
|
|
388
|
-
isFocused
|
|
389
|
-
} = _ref10;
|
|
390
|
-
setIsEditingText(isFocused);
|
|
391
|
-
}, []);
|
|
392
|
-
useEffect(() => {
|
|
393
|
-
let mounted = true;
|
|
394
|
-
const isAnyAztecInputFocused = RCTAztecView.InputState.isFocused();
|
|
395
|
-
|
|
396
|
-
if (isAnyAztecInputFocused) {
|
|
397
|
-
setIsEditingText(isAnyAztecInputFocused);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
RCTAztecView.InputState.addFocusChangeListener(onFocusChangeAztec);
|
|
401
|
-
const screenReaderChangedListener = AccessibilityInfo.addEventListener('screenReaderChanged', setIsScreenReaderEnabled);
|
|
402
|
-
AccessibilityInfo.isScreenReaderEnabled().then(screenReaderEnabled => {
|
|
403
|
-
if (mounted) {
|
|
404
|
-
setIsScreenReaderEnabled(screenReaderEnabled);
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
return () => {
|
|
408
|
-
mounted = false;
|
|
409
|
-
RCTAztecView.InputState.removeFocusChangeListener(onFocusChangeAztec);
|
|
410
|
-
screenReaderChangedListener.remove();
|
|
411
|
-
};
|
|
412
|
-
}, []);
|
|
413
422
|
const onLongPressDraggable = useCallback(() => {
|
|
414
423
|
// Ensure that no text input is focused when starting the dragging gesture in order to prevent conflicts with text editing.
|
|
415
424
|
RCTAztecView.InputState.blurCurrentFocusedElement();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.native.js"],"names":["AccessibilityInfo","useSafeAreaInsets","useSafeAreaFrame","Animated","runOnJS","runOnUI","useAnimatedRef","useAnimatedStyle","useSharedValue","withDelay","withTiming","ZoomInEasyDown","Draggable","DraggableTrigger","select","useSelect","useDispatch","useCallback","useEffect","useRef","useState","Platform","getBlockType","generateHapticFeedback","RCTAztecView","useScrollWhenDragging","DraggableChip","store","blockEditorStore","useBlockListContext","DroppingInsertionPoint","useBlockDropZone","styles","CHIP_OFFSET_TO_TOUCH_POSITION","BLOCK_OPACITY_ANIMATION_CONFIG","duration","BLOCK_OPACITY_ANIMATION_DELAY","DEFAULT_LONG_PRESS_MIN_DURATION","DEFAULT_IOS_LONG_PRESS_MIN_DURATION","BlockDraggableWrapper","children","isRTL","draggedBlockIcon","setDraggedBlockIcon","selectBlock","startDraggingBlocks","stopDraggingBlocks","scrollRef","animatedScrollRef","left","right","width","safeAreaOffset","contentWidth","scroll","offsetY","chip","x","y","height","currentYPosition","isDragging","startScrolling","scrollOnDragOver","stopScrolling","draggingScrollHandler","scrollHandler","event","contentOffset","value","onBlockDragOver","onBlockDragEnd","onBlockDrop","targetBlockIndex","setDraggedBlockIconByClientId","clientId","blockName","getBlockName","blockIcon","icon","onStartDragging","position","stopDragging","onStopDragging","srcRootClientId","srcClientIds","type","undefined","onChipLayout","nativeEvent","layout","startDragging","id","dragPosition","updateDragging","chipDynamicStyles","chipOffset","translateX","transform","translateY","chipStyles","exitingAnimation","currentHeight","currentWidth","animations","scale","initialValues","onScroll","BlockDraggable","draggingClientId","enabled","testID","wasBeingDragged","isEditingText","setIsEditingText","isScreenReaderEnabled","setIsScreenReaderEnabled","draggingAnimation","opacity","startDraggingBlock","stopDraggingBlock","isDraggable","isBeingDragged","isBlockSelected","_select","getBlockRootClientId","getTemplateLock","isBlockBeingDragged","getSelectedBlockClientId","rootClientId","templateLock","selectedBlockClientId","current","onFocusChangeAztec","isFocused","mounted","isAnyAztecInputFocused","InputState","addFocusChangeListener","screenReaderChangedListener","addEventListener","then","screenReaderEnabled","removeFocusChangeListener","remove","onLongPressDraggable","blurCurrentFocusedElement","animatedWrapperStyles","wrapperStyles","canDragBlock","ios","android"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iBAAT,QAAkC,cAAlC;AACA,SACCC,iBADD,EAECC,gBAFD,QAGO,gCAHP;AAIA,OAAOC,QAAP,IACCC,OADD,EAECC,OAFD,EAGCC,cAHD,EAICC,gBAJD,EAKCC,cALD,EAMCC,SAND,EAOCC,UAPD,EAQCC,cARD,QASO,yBATP;AAWA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,gBAApB,QAA4C,uBAA5C;AACA,SAASC,MAAT,EAAiBC,SAAjB,EAA4BC,WAA5B,QAA+C,iBAA/C;AACA,SACCC,WADD,EAECC,SAFD,EAGCC,MAHD,EAICC,QAJD,EAKCC,QALD,QAMO,oBANP;AAOA,SAASC,YAAT,QAA6B,mBAA7B;AACA,SAASC,sBAAT,QAAuC,gCAAvC;AACA,OAAOC,YAAP,MAAyB,+BAAzB;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,mBAAT,QAAoC,kCAApC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,MAAMC,6BAA6B,GAAG,EAAtC;AACA,MAAMC,8BAA8B,GAAG;AAAEC,EAAAA,QAAQ,EAAE;AAAZ,CAAvC;AACA,MAAMC,6BAA6B,GAAG,GAAtC;AACA,MAAMC,+BAA+B,GAAG,GAAxC;AACA,MAAMC,mCAAm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BAAqB,GAAG5I,gBAAgB,CAAE,MAAM;AACrD,WAAO;AACN+G,MAAAA,OAAO,EAAED,iBAAiB,CAACC,OAAlB,CAA0BjD;AAD7B,KAAP;AAGA,GAJ6C,CAA9C;AAKA,QAAM+E,aAAa,GAAG,CACrBD,qBADqB,EAErBnH,MAAM,CAAE,8BAAF,CAFe,CAAtB;AAKA,QAAMqH,YAAY,GACjBvC,OAAO,IACP,CAAEK,qBADF,KAEE,CAAEQ,eAAF,IAAqB,CAAEV,aAFzB,CADD;;AAKA,MAAK,CAAEQ,WAAP,EAAqB;AACpB,WAAOjF,QAAQ,CAAE;AAAEiF,MAAAA,WAAW,EAAE;AAAf,KAAF,CAAf;AACA;;AAED,SACC,cAAC,gBAAD;AACC,IAAA,EAAE,EAAGZ,gBAAgB,IAAIlC,QAD1B;AAEC,IAAA,OAAO,EAAGmC,OAAO,IAAIuC,YAFtB;AAGC,IAAA,WAAW,EAAGhI,QAAQ,CAACP,MAAT,CAAiB;AAC9B;AACA;AACA;AACA;AACAwI,MAAAA,GAAG,EAAED,YAAY,GACd/G,mCADc,GAEdD,+BAP2B;AAQ9BkH,MAAAA,OAAO,EAAElH;AARqB,KAAjB,CAHf;AAaC,IAAA,WAAW,EAAG4G,oBAbf;AAcC,IAAA,MAAM,EAAGlC;AAdV,KAgBC,cAAC,QAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAGqC;AAAvB,KACG5G,QAAQ,CAAE;AAAEiF,IAAAA,WAAW,EAAE;AAAf,GAAF,CADX,CAhBD,CADD;AAsBA,CApJD;;AAsJA,SAASlF,qBAAT;AACA,eAAeqE,cAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo } from 'react-native';\nimport {\n\tuseSafeAreaInsets,\n\tuseSafeAreaFrame,\n} from 'react-native-safe-area-context';\nimport Animated, {\n\trunOnJS,\n\trunOnUI,\n\tuseAnimatedRef,\n\tuseAnimatedStyle,\n\tuseSharedValue,\n\twithDelay,\n\twithTiming,\n\tZoomInEasyDown,\n} from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport { Draggable, DraggableTrigger } from '@wordpress/components';\nimport { select, useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tPlatform,\n} from '@wordpress/element';\nimport { getBlockType } from '@wordpress/blocks';\nimport { generateHapticFeedback } from '@wordpress/react-native-bridge';\nimport RCTAztecView from '@wordpress/react-native-aztec';\n\n/**\n * Internal dependencies\n */\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport DraggableChip from './draggable-chip';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockListContext } from '../block-list/block-list-context';\nimport DroppingInsertionPoint from './dropping-insertion-point';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport styles from './style.scss';\n\nconst CHIP_OFFSET_TO_TOUCH_POSITION = 32;\nconst BLOCK_OPACITY_ANIMATION_CONFIG = { duration: 350 };\nconst BLOCK_OPACITY_ANIMATION_DELAY = 250;\nconst DEFAULT_LONG_PRESS_MIN_DURATION = 500;\nconst DEFAULT_IOS_LONG_PRESS_MIN_DURATION =\n\tDEFAULT_LONG_PRESS_MIN_DURATION - 50;\n\n/**\n * Block draggable wrapper component\n *\n * This component handles all the interactions for dragging blocks.\n * It relies on the block list and its context for dragging, hence it\n * should be rendered between the `BlockListProvider` component and the\n * block list rendering. It also requires listening to scroll events,\n * therefore for this purpose, it returns the `onScroll` event handler\n * that should be attached to the list that renders the blocks.\n *\n *\n * @param {Object} props Component props.\n * @param {JSX.Element} props.children Children to be rendered.\n * @param {boolean} props.isRTL Check if current locale is RTL.\n *\n * @return {Function} Render function that passes `onScroll` event handler.\n */\nconst BlockDraggableWrapper = ( { children, isRTL } ) => {\n\tconst [ draggedBlockIcon, setDraggedBlockIcon ] = useState();\n\n\tconst { selectBlock, startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { scrollRef } = useBlockListContext();\n\tconst animatedScrollRef = useAnimatedRef();\n\tconst { left, right } = useSafeAreaInsets();\n\tconst { width } = useSafeAreaFrame();\n\tconst safeAreaOffset = left + right;\n\tconst contentWidth = width - safeAreaOffset;\n\tanimatedScrollRef( scrollRef );\n\n\tconst scroll = {\n\t\toffsetY: useSharedValue( 0 ),\n\t};\n\tconst chip = {\n\t\tx: useSharedValue( 0 ),\n\t\ty: useSharedValue( 0 ),\n\t\twidth: useSharedValue( 0 ),\n\t\theight: useSharedValue( 0 ),\n\t};\n\tconst currentYPosition = useSharedValue( 0 );\n\tconst isDragging = useSharedValue( false );\n\n\tconst [\n\t\tstartScrolling,\n\t\tscrollOnDragOver,\n\t\tstopScrolling,\n\t\tdraggingScrollHandler,\n\t] = useScrollWhenDragging();\n\n\tconst scrollHandler = ( event ) => {\n\t\t'worklet';\n\t\tconst { contentOffset } = event;\n\t\tscroll.offsetY.value = contentOffset.y;\n\n\t\tdraggingScrollHandler( event );\n\t};\n\n\tconst { onBlockDragOver, onBlockDragEnd, onBlockDrop, targetBlockIndex } =\n\t\tuseBlockDropZone();\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.value ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tconst setDraggedBlockIconByClientId = ( clientId ) => {\n\t\tconst blockName = select( blockEditorStore ).getBlockName( clientId );\n\t\tconst blockIcon = getBlockType( blockName )?.icon;\n\t\tif ( blockIcon ) {\n\t\t\tsetDraggedBlockIcon( blockIcon );\n\t\t}\n\t};\n\n\tconst onStartDragging = ( { clientId, position } ) => {\n\t\tif ( clientId ) {\n\t\t\tstartDraggingBlocks( [ clientId ] );\n\t\t\tsetDraggedBlockIconByClientId( clientId );\n\t\t\trunOnUI( startScrolling )( position.y );\n\t\t\tgenerateHapticFeedback();\n\t\t} else {\n\t\t\t// We stop dragging if no block is found.\n\t\t\trunOnUI( stopDragging )();\n\t\t}\n\t};\n\n\tconst onStopDragging = ( { clientId } ) => {\n\t\tif ( clientId ) {\n\t\t\tonBlockDrop( {\n\t\t\t\t// Dropping is only allowed at root level\n\t\t\t\tsrcRootClientId: '',\n\t\t\t\tsrcClientIds: [ clientId ],\n\t\t\t\ttype: 'block',\n\t\t\t} );\n\t\t\tselectBlock( clientId );\n\t\t\tsetDraggedBlockIcon( undefined );\n\t\t}\n\t\tonBlockDragEnd();\n\t\tstopDraggingBlocks();\n\t};\n\n\tconst onChipLayout = ( { nativeEvent: { layout } } ) => {\n\t\tif ( layout.width > 0 ) {\n\t\t\tchip.width.value = layout.width;\n\t\t}\n\t\tif ( layout.height > 0 ) {\n\t\t\tchip.height.value = layout.height;\n\t\t}\n\t};\n\n\tconst startDragging = ( { x, y, id } ) => {\n\t\t'worklet';\n\t\tconst dragPosition = { x, y };\n\t\tchip.x.value = dragPosition.x;\n\t\tchip.y.value = dragPosition.y;\n\t\tcurrentYPosition.value = dragPosition.y;\n\n\t\tisDragging.value = true;\n\n\t\trunOnJS( onStartDragging )( { clientId: id, position: dragPosition } );\n\t};\n\n\tconst updateDragging = ( { x, y } ) => {\n\t\t'worklet';\n\t\tconst dragPosition = { x, y };\n\t\tchip.x.value = dragPosition.x;\n\t\tchip.y.value = dragPosition.y;\n\t\tcurrentYPosition.value = dragPosition.y;\n\n\t\trunOnJS( onBlockDragOver )( { x, y: y + scroll.offsetY.value } );\n\n\t\t// Update scrolling velocity\n\t\tscrollOnDragOver( dragPosition.y );\n\t};\n\n\tconst stopDragging = ( { id } ) => {\n\t\t'worklet';\n\t\tisDragging.value = false;\n\n\t\tstopScrolling();\n\t\trunOnJS( onStopDragging )( { clientId: id } );\n\t};\n\n\tconst chipDynamicStyles = useAnimatedStyle( () => {\n\t\tconst chipOffset = chip.width.value / 2;\n\t\tconst translateX = ! isRTL\n\t\t\t? chip.x.value - chipOffset\n\t\t\t: -( contentWidth - ( chip.x.value + chipOffset ) );\n\n\t\treturn {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateX,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttranslateY:\n\t\t\t\t\t\tchip.y.value -\n\t\t\t\t\t\tchip.height.value -\n\t\t\t\t\t\tCHIP_OFFSET_TO_TOUCH_POSITION,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t} );\n\tconst chipStyles = [\n\t\tchipDynamicStyles,\n\t\tstyles[ 'draggable-chip__wrapper' ],\n\t];\n\n\tconst exitingAnimation = ( { currentHeight, currentWidth } ) => {\n\t\t'worklet';\n\t\tconst translateX = ! isRTL ? 0 : currentWidth * -1;\n\t\tconst duration = 150;\n\t\tconst animations = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: withTiming( currentHeight, {\n\t\t\t\t\t\tduration,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttranslateX: withTiming( translateX, {\n\t\t\t\t\t\tduration,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\t{ scale: withTiming( 0, { duration } ) },\n\t\t\t],\n\t\t};\n\t\tconst initialValues = {\n\t\t\ttransform: [ { translateY: 0 }, { translateX }, { scale: 1 } ],\n\t\t};\n\t\treturn {\n\t\t\tinitialValues,\n\t\t\tanimations,\n\t\t};\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<DroppingInsertionPoint\n\t\t\t\tscroll={ scroll }\n\t\t\t\tcurrentYPosition={ currentYPosition }\n\t\t\t\tisDragging={ isDragging }\n\t\t\t\ttargetBlockIndex={ targetBlockIndex }\n\t\t\t/>\n\t\t\t<Draggable\n\t\t\t\tonDragStart={ startDragging }\n\t\t\t\tonDragOver={ updateDragging }\n\t\t\t\tonDragEnd={ stopDragging }\n\t\t\t\ttestID=\"block-draggable-wrapper\"\n\t\t\t>\n\t\t\t\t{ children( { onScroll: scrollHandler } ) }\n\t\t\t</Draggable>\n\t\t\t<Animated.View\n\t\t\t\tonLayout={ onChipLayout }\n\t\t\t\tstyle={ chipStyles }\n\t\t\t\tpointerEvents=\"none\"\n\t\t\t>\n\t\t\t\t{ draggedBlockIcon && (\n\t\t\t\t\t<Animated.View\n\t\t\t\t\t\tentering={ ZoomInEasyDown.duration( 200 ) }\n\t\t\t\t\t\texiting={ exitingAnimation }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DraggableChip icon={ draggedBlockIcon } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t) }\n\t\t\t</Animated.View>\n\t\t</>\n\t);\n};\n\n/**\n * Block draggable component\n *\n * This component serves for animating the block when it is being dragged.\n * Hence, it should be wrapped around the rendering of a block.\n *\n * @param {Object} props Component props.\n * @param {JSX.Element} props.children Children to be rendered.\n * @param {string} props.clientId Client id of the block.\n * @param {string} [props.draggingClientId] Client id to use for dragging. If not defined, the value from `clientId` will be used.\n * @param {boolean} [props.enabled] Enables the draggable trigger.\n * @param {string} [props.testID] Id used for querying the long-press gesture handler in tests.\n *\n * @return {Function} Render function which includes the parameter `isDraggable` to determine if the block can be dragged.\n */\nconst BlockDraggable = ( {\n\tclientId,\n\tchildren,\n\tdraggingClientId,\n\tenabled = true,\n\ttestID,\n} ) => {\n\tconst wasBeingDragged = useRef( false );\n\tconst [ isEditingText, setIsEditingText ] = useState( false );\n\tconst [ isScreenReaderEnabled, setIsScreenReaderEnabled ] =\n\t\tuseState( false );\n\n\tconst draggingAnimation = {\n\t\topacity: useSharedValue( 1 ),\n\t};\n\n\tconst startDraggingBlock = () => {\n\t\tdraggingAnimation.opacity.value = withTiming(\n\t\t\t0.4,\n\t\t\tBLOCK_OPACITY_ANIMATION_CONFIG\n\t\t);\n\t};\n\n\tconst stopDraggingBlock = () => {\n\t\tdraggingAnimation.opacity.value = withDelay(\n\t\t\tBLOCK_OPACITY_ANIMATION_DELAY,\n\t\t\twithTiming( 1, BLOCK_OPACITY_ANIMATION_CONFIG )\n\t\t);\n\t};\n\n\tconst { isDraggable, isBeingDragged, isBlockSelected } = useSelect(\n\t\t( _select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tisBlockBeingDragged,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t} = _select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst templateLock = rootClientId\n\t\t\t\t? getTemplateLock( rootClientId )\n\t\t\t\t: null;\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\treturn {\n\t\t\t\tisBeingDragged: isBlockBeingDragged( clientId ),\n\t\t\t\tisDraggable: 'all' !== templateLock,\n\t\t\t\tisBlockSelected:\n\t\t\t\t\tselectedBlockClientId && selectedBlockClientId === clientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( isBeingDragged !== wasBeingDragged.current ) {\n\t\t\tif ( isBeingDragged ) {\n\t\t\t\tstartDraggingBlock();\n\t\t\t} else {\n\t\t\t\tstopDraggingBlock();\n\t\t\t}\n\t\t}\n\t\twasBeingDragged.current = isBeingDragged;\n\t}, [ isBeingDragged ] );\n\n\tconst onFocusChangeAztec = useCallback( ( { isFocused } ) => {\n\t\tsetIsEditingText( isFocused );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tlet mounted = true;\n\n\t\tconst isAnyAztecInputFocused = RCTAztecView.InputState.isFocused();\n\t\tif ( isAnyAztecInputFocused ) {\n\t\t\tsetIsEditingText( isAnyAztecInputFocused );\n\t\t}\n\n\t\tRCTAztecView.InputState.addFocusChangeListener( onFocusChangeAztec );\n\n\t\tconst screenReaderChangedListener = AccessibilityInfo.addEventListener(\n\t\t\t'screenReaderChanged',\n\t\t\tsetIsScreenReaderEnabled\n\t\t);\n\t\tAccessibilityInfo.isScreenReaderEnabled().then(\n\t\t\t( screenReaderEnabled ) => {\n\t\t\t\tif ( mounted ) {\n\t\t\t\t\tsetIsScreenReaderEnabled( screenReaderEnabled );\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tmounted = false;\n\n\t\t\tRCTAztecView.InputState.removeFocusChangeListener(\n\t\t\t\tonFocusChangeAztec\n\t\t\t);\n\n\t\t\tscreenReaderChangedListener.remove();\n\t\t};\n\t}, [] );\n\n\tconst onLongPressDraggable = useCallback( () => {\n\t\t// Ensure that no text input is focused when starting the dragging gesture in order to prevent conflicts with text editing.\n\t\tRCTAztecView.InputState.blurCurrentFocusedElement();\n\t}, [] );\n\n\tconst animatedWrapperStyles = useAnimatedStyle( () => {\n\t\treturn {\n\t\t\topacity: draggingAnimation.opacity.value,\n\t\t};\n\t} );\n\tconst wrapperStyles = [\n\t\tanimatedWrapperStyles,\n\t\tstyles[ 'draggable-wrapper__container' ],\n\t];\n\n\tconst canDragBlock =\n\t\tenabled &&\n\t\t! isScreenReaderEnabled &&\n\t\t( ! isBlockSelected || ! isEditingText );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { isDraggable: false } );\n\t}\n\n\treturn (\n\t\t<DraggableTrigger\n\t\t\tid={ draggingClientId || clientId }\n\t\t\tenabled={ enabled && canDragBlock }\n\t\t\tminDuration={ Platform.select( {\n\t\t\t\t// On iOS, using a lower min duration than the default\n\t\t\t\t// value prevents the long-press gesture from being\n\t\t\t\t// triggered in underneath elements. This is required to\n\t\t\t\t// prevent enabling text editing when dragging is available.\n\t\t\t\tios: canDragBlock\n\t\t\t\t\t? DEFAULT_IOS_LONG_PRESS_MIN_DURATION\n\t\t\t\t\t: DEFAULT_LONG_PRESS_MIN_DURATION,\n\t\t\t\tandroid: DEFAULT_LONG_PRESS_MIN_DURATION,\n\t\t\t} ) }\n\t\t\tonLongPress={ onLongPressDraggable }\n\t\t\ttestID={ testID }\n\t\t>\n\t\t\t<Animated.View style={ wrapperStyles }>\n\t\t\t\t{ children( { isDraggable: true } ) }\n\t\t\t</Animated.View>\n\t\t</DraggableTrigger>\n\t);\n};\n\nexport { BlockDraggableWrapper };\nexport default BlockDraggable;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.native.js"],"names":["AccessibilityInfo","useSafeAreaInsets","useSafeAreaFrame","Animated","runOnJS","runOnUI","useAnimatedRef","useAnimatedStyle","useSharedValue","withDelay","withTiming","ZoomInEasyDown","Draggable","DraggableTrigger","select","useSelect","useDispatch","useCallback","useEffect","useRef","useState","Platform","getBlockType","generateHapticFeedback","RCTAztecView","useScrollWhenDragging","DraggableChip","store","blockEditorStore","useBlockListContext","DroppingInsertionPoint","useBlockDropZone","styles","CHIP_OFFSET_TO_TOUCH_POSITION","BLOCK_OPACITY_ANIMATION_CONFIG","duration","BLOCK_OPACITY_ANIMATION_DELAY","DEFAULT_LONG_PRESS_MIN_DURATION","DEFAULT_IOS_LONG_PRESS_MIN_DURATION","BlockDraggableWrapper","children","isRTL","draggedBlockIcon","setDraggedBlockIcon","selectBlock","startDraggingBlocks","stopDraggingBlocks","scrollRef","animatedScrollRef","left","right","width","safeAreaOffset","contentWidth","scroll","offsetY","chip","x","y","height","currentYPosition","isDragging","startScrolling","scrollOnDragOver","stopScrolling","draggingScrollHandler","scrollHandler","event","contentOffset","value","onBlockDragOver","onBlockDragEnd","onBlockDrop","targetBlockIndex","setDraggedBlockIconByClientId","clientId","blockName","getBlockName","blockIcon","icon","onStartDragging","position","stopDragging","onStopDragging","srcRootClientId","srcClientIds","type","undefined","onChipLayout","nativeEvent","layout","startDragging","id","dragPosition","updateDragging","chipDynamicStyles","chipOffset","translateX","transform","translateY","chipStyles","exitingAnimation","currentHeight","currentWidth","animations","scale","initialValues","onScroll","useIsScreenReaderEnabled","isScreenReaderEnabled","setIsScreenReaderEnabled","mounted","changeListener","addEventListener","enabled","then","screenReaderEnabled","remove","useIsEditingText","isEditingText","setIsEditingText","InputState","isFocused","onFocusChangeAztec","addFocusChangeListener","removeFocusChangeListener","BlockDraggable","draggingClientId","testID","wasBeingDragged","draggingAnimation","opacity","startDraggingBlock","stopDraggingBlock","isDraggable","isBeingDragged","isBlockSelected","_select","getBlockRootClientId","getTemplateLock","isBlockBeingDragged","getSelectedBlockClientId","rootClientId","templateLock","selectedBlockClientId","current","onLongPressDraggable","blurCurrentFocusedElement","animatedWrapperStyles","wrapperStyles","canDragBlock","ios","android"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,iBAAT,QAAkC,cAAlC;AACA,SACCC,iBADD,EAECC,gBAFD,QAGO,gCAHP;AAIA,OAAOC,QAAP,IACCC,OADD,EAECC,OAFD,EAGCC,cAHD,EAICC,gBAJD,EAKCC,cALD,EAMCC,SAND,EAOCC,UAPD,EAQCC,cARD,QASO,yBATP;AAWA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,gBAApB,QAA4C,uBAA5C;AACA,SAASC,MAAT,EAAiBC,SAAjB,EAA4BC,WAA5B,QAA+C,iBAA/C;AACA,SACCC,WADD,EAECC,SAFD,EAGCC,MAHD,EAICC,QAJD,EAKCC,QALD,QAMO,oBANP;AAOA,SAASC,YAAT,QAA6B,mBAA7B;AACA,SAASC,sBAAT,QAAuC,gCAAvC;AACA,OAAOC,YAAP,MAAyB,+BAAzB;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,mBAAT,QAAoC,kCAApC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AACA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,MAAMC,6BAA6B,GAAG,EAAtC;AACA,MAAMC,8BAA8B,GAAG;AAAEC,EAAAA,QAAQ,EAAE;AAAZ,CAAvC;AACA,MAAMC,6BAA6B,GAAG,GAAtC;AACA,MAAMC,+BAA+B,GAAG,GAAxC;AACA,MAAMC,mCAAmC,GACxCD,+BAA+B,GAAG,EADnC;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;A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E,MAAM;AAC/C;AACAO,IAAAA,YAAY,CAACiG,UAAb,CAAwB0B,yBAAxB;AACA,GAHuC,EAGrC,EAHqC,CAAxC;AAKA,QAAMC,qBAAqB,GAAG7I,gBAAgB,CAAE,MAAM;AACrD,WAAO;AACN4H,MAAAA,OAAO,EAAED,iBAAiB,CAACC,OAAlB,CAA0B9D;AAD7B,KAAP;AAGA,GAJ6C,CAA9C;AAKA,QAAMgF,aAAa,GAAG,CACrBD,qBADqB,EAErBpH,MAAM,CAAE,8BAAF,CAFe,CAAtB;AAKA,QAAMsH,YAAY,GACjBpC,OAAO,IACP,CAAEL,qBADF,KAEE,CAAE2B,eAAF,IAAqB,CAAEjB,aAFzB,CADD;;AAKA,MAAK,CAAEe,WAAP,EAAqB;AACpB,WAAO9F,QAAQ,CAAE;AAAE8F,MAAAA,WAAW,EAAE;AAAf,KAAF,CAAf;AACA;;AAED,SACC,cAAC,gBAAD;AACC,IAAA,EAAE,EAAGP,gBAAgB,IAAIpD,QAD1B;AAEC,IAAA,OAAO,EAAGuC,OAAO,IAAIoC,YAFtB;AAGC,IAAA,WAAW,EAAGjI,QAAQ,CAACP,MAAT,CAAiB;AAC9B;AACA;AACA;AACA;AACAyI,MAAAA,GAAG,EAAED,YAAY,GACdhH,mCADc,GAEdD,+BAP2B;AAQ9BmH,MAAAA,OAAO,EAAEnH;AARqB,KAAjB,CAHf;AAaC,IAAA,WAAW,EAAG6G,oBAbf;AAcC,IAAA,MAAM,EAAGlB;AAdV,KAgBC,cAAC,QAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAGqB;AAAvB,KACG7G,QAAQ,CAAE;AAAE8F,IAAAA,WAAW,EAAE;AAAf,GAAF,CADX,CAhBD,CADD;AAsBA,CA9GD;;AAgHA,SAAS/F,qBAAT;AACA,eAAeuF,cAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { AccessibilityInfo } from 'react-native';\nimport {\n\tuseSafeAreaInsets,\n\tuseSafeAreaFrame,\n} from 'react-native-safe-area-context';\nimport Animated, {\n\trunOnJS,\n\trunOnUI,\n\tuseAnimatedRef,\n\tuseAnimatedStyle,\n\tuseSharedValue,\n\twithDelay,\n\twithTiming,\n\tZoomInEasyDown,\n} from 'react-native-reanimated';\n\n/**\n * WordPress dependencies\n */\nimport { Draggable, DraggableTrigger } from '@wordpress/components';\nimport { select, useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\tPlatform,\n} from '@wordpress/element';\nimport { getBlockType } from '@wordpress/blocks';\nimport { generateHapticFeedback } from '@wordpress/react-native-bridge';\nimport RCTAztecView from '@wordpress/react-native-aztec';\n\n/**\n * Internal dependencies\n */\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport DraggableChip from './draggable-chip';\nimport { store as blockEditorStore } from '../../store';\nimport { useBlockListContext } from '../block-list/block-list-context';\nimport DroppingInsertionPoint from './dropping-insertion-point';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport styles from './style.scss';\n\nconst CHIP_OFFSET_TO_TOUCH_POSITION = 32;\nconst BLOCK_OPACITY_ANIMATION_CONFIG = { duration: 350 };\nconst BLOCK_OPACITY_ANIMATION_DELAY = 250;\nconst DEFAULT_LONG_PRESS_MIN_DURATION = 500;\nconst DEFAULT_IOS_LONG_PRESS_MIN_DURATION =\n\tDEFAULT_LONG_PRESS_MIN_DURATION - 50;\n\n/**\n * Block draggable wrapper component\n *\n * This component handles all the interactions for dragging blocks.\n * It relies on the block list and its context for dragging, hence it\n * should be rendered between the `BlockListProvider` component and the\n * block list rendering. It also requires listening to scroll events,\n * therefore for this purpose, it returns the `onScroll` event handler\n * that should be attached to the list that renders the blocks.\n *\n *\n * @param {Object} props Component props.\n * @param {JSX.Element} props.children Children to be rendered.\n * @param {boolean} props.isRTL Check if current locale is RTL.\n *\n * @return {Function} Render function that passes `onScroll` event handler.\n */\nconst BlockDraggableWrapper = ( { children, isRTL } ) => {\n\tconst [ draggedBlockIcon, setDraggedBlockIcon ] = useState();\n\n\tconst { selectBlock, startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { scrollRef } = useBlockListContext();\n\tconst animatedScrollRef = useAnimatedRef();\n\tconst { left, right } = useSafeAreaInsets();\n\tconst { width } = useSafeAreaFrame();\n\tconst safeAreaOffset = left + right;\n\tconst contentWidth = width - safeAreaOffset;\n\tanimatedScrollRef( scrollRef );\n\n\tconst scroll = {\n\t\toffsetY: useSharedValue( 0 ),\n\t};\n\tconst chip = {\n\t\tx: useSharedValue( 0 ),\n\t\ty: useSharedValue( 0 ),\n\t\twidth: useSharedValue( 0 ),\n\t\theight: useSharedValue( 0 ),\n\t};\n\tconst currentYPosition = useSharedValue( 0 );\n\tconst isDragging = useSharedValue( false );\n\n\tconst [\n\t\tstartScrolling,\n\t\tscrollOnDragOver,\n\t\tstopScrolling,\n\t\tdraggingScrollHandler,\n\t] = useScrollWhenDragging();\n\n\tconst scrollHandler = ( event ) => {\n\t\t'worklet';\n\t\tconst { contentOffset } = event;\n\t\tscroll.offsetY.value = contentOffset.y;\n\n\t\tdraggingScrollHandler( event );\n\t};\n\n\tconst { onBlockDragOver, onBlockDragEnd, onBlockDrop, targetBlockIndex } =\n\t\tuseBlockDropZone();\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.value ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tconst setDraggedBlockIconByClientId = ( clientId ) => {\n\t\tconst blockName = select( blockEditorStore ).getBlockName( clientId );\n\t\tconst blockIcon = getBlockType( blockName )?.icon;\n\t\tif ( blockIcon ) {\n\t\t\tsetDraggedBlockIcon( blockIcon );\n\t\t}\n\t};\n\n\tconst onStartDragging = ( { clientId, position } ) => {\n\t\tif ( clientId ) {\n\t\t\tstartDraggingBlocks( [ clientId ] );\n\t\t\tsetDraggedBlockIconByClientId( clientId );\n\t\t\trunOnUI( startScrolling )( position.y );\n\t\t\tgenerateHapticFeedback();\n\t\t} else {\n\t\t\t// We stop dragging if no block is found.\n\t\t\trunOnUI( stopDragging )();\n\t\t}\n\t};\n\n\tconst onStopDragging = ( { clientId } ) => {\n\t\tif ( clientId ) {\n\t\t\tonBlockDrop( {\n\t\t\t\t// Dropping is only allowed at root level\n\t\t\t\tsrcRootClientId: '',\n\t\t\t\tsrcClientIds: [ clientId ],\n\t\t\t\ttype: 'block',\n\t\t\t} );\n\t\t\tselectBlock( clientId );\n\t\t\tsetDraggedBlockIcon( undefined );\n\t\t}\n\t\tonBlockDragEnd();\n\t\tstopDraggingBlocks();\n\t};\n\n\tconst onChipLayout = ( { nativeEvent: { layout } } ) => {\n\t\tif ( layout.width > 0 ) {\n\t\t\tchip.width.value = layout.width;\n\t\t}\n\t\tif ( layout.height > 0 ) {\n\t\t\tchip.height.value = layout.height;\n\t\t}\n\t};\n\n\tconst startDragging = ( { x, y, id } ) => {\n\t\t'worklet';\n\t\tconst dragPosition = { x, y };\n\t\tchip.x.value = dragPosition.x;\n\t\tchip.y.value = dragPosition.y;\n\t\tcurrentYPosition.value = dragPosition.y;\n\n\t\tisDragging.value = true;\n\n\t\trunOnJS( onStartDragging )( { clientId: id, position: dragPosition } );\n\t};\n\n\tconst updateDragging = ( { x, y } ) => {\n\t\t'worklet';\n\t\tconst dragPosition = { x, y };\n\t\tchip.x.value = dragPosition.x;\n\t\tchip.y.value = dragPosition.y;\n\t\tcurrentYPosition.value = dragPosition.y;\n\n\t\trunOnJS( onBlockDragOver )( { x, y: y + scroll.offsetY.value } );\n\n\t\t// Update scrolling velocity\n\t\tscrollOnDragOver( dragPosition.y );\n\t};\n\n\tconst stopDragging = ( { id } ) => {\n\t\t'worklet';\n\t\tisDragging.value = false;\n\n\t\tstopScrolling();\n\t\trunOnJS( onStopDragging )( { clientId: id } );\n\t};\n\n\tconst chipDynamicStyles = useAnimatedStyle( () => {\n\t\tconst chipOffset = chip.width.value / 2;\n\t\tconst translateX = ! isRTL\n\t\t\t? chip.x.value - chipOffset\n\t\t\t: -( contentWidth - ( chip.x.value + chipOffset ) );\n\n\t\treturn {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateX,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttranslateY:\n\t\t\t\t\t\tchip.y.value -\n\t\t\t\t\t\tchip.height.value -\n\t\t\t\t\t\tCHIP_OFFSET_TO_TOUCH_POSITION,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t} );\n\tconst chipStyles = [\n\t\tchipDynamicStyles,\n\t\tstyles[ 'draggable-chip__wrapper' ],\n\t];\n\n\tconst exitingAnimation = ( { currentHeight, currentWidth } ) => {\n\t\t'worklet';\n\t\tconst translateX = ! isRTL ? 0 : currentWidth * -1;\n\t\tconst duration = 150;\n\t\tconst animations = {\n\t\t\ttransform: [\n\t\t\t\t{\n\t\t\t\t\ttranslateY: withTiming( currentHeight, {\n\t\t\t\t\t\tduration,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttranslateX: withTiming( translateX, {\n\t\t\t\t\t\tduration,\n\t\t\t\t\t} ),\n\t\t\t\t},\n\t\t\t\t{ scale: withTiming( 0, { duration } ) },\n\t\t\t],\n\t\t};\n\t\tconst initialValues = {\n\t\t\ttransform: [ { translateY: 0 }, { translateX }, { scale: 1 } ],\n\t\t};\n\t\treturn {\n\t\t\tinitialValues,\n\t\t\tanimations,\n\t\t};\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<DroppingInsertionPoint\n\t\t\t\tscroll={ scroll }\n\t\t\t\tcurrentYPosition={ currentYPosition }\n\t\t\t\tisDragging={ isDragging }\n\t\t\t\ttargetBlockIndex={ targetBlockIndex }\n\t\t\t/>\n\t\t\t<Draggable\n\t\t\t\tonDragStart={ startDragging }\n\t\t\t\tonDragOver={ updateDragging }\n\t\t\t\tonDragEnd={ stopDragging }\n\t\t\t\ttestID=\"block-draggable-wrapper\"\n\t\t\t>\n\t\t\t\t{ children( { onScroll: scrollHandler } ) }\n\t\t\t</Draggable>\n\t\t\t<Animated.View\n\t\t\t\tonLayout={ onChipLayout }\n\t\t\t\tstyle={ chipStyles }\n\t\t\t\tpointerEvents=\"none\"\n\t\t\t>\n\t\t\t\t{ draggedBlockIcon && (\n\t\t\t\t\t<Animated.View\n\t\t\t\t\t\tentering={ ZoomInEasyDown.duration( 200 ) }\n\t\t\t\t\t\texiting={ exitingAnimation }\n\t\t\t\t\t>\n\t\t\t\t\t\t<DraggableChip icon={ draggedBlockIcon } />\n\t\t\t\t\t</Animated.View>\n\t\t\t\t) }\n\t\t\t</Animated.View>\n\t\t</>\n\t);\n};\n\nfunction useIsScreenReaderEnabled() {\n\tconst [ isScreenReaderEnabled, setIsScreenReaderEnabled ] =\n\t\tuseState( false );\n\n\tuseEffect( () => {\n\t\tlet mounted = true;\n\n\t\tconst changeListener = AccessibilityInfo.addEventListener(\n\t\t\t'screenReaderChanged',\n\t\t\t( enabled ) => setIsScreenReaderEnabled( enabled )\n\t\t);\n\n\t\tAccessibilityInfo.isScreenReaderEnabled().then(\n\t\t\t( screenReaderEnabled ) => {\n\t\t\t\tif ( mounted && screenReaderEnabled ) {\n\t\t\t\t\tsetIsScreenReaderEnabled( screenReaderEnabled );\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\treturn () => {\n\t\t\tmounted = false;\n\n\t\t\tchangeListener.remove();\n\t\t};\n\t}, [] );\n\n\treturn isScreenReaderEnabled;\n}\n\nfunction useIsEditingText() {\n\tconst [ isEditingText, setIsEditingText ] = useState( () =>\n\t\tRCTAztecView.InputState.isFocused()\n\t);\n\n\tuseEffect( () => {\n\t\tconst onFocusChangeAztec = ( { isFocused } ) => {\n\t\t\tsetIsEditingText( isFocused );\n\t\t};\n\n\t\tRCTAztecView.InputState.addFocusChangeListener( onFocusChangeAztec );\n\n\t\treturn () => {\n\t\t\tRCTAztecView.InputState.removeFocusChangeListener(\n\t\t\t\tonFocusChangeAztec\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\treturn isEditingText;\n}\n\n/**\n * Block draggable component\n *\n * This component serves for animating the block when it is being dragged.\n * Hence, it should be wrapped around the rendering of a block.\n *\n * @param {Object} props Component props.\n * @param {JSX.Element} props.children Children to be rendered.\n * @param {string} props.clientId Client id of the block.\n * @param {string} [props.draggingClientId] Client id to use for dragging. If not defined, the value from `clientId` will be used.\n * @param {boolean} [props.enabled] Enables the draggable trigger.\n * @param {string} [props.testID] Id used for querying the long-press gesture handler in tests.\n *\n * @return {Function} Render function which includes the parameter `isDraggable` to determine if the block can be dragged.\n */\nconst BlockDraggable = ( {\n\tclientId,\n\tchildren,\n\tdraggingClientId,\n\tenabled = true,\n\ttestID,\n} ) => {\n\tconst wasBeingDragged = useRef( false );\n\tconst isEditingText = useIsEditingText();\n\tconst isScreenReaderEnabled = useIsScreenReaderEnabled();\n\n\tconst draggingAnimation = {\n\t\topacity: useSharedValue( 1 ),\n\t};\n\n\tconst startDraggingBlock = () => {\n\t\tdraggingAnimation.opacity.value = withTiming(\n\t\t\t0.4,\n\t\t\tBLOCK_OPACITY_ANIMATION_CONFIG\n\t\t);\n\t};\n\n\tconst stopDraggingBlock = () => {\n\t\tdraggingAnimation.opacity.value = withDelay(\n\t\t\tBLOCK_OPACITY_ANIMATION_DELAY,\n\t\t\twithTiming( 1, BLOCK_OPACITY_ANIMATION_CONFIG )\n\t\t);\n\t};\n\n\tconst { isDraggable, isBeingDragged, isBlockSelected } = useSelect(\n\t\t( _select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tisBlockBeingDragged,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t} = _select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\tconst templateLock = rootClientId\n\t\t\t\t? getTemplateLock( rootClientId )\n\t\t\t\t: null;\n\t\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\n\t\t\treturn {\n\t\t\t\tisBeingDragged: isBlockBeingDragged( clientId ),\n\t\t\t\tisDraggable: 'all' !== templateLock,\n\t\t\t\tisBlockSelected:\n\t\t\t\t\tselectedBlockClientId && selectedBlockClientId === clientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( isBeingDragged !== wasBeingDragged.current ) {\n\t\t\tif ( isBeingDragged ) {\n\t\t\t\tstartDraggingBlock();\n\t\t\t} else {\n\t\t\t\tstopDraggingBlock();\n\t\t\t}\n\t\t}\n\t\twasBeingDragged.current = isBeingDragged;\n\t}, [ isBeingDragged ] );\n\n\tconst onLongPressDraggable = useCallback( () => {\n\t\t// Ensure that no text input is focused when starting the dragging gesture in order to prevent conflicts with text editing.\n\t\tRCTAztecView.InputState.blurCurrentFocusedElement();\n\t}, [] );\n\n\tconst animatedWrapperStyles = useAnimatedStyle( () => {\n\t\treturn {\n\t\t\topacity: draggingAnimation.opacity.value,\n\t\t};\n\t} );\n\tconst wrapperStyles = [\n\t\tanimatedWrapperStyles,\n\t\tstyles[ 'draggable-wrapper__container' ],\n\t];\n\n\tconst canDragBlock =\n\t\tenabled &&\n\t\t! isScreenReaderEnabled &&\n\t\t( ! isBlockSelected || ! isEditingText );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { isDraggable: false } );\n\t}\n\n\treturn (\n\t\t<DraggableTrigger\n\t\t\tid={ draggingClientId || clientId }\n\t\t\tenabled={ enabled && canDragBlock }\n\t\t\tminDuration={ Platform.select( {\n\t\t\t\t// On iOS, using a lower min duration than the default\n\t\t\t\t// value prevents the long-press gesture from being\n\t\t\t\t// triggered in underneath elements. This is required to\n\t\t\t\t// prevent enabling text editing when dragging is available.\n\t\t\t\tios: canDragBlock\n\t\t\t\t\t? DEFAULT_IOS_LONG_PRESS_MIN_DURATION\n\t\t\t\t\t: DEFAULT_LONG_PRESS_MIN_DURATION,\n\t\t\t\tandroid: DEFAULT_LONG_PRESS_MIN_DURATION,\n\t\t\t} ) }\n\t\t\tonLongPress={ onLongPressDraggable }\n\t\t\ttestID={ testID }\n\t\t>\n\t\t\t<Animated.View style={ wrapperStyles }>\n\t\t\t\t{ children( { isDraggable: true } ) }\n\t\t\t</Animated.View>\n\t\t</DraggableTrigger>\n\t);\n};\n\nexport { BlockDraggableWrapper };\nexport default BlockDraggable;\n"]}
|
|
@@ -5,7 +5,6 @@ import { createElement } from "@wordpress/element";
|
|
|
5
5
|
* External dependencies
|
|
6
6
|
*/
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
-
import { pick } from 'lodash';
|
|
9
8
|
/**
|
|
10
9
|
* WordPress dependencies
|
|
11
10
|
*/
|
|
@@ -37,7 +36,10 @@ export const Edit = props => {
|
|
|
37
36
|
const blockContext = useContext(BlockContext); // Assign context values using the block type's declared context needs.
|
|
38
37
|
|
|
39
38
|
const context = useMemo(() => {
|
|
40
|
-
return blockType && blockType.usesContext ?
|
|
39
|
+
return blockType && blockType.usesContext ? Object.fromEntries(Object.entries(blockContext).filter(_ref => {
|
|
40
|
+
let [key] = _ref;
|
|
41
|
+
return blockType.usesContext.includes(key);
|
|
42
|
+
})) : DEFAULT_BLOCK_CONTEXT;
|
|
41
43
|
}, [blockType, blockContext]);
|
|
42
44
|
|
|
43
45
|
if (!blockType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-edit/edit.js"],"names":["classnames","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-edit/edit.js"],"names":["classnames","withFilters","getBlockDefaultClassName","hasBlockSupport","getBlockType","useContext","useMemo","BlockContext","DEFAULT_BLOCK_CONTEXT","Edit","props","attributes","name","blockType","blockContext","context","usesContext","Object","fromEntries","entries","filter","key","includes","Component","edit","save","apiVersion","generatedClassName","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AAC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e,CAAEU,SAAF,EAAa,WAAb,EAA0B,IAA1B,CAAf,GACxBX,wBAAwB,CAAEU,IAAF,CADA,GAExB,IAFH;AAGA,QAAMgB,SAAS,GAAG5B,UAAU,CAC3B2B,kBAD2B,EAE3BhB,UAAU,CAACiB,SAFgB,EAG3BlB,KAAK,CAACkB,SAHqB,CAA5B;AAMA,SACC,cAAC,SAAD,eAAgBlB,KAAhB;AAAwB,IAAA,OAAO,EAAGK,OAAlC;AAA4C,IAAA,SAAS,EAAGa;AAAxD,KADD;AAGA,CA1CM;AA4CP,eAAe3B,WAAW,CAAE,kBAAF,CAAX,CAAmCQ,IAAnC,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { withFilters } from '@wordpress/components';\nimport {\n\tgetBlockDefaultClassName,\n\thasBlockSupport,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockContext from '../block-context';\n\n/**\n * Default value used for blocks which do not define their own context needs,\n * used to guarantee that a block's `context` prop will always be an object. It\n * is assigned as a constant since it is always expected to be an empty object,\n * and in order to avoid unnecessary React reconciliations of a changing object.\n *\n * @type {{}}\n */\nconst DEFAULT_BLOCK_CONTEXT = {};\n\nexport const Edit = ( props ) => {\n\tconst { attributes = {}, name } = props;\n\tconst blockType = getBlockType( name );\n\tconst blockContext = useContext( BlockContext );\n\n\t// Assign context values using the block type's declared context needs.\n\tconst context = useMemo( () => {\n\t\treturn blockType && blockType.usesContext\n\t\t\t? Object.fromEntries(\n\t\t\t\t\tObject.entries( blockContext ).filter( ( [ key ] ) =>\n\t\t\t\t\t\tblockType.usesContext.includes( key )\n\t\t\t\t\t)\n\t\t\t )\n\t\t\t: DEFAULT_BLOCK_CONTEXT;\n\t}, [ blockType, blockContext ] );\n\n\tif ( ! blockType ) {\n\t\treturn null;\n\t}\n\n\t// `edit` and `save` are functions or components describing the markup\n\t// with which a block is displayed. If `blockType` is valid, assign\n\t// them preferentially as the render value for the block.\n\tconst Component = blockType.edit || blockType.save;\n\n\tif ( blockType.apiVersion > 1 ) {\n\t\treturn <Component { ...props } context={ context } />;\n\t}\n\n\t// Generate a class name for the block's editable form.\n\tconst generatedClassName = hasBlockSupport( blockType, 'className', true )\n\t\t? getBlockDefaultClassName( name )\n\t\t: null;\n\tconst className = classnames(\n\t\tgeneratedClassName,\n\t\tattributes.className,\n\t\tprops.className\n\t);\n\n\treturn (\n\t\t<Component { ...props } context={ context } className={ className } />\n\t);\n};\n\nexport default withFilters( 'editor.BlockEdit' )( Edit );\n"]}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { createElement } from "@wordpress/element";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* External dependencies
|
|
6
|
-
*/
|
|
7
|
-
import { pick } from 'lodash';
|
|
8
4
|
/**
|
|
9
5
|
* WordPress dependencies
|
|
10
6
|
*/
|
|
11
|
-
|
|
12
7
|
import { withFilters } from '@wordpress/components';
|
|
13
8
|
import { getBlockType } from '@wordpress/blocks';
|
|
14
9
|
import { useContext, useMemo } from '@wordpress/element';
|
|
@@ -35,7 +30,10 @@ export const Edit = props => {
|
|
|
35
30
|
const blockContext = useContext(BlockContext); // Assign context values using the block type's declared context needs.
|
|
36
31
|
|
|
37
32
|
const context = useMemo(() => {
|
|
38
|
-
return blockType && blockType.usesContext ?
|
|
33
|
+
return blockType && blockType.usesContext ? Object.fromEntries(Object.entries(blockContext).filter(_ref => {
|
|
34
|
+
let [key] = _ref;
|
|
35
|
+
return blockType.usesContext.includes(key);
|
|
36
|
+
})) : DEFAULT_BLOCK_CONTEXT;
|
|
39
37
|
}, [blockType, blockContext]);
|
|
40
38
|
|
|
41
39
|
if (!blockType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-edit/edit.native.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-edit/edit.native.js"],"names":["withFilters","getBlockType","useContext","useMemo","BlockContext","DEFAULT_BLOCK_CONTEXT","Edit","props","name","blockType","blockContext","context","usesContext","Object","fromEntries","entries","filter","key","includes","Component","edit"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,uBAA5B;AACA,SAASC,YAAT,QAA6B,mBAA7B;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,qBAAqB,GAAG,EAA9B;AAEA,OAAO,MAAMC,IAAI,GAAKC,KAAF,IAAa;AAChC,QAAM;AAAEC,IAAAA;AAAF,MAAWD,KAAjB;AACA,QAAME,SAAS,GAAGR,YAAY,CAAEO,IAAF,CAA9B;AAEA,QAAME,YAAY,GAAGR,UAAU,CAAEE,YAAF,CAA/B,CAJgC,CAMhC;;AACA,QAAMO,OAAO,GAAGR,OAAO,CAAE,MAAM;AAC9B,WAAOM,SAAS,IAAIA,SAAS,CAACG,WAAvB,GACJC,MAAM,CAACC,WAAP,CACAD,MAAM,CAACE,OAAP,CAAgBL,YAAhB,EAA+BM,MAA/B,CAAuC;AAAA,UAAE,CAAEC,GAAF,CAAF;AAAA,aACtCR,SAAS,CAACG,WAAV,CAAsBM,QAAtB,CAAgCD,GAAhC,CADsC;AAAA,KAAvC,CADA,CADI,GAMJZ,qBANH;AAOA,GARsB,EAQpB,CAAEI,SAAF,EAAaC,YAAb,CARoB,CAAvB;;AAUA,MAAK,CAAED,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,QAAMU,SAAS,GAAGV,SAAS,CAACW,IAA5B;AAEA,SAAO,cAAC,SAAD,eAAgBb,KAAhB;AAAwB,IAAA,OAAO,EAAGI;AAAlC,KAAP;AACA,CAxBM;AA0BP,eAAeX,WAAW,CAAE,kBAAF,CAAX,CAAmCM,IAAnC,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { withFilters } from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockContext from '../block-context';\n\n/**\n * Default value used for blocks which do not define their own context needs,\n * used to guarantee that a block's `context` prop will always be an object. It\n * is assigned as a constant since it is always expected to be an empty object,\n * and in order to avoid unnecessary React reconciliations of a changing object.\n *\n * @type {{}}\n */\nconst DEFAULT_BLOCK_CONTEXT = {};\n\nexport const Edit = ( props ) => {\n\tconst { name } = props;\n\tconst blockType = getBlockType( name );\n\n\tconst blockContext = useContext( BlockContext );\n\n\t// Assign context values using the block type's declared context needs.\n\tconst context = useMemo( () => {\n\t\treturn blockType && blockType.usesContext\n\t\t\t? Object.fromEntries(\n\t\t\t\t\tObject.entries( blockContext ).filter( ( [ key ] ) =>\n\t\t\t\t\t\tblockType.usesContext.includes( key )\n\t\t\t\t\t)\n\t\t\t )\n\t\t\t: DEFAULT_BLOCK_CONTEXT;\n\t}, [ blockType, blockContext ] );\n\n\tif ( ! blockType ) {\n\t\treturn null;\n\t}\n\n\tconst Component = blockType.edit;\n\n\treturn <Component { ...props } context={ context } />;\n};\n\nexport default withFilters( 'editor.BlockEdit' )( Edit );\n"]}
|