@wordpress/block-editor 12.12.2-next.f8d8eceb.0 → 12.14.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 +3 -1
- package/build/components/block-heading-level-dropdown/index.js +1 -1
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-list/index.js +2 -9
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +16 -3
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +6 -4
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-styles/index.js +0 -8
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +18 -14
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +11 -81
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/empty-block-inserter.js +56 -0
- package/build/components/block-tools/empty-block-inserter.js.map +1 -0
- package/build/components/block-tools/index.js +48 -9
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/selected-block-tools.js +113 -0
- package/build/components/block-tools/selected-block-tools.js.map +1 -0
- package/build/components/block-tools/use-selected-block-tool-props.js +56 -0
- package/build/components/block-tools/use-selected-block-tool-props.js.map +1 -0
- package/build/components/editable-text/index.js +1 -2
- package/build/components/editable-text/index.js.map +1 -1
- package/build/components/iframe/index.js +4 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/{explorer.js → index.js} +7 -7
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -4
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/index.js +75 -0
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +108 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
- package/build/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +18 -34
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +55 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/utils.js +70 -0
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +9 -5
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +15 -12
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.js +3 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/link-control/index.js +6 -5
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +39 -0
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +16 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/index.js +3 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +69 -18
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +1 -14
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +1 -1
- package/build/components/resizable-box-popover/index.js.map +1 -1
- package/build/components/rich-text/index.js +0 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/format-edit.js +45 -0
- package/build/components/rich-text/native/format-edit.js.map +1 -0
- package/build/components/rich-text/native/get-format-colors.native.js +41 -0
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -0
- package/build/components/rich-text/native/index.js +9 -0
- package/build/components/rich-text/native/index.js.map +1 -0
- package/build/components/rich-text/native/index.native.js +1158 -0
- package/build/components/rich-text/native/index.native.js.map +1 -0
- package/build/components/rich-text/native/toolbar-button-with-options.native.js +58 -0
- package/build/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
- package/build/components/rich-text/native/use-format-types.js +111 -0
- package/build/components/rich-text/native/use-format-types.js.map +1 -0
- package/build/components/rich-text/use-paste-handler.js +2 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +7 -3
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +10 -10
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +2 -2
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +7 -6
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +16 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +7 -8
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-rename-ui.js +7 -5
- package/build/hooks/block-rename-ui.js.map +1 -1
- package/build/hooks/content-lock-ui.js +5 -5
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +8 -7
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-fields.js +4 -4
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/duotone.js +14 -22
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +90 -86
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +10 -9
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +10 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +30 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +3 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +30 -37
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +18 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -13
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-list/index.js +3 -10
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +16 -3
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +7 -5
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +0 -8
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +17 -13
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +11 -80
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/empty-block-inserter.js +48 -0
- package/build-module/components/block-tools/empty-block-inserter.js.map +1 -0
- package/build-module/components/block-tools/index.js +48 -9
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-tools.js +105 -0
- package/build-module/components/block-tools/selected-block-tools.js.map +1 -0
- package/build-module/components/block-tools/use-selected-block-tool-props.js +50 -0
- package/build-module/components/block-tools/use-selected-block-tool-props.js.map +1 -0
- package/build-module/components/editable-text/index.js +1 -2
- package/build-module/components/editable-text/index.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/{explorer.js → index.js} +5 -5
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/index.js +66 -0
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +42 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +100 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
- package/build-module/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +7 -20
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +47 -0
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js +58 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +9 -5
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +15 -12
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.js +4 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/link-control/index.js +7 -6
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +39 -0
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/index.js +3 -2
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +69 -17
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +1 -14
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +1 -1
- package/build-module/components/resizable-box-popover/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/format-edit.js +38 -0
- package/build-module/components/rich-text/native/format-edit.js.map +1 -0
- package/build-module/components/rich-text/native/get-format-colors.native.js +34 -0
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -0
- package/build-module/components/rich-text/native/index.js +2 -0
- package/build-module/components/rich-text/native/index.js.map +1 -0
- package/build-module/components/rich-text/native/index.native.js +1148 -0
- package/build-module/components/rich-text/native/index.native.js.map +1 -0
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +51 -0
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
- package/build-module/components/rich-text/native/use-format-types.js +104 -0
- package/build-module/components/rich-text/native/use-format-types.js.map +1 -0
- package/build-module/components/rich-text/use-paste-handler.js +2 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +2 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +7 -3
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +8 -8
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +2 -2
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +5 -4
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +17 -5
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +5 -6
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-rename-ui.js +5 -3
- package/build-module/hooks/block-rename-ui.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +3 -3
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +6 -5
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-fields.js +4 -4
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/duotone.js +15 -23
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +90 -86
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +11 -10
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +10 -13
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +30 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +4 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +29 -37
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +17 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +15 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +16 -15
- package/build-style/style.css +16 -15
- package/package.json +31 -31
- package/src/components/block-heading-level-dropdown/index.js +1 -1
- package/src/components/block-list/index.js +4 -18
- package/src/components/block-list-appender/index.js +20 -4
- package/src/components/block-quick-navigation/index.js +11 -5
- package/src/components/block-styles/index.js +0 -10
- package/src/components/block-switcher/pattern-transformations-menu.js +20 -14
- package/src/components/block-toolbar/style.scss +8 -0
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-contextual-toolbar.js +11 -134
- package/src/components/block-tools/empty-block-inserter.js +56 -0
- package/src/components/block-tools/index.js +72 -16
- package/src/components/block-tools/selected-block-tools.js +127 -0
- package/src/components/block-tools/style.scss +0 -10
- package/src/components/block-tools/use-selected-block-tool-props.js +66 -0
- package/src/components/editable-text/index.js +1 -8
- package/src/components/iframe/index.js +4 -3
- package/src/components/inserter/block-patterns-explorer/{explorer.js → index.js} +4 -4
- package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -1
- package/src/components/inserter/block-patterns-tab/index.js +118 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +175 -0
- package/src/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +15 -21
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +96 -0
- package/src/components/inserter/block-patterns-tab/utils.js +76 -0
- package/src/components/inserter/media-tab/media-list.js +7 -7
- package/src/components/inserter/media-tab/media-preview.js +27 -22
- package/src/components/inserter/menu.js +4 -5
- package/src/components/link-control/README.md +2 -2
- package/src/components/link-control/index.js +15 -6
- package/src/components/link-control/style.scss +8 -5
- package/src/components/list-view/block-select-button.js +44 -1
- package/src/components/list-view/block.js +11 -11
- package/src/components/list-view/index.js +2 -0
- package/src/components/media-replace-flow/style.scss +2 -2
- package/src/components/navigable-toolbar/index.js +71 -25
- package/src/components/plain-text/README.md +3 -3
- package/src/components/provider/use-block-sync.js +2 -21
- package/src/components/resizable-box-popover/index.js +1 -1
- package/src/components/rich-text/README.md +9 -8
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +3 -1
- package/src/components/rich-text/native/format-edit.js +44 -0
- package/src/components/rich-text/native/get-format-colors.native.js +54 -0
- package/src/components/rich-text/native/index.js +1 -0
- package/src/components/rich-text/native/index.native.js +1363 -0
- package/src/components/rich-text/native/style.native.scss +28 -0
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +79 -0
- package/src/components/rich-text/native/test/index.native.js +278 -0
- package/src/components/rich-text/native/test/performance/rich-text.native.js +44 -0
- package/src/components/rich-text/native/toolbar-button-with-options.native.js +61 -0
- package/src/components/rich-text/native/use-format-types.js +146 -0
- package/src/components/rich-text/use-paste-handler.js +1 -6
- package/src/components/url-popover/image-url-input-ui.js +1 -0
- package/src/components/writing-flow/use-tab-nav.js +8 -3
- package/src/hooks/align.js +8 -8
- package/src/hooks/align.native.js +2 -2
- package/src/hooks/anchor.js +21 -23
- package/src/hooks/background.js +28 -6
- package/src/hooks/block-hooks.js +20 -16
- package/src/hooks/block-rename-ui.js +6 -4
- package/src/hooks/content-lock-ui.js +3 -3
- package/src/hooks/custom-class-name.js +7 -6
- package/src/hooks/custom-fields.js +5 -5
- package/src/hooks/duotone.js +29 -38
- package/src/hooks/layout.js +114 -105
- package/src/hooks/position.js +8 -21
- package/src/hooks/style.js +17 -31
- package/src/hooks/test/align.js +4 -4
- package/src/hooks/utils.js +33 -1
- package/src/private-apis.js +4 -1
- package/src/store/actions.js +26 -72
- package/src/store/reducer.js +19 -0
- package/src/store/selectors.js +13 -19
- package/build/components/block-tools/selected-block-popover.js +0 -221
- package/build/components/block-tools/selected-block-popover.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
- package/build/components/inserter/block-patterns-filter.js.map +0 -1
- package/build/components/inserter/block-patterns-tab.js +0 -270
- package/build/components/inserter/block-patterns-tab.js.map +0 -1
- package/build/store/utils.js +0 -22
- package/build/store/utils.js.map +0 -1
- package/build-module/components/block-tools/selected-block-popover.js +0 -213
- package/build-module/components/block-tools/selected-block-popover.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
- package/build-module/components/inserter/block-patterns-filter.js.map +0 -1
- package/build-module/components/inserter/block-patterns-tab.js +0 -254
- package/build-module/components/inserter/block-patterns-tab.js.map +0 -1
- package/build-module/store/utils.js +0 -16
- package/build-module/store/utils.js.map +0 -1
- package/src/components/block-tools/selected-block-popover.js +0 -265
- package/src/components/inserter/block-patterns-tab.js +0 -448
- package/src/store/utils.js +0 -12
- /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
package/src/store/actions.js
CHANGED
|
@@ -23,7 +23,6 @@ import deprecated from '@wordpress/deprecated';
|
|
|
23
23
|
/**
|
|
24
24
|
* Internal dependencies
|
|
25
25
|
*/
|
|
26
|
-
import { mapRichTextSettings } from './utils';
|
|
27
26
|
import {
|
|
28
27
|
retrieveSelectedAttribute,
|
|
29
28
|
START_OF_SELECTED_AREA,
|
|
@@ -759,43 +758,23 @@ export const __unstableDeleteSelection =
|
|
|
759
758
|
const selectionB = selectionEnd;
|
|
760
759
|
|
|
761
760
|
const blockA = select.getBlock( selectionA.clientId );
|
|
762
|
-
const blockAType = getBlockType( blockA.name );
|
|
763
|
-
|
|
764
761
|
const blockB = select.getBlock( selectionB.clientId );
|
|
765
|
-
const blockBType = getBlockType( blockB.name );
|
|
766
762
|
|
|
767
763
|
const htmlA = blockA.attributes[ selectionA.attributeKey ];
|
|
768
764
|
const htmlB = blockB.attributes[ selectionB.attributeKey ];
|
|
769
765
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
const attributeDefinitionB =
|
|
773
|
-
blockBType.attributes[ selectionB.attributeKey ];
|
|
774
|
-
|
|
775
|
-
let valueA = create( {
|
|
776
|
-
html: htmlA,
|
|
777
|
-
...mapRichTextSettings( attributeDefinitionA ),
|
|
778
|
-
} );
|
|
779
|
-
let valueB = create( {
|
|
780
|
-
html: htmlB,
|
|
781
|
-
...mapRichTextSettings( attributeDefinitionB ),
|
|
782
|
-
} );
|
|
766
|
+
let valueA = create( { html: htmlA } );
|
|
767
|
+
let valueB = create( { html: htmlB } );
|
|
783
768
|
|
|
784
769
|
valueA = remove( valueA, selectionA.offset, valueA.text.length );
|
|
785
770
|
valueB = insert( valueB, START_OF_SELECTED_AREA, 0, selectionB.offset );
|
|
786
771
|
|
|
787
772
|
// Clone the blocks so we don't manipulate the original.
|
|
788
773
|
const cloneA = cloneBlock( blockA, {
|
|
789
|
-
[ selectionA.attributeKey ]: toHTMLString( {
|
|
790
|
-
value: valueA,
|
|
791
|
-
...mapRichTextSettings( attributeDefinitionA ),
|
|
792
|
-
} ),
|
|
774
|
+
[ selectionA.attributeKey ]: toHTMLString( { value: valueA } ),
|
|
793
775
|
} );
|
|
794
776
|
const cloneB = cloneBlock( blockB, {
|
|
795
|
-
[ selectionB.attributeKey ]: toHTMLString( {
|
|
796
|
-
value: valueB,
|
|
797
|
-
...mapRichTextSettings( attributeDefinitionB ),
|
|
798
|
-
} ),
|
|
777
|
+
[ selectionB.attributeKey ]: toHTMLString( { value: valueB } ),
|
|
799
778
|
} );
|
|
800
779
|
|
|
801
780
|
const followingBlock = isForward ? cloneA : cloneB;
|
|
@@ -831,20 +810,10 @@ export const __unstableDeleteSelection =
|
|
|
831
810
|
const newAttributeKey = retrieveSelectedAttribute( updatedAttributes );
|
|
832
811
|
|
|
833
812
|
const convertedHtml = updatedAttributes[ newAttributeKey ];
|
|
834
|
-
const convertedValue = create( {
|
|
835
|
-
html: convertedHtml,
|
|
836
|
-
...mapRichTextSettings(
|
|
837
|
-
targetBlockType.attributes[ newAttributeKey ]
|
|
838
|
-
),
|
|
839
|
-
} );
|
|
813
|
+
const convertedValue = create( { html: convertedHtml } );
|
|
840
814
|
const newOffset = convertedValue.text.indexOf( START_OF_SELECTED_AREA );
|
|
841
815
|
const newValue = remove( convertedValue, newOffset, newOffset + 1 );
|
|
842
|
-
const newHtml = toHTMLString( {
|
|
843
|
-
value: newValue,
|
|
844
|
-
...mapRichTextSettings(
|
|
845
|
-
targetBlockType.attributes[ newAttributeKey ]
|
|
846
|
-
),
|
|
847
|
-
} );
|
|
816
|
+
const newHtml = toHTMLString( { value: newValue } );
|
|
848
817
|
|
|
849
818
|
updatedAttributes[ newAttributeKey ] = newHtml;
|
|
850
819
|
|
|
@@ -931,27 +900,13 @@ export const __unstableSplitSelection =
|
|
|
931
900
|
const selectionB = selectionEnd;
|
|
932
901
|
|
|
933
902
|
const blockA = select.getBlock( selectionA.clientId );
|
|
934
|
-
const blockAType = getBlockType( blockA.name );
|
|
935
|
-
|
|
936
903
|
const blockB = select.getBlock( selectionB.clientId );
|
|
937
|
-
const blockBType = getBlockType( blockB.name );
|
|
938
904
|
|
|
939
905
|
const htmlA = blockA.attributes[ selectionA.attributeKey ];
|
|
940
906
|
const htmlB = blockB.attributes[ selectionB.attributeKey ];
|
|
941
907
|
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
const attributeDefinitionB =
|
|
945
|
-
blockBType.attributes[ selectionB.attributeKey ];
|
|
946
|
-
|
|
947
|
-
let valueA = create( {
|
|
948
|
-
html: htmlA,
|
|
949
|
-
...mapRichTextSettings( attributeDefinitionA ),
|
|
950
|
-
} );
|
|
951
|
-
let valueB = create( {
|
|
952
|
-
html: htmlB,
|
|
953
|
-
...mapRichTextSettings( attributeDefinitionB ),
|
|
954
|
-
} );
|
|
908
|
+
let valueA = create( { html: htmlA } );
|
|
909
|
+
let valueB = create( { html: htmlB } );
|
|
955
910
|
|
|
956
911
|
valueA = remove( valueA, selectionA.offset, valueA.text.length );
|
|
957
912
|
valueB = remove( valueB, 0, selectionB.offset );
|
|
@@ -964,7 +919,6 @@ export const __unstableSplitSelection =
|
|
|
964
919
|
...blockA.attributes,
|
|
965
920
|
[ selectionA.attributeKey ]: toHTMLString( {
|
|
966
921
|
value: valueA,
|
|
967
|
-
...mapRichTextSettings( attributeDefinitionA ),
|
|
968
922
|
} ),
|
|
969
923
|
},
|
|
970
924
|
},
|
|
@@ -975,7 +929,6 @@ export const __unstableSplitSelection =
|
|
|
975
929
|
...blockB.attributes,
|
|
976
930
|
[ selectionB.attributeKey ]: toHTMLString( {
|
|
977
931
|
value: valueB,
|
|
978
|
-
...mapRichTextSettings( attributeDefinitionB ),
|
|
979
932
|
} ),
|
|
980
933
|
},
|
|
981
934
|
},
|
|
@@ -1143,10 +1096,7 @@ export const mergeBlocks =
|
|
|
1143
1096
|
const selectedBlock = clientId === clientIdA ? cloneA : cloneB;
|
|
1144
1097
|
const html = selectedBlock.attributes[ attributeKey ];
|
|
1145
1098
|
const value = insert(
|
|
1146
|
-
create( {
|
|
1147
|
-
html,
|
|
1148
|
-
...mapRichTextSettings( attributeDefinition ),
|
|
1149
|
-
} ),
|
|
1099
|
+
create( { html } ),
|
|
1150
1100
|
START_OF_SELECTED_AREA,
|
|
1151
1101
|
offset,
|
|
1152
1102
|
offset
|
|
@@ -1154,7 +1104,6 @@ export const mergeBlocks =
|
|
|
1154
1104
|
|
|
1155
1105
|
selectedBlock.attributes[ attributeKey ] = toHTMLString( {
|
|
1156
1106
|
value,
|
|
1157
|
-
...mapRichTextSettings( attributeDefinition ),
|
|
1158
1107
|
} );
|
|
1159
1108
|
}
|
|
1160
1109
|
|
|
@@ -1180,22 +1129,12 @@ export const mergeBlocks =
|
|
|
1180
1129
|
const newAttributeKey =
|
|
1181
1130
|
retrieveSelectedAttribute( updatedAttributes );
|
|
1182
1131
|
const convertedHtml = updatedAttributes[ newAttributeKey ];
|
|
1183
|
-
const convertedValue = create( {
|
|
1184
|
-
html: convertedHtml,
|
|
1185
|
-
...mapRichTextSettings(
|
|
1186
|
-
blockAType.attributes[ newAttributeKey ]
|
|
1187
|
-
),
|
|
1188
|
-
} );
|
|
1132
|
+
const convertedValue = create( { html: convertedHtml } );
|
|
1189
1133
|
const newOffset = convertedValue.text.indexOf(
|
|
1190
1134
|
START_OF_SELECTED_AREA
|
|
1191
1135
|
);
|
|
1192
1136
|
const newValue = remove( convertedValue, newOffset, newOffset + 1 );
|
|
1193
|
-
const newHtml = toHTMLString( {
|
|
1194
|
-
value: newValue,
|
|
1195
|
-
...mapRichTextSettings(
|
|
1196
|
-
blockAType.attributes[ newAttributeKey ]
|
|
1197
|
-
),
|
|
1198
|
-
} );
|
|
1137
|
+
const newHtml = toHTMLString( { value: newValue } );
|
|
1199
1138
|
|
|
1200
1139
|
updatedAttributes[ newAttributeKey ] = newHtml;
|
|
1201
1140
|
|
|
@@ -1980,3 +1919,18 @@ export function unsetBlockEditingMode( clientId = '' ) {
|
|
|
1980
1919
|
clientId,
|
|
1981
1920
|
};
|
|
1982
1921
|
}
|
|
1922
|
+
|
|
1923
|
+
/**
|
|
1924
|
+
* Action that sets the element that had focus when focus leaves the editor canvas.
|
|
1925
|
+
*
|
|
1926
|
+
* @param {Object} lastFocus The last focused element.
|
|
1927
|
+
*
|
|
1928
|
+
*
|
|
1929
|
+
* @return {Object} Action object.
|
|
1930
|
+
*/
|
|
1931
|
+
export function setLastFocus( lastFocus = null ) {
|
|
1932
|
+
return {
|
|
1933
|
+
type: 'LAST_FOCUS',
|
|
1934
|
+
lastFocus,
|
|
1935
|
+
};
|
|
1936
|
+
}
|
package/src/store/reducer.js
CHANGED
|
@@ -1962,6 +1962,24 @@ export function registeredInserterMediaCategories( state = [], action ) {
|
|
|
1962
1962
|
case 'REGISTER_INSERTER_MEDIA_CATEGORY':
|
|
1963
1963
|
return [ ...state, action.category ];
|
|
1964
1964
|
}
|
|
1965
|
+
|
|
1966
|
+
return state;
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* Reducer setting last focused element
|
|
1971
|
+
*
|
|
1972
|
+
* @param {boolean} state Current state.
|
|
1973
|
+
* @param {Object} action Dispatched action.
|
|
1974
|
+
*
|
|
1975
|
+
* @return {boolean} Updated state.
|
|
1976
|
+
*/
|
|
1977
|
+
export function lastFocus( state = false, action ) {
|
|
1978
|
+
switch ( action.type ) {
|
|
1979
|
+
case 'LAST_FOCUS':
|
|
1980
|
+
return action.lastFocus;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1965
1983
|
return state;
|
|
1966
1984
|
}
|
|
1967
1985
|
|
|
@@ -1981,6 +1999,7 @@ const combinedReducers = combineReducers( {
|
|
|
1981
1999
|
settings,
|
|
1982
2000
|
preferences,
|
|
1983
2001
|
lastBlockAttributesChange,
|
|
2002
|
+
lastFocus,
|
|
1984
2003
|
editorMode,
|
|
1985
2004
|
hasBlockMovingClientId,
|
|
1986
2005
|
highlightedBlock,
|
package/src/store/selectors.js
CHANGED
|
@@ -26,7 +26,6 @@ import { createRegistrySelector } from '@wordpress/data';
|
|
|
26
26
|
/**
|
|
27
27
|
* Internal dependencies
|
|
28
28
|
*/
|
|
29
|
-
import { mapRichTextSettings } from './utils';
|
|
30
29
|
import { orderBy } from '../utils/sorting';
|
|
31
30
|
|
|
32
31
|
/**
|
|
@@ -1114,27 +1113,13 @@ export const __unstableGetSelectedBlocksWithPartialSelection = ( state ) => {
|
|
|
1114
1113
|
: [ selectionAnchor, selectionFocus ];
|
|
1115
1114
|
|
|
1116
1115
|
const blockA = getBlock( state, selectionStart.clientId );
|
|
1117
|
-
const blockAType = getBlockType( blockA.name );
|
|
1118
|
-
|
|
1119
1116
|
const blockB = getBlock( state, selectionEnd.clientId );
|
|
1120
|
-
const blockBType = getBlockType( blockB.name );
|
|
1121
1117
|
|
|
1122
1118
|
const htmlA = blockA.attributes[ selectionStart.attributeKey ];
|
|
1123
1119
|
const htmlB = blockB.attributes[ selectionEnd.attributeKey ];
|
|
1124
1120
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
const attributeDefinitionB =
|
|
1128
|
-
blockBType.attributes[ selectionEnd.attributeKey ];
|
|
1129
|
-
|
|
1130
|
-
let valueA = create( {
|
|
1131
|
-
html: htmlA,
|
|
1132
|
-
...mapRichTextSettings( attributeDefinitionA ),
|
|
1133
|
-
} );
|
|
1134
|
-
let valueB = create( {
|
|
1135
|
-
html: htmlB,
|
|
1136
|
-
...mapRichTextSettings( attributeDefinitionB ),
|
|
1137
|
-
} );
|
|
1121
|
+
let valueA = create( { html: htmlA } );
|
|
1122
|
+
let valueB = create( { html: htmlB } );
|
|
1138
1123
|
|
|
1139
1124
|
valueA = remove( valueA, 0, selectionStart.offset );
|
|
1140
1125
|
valueB = remove( valueB, selectionEnd.offset, valueB.text.length );
|
|
@@ -1146,7 +1131,6 @@ export const __unstableGetSelectedBlocksWithPartialSelection = ( state ) => {
|
|
|
1146
1131
|
...blockA.attributes,
|
|
1147
1132
|
[ selectionStart.attributeKey ]: toHTMLString( {
|
|
1148
1133
|
value: valueA,
|
|
1149
|
-
...mapRichTextSettings( attributeDefinitionA ),
|
|
1150
1134
|
} ),
|
|
1151
1135
|
},
|
|
1152
1136
|
},
|
|
@@ -1156,7 +1140,6 @@ export const __unstableGetSelectedBlocksWithPartialSelection = ( state ) => {
|
|
|
1156
1140
|
...blockB.attributes,
|
|
1157
1141
|
[ selectionEnd.attributeKey ]: toHTMLString( {
|
|
1158
1142
|
value: valueB,
|
|
1159
|
-
...mapRichTextSettings( attributeDefinitionB ),
|
|
1160
1143
|
} ),
|
|
1161
1144
|
},
|
|
1162
1145
|
},
|
|
@@ -3022,3 +3005,14 @@ export const isGroupable = createRegistrySelector(
|
|
|
3022
3005
|
);
|
|
3023
3006
|
}
|
|
3024
3007
|
);
|
|
3008
|
+
|
|
3009
|
+
/**
|
|
3010
|
+
* Returns the element of the last element that had focus when focus left the editor canvas.
|
|
3011
|
+
*
|
|
3012
|
+
* @param {Object} state Block editor state.
|
|
3013
|
+
*
|
|
3014
|
+
* @return {Object} Element.
|
|
3015
|
+
*/
|
|
3016
|
+
export function getLastFocus( state ) {
|
|
3017
|
+
return state.lastFocus;
|
|
3018
|
+
}
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = WrappedBlockPopover;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
var _blocks = require("@wordpress/blocks");
|
|
12
|
-
var _data = require("@wordpress/data");
|
|
13
|
-
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
14
|
-
var _blockSelectionButton = _interopRequireDefault(require("./block-selection-button"));
|
|
15
|
-
var _blockContextualToolbar = _interopRequireDefault(require("./block-contextual-toolbar"));
|
|
16
|
-
var _store = require("../../store");
|
|
17
|
-
var _blockPopover = _interopRequireDefault(require("../block-popover"));
|
|
18
|
-
var _useBlockToolbarPopoverProps = _interopRequireDefault(require("./use-block-toolbar-popover-props"));
|
|
19
|
-
var _inserter = _interopRequireDefault(require("../inserter"));
|
|
20
|
-
var _useShouldContextualToolbarShow = require("../../utils/use-should-contextual-toolbar-show");
|
|
21
|
-
/**
|
|
22
|
-
* External dependencies
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* WordPress dependencies
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Internal dependencies
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
function selector(select) {
|
|
34
|
-
const {
|
|
35
|
-
__unstableGetEditorMode,
|
|
36
|
-
hasMultiSelection,
|
|
37
|
-
isTyping,
|
|
38
|
-
getLastMultiSelectedBlockClientId
|
|
39
|
-
} = select(_store.store);
|
|
40
|
-
return {
|
|
41
|
-
editorMode: __unstableGetEditorMode(),
|
|
42
|
-
hasMultiSelection: hasMultiSelection(),
|
|
43
|
-
isTyping: isTyping(),
|
|
44
|
-
lastClientId: hasMultiSelection() ? getLastMultiSelectedBlockClientId() : null
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function SelectedBlockPopover({
|
|
48
|
-
clientId,
|
|
49
|
-
rootClientId,
|
|
50
|
-
isEmptyDefaultBlock,
|
|
51
|
-
capturingClientId,
|
|
52
|
-
__unstablePopoverSlot,
|
|
53
|
-
__unstableContentRef
|
|
54
|
-
}) {
|
|
55
|
-
const {
|
|
56
|
-
editorMode,
|
|
57
|
-
hasMultiSelection,
|
|
58
|
-
isTyping,
|
|
59
|
-
lastClientId
|
|
60
|
-
} = (0, _data.useSelect)(selector, []);
|
|
61
|
-
const isInsertionPointVisible = (0, _data.useSelect)(select => {
|
|
62
|
-
const {
|
|
63
|
-
isBlockInsertionPointVisible,
|
|
64
|
-
getBlockInsertionPoint,
|
|
65
|
-
getBlockOrder
|
|
66
|
-
} = select(_store.store);
|
|
67
|
-
if (!isBlockInsertionPointVisible()) {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
const insertionPoint = getBlockInsertionPoint();
|
|
71
|
-
const order = getBlockOrder(insertionPoint.rootClientId);
|
|
72
|
-
return order[insertionPoint.index] === clientId;
|
|
73
|
-
}, [clientId]);
|
|
74
|
-
const isToolbarForced = (0, _element.useRef)(false);
|
|
75
|
-
const {
|
|
76
|
-
shouldShowContextualToolbar,
|
|
77
|
-
canFocusHiddenToolbar
|
|
78
|
-
} = (0, _useShouldContextualToolbarShow.useShouldContextualToolbarShow)();
|
|
79
|
-
const {
|
|
80
|
-
stopTyping
|
|
81
|
-
} = (0, _data.useDispatch)(_store.store);
|
|
82
|
-
const showEmptyBlockSideInserter = !isTyping && editorMode === 'edit' && isEmptyDefaultBlock;
|
|
83
|
-
const shouldShowBreadcrumb = !hasMultiSelection && (editorMode === 'navigation' || editorMode === 'zoom-out');
|
|
84
|
-
(0, _keyboardShortcuts.useShortcut)('core/block-editor/focus-toolbar', () => {
|
|
85
|
-
isToolbarForced.current = true;
|
|
86
|
-
stopTyping(true);
|
|
87
|
-
}, {
|
|
88
|
-
isDisabled: !canFocusHiddenToolbar
|
|
89
|
-
});
|
|
90
|
-
(0, _element.useEffect)(() => {
|
|
91
|
-
isToolbarForced.current = false;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// Stores the active toolbar item index so the block toolbar can return focus
|
|
95
|
-
// to it when re-mounting.
|
|
96
|
-
const initialToolbarItemIndexRef = (0, _element.useRef)();
|
|
97
|
-
(0, _element.useEffect)(() => {
|
|
98
|
-
// Resets the index whenever the active block changes so this is not
|
|
99
|
-
// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
100
|
-
initialToolbarItemIndexRef.current = undefined;
|
|
101
|
-
}, [clientId]);
|
|
102
|
-
const popoverProps = (0, _useBlockToolbarPopoverProps.default)({
|
|
103
|
-
contentElement: __unstableContentRef?.current,
|
|
104
|
-
clientId
|
|
105
|
-
});
|
|
106
|
-
if (showEmptyBlockSideInserter) {
|
|
107
|
-
return (0, _react.createElement)(_blockPopover.default, {
|
|
108
|
-
clientId: capturingClientId || clientId,
|
|
109
|
-
__unstableCoverTarget: true,
|
|
110
|
-
bottomClientId: lastClientId,
|
|
111
|
-
className: (0, _classnames.default)('block-editor-block-list__block-side-inserter-popover', {
|
|
112
|
-
'is-insertion-point-visible': isInsertionPointVisible
|
|
113
|
-
}),
|
|
114
|
-
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
115
|
-
__unstableContentRef: __unstableContentRef,
|
|
116
|
-
resize: false,
|
|
117
|
-
shift: false,
|
|
118
|
-
...popoverProps
|
|
119
|
-
}, (0, _react.createElement)("div", {
|
|
120
|
-
className: "block-editor-block-list__empty-block-inserter"
|
|
121
|
-
}, (0, _react.createElement)(_inserter.default, {
|
|
122
|
-
position: "bottom right",
|
|
123
|
-
rootClientId: rootClientId,
|
|
124
|
-
clientId: clientId,
|
|
125
|
-
__experimentalIsQuick: true
|
|
126
|
-
})));
|
|
127
|
-
}
|
|
128
|
-
if (shouldShowBreadcrumb || shouldShowContextualToolbar) {
|
|
129
|
-
return (0, _react.createElement)(_blockPopover.default, {
|
|
130
|
-
clientId: capturingClientId || clientId,
|
|
131
|
-
bottomClientId: lastClientId,
|
|
132
|
-
className: (0, _classnames.default)('block-editor-block-list__block-popover', {
|
|
133
|
-
'is-insertion-point-visible': isInsertionPointVisible
|
|
134
|
-
}),
|
|
135
|
-
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
136
|
-
__unstableContentRef: __unstableContentRef,
|
|
137
|
-
resize: false,
|
|
138
|
-
...popoverProps
|
|
139
|
-
}, shouldShowContextualToolbar && (0, _react.createElement)(_blockContextualToolbar.default
|
|
140
|
-
// If the toolbar is being shown because of being forced
|
|
141
|
-
// it should focus the toolbar right after the mount.
|
|
142
|
-
, {
|
|
143
|
-
focusOnMount: isToolbarForced.current,
|
|
144
|
-
__experimentalInitialIndex: initialToolbarItemIndexRef.current,
|
|
145
|
-
__experimentalOnIndexChange: index => {
|
|
146
|
-
initialToolbarItemIndexRef.current = index;
|
|
147
|
-
}
|
|
148
|
-
// Resets the index whenever the active block changes so
|
|
149
|
-
// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
|
|
150
|
-
,
|
|
151
|
-
key: clientId
|
|
152
|
-
}), shouldShowBreadcrumb && (0, _react.createElement)(_blockSelectionButton.default, {
|
|
153
|
-
clientId: clientId,
|
|
154
|
-
rootClientId: rootClientId
|
|
155
|
-
}));
|
|
156
|
-
}
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
function wrapperSelector(select) {
|
|
160
|
-
const {
|
|
161
|
-
getSelectedBlockClientId,
|
|
162
|
-
getFirstMultiSelectedBlockClientId,
|
|
163
|
-
getBlockRootClientId,
|
|
164
|
-
getBlock,
|
|
165
|
-
getBlockParents,
|
|
166
|
-
__experimentalGetBlockListSettingsForBlocks
|
|
167
|
-
} = select(_store.store);
|
|
168
|
-
const clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
|
|
169
|
-
if (!clientId) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
const {
|
|
173
|
-
name,
|
|
174
|
-
attributes = {}
|
|
175
|
-
} = getBlock(clientId) || {};
|
|
176
|
-
const blockParentsClientIds = getBlockParents(clientId);
|
|
177
|
-
|
|
178
|
-
// Get Block List Settings for all ancestors of the current Block clientId.
|
|
179
|
-
const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(blockParentsClientIds);
|
|
180
|
-
|
|
181
|
-
// Get the clientId of the topmost parent with the capture toolbars setting.
|
|
182
|
-
const capturingClientId = blockParentsClientIds.find(parentClientId => parentBlockListSettings[parentClientId]?.__experimentalCaptureToolbars);
|
|
183
|
-
return {
|
|
184
|
-
clientId,
|
|
185
|
-
rootClientId: getBlockRootClientId(clientId),
|
|
186
|
-
name,
|
|
187
|
-
isEmptyDefaultBlock: name && (0, _blocks.isUnmodifiedDefaultBlock)({
|
|
188
|
-
name,
|
|
189
|
-
attributes
|
|
190
|
-
}),
|
|
191
|
-
capturingClientId
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
function WrappedBlockPopover({
|
|
195
|
-
__unstablePopoverSlot,
|
|
196
|
-
__unstableContentRef
|
|
197
|
-
}) {
|
|
198
|
-
const selected = (0, _data.useSelect)(wrapperSelector, []);
|
|
199
|
-
if (!selected) {
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
const {
|
|
203
|
-
clientId,
|
|
204
|
-
rootClientId,
|
|
205
|
-
name,
|
|
206
|
-
isEmptyDefaultBlock,
|
|
207
|
-
capturingClientId
|
|
208
|
-
} = selected;
|
|
209
|
-
if (!name) {
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
return (0, _react.createElement)(SelectedBlockPopover, {
|
|
213
|
-
clientId: clientId,
|
|
214
|
-
rootClientId: rootClientId,
|
|
215
|
-
isEmptyDefaultBlock: isEmptyDefaultBlock,
|
|
216
|
-
capturingClientId: capturingClientId,
|
|
217
|
-
__unstablePopoverSlot: __unstablePopoverSlot,
|
|
218
|
-
__unstableContentRef: __unstableContentRef
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
//# sourceMappingURL=selected-block-popover.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_blocks","_data","_keyboardShortcuts","_blockSelectionButton","_blockContextualToolbar","_store","_blockPopover","_useBlockToolbarPopoverProps","_inserter","_useShouldContextualToolbarShow","selector","select","__unstableGetEditorMode","hasMultiSelection","isTyping","getLastMultiSelectedBlockClientId","blockEditorStore","editorMode","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","useSelect","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isToolbarForced","useRef","shouldShowContextualToolbar","canFocusHiddenToolbar","useShouldContextualToolbarShow","stopTyping","useDispatch","showEmptyBlockSideInserter","shouldShowBreadcrumb","useShortcut","current","isDisabled","useEffect","initialToolbarItemIndexRef","undefined","popoverProps","useBlockToolbarPopoverProps","contentElement","_react","createElement","default","__unstableCoverTarget","bottomClientId","className","classnames","resize","shift","position","__experimentalIsQuick","focusOnMount","__experimentalInitialIndex","__experimentalOnIndexChange","key","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","find","parentClientId","__experimentalCaptureToolbars","isUnmodifiedDefaultBlock","WrappedBlockPopover","selected"],"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\nimport Inserter from '../inserter';\nimport { useShouldContextualToolbarShow } from '../../utils/use-should-contextual-toolbar-show';\n\nfunction selector( select ) {\n\tconst {\n\t\t__unstableGetEditorMode,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\teditorMode: __unstableGetEditorMode(),\n\t\thasMultiSelection: hasMultiSelection(),\n\t\tisTyping: isTyping(),\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { editorMode, hasMultiSelection, isTyping, lastClientId } = useSelect(\n\t\tselector,\n\t\t[]\n\t);\n\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isToolbarForced = useRef( false );\n\tconst { shouldShowContextualToolbar, canFocusHiddenToolbar } =\n\t\tuseShouldContextualToolbarShow();\n\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && editorMode === 'edit' && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb =\n\t\t! hasMultiSelection &&\n\t\t( editorMode === 'navigation' || editorMode === 'zoom-out' );\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tuseEffect( () => {\n\t\t// Resets the index whenever the active block changes so this is not\n\t\t// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\tinitialToolbarItemIndexRef.current = undefined;\n\t}, [ clientId ] );\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\tif ( showEmptyBlockSideInserter ) {\n\t\treturn (\n\t\t\t<BlockPopover\n\t\t\t\tclientId={ capturingClientId || clientId }\n\t\t\t\t__unstableCoverTarget\n\t\t\t\tbottomClientId={ lastClientId }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-block-list__block-side-inserter-popover',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\tresize={ false }\n\t\t\t\tshift={ false }\n\t\t\t\t{ ...popoverProps }\n\t\t\t>\n\t\t\t\t<div className=\"block-editor-block-list__empty-block-inserter\">\n\t\t\t\t\t<Inserter\n\t\t\t\t\t\tposition=\"bottom right\"\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</BlockPopover>\n\t\t);\n\t}\n\n\tif ( shouldShowBreadcrumb || shouldShowContextualToolbar ) {\n\t\treturn (\n\t\t\t<BlockPopover\n\t\t\t\tclientId={ capturingClientId || clientId }\n\t\t\t\tbottomClientId={ lastClientId }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-block-list__block-popover',\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\tresize={ false }\n\t\t\t\t{ ...popoverProps }\n\t\t\t>\n\t\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t\t}\n\t\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t\t} }\n\t\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t\t<BlockSelectionButton\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</BlockPopover>\n\t\t);\n\t}\n\n\treturn null;\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = blockParentsClientIds.find(\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;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C;IAAW,CAAE,CAAC;IACzDpD;EACD,CAAC;AACF;AAEe,SAAS2D,mBAAmBA,CAAE;EAC5C1D,qBAAqB;EACrBC;AACD,CAAC,EAAG;EACH,MAAM0D,QAAQ,GAAG,IAAAzD,eAAS,EAAEyC,eAAe,EAAE,EAAG,CAAC;EAEjD,IAAK,CAAEgB,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,MAAM;IACL/D,QAAQ;IACRC,YAAY;IACZqD,IAAI;IACJpD,mBAAmB;IACnBC;EACD,CAAC,GAAG4D,QAAQ;EAEZ,IAAK,CAAET,IAAI,EAAG;IACb,OAAO,IAAI;EACZ;EAEA,OACC,IAAAtB,MAAA,CAAAC,aAAA,EAAClC,oBAAoB;IACpBC,QAAQ,EAAGA,QAAU;IACrBC,YAAY,EAAGA,YAAc;IAC7BC,mBAAmB,EAAGA,mBAAqB;IAC3CC,iBAAiB,EAAGA,iBAAmB;IACvCC,qBAAqB,EAAGA,qBAAuB;IAC/CC,oBAAoB,EAAGA;EAAsB,CAC7C,CAAC;AAEJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_i18n","_sidebar","_interopRequireDefault","_patternsList","_blockPatternsTab","PatternsExplorer","initialCategory","rootClientId","searchValue","setSearchValue","useState","patternSourceFilter","setPatternSourceFilter","selectedCategory","setSelectedCategory","name","patternCategories","usePatternsCategories","_react","createElement","className","default","onClickCategory","PatternsExplorerModal","onModalClose","restProps","Modal","title","__","onRequestClose","isFullScreen","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/explorer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternExplorerSidebar from './sidebar';\nimport PatternList from './patterns-list';\nimport { usePatternsCategories } from '../block-patterns-tab';\n\nfunction PatternsExplorer( { initialCategory, rootClientId } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst [ selectedCategory, setSelectedCategory ] = useState(\n\t\tinitialCategory?.name\n\t);\n\n\tconst patternCategories = usePatternsCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-explorer\">\n\t\t\t<PatternExplorerSidebar\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tonClickCategory={ setSelectedCategory }\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tsetSearchValue={ setSearchValue }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\tsetPatternSourceFilter={ setPatternSourceFilter }\n\t\t\t/>\n\t\t\t<PatternList\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerModal( { onModalClose, ...restProps } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Patterns' ) }\n\t\t\tonRequestClose={ onModalClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<PatternsExplorer { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nexport default PatternsExplorerModal;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAZA;AACA;AACA;;AAKA;AACA;AACA;;AAKA,SAASO,gBAAgBA,CAAE;EAAEC,eAAe;EAAEC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AC9B,CAAC;AAEV;AAAC,IAAAM,QAAA,GAEcR,qBAAqB;AAAAS,OAAA,CAAAX,OAAA,GAAAU,QAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_blockPatternsTab","PatternsListHeader","filterValue","filteredBlockPatternsLength","_react","createElement","__experimentalHeading","level","lineHeight","className","sprintf","_n","PatternList","searchValue","selectedCategory","patternCategories","container","useRef","debouncedSpeak","useDebounce","speak","destinationRootClientId","onInsertBlocks","useInsertionPoint","shouldFocusBlock","patterns","onClickPattern","usePatternsState","registeredPatternCategories","useMemo","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","allPatternsCategory","myPatternsCategory","id","hasKnownCategory","categories","some","category","includes","length","searchItems","useEffect","count","resultsFoundMessage","pagingProps","usePatternsPaging","previousSearchValue","setPreviousSearchValue","useState","changePage","hasItems","ref","default","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","isDraggable","_default","exports"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/patterns-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport { allPatternsCategory, myPatternsCategory } from '../block-patterns-tab';\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight={ '48px' }\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d pattern found',\n\t\t\t\t\t'%d patterns found',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( { searchValue, selectedCategory, patternCategories } ) {\n\tconst container = useRef();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst filteredPatterns = patterns.filter( ( pattern ) => {\n\t\t\tif ( selectedCategory === allPatternsCategory.name ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === myPatternsCategory.name && pattern.id ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === 'uncategorized' ) {\n\t\t\t\tconst hasKnownCategory = pattern.categories.some(\n\t\t\t\t\t( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t);\n\n\t\t\t\treturn ! pattern.categories?.length || ! hasKnownCategory;\n\t\t\t}\n\n\t\t\treturn pattern.categories?.includes( selectedCategory );\n\t\t} );\n\n\t\tif ( ! searchValue ) {\n\t\t\treturn filteredPatterns;\n\t\t}\n\n\t\treturn searchItems( filteredPatterns, searchValue );\n\t}, [\n\t\tsearchValue,\n\t\tpatterns,\n\t\tselectedCategory,\n\t\tregisteredPatternCategories,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! searchValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ searchValue, debouncedSpeak, filteredBlockPatterns.length ] );\n\n\tconst pagingProps = usePatternsPaging(\n\t\tfilteredBlockPatterns,\n\t\tselectedCategory,\n\t\tcontainer\n\t);\n\n\t// Reset page when search value changes.\n\tconst [ previousSearchValue, setPreviousSearchValue ] =\n\t\tuseState( searchValue );\n\tif ( searchValue !== previousSearchValue ) {\n\t\tsetPreviousSearchValue( searchValue );\n\t\tpagingProps.changePage( 1 );\n\t}\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-patterns-explorer__list\"\n\t\t\tref={ container }\n\t\t>\n\t\t\t<PatternsListHeader\n\t\t\t\tfilterValue={ searchValue }\n\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t/>\n\n\t\t\t<InserterListbox>\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tshownPatterns={\n\t\t\t\t\t\t\t\tpagingProps.categoryPatternsAsyncList\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t\t/>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E,aAAa,EACZV,WAAW,CAACW,yBACZ;IACDC,aAAa,EAAGZ,WAAW,CAACa,gBAAkB;IAC9CrC,cAAc,EAAGA,cAAgB;IACjCsC,WAAW,EAAG;EAAO,CACrB,CAAC,EACF,IAAA5D,MAAA,CAAAC,aAAA,EAACP,oBAAA,CAAA4D,OAAmB;IAAA,GAAMR;EAAW,CAAI,CACxC,CAEa,CACb,CAAC;AAER;AAAC,IAAAe,QAAA,GAEcrD,WAAW;AAAAsD,OAAA,CAAAR,OAAA,GAAAO,QAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","PatternCategoriesList","selectedCategory","patternCategories","onClickCategory","baseClassName","_react","createElement","className","map","name","label","Button","key","isPressed","onClick","PatternsExplorerSearch","searchValue","setSearchValue","SearchControl","__nextHasNoMarginBottom","onChange","value","__","placeholder","PatternExplorerSidebar","_default","exports","default"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, SearchControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nfunction PatternCategoriesList( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ `${ baseClassName }__categories-list` }>\n\t\t\t{ patternCategories.map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tclassName={ `${ baseClassName }__categories-list__item` }\n\t\t\t\t\t\tisPressed={ selectedCategory === name }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonClickCategory( name );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerSearch( { searchValue, setSearchValue } ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__search';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tonChange={ setSearchValue }\n\t\t\t\tvalue={ searchValue }\n\t\t\t\tlabel={ __( 'Search for patterns' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternExplorerSidebar( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\tsearchValue,\n\tsetSearchValue,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<PatternsExplorerSearch\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tsetSearchValue={ setSearchValue }\n\t\t\t/>\n\t\t\t{ ! searchValue && (\n\t\t\t\t<PatternCategoriesList\n\t\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default PatternExplorerSidebar;\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA,SAASE,qBAAqBA,CAAE;EAC/BC,gBAAgB;EAChBC,iBAAiB;EACjBC;AACD,CAAC,EAAG;EACH,MAAMC,aAAa,GAAG,+CAA+C;EACrE,OACC,IAAAC,MAAA,CAAAC,aAAA;IAAKC,SAAS,EAAI,GAAGH,aAAe;EAAoB,GACrDF,iBAAiB,CAACM,GAAG,CAAE,CAAE;IAAEC,IAAI;IAAEC;EAAM,CAAC,KAAM;IAC/C,OACC,IAAAL,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAc,MAAM;MACNC,GAAG,EAAGH,I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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_icons","_element","_blockPatternsTab","PATTERN_TYPES","all","synced","unsynced","user","theme","directory","exports","SYNC_TYPES","full","getShouldDisableSyncFilter","sourceFilter","getShouldDisableNonUserSources","category","name","myPatternsCategory","BlockPatternsSyncFilter","setPatternSyncFilter","setPatternSourceFilter","patternSyncFilter","patternSourceFilter","scrollContainerRef","currentPatternSourceFilter","shouldDisableSyncFilter","shouldDisableNonUserSources","patternSyncMenuOptions","useMemo","value","label","__","disabled","patternSourceMenuOptions","handleSetSourceFilterChange","newSourceFilter","_react","createElement","Fragment","DropdownMenu","popoverProps","placement","icon","Icon","SVG","width","height","viewBox","fill","xmlns","Path","d","MenuGroup","MenuItemsChoice","choices","onSelect","current","scrollTo","className","createInterpolateElement","Link","ExternalLink","href"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-filter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tSVG,\n\tPath,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItemsChoice,\n\tExternalLink,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { Icon } from '@wordpress/icons';\nimport { useMemo, createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { myPatternsCategory } from './block-patterns-tab';\n\nexport const PATTERN_TYPES = {\n\tall: 'all',\n\tsynced: 'synced',\n\tunsynced: 'unsynced',\n\tuser: 'user',\n\ttheme: 'theme',\n\tdirectory: 'directory',\n};\n\nexport const SYNC_TYPES = {\n\tall: 'all',\n\tfull: 'fully',\n\tunsynced: 'unsynced',\n};\n\nconst getShouldDisableSyncFilter = ( sourceFilter ) =>\n\tsourceFilter !== PATTERN_TYPES.all && sourceFilter !== PATTERN_TYPES.user;\n\nconst getShouldDisableNonUserSources = ( category ) => {\n\treturn category.name === myPatternsCategory.name;\n};\n\nexport function BlockPatternsSyncFilter( {\n\tsetPatternSyncFilter,\n\tsetPatternSourceFilter,\n\tpatternSyncFilter,\n\tpatternSourceFilter,\n\tscrollContainerRef,\n\tcategory,\n} ) {\n\t// If the category is `myPatterns` then we need to set the source filter to `user`, but\n\t// we do this by deriving from props rather than calling setPatternSourceFilter otherwise\n\t// the user may be confused when switching to another category if the haven't explicity set\n\t// this filter themselves.\n\tconst currentPatternSourceFilter =\n\t\tcategory.name === myPatternsCategory.name\n\t\t\t? PATTERN_TYPES.user\n\t\t\t: patternSourceFilter;\n\n\t// We need to disable the sync filter option if the source filter is not 'all' or 'user'\n\t// otherwise applying them will just result in no patterns being shown.\n\tconst shouldDisableSyncFilter = getShouldDisableSyncFilter(\n\t\tcurrentPatternSourceFilter\n\t);\n\n\t// We also need to disable the directory and theme source filter options if the category\n\t// is `myPatterns` otherwise applying them will also just result in no patterns being shown.\n\tconst shouldDisableNonUserSources =\n\t\tgetShouldDisableNonUserSources( category );\n\n\tconst patternSyncMenuOptions = useMemo(\n\t\t() => [\n\t\t\t{ value: SYNC_TYPES.all, label: __( 'All' ) },\n\t\t\t{\n\t\t\t\tvalue: SYNC_TYPES.full,\n\t\t\t\tlabel: __( 'Synced' ),\n\t\t\t\tdisabled: shouldDisableSyncFilter,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: SYNC_TYPES.unsynced,\n\t\t\t\tlabel: __( 'Not synced' ),\n\t\t\t\tdisabled: shouldDisableSyncFilter,\n\t\t\t},\n\t\t],\n\t\t[ shouldDisableSyncFilter ]\n\t);\n\n\tconst patternSourceMenuOptions = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tvalue: PATTERN_TYPES.all,\n\t\t\t\tlabel: __( 'All' ),\n\t\t\t\tdisabled: shouldDisableNonUserSources,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: PATTERN_TYPES.directory,\n\t\t\t\tlabel: __( 'Pattern Directory' ),\n\t\t\t\tdisabled: shouldDisableNonUserSources,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: PATTERN_TYPES.theme,\n\t\t\t\tlabel: __( 'Theme & Plugins' ),\n\t\t\t\tdisabled: shouldDisableNonUserSources,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: PATTERN_TYPES.user,\n\t\t\t\tlabel: __( 'User' ),\n\t\t\t},\n\t\t],\n\t\t[ shouldDisableNonUserSources ]\n\t);\n\n\tfunction handleSetSourceFilterChange( newSourceFilter ) {\n\t\tsetPatternSourceFilter( newSourceFilter );\n\t\tif ( getShouldDisableSyncFilter( newSourceFilter ) ) {\n\t\t\tsetPatternSyncFilter( SYNC_TYPES.all );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tplacement: 'right-end',\n\t\t\t\t} }\n\t\t\t\tlabel=\"Filter patterns\"\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<SVG\n\t\t\t\t\t\t\t\twidth=\"24\"\n\t\t\t\t\t\t\t\theight=\"24\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Path\n\t\t\t\t\t\t\t\t\td=\"M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z\"\n\t\t\t\t\t\t\t\t\tfill=\"#1E1E1E\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</SVG>\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Source' ) }>\n\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\tchoices={ patternSourceMenuOptions }\n\t\t\t\t\t\t\t\tonSelect={ ( value ) => {\n\t\t\t\t\t\t\t\t\thandleSetSourceFilterChange( value );\n\t\t\t\t\t\t\t\t\tscrollContainerRef.current?.scrollTo(\n\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tvalue={ currentPatternSourceFilter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Type' ) }>\n\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\tchoices={ patternSyncMenuOptions }\n\t\t\t\t\t\t\t\tonSelect={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetPatternSyncFilter( value );\n\t\t\t\t\t\t\t\t\tscrollContainerRef.current?.scrollTo(\n\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tvalue={ patternSyncFilter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<div className=\"block-editor-tool-selector__help\">\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Patterns are available from the <Link>WordPress.org Pattern Directory</Link>, bundled in the active theme, or created by users on this site. Only patterns created on this site can be synced.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tLink: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/patterns/'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t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