@wordpress/edit-site 5.25.0 → 5.26.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 +2 -0
- package/LICENSE.md +1 -1
- package/build/components/block-editor/back-button.js +3 -2
- package/build/components/block-editor/back-button.js.map +1 -1
- package/build/components/block-editor/resizable-editor.js +2 -2
- package/build/components/block-editor/resizable-editor.js.map +1 -1
- package/build/components/block-editor/use-post-link-props.js +27 -0
- package/build/components/block-editor/use-post-link-props.js.map +1 -0
- package/build/components/block-editor/use-site-editor-settings.js +7 -24
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/create-template-part-modal/index.js +15 -7
- package/build/components/create-template-part-modal/index.js.map +1 -1
- package/build/components/editor/index.js +15 -16
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +9 -7
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/collection-font-variant.js +5 -2
- package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js +3 -3
- package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +5 -5
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +8 -4
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +38 -21
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +2 -2
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/library-font-variant.js +5 -2
- package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build/components/global-styles/font-library-modal/local-fonts.js +26 -10
- package/build/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/resolvers.js +6 -6
- package/build/components/global-styles/font-library-modal/resolvers.js.map +1 -1
- package/build/components/global-styles/font-library-modal/{tab-layout.js → tab-panel-layout.js} +4 -4
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -0
- package/build/components/global-styles/font-library-modal/utils/index.js +35 -38
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/preview.js +43 -1
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-color-palette.js +16 -12
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-revisions/index.js +52 -52
- package/build/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +26 -35
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +40 -22
- package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build/components/global-styles/ui.js +13 -62
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/header-edit-mode/document-tools/index.js +8 -106
- package/build/components/header-edit-mode/document-tools/index.js.map +1 -1
- package/build/components/header-edit-mode/index.js +7 -11
- package/build/components/header-edit-mode/index.js.map +1 -1
- package/build/components/header-edit-mode/mode-switcher/index.js +0 -2
- package/build/components/header-edit-mode/mode-switcher/index.js.map +1 -1
- package/build/components/header-edit-mode/more-menu/index.js +10 -7
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/edit-mode.js +0 -23
- package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build/components/keyboard-shortcuts/register.js +0 -36
- package/build/components/keyboard-shortcuts/register.js.map +1 -1
- package/build/components/layout/index.js +6 -13
- package/build/components/layout/index.js.map +1 -1
- package/build/components/page-main/index.js +4 -4
- package/build/components/page-main/index.js.map +1 -1
- package/build/components/page-pages/index.js +84 -37
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/dataviews-pattern-actions.js +305 -0
- package/build/components/page-patterns/dataviews-pattern-actions.js.map +1 -0
- package/build/components/page-patterns/dataviews-patterns.js +307 -0
- package/build/components/page-patterns/dataviews-patterns.js.map +1 -0
- package/build/components/page-patterns/duplicate-menu-item.js +1 -1
- package/build/components/page-patterns/duplicate-menu-item.js.map +1 -1
- package/build/components/page-patterns/grid-item.js +4 -3
- package/build/components/page-patterns/grid-item.js.map +1 -1
- package/build/components/page-patterns/patterns-list.js +2 -1
- package/build/components/page-patterns/patterns-list.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +23 -13
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/index.js +312 -36
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/{page-patterns/pagination.js → pagination/index.js} +25 -12
- package/build/components/pagination/index.js.map +1 -0
- package/build/components/{page-pages/side-editor.js → post-preview/index.js} +8 -4
- package/build/components/post-preview/index.js.map +1 -0
- package/build/components/preferences-modal/enable-feature.js +3 -2
- package/build/components/preferences-modal/enable-feature.js.map +1 -1
- package/build/components/preferences-modal/enable-panel-option.js +33 -0
- package/build/components/preferences-modal/enable-panel-option.js.map +1 -0
- package/build/components/preferences-modal/index.js +57 -9
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/revisions/index.js +3 -7
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/routes/link.js +6 -2
- package/build/components/routes/link.js.map +1 -1
- package/build/components/save-button/index.js +6 -3
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/sidebar/index.js +3 -11
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/add-new-view.js +2 -2
- package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +18 -5
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +3 -3
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/default-sidebar.js +1 -5
- package/build/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js +62 -10
- package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/index.js +1 -1
- package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/plugin-sidebar/index.js +0 -4
- package/build/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +4 -13
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-details-footer/index.js +1 -1
- package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +5 -2
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-page/index.js +4 -1
- package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-pages-dataviews/index.js +69 -0
- package/build/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -0
- package/build/components/style-book/index.js +38 -8
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +11 -6
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build/index.js +12 -7
- package/build/index.js.map +1 -1
- package/build/store/actions.js +39 -44
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +6 -2
- package/build/store/private-actions.js.map +1 -1
- package/build/store/reducer.js +0 -46
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +32 -41
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-is-list-page.js +1 -1
- package/build/utils/get-is-list-page.js.map +1 -1
- package/build-module/components/block-editor/back-button.js +4 -3
- package/build-module/components/block-editor/back-button.js.map +1 -1
- package/build-module/components/block-editor/resizable-editor.js +2 -2
- package/build-module/components/block-editor/resizable-editor.js.map +1 -1
- package/build-module/components/block-editor/use-post-link-props.js +20 -0
- package/build-module/components/block-editor/use-post-link-props.js.map +1 -0
- package/build-module/components/block-editor/use-site-editor-settings.js +8 -25
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/create-template-part-modal/index.js +14 -7
- package/build-module/components/create-template-part-modal/index.js.map +1 -1
- package/build-module/components/editor/index.js +16 -17
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +9 -7
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +5 -2
- package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js +3 -3
- package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +7 -7
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +8 -4
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +39 -22
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +2 -2
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js +5 -2
- package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/local-fonts.js +27 -11
- package/build-module/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/resolvers.js +5 -5
- package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/{tab-layout.js → tab-panel-layout.js} +4 -4
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -0
- package/build-module/components/global-styles/font-library-modal/utils/index.js +34 -36
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/preview.js +45 -3
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-color-palette.js +17 -13
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/index.js +53 -53
- package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +27 -36
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +40 -22
- package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
- package/build-module/components/global-styles/ui.js +15 -64
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/header-edit-mode/document-tools/index.js +13 -110
- package/build-module/components/header-edit-mode/document-tools/index.js.map +1 -1
- package/build-module/components/header-edit-mode/index.js +7 -11
- package/build-module/components/header-edit-mode/index.js.map +1 -1
- package/build-module/components/header-edit-mode/mode-switcher/index.js +0 -2
- package/build-module/components/header-edit-mode/mode-switcher/index.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +10 -7
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/edit-mode.js +0 -23
- package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/register.js +0 -36
- package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
- package/build-module/components/layout/index.js +6 -13
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/page-main/index.js +4 -4
- package/build-module/components/page-main/index.js.map +1 -1
- package/build-module/components/page-pages/index.js +83 -36
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/dataviews-pattern-actions.js +292 -0
- package/build-module/components/page-patterns/dataviews-pattern-actions.js.map +1 -0
- package/build-module/components/page-patterns/dataviews-patterns.js +299 -0
- package/build-module/components/page-patterns/dataviews-patterns.js.map +1 -0
- package/build-module/components/page-patterns/duplicate-menu-item.js +1 -1
- package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/grid-item.js +4 -3
- package/build-module/components/page-patterns/grid-item.js.map +1 -1
- package/build-module/components/page-patterns/patterns-list.js +2 -1
- package/build-module/components/page-patterns/patterns-list.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +23 -13
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/index.js +314 -38
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/{page-patterns/pagination.js → pagination/index.js} +24 -12
- package/build-module/components/pagination/index.js.map +1 -0
- package/build-module/components/{page-pages/side-editor.js → post-preview/index.js} +7 -3
- package/build-module/components/post-preview/index.js.map +1 -0
- package/build-module/components/preferences-modal/enable-feature.js +3 -2
- package/build-module/components/preferences-modal/enable-feature.js.map +1 -1
- package/build-module/components/preferences-modal/enable-panel-option.js +26 -0
- package/build-module/components/preferences-modal/enable-panel-option.js.map +1 -0
- package/build-module/components/preferences-modal/index.js +57 -9
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/revisions/index.js +4 -8
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/routes/link.js +5 -2
- package/build-module/components/routes/link.js.map +1 -1
- package/build-module/components/save-button/index.js +6 -3
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +3 -11
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +17 -5
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +2 -2
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/default-sidebar.js +1 -5
- package/build-module/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +64 -12
- package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/index.js +2 -2
- package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js +0 -4
- package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +6 -15
- package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-details-footer/index.js +1 -1
- package/build-module/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +5 -2
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-page/index.js +4 -1
- package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js +61 -0
- package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -0
- package/build-module/components/style-book/index.js +40 -10
- package/build-module/components/style-book/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +11 -6
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/index.js +12 -7
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +36 -41
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +6 -2
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -44
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +30 -38
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-is-list-page.js +1 -1
- package/build-module/utils/get-is-list-page.js.map +1 -1
- package/build-style/style-rtl.css +357 -268
- package/build-style/style.css +357 -268
- package/package.json +42 -42
- package/src/components/add-new-template/style.scss +2 -1
- package/src/components/block-editor/back-button.js +4 -2
- package/src/components/block-editor/resizable-editor.js +1 -1
- package/src/components/block-editor/style.scss +1 -2
- package/src/components/block-editor/use-post-link-props.js +20 -0
- package/src/components/block-editor/use-site-editor-settings.js +10 -41
- package/src/components/code-editor/style.scss +0 -4
- package/src/components/create-template-part-modal/index.js +83 -82
- package/src/components/editor/index.js +24 -31
- package/src/components/editor-canvas-container/index.js +8 -6
- package/src/components/global-styles/font-library-modal/collection-font-variant.js +7 -2
- package/src/components/global-styles/font-library-modal/confirm-delete-dialog.js +3 -3
- package/src/components/global-styles/font-library-modal/context.js +7 -7
- package/src/components/global-styles/font-library-modal/font-collection.js +10 -5
- package/src/components/global-styles/font-library-modal/index.js +44 -24
- package/src/components/global-styles/font-library-modal/installed-fonts.js +3 -3
- package/src/components/global-styles/font-library-modal/library-font-variant.js +7 -2
- package/src/components/global-styles/font-library-modal/local-fonts.js +53 -26
- package/src/components/global-styles/font-library-modal/resolvers.js +5 -5
- package/src/components/global-styles/font-library-modal/style.scss +5 -2
- package/src/components/global-styles/font-library-modal/{tab-layout.js → tab-panel-layout.js} +9 -3
- package/src/components/global-styles/font-library-modal/utils/index.js +21 -23
- package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamily.spec.js +58 -0
- package/src/components/global-styles/preview.js +55 -3
- package/src/components/global-styles/screen-color-palette.js +16 -26
- package/src/components/global-styles/screen-revisions/index.js +91 -92
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +37 -38
- package/src/components/global-styles/screen-revisions/style.scss +77 -20
- package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +67 -0
- package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +73 -46
- package/src/components/global-styles/ui.js +13 -74
- package/src/components/header-edit-mode/document-tools/index.js +33 -165
- package/src/components/header-edit-mode/index.js +6 -17
- package/src/components/header-edit-mode/mode-switcher/index.js +0 -4
- package/src/components/header-edit-mode/more-menu/index.js +9 -7
- package/src/components/header-edit-mode/style.scss +0 -47
- package/src/components/keyboard-shortcuts/edit-mode.js +1 -26
- package/src/components/keyboard-shortcuts/register.js +0 -43
- package/src/components/layout/index.js +8 -27
- package/src/components/layout/style.scss +10 -3
- package/src/components/list/style.scss +0 -5
- package/src/components/page/style.scss +1 -1
- package/src/components/page-main/index.js +8 -8
- package/src/components/page-pages/index.js +112 -41
- package/src/components/page-pages/style.scss +3 -2
- package/src/components/page-patterns/dataviews-pattern-actions.js +329 -0
- package/src/components/page-patterns/dataviews-patterns.js +380 -0
- package/src/components/page-patterns/duplicate-menu-item.js +1 -1
- package/src/components/page-patterns/grid-item.js +3 -2
- package/src/components/page-patterns/patterns-list.js +2 -1
- package/src/components/page-patterns/style.scss +89 -26
- package/src/components/page-patterns/use-patterns.js +24 -15
- package/src/components/page-templates/index.js +399 -64
- package/src/components/{page-patterns/pagination.js → pagination/index.js} +21 -10
- package/src/components/pagination/style.scss +5 -0
- package/src/components/post-preview/index.js +16 -0
- package/src/components/preferences-modal/enable-feature.js +9 -5
- package/src/components/preferences-modal/enable-panel-option.js +23 -0
- package/src/components/preferences-modal/index.js +107 -22
- package/src/components/revisions/index.js +8 -15
- package/src/components/routes/link.js +11 -3
- package/src/components/save-button/index.js +16 -3
- package/src/components/sidebar/index.js +6 -13
- package/src/components/sidebar-dataviews/add-new-view.js +1 -1
- package/src/components/sidebar-dataviews/default-views.js +23 -6
- package/src/components/sidebar-dataviews/index.js +2 -2
- package/src/components/sidebar-edit-mode/default-sidebar.js +0 -12
- package/src/components/sidebar-edit-mode/global-styles-sidebar.js +85 -14
- package/src/components/sidebar-edit-mode/page-panels/index.js +15 -1
- package/src/components/sidebar-edit-mode/plugin-sidebar/index.js +0 -12
- package/src/components/sidebar-edit-mode/style.scss +0 -10
- package/src/components/sidebar-edit-mode/template-panel/index.js +44 -40
- package/src/components/sidebar-edit-mode/template-panel/style.scss +0 -4
- package/src/components/sidebar-navigation-screen-details-footer/index.js +1 -1
- package/src/components/sidebar-navigation-screen-global-styles/index.js +3 -2
- package/src/components/sidebar-navigation-screen-page/index.js +2 -1
- package/src/components/sidebar-navigation-screen-pages-dataviews/index.js +77 -0
- package/src/components/site-hub/style.scss +5 -2
- package/src/components/style-book/index.js +65 -21
- package/src/components/style-book/style.scss +3 -3
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +4 -1
- package/src/hooks/commands/use-edit-mode-commands.js +8 -12
- package/src/index.js +11 -5
- package/src/store/actions.js +35 -45
- package/src/store/private-actions.js +7 -3
- package/src/store/reducer.js +0 -44
- package/src/store/selectors.js +32 -38
- package/src/store/test/actions.js +11 -39
- package/src/store/test/reducer.js +1 -82
- package/src/store/test/selectors.js +0 -24
- package/src/style.scss +1 -1
- package/src/utils/get-is-list-page.js +2 -3
- package/build/components/global-styles/font-library-modal/tab-layout.js.map +0 -1
- package/build/components/global-styles/screen-revisions/get-revision-changes.js +0 -146
- package/build/components/global-styles/screen-revisions/get-revision-changes.js.map +0 -1
- package/build/components/header-edit-mode/undo-redo/redo.js +0 -41
- package/build/components/header-edit-mode/undo-redo/redo.js.map +0 -1
- package/build/components/header-edit-mode/undo-redo/undo.js +0 -40
- package/build/components/header-edit-mode/undo-redo/undo.js.map +0 -1
- package/build/components/page-pages/side-editor.js.map +0 -1
- package/build/components/page-patterns/pagination.js.map +0 -1
- package/build/components/page-templates/dataviews-templates.js +0 -317
- package/build/components/page-templates/dataviews-templates.js.map +0 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +0 -60
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +0 -109
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
- package/build/components/sidebar-edit-mode/sidebar-fixed-bottom.js +0 -35
- package/build/components/sidebar-edit-mode/sidebar-fixed-bottom.js.map +0 -1
- package/build/components/sidebar-edit-mode/template-panel/last-revision.js +0 -73
- package/build/components/sidebar-edit-mode/template-panel/last-revision.js.map +0 -1
- package/build/components/sidebar-edit-mode/template-panel/pattern-categories.js +0 -219
- package/build/components/sidebar-edit-mode/template-panel/pattern-categories.js.map +0 -1
- package/build-module/components/global-styles/font-library-modal/tab-layout.js.map +0 -1
- package/build-module/components/global-styles/screen-revisions/get-revision-changes.js +0 -139
- package/build-module/components/global-styles/screen-revisions/get-revision-changes.js.map +0 -1
- package/build-module/components/header-edit-mode/undo-redo/redo.js +0 -33
- package/build-module/components/header-edit-mode/undo-redo/redo.js.map +0 -1
- package/build-module/components/header-edit-mode/undo-redo/undo.js +0 -32
- package/build-module/components/header-edit-mode/undo-redo/undo.js.map +0 -1
- package/build-module/components/page-pages/side-editor.js.map +0 -1
- package/build-module/components/page-patterns/pagination.js.map +0 -1
- package/build-module/components/page-templates/dataviews-templates.js +0 -309
- package/build-module/components/page-templates/dataviews-templates.js.map +0 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +0 -53
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +0 -102
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js +0 -27
- package/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/template-panel/last-revision.js +0 -65
- package/build-module/components/sidebar-edit-mode/template-panel/last-revision.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js +0 -209
- package/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js.map +0 -1
- package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamilies.spec.js +0 -62
- package/src/components/global-styles/font-library-modal/utils/test/wpKebabCase.spec.js +0 -28
- package/src/components/global-styles/screen-revisions/get-revision-changes.js +0 -171
- package/src/components/global-styles/screen-revisions/test/get-revision-changes.js +0 -191
- package/src/components/header-edit-mode/undo-redo/redo.js +0 -38
- package/src/components/header-edit-mode/undo-redo/undo.js +0 -34
- package/src/components/page-pages/side-editor.js +0 -14
- package/src/components/page-templates/dataviews-templates.js +0 -360
- package/src/components/secondary-sidebar/inserter-sidebar.js +0 -66
- package/src/components/secondary-sidebar/list-view-sidebar.js +0 -123
- package/src/components/secondary-sidebar/style.scss +0 -65
- package/src/components/sidebar-edit-mode/sidebar-fixed-bottom.js +0 -26
- package/src/components/sidebar-edit-mode/template-panel/last-revision.js +0 -82
- package/src/components/sidebar-edit-mode/template-panel/pattern-categories.js +0 -279
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","globalStylesChangesCache","Map","EMPTY_ARRAY","translationMap","caption","link","button","heading","isObject","obj","getTranslation","key","blockNames","keyArray","split","blockName","undefined","deepCompare","changedObject","originalObject","parentPath","slice","join","allKeys","Set","Object","keys","diffs","path","changedPath","concat","getRevisionChanges","revision","previousRevision","cacheKey","JSON","stringify","has","get","changedValueTree","styles","color","typography","spacing","blocks","elements","settings","length","set","result","reduce","acc","curr","translation","includes","push"],"sources":["@wordpress/edit-site/src/components/global-styles/screen-revisions/get-revision-changes.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\nconst globalStylesChangesCache = new Map();\nconst EMPTY_ARRAY = [];\n\nconst translationMap = {\n\tcaption: __( 'Caption' ),\n\tlink: __( 'Link' ),\n\tbutton: __( 'Button' ),\n\theading: __( 'Heading' ),\n\t'settings.color': __( 'Color settings' ),\n\t'settings.typography': __( 'Typography settings' ),\n\t'styles.color': __( 'Colors' ),\n\t'styles.spacing': __( 'Spacing' ),\n\t'styles.typography': __( 'Typography' ),\n};\n\nconst isObject = ( obj ) => obj !== null && typeof obj === 'object';\n\n/**\n * Get the translation for a given global styles key.\n * @param {string} key A key representing a path to a global style property or setting.\n * @param {Record<string,string>} blockNames A key/value pair object of block names and their rendered titles.\n * @return {string|undefined} A translated key or undefined if no translation exists.\n */\nfunction getTranslation( key, blockNames ) {\n\tif ( translationMap[ key ] ) {\n\t\treturn translationMap[ key ];\n\t}\n\n\tconst keyArray = key.split( '.' );\n\n\tif ( keyArray?.[ 0 ] === 'blocks' ) {\n\t\tconst blockName = blockNames[ keyArray[ 1 ] ];\n\t\treturn blockName\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %s: block name.\n\t\t\t\t\t__( '%s block' ),\n\t\t\t\t\tblockName\n\t\t\t )\n\t\t\t: keyArray[ 1 ];\n\t}\n\n\tif ( keyArray?.[ 0 ] === 'elements' ) {\n\t\treturn sprintf(\n\t\t\t// translators: %s: element name, e.g., heading button, link, caption.\n\t\t\t__( '%s element' ),\n\t\t\ttranslationMap[ keyArray[ 1 ] ]\n\t\t);\n\t}\n\n\treturn undefined;\n}\n\n/**\n * A deep comparison of two objects, optimized for comparing global styles.\n * @param {Object} changedObject The changed object to compare.\n * @param {Object} originalObject The original object to compare against.\n * @param {string} parentPath A key/value pair object of block names and their rendered titles.\n * @return {string[]} An array of paths whose values have changed.\n */\nfunction deepCompare( changedObject, originalObject, parentPath = '' ) {\n\t// We have two non-object values to compare.\n\tif ( ! isObject( changedObject ) && ! isObject( originalObject ) ) {\n\t\t/*\n\t\t * Only return a path if the value has changed.\n\t\t * And then only the path name up to 2 levels deep.\n\t\t */\n\t\treturn changedObject !== originalObject\n\t\t\t? parentPath.split( '.' ).slice( 0, 2 ).join( '.' )\n\t\t\t: undefined;\n\t}\n\n\t// Enable comparison when an object doesn't have a corresponding property to compare.\n\tchangedObject = isObject( changedObject ) ? changedObject : {};\n\toriginalObject = isObject( originalObject ) ? originalObject : {};\n\n\tconst allKeys = new Set( [\n\t\t...Object.keys( changedObject ),\n\t\t...Object.keys( originalObject ),\n\t] );\n\n\tlet diffs = [];\n\tfor ( const key of allKeys ) {\n\t\tconst path = parentPath ? parentPath + '.' + key : key;\n\t\tconst changedPath = deepCompare(\n\t\t\tchangedObject[ key ],\n\t\t\toriginalObject[ key ],\n\t\t\tpath\n\t\t);\n\t\tif ( changedPath ) {\n\t\t\tdiffs = diffs.concat( changedPath );\n\t\t}\n\t}\n\treturn diffs;\n}\n\n/**\n * Get an array of translated summarized global styles changes.\n * Results are cached using a Map() key of `JSON.stringify( { revision, previousRevision } )`.\n *\n * @param {Object} revision The changed object to compare.\n * @param {Object} previousRevision The original object to compare against.\n * @param {Record<string,string>} blockNames A key/value pair object of block names and their rendered titles.\n * @return {string[]} An array of translated changes.\n */\nexport default function getRevisionChanges(\n\trevision,\n\tpreviousRevision,\n\tblockNames\n) {\n\tconst cacheKey = JSON.stringify( { revision, previousRevision } );\n\n\tif ( globalStylesChangesCache.has( cacheKey ) ) {\n\t\treturn globalStylesChangesCache.get( cacheKey );\n\t}\n\n\t/*\n\t * Compare the two revisions with normalized keys.\n\t * The order of these keys determines the order in which\n\t * they'll appear in the results.\n\t */\n\tconst changedValueTree = deepCompare(\n\t\t{\n\t\t\tstyles: {\n\t\t\t\tcolor: revision?.styles?.color,\n\t\t\t\ttypography: revision?.styles?.typography,\n\t\t\t\tspacing: revision?.styles?.spacing,\n\t\t\t},\n\t\t\tblocks: revision?.styles?.blocks,\n\t\t\telements: revision?.styles?.elements,\n\t\t\tsettings: revision?.settings,\n\t\t},\n\t\t{\n\t\t\tstyles: {\n\t\t\t\tcolor: previousRevision?.styles?.color,\n\t\t\t\ttypography: previousRevision?.styles?.typography,\n\t\t\t\tspacing: previousRevision?.styles?.spacing,\n\t\t\t},\n\t\t\tblocks: previousRevision?.styles?.blocks,\n\t\t\telements: previousRevision?.styles?.elements,\n\t\t\tsettings: previousRevision?.settings,\n\t\t}\n\t);\n\n\tif ( ! changedValueTree.length ) {\n\t\tglobalStylesChangesCache.set( cacheKey, EMPTY_ARRAY );\n\t\treturn EMPTY_ARRAY;\n\t}\n\n\t// Remove duplicate results.\n\tconst result = [ ...new Set( changedValueTree ) ]\n\t\t/*\n\t\t * Translate the keys.\n\t\t * Remove duplicate or empty translations.\n\t\t */\n\t\t.reduce( ( acc, curr ) => {\n\t\t\tconst translation = getTranslation( curr, blockNames );\n\t\t\tif ( translation && ! acc.includes( translation ) ) {\n\t\t\t\tacc.push( translation );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\tglobalStylesChangesCache.set( cacheKey, result );\n\n\treturn result;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAE7C,MAAMC,wBAAwB,GAAG,IAAIC,GAAG,CAAC,CAAC;AAC1C,MAAMC,WAAW,GAAG,EAAE;AAEtB,MAAMC,cAAc,GAAG;EACtBC,OAAO,EAAEN,EAAE,CAAE,SAAU,CAAC;EACxBO,IAAI,EAAEP,EAAE,CAAE,MAAO,CAAC;EAClBQ,MAAM,EAAER,EAAE,CAAE,QAAS,CAAC;EACtBS,OAAO,EAAET,EAAE,CAAE,SAAU,CAAC;EACxB,gBAAgB,EAAEA,EAAE,CAAE,gBAAiB,CAAC;EACxC,qBAAqB,EAAEA,EAAE,CAAE,qBAAsB,CAAC;EAClD,cAAc,EAAEA,EAAE,CAAE,QAAS,CAAC;EAC9B,gBAAgB,EAAEA,EAAE,CAAE,SAAU,CAAC;EACjC,mBAAmB,EAAEA,EAAE,CAAE,YAAa;AACvC,CAAC;AAED,MAAMU,QAAQ,GAAKC,GAAG,IAAMA,GAAG,KAAK,IAAI,IAAI,OAAOA,GAAG,KAAK,QAAQ;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAAEC,GAAG,EAAEC,UAAU,EAAG;EAC1C,IAAKT,cAAc,CAAEQ,GAAG,CAAE,E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AE;MACPC,KAAK,EAAER,gBAAgB,EAAEO,MAAM,EAAEC,KAAK;MACtCC,UAAU,EAAET,gBAAgB,EAAEO,MAAM,EAAEE,UAAU;MAChDC,OAAO,EAAEV,gBAAgB,EAAEO,MAAM,EAAEG;IACpC,CAAC;IACDC,MAAM,EAAEX,gBAAgB,EAAEO,MAAM,EAAEI,MAAM;IACxCC,QAAQ,EAAEZ,gBAAgB,EAAEO,MAAM,EAAEK,QAAQ;IAC5CC,QAAQ,EAAEb,gBAAgB,EAAEa;EAC7B,CACD,CAAC;EAED,IAAK,CAAEP,gBAAgB,CAACQ,MAAM,EAAG;IAChC/C,wBAAwB,CAACgD,GAAG,CAAEd,QAAQ,EAAEhC,WAAY,CAAC;IACrD,OAAOA,WAAW;EACnB;;EAEA;EACA,MAAM+C,MAAM,GAAG,CAAE,GAAG,IAAIzB,GAAG,CAAEe,gBAAiB,CAAC;EAC9C;AACF;AACA;AACA,KAHE,CAICW,MAAM,CAAE,CAAEC,GAAG,EAAEC,IAAI,KAAM;IACzB,MAAMC,WAAW,GAAG3C,cAAc,CAAE0C,IAAI,EAAExC,UAAW,CAAC;IACtD,IAAKyC,WAAW,IAAI,CAAEF,GAAG,CAACG,QAAQ,CAAED,WAAY,CAAC,EAAG;MACnDF,GAAG,CAACI,IAAI,CAAEF,WAAY,CAAC;IACxB;IACA,OAAOF,GAAG;EACX,CAAC,EAAE,EAAG,CAAC;EAERnD,wBAAwB,CAACgD,GAAG,CAAEd,QAAQ,EAAEe,MAAO,CAAC;EAEhD,OAAOA,MAAM;AACd"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import { Button } from '@wordpress/components';
|
|
7
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
-
import { redo as redoIcon, undo as undoIcon } from '@wordpress/icons';
|
|
9
|
-
import { displayShortcut, isAppleOS } from '@wordpress/keycodes';
|
|
10
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
-
import { forwardRef } from '@wordpress/element';
|
|
12
|
-
function RedoButton(props, ref) {
|
|
13
|
-
const shortcut = isAppleOS() ? displayShortcut.primaryShift('z') : displayShortcut.primary('y');
|
|
14
|
-
const hasRedo = useSelect(select => select(coreStore).hasRedo(), []);
|
|
15
|
-
const {
|
|
16
|
-
redo
|
|
17
|
-
} = useDispatch(coreStore);
|
|
18
|
-
return createElement(Button, {
|
|
19
|
-
...props,
|
|
20
|
-
ref: ref,
|
|
21
|
-
icon: !isRTL() ? redoIcon : undoIcon,
|
|
22
|
-
label: __('Redo'),
|
|
23
|
-
shortcut: shortcut
|
|
24
|
-
// If there are no undo levels we don't want to actually disable this
|
|
25
|
-
// button, because it will remove focus for keyboard users.
|
|
26
|
-
// See: https://github.com/WordPress/gutenberg/issues/3486
|
|
27
|
-
,
|
|
28
|
-
"aria-disabled": !hasRedo,
|
|
29
|
-
onClick: hasRedo ? redo : undefined
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
export default forwardRef(RedoButton);
|
|
33
|
-
//# sourceMappingURL=redo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__","isRTL","Button","useSelect","useDispatch","redo","redoIcon","undo","undoIcon","displayShortcut","isAppleOS","store","coreStore","forwardRef","RedoButton","props","ref","shortcut","primaryShift","primary","hasRedo","select","createElement","icon","label","onClick","undefined"],"sources":["@wordpress/edit-site/src/components/header-edit-mode/undo-redo/redo.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { redo as redoIcon, undo as undoIcon } from '@wordpress/icons';\nimport { displayShortcut, isAppleOS } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { forwardRef } from '@wordpress/element';\n\nfunction RedoButton( props, ref ) {\n\tconst shortcut = isAppleOS()\n\t\t? displayShortcut.primaryShift( 'z' )\n\t\t: displayShortcut.primary( 'y' );\n\n\tconst hasRedo = useSelect(\n\t\t( select ) => select( coreStore ).hasRedo(),\n\t\t[]\n\t);\n\tconst { redo } = useDispatch( coreStore );\n\treturn (\n\t\t<Button\n\t\t\t{ ...props }\n\t\t\tref={ ref }\n\t\t\ticon={ ! isRTL() ? redoIcon : undoIcon }\n\t\t\tlabel={ __( 'Redo' ) }\n\t\t\tshortcut={ shortcut }\n\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\taria-disabled={ ! hasRedo }\n\t\t\tonClick={ hasRedo ? redo : undefined }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( RedoButton );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,IAAI,IAAIC,QAAQ,EAAEC,IAAI,IAAIC,QAAQ,QAAQ,kBAAkB;AACrE,SAASC,eAAe,EAAEC,SAAS,QAAQ,qBAAqB;AAChE,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,UAAU,QAAQ,oBAAoB;AAE/C,SAASC,UAAUA,CAAEC,KAAK,EAAEC,GAAG,EAAG;EACjC,MAAMC,QAAQ,GAAGP,SAAS,CAAC,CAAC,GACzBD,eAAe,CAACS,YAAY,CAAE,GAAI,CAAC,GACnCT,eAAe,CAACU,OAAO,CAAE,GAAI,CAAC;EAEjC,MAAMC,OAAO,GAAGjB,SAAS,CACtBkB,MAAM,IAAMA,MAAM,CAAET,SAAU,CAAC,CAACQ,OAAO,CAAC,CAAC,EAC3C,EACD,CAAC;EACD,MAAM;IAAEf;EAAK,CAAC,GAAGD,WAAW,CAAEQ,SAAU,CAAC;EACzC,OACCU,aAAA,CAACpB,MAAM;IAAA,GACDa,KAAK;IACVC,GAAG,EAAGA,GAAK;IACXO,IAAI,EAAG,CAAEtB,KAAK,CAAC,CAAC,GAAGK,QAAQ,GAAGE,QAAU;IACxCgB,KAAK,EAAGxB,EAAE,CAAE,MAAO,CAAG;IACtBiB,QAAQ,EAAGA;IACX;IACA;IACA;IAAA;IACA,iBAAgB,CAAEG,OAAS;IAC3BK,OAAO,EAAGL,OAAO,GAAGf,IAAI,GAAGqB;EAAW,CACtC,CAAC;AAEJ;AAEA,eAAeb,UAAU,CAAEC,UAAW,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import { Button } from '@wordpress/components';
|
|
7
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
-
import { undo as undoIcon, redo as redoIcon } from '@wordpress/icons';
|
|
9
|
-
import { displayShortcut } from '@wordpress/keycodes';
|
|
10
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
-
import { forwardRef } from '@wordpress/element';
|
|
12
|
-
function UndoButton(props, ref) {
|
|
13
|
-
const hasUndo = useSelect(select => select(coreStore).hasUndo(), []);
|
|
14
|
-
const {
|
|
15
|
-
undo
|
|
16
|
-
} = useDispatch(coreStore);
|
|
17
|
-
return createElement(Button, {
|
|
18
|
-
...props,
|
|
19
|
-
ref: ref,
|
|
20
|
-
icon: !isRTL() ? undoIcon : redoIcon,
|
|
21
|
-
label: __('Undo'),
|
|
22
|
-
shortcut: displayShortcut.primary('z')
|
|
23
|
-
// If there are no undo levels we don't want to actually disable this
|
|
24
|
-
// button, because it will remove focus for keyboard users.
|
|
25
|
-
// See: https://github.com/WordPress/gutenberg/issues/3486
|
|
26
|
-
,
|
|
27
|
-
"aria-disabled": !hasUndo,
|
|
28
|
-
onClick: hasUndo ? undo : undefined
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
export default forwardRef(UndoButton);
|
|
32
|
-
//# sourceMappingURL=undo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__","isRTL","Button","useSelect","useDispatch","undo","undoIcon","redo","redoIcon","displayShortcut","store","coreStore","forwardRef","UndoButton","props","ref","hasUndo","select","createElement","icon","label","shortcut","primary","onClick","undefined"],"sources":["@wordpress/edit-site/src/components/header-edit-mode/undo-redo/undo.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { undo as undoIcon, redo as redoIcon } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { forwardRef } from '@wordpress/element';\n\nfunction UndoButton( props, ref ) {\n\tconst hasUndo = useSelect(\n\t\t( select ) => select( coreStore ).hasUndo(),\n\t\t[]\n\t);\n\tconst { undo } = useDispatch( coreStore );\n\treturn (\n\t\t<Button\n\t\t\t{ ...props }\n\t\t\tref={ ref }\n\t\t\ticon={ ! isRTL() ? undoIcon : redoIcon }\n\t\t\tlabel={ __( 'Undo' ) }\n\t\t\tshortcut={ displayShortcut.primary( 'z' ) }\n\t\t\t// If there are no undo levels we don't want to actually disable this\n\t\t\t// button, because it will remove focus for keyboard users.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/3486\n\t\t\taria-disabled={ ! hasUndo }\n\t\t\tonClick={ hasUndo ? undo : undefined }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( UndoButton );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,IAAI,IAAIC,QAAQ,EAAEC,IAAI,IAAIC,QAAQ,QAAQ,kBAAkB;AACrE,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,UAAU,QAAQ,oBAAoB;AAE/C,SAASC,UAAUA,CAAEC,KAAK,EAAEC,GAAG,EAAG;EACjC,MAAMC,OAAO,GAAGb,SAAS,CACtBc,MAAM,IAAMA,MAAM,CAAEN,SAAU,CAAC,CAACK,OAAO,CAAC,CAAC,EAC3C,EACD,CAAC;EACD,MAAM;IAAEX;EAAK,CAAC,GAAGD,WAAW,CAAEO,SAAU,CAAC;EACzC,OACCO,aAAA,CAAChB,MAAM;IAAA,GACDY,KAAK;IACVC,GAAG,EAAGA,GAAK;IACXI,IAAI,EAAG,CAAElB,KAAK,CAAC,CAAC,GAAGK,QAAQ,GAAGE,QAAU;IACxCY,KAAK,EAAGpB,EAAE,CAAE,MAAO,CAAG;IACtBqB,QAAQ,EAAGZ,eAAe,CAACa,OAAO,CAAE,GAAI;IACxC;IACA;IACA;IAAA;IACA,iBAAgB,CAAEN,OAAS;IAC3BO,OAAO,EAAGP,OAAO,GAAGX,IAAI,GAAGmB;EAAW,CACtC,CAAC;AAEJ;AAEA,eAAeZ,UAAU,CAAEC,UAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Editor","useInitEditedEntity","SideEditor","postType","postId","createElement"],"sources":["@wordpress/edit-site/src/components/page-pages/side-editor.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport Editor from '../editor';\nimport { useInitEditedEntity } from '../sync-state-with-url/use-init-edited-entity-from-url';\n\nexport default function SideEditor( { postType, postId } ) {\n\tuseInitEditedEntity( {\n\t\tpostId,\n\t\tpostType,\n\t} );\n\n\treturn <Editor />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,WAAW;AAC9B,SAASC,mBAAmB,QAAQ,wDAAwD;AAE5F,eAAe,SAASC,UAAUA,CAAE;EAAEC,QAAQ;EAAEC;AAAO,CAAC,EAAG;EAC1DH,mBAAmB,CAAE;IACpBG,MAAM;IACND;EACD,CAAE,CAAC;EAEH,OAAOE,aAAA,CAACL,MAAM,MAAE,CAAC;AAClB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalHStack","HStack","__experimentalText","Text","Button","__","_x","_n","sprintf","Pagination","currentPage","numPages","changePage","totalItems","createElement","expanded","spacing","justify","className","variant","onClick","disabled"],"sources":["@wordpress/edit-site/src/components/page-patterns/pagination.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalText as Text,\n\tButton,\n} from '@wordpress/components';\nimport { __, _x, _n, sprintf } from '@wordpress/i18n';\n\nexport default function Pagination( {\n\tcurrentPage,\n\tnumPages,\n\tchangePage,\n\ttotalItems,\n} ) {\n\treturn (\n\t\t<HStack\n\t\t\texpanded={ false }\n\t\t\tspacing={ 3 }\n\t\t\tjustify=\"flex-start\"\n\t\t\tclassName=\"edit-site-patterns__grid-pagination\"\n\t\t>\n\t\t\t<Text variant=\"muted\">\n\t\t\t\t{\n\t\t\t\t\t// translators: %s: Total number of patterns.\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: Total number of patterns.\n\t\t\t\t\t\t_n( '%s item', '%s items', totalItems ),\n\t\t\t\t\t\ttotalItems\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t</Text>\n\t\t\t<HStack expanded={ false } spacing={ 1 }>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => changePage( 1 ) }\n\t\t\t\t\tdisabled={ currentPage === 1 }\n\t\t\t\t\taria-label={ __( 'First page' ) }\n\t\t\t\t>\n\t\t\t\t\t«\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => changePage( currentPage - 1 ) }\n\t\t\t\t\tdisabled={ currentPage === 1 }\n\t\t\t\t\taria-label={ __( 'Previous page' ) }\n\t\t\t\t>\n\t\t\t\t\t‹\n\t\t\t\t</Button>\n\t\t\t</HStack>\n\t\t\t<Text variant=\"muted\">\n\t\t\t\t{ sprintf(\n\t\t\t\t\t// translators: %1$s: Current page number, %2$s: Total number of pages.\n\t\t\t\t\t_x( '%1$s of %2$s', 'paging' ),\n\t\t\t\t\tcurrentPage,\n\t\t\t\t\tnumPages\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t\t<HStack expanded={ false } spacing={ 1 }>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => changePage( currentPage + 1 ) }\n\t\t\t\t\tdisabled={ currentPage === numPages }\n\t\t\t\t\taria-label={ __( 'Next page' ) }\n\t\t\t\t>\n\t\t\t\t\t›\n\t\t\t\t</Button>\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\tonClick={ () => changePage( numPages ) }\n\t\t\t\t\tdisabled={ currentPage === numPages }\n\t\t\t\t\taria-label={ __( 'Last page' ) }\n\t\t\t\t>\n\t\t\t\t\t»\n\t\t\t\t</Button>\n\t\t\t</HStack>\n\t\t</HStack>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,oBAAoB,IAAIC,MAAM,EAC9BC,kBAAkB,IAAIC,IAAI,EAC1BC,MAAM,QACA,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAErD,eAAe,SAASC,UAAUA,CAAE;EACnCC,WAAW;EACXC,QAAQ;EACRC,UAAU;EACVC;AACD,CAAC,EAAG;EACH,OACCC,aAAA,CAACb,MAAM;IACNc,QAAQ,EAAG,KAAO;IAClBC,OAAO,EAAG,C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AU,CAAED,QAAS,CAAG;IACxCU,QAAQ,EAAGX,WAAW,KAAKC,QAAU;IACrC,cAAaN,EAAE,CAAE,WAAY;EAAG,GAChC,MAEO,CACD,CACD,CAAC;AAEX"}
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import removeAccents from 'remove-accents';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { Icon, __experimentalView as View, __experimentalText as Text, __experimentalHStack as HStack, __experimentalVStack as VStack, VisuallyHidden } from '@wordpress/components';
|
|
11
|
-
import { __, _x } from '@wordpress/i18n';
|
|
12
|
-
import { useState, useMemo, useCallback } from '@wordpress/element';
|
|
13
|
-
import { useEntityRecords } from '@wordpress/core-data';
|
|
14
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
15
|
-
import { parse } from '@wordpress/blocks';
|
|
16
|
-
import { BlockPreview, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
17
|
-
import { DataViews } from '@wordpress/dataviews';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Internal dependencies
|
|
21
|
-
*/
|
|
22
|
-
import Page from '../page';
|
|
23
|
-
import Link from '../routes/link';
|
|
24
|
-
import { useAddedBy, AvatarImage } from '../list/added-by';
|
|
25
|
-
import { TEMPLATE_POST_TYPE, ENUMERATION_TYPE, OPERATOR_IN, OPERATOR_NOT_IN, LAYOUT_GRID, LAYOUT_TABLE } from '../../utils/constants';
|
|
26
|
-
import { useResetTemplateAction, deleteTemplateAction, renameTemplateAction } from './template-actions';
|
|
27
|
-
import usePatternSettings from '../page-patterns/use-pattern-settings';
|
|
28
|
-
import { unlock } from '../../lock-unlock';
|
|
29
|
-
const {
|
|
30
|
-
ExperimentalBlockEditorProvider,
|
|
31
|
-
useGlobalStyle
|
|
32
|
-
} = unlock(blockEditorPrivateApis);
|
|
33
|
-
const EMPTY_ARRAY = [];
|
|
34
|
-
const defaultConfigPerViewType = {
|
|
35
|
-
[LAYOUT_TABLE]: {},
|
|
36
|
-
[LAYOUT_GRID]: {
|
|
37
|
-
mediaField: 'preview',
|
|
38
|
-
primaryField: 'title'
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const DEFAULT_VIEW = {
|
|
42
|
-
type: LAYOUT_TABLE,
|
|
43
|
-
search: '',
|
|
44
|
-
page: 1,
|
|
45
|
-
perPage: 20,
|
|
46
|
-
// All fields are visible by default, so it's
|
|
47
|
-
// better to keep track of the hidden ones.
|
|
48
|
-
hiddenFields: ['preview'],
|
|
49
|
-
layout: {},
|
|
50
|
-
filters: []
|
|
51
|
-
};
|
|
52
|
-
function normalizeSearchInput(input = '') {
|
|
53
|
-
return removeAccents(input.trim().toLowerCase());
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// TODO: these are going to be reused in the template part list.
|
|
57
|
-
// That's the reason for leaving the template parts code for now.
|
|
58
|
-
function TemplateTitle({
|
|
59
|
-
item
|
|
60
|
-
}) {
|
|
61
|
-
const {
|
|
62
|
-
isCustomized
|
|
63
|
-
} = useAddedBy(item.type, item.id);
|
|
64
|
-
return createElement(VStack, {
|
|
65
|
-
spacing: 1
|
|
66
|
-
}, createElement(View, {
|
|
67
|
-
as: "span",
|
|
68
|
-
className: "edit-site-list-title__customized-info"
|
|
69
|
-
}, createElement(Link, {
|
|
70
|
-
params: {
|
|
71
|
-
postId: item.id,
|
|
72
|
-
postType: item.type,
|
|
73
|
-
canvas: 'edit'
|
|
74
|
-
}
|
|
75
|
-
}, decodeEntities(item.title?.rendered || item.slug) || __('(no title)'))), isCustomized && createElement("span", {
|
|
76
|
-
className: "edit-site-list-added-by__customized-info"
|
|
77
|
-
}, item.type === TEMPLATE_POST_TYPE ? _x('Customized', 'template') : _x('Customized', 'template part')));
|
|
78
|
-
}
|
|
79
|
-
function AuthorField({
|
|
80
|
-
item
|
|
81
|
-
}) {
|
|
82
|
-
const {
|
|
83
|
-
text,
|
|
84
|
-
icon,
|
|
85
|
-
imageUrl
|
|
86
|
-
} = useAddedBy(item.type, item.id);
|
|
87
|
-
return createElement(HStack, {
|
|
88
|
-
alignment: "left",
|
|
89
|
-
spacing: 1
|
|
90
|
-
}, imageUrl ? createElement(AvatarImage, {
|
|
91
|
-
imageUrl: imageUrl
|
|
92
|
-
}) : createElement("div", {
|
|
93
|
-
className: "edit-site-list-added-by__icon"
|
|
94
|
-
}, createElement(Icon, {
|
|
95
|
-
icon: icon
|
|
96
|
-
})), createElement("span", null, text));
|
|
97
|
-
}
|
|
98
|
-
function TemplatePreview({
|
|
99
|
-
content,
|
|
100
|
-
viewType
|
|
101
|
-
}) {
|
|
102
|
-
const settings = usePatternSettings();
|
|
103
|
-
const [backgroundColor = 'white'] = useGlobalStyle('color.background');
|
|
104
|
-
const blocks = useMemo(() => {
|
|
105
|
-
return parse(content);
|
|
106
|
-
}, [content]);
|
|
107
|
-
if (!blocks?.length) {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
// Wrap everything in a block editor provider to ensure 'styles' that are needed
|
|
111
|
-
// for the previews are synced between the site editor store and the block editor store.
|
|
112
|
-
// Additionally we need to have the `__experimentalBlockPatterns` setting in order to
|
|
113
|
-
// render patterns inside the previews.
|
|
114
|
-
// TODO: Same approach is used in the patterns list and it becomes obvious that some of
|
|
115
|
-
// the block editor settings are needed in context where we don't have the block editor.
|
|
116
|
-
// Explore how we can solve this in a better way.
|
|
117
|
-
return createElement(ExperimentalBlockEditorProvider, {
|
|
118
|
-
settings: settings
|
|
119
|
-
}, createElement("div", {
|
|
120
|
-
className: `page-templates-preview-field is-viewtype-${viewType}`,
|
|
121
|
-
style: {
|
|
122
|
-
backgroundColor
|
|
123
|
-
}
|
|
124
|
-
}, createElement(BlockPreview, {
|
|
125
|
-
blocks: blocks
|
|
126
|
-
})));
|
|
127
|
-
}
|
|
128
|
-
export default function DataviewsTemplates() {
|
|
129
|
-
const [view, setView] = useState(DEFAULT_VIEW);
|
|
130
|
-
const {
|
|
131
|
-
records: allTemplates,
|
|
132
|
-
isResolving: isLoadingData
|
|
133
|
-
} = useEntityRecords('postType', TEMPLATE_POST_TYPE, {
|
|
134
|
-
per_page: -1
|
|
135
|
-
});
|
|
136
|
-
const authors = useMemo(() => {
|
|
137
|
-
if (!allTemplates) {
|
|
138
|
-
return EMPTY_ARRAY;
|
|
139
|
-
}
|
|
140
|
-
const authorsSet = new Set();
|
|
141
|
-
allTemplates.forEach(template => {
|
|
142
|
-
authorsSet.add(template.author_text);
|
|
143
|
-
});
|
|
144
|
-
return Array.from(authorsSet).map(author => ({
|
|
145
|
-
value: author,
|
|
146
|
-
label: author
|
|
147
|
-
}));
|
|
148
|
-
}, [allTemplates]);
|
|
149
|
-
const fields = useMemo(() => [{
|
|
150
|
-
header: __('Preview'),
|
|
151
|
-
id: 'preview',
|
|
152
|
-
render: ({
|
|
153
|
-
item
|
|
154
|
-
}) => {
|
|
155
|
-
return createElement(TemplatePreview, {
|
|
156
|
-
content: item.content.raw,
|
|
157
|
-
viewType: view.type
|
|
158
|
-
});
|
|
159
|
-
},
|
|
160
|
-
minWidth: 120,
|
|
161
|
-
maxWidth: 120,
|
|
162
|
-
enableSorting: false
|
|
163
|
-
}, {
|
|
164
|
-
header: __('Template'),
|
|
165
|
-
id: 'title',
|
|
166
|
-
getValue: ({
|
|
167
|
-
item
|
|
168
|
-
}) => item.title?.rendered || item.slug,
|
|
169
|
-
render: ({
|
|
170
|
-
item
|
|
171
|
-
}) => createElement(TemplateTitle, {
|
|
172
|
-
item: item
|
|
173
|
-
}),
|
|
174
|
-
maxWidth: 400,
|
|
175
|
-
enableHiding: false
|
|
176
|
-
}, {
|
|
177
|
-
header: __('Description'),
|
|
178
|
-
id: 'description',
|
|
179
|
-
getValue: ({
|
|
180
|
-
item
|
|
181
|
-
}) => item.description,
|
|
182
|
-
render: ({
|
|
183
|
-
item
|
|
184
|
-
}) => {
|
|
185
|
-
return item.description ? decodeEntities(item.description) : createElement(Fragment, null, createElement(Text, {
|
|
186
|
-
variant: "muted",
|
|
187
|
-
"aria-hidden": "true"
|
|
188
|
-
}, "\u2014"), createElement(VisuallyHidden, null, __('No description.')));
|
|
189
|
-
},
|
|
190
|
-
maxWidth: 200,
|
|
191
|
-
enableSorting: false
|
|
192
|
-
}, {
|
|
193
|
-
header: __('Author'),
|
|
194
|
-
id: 'author',
|
|
195
|
-
getValue: ({
|
|
196
|
-
item
|
|
197
|
-
}) => item.author_text,
|
|
198
|
-
render: ({
|
|
199
|
-
item
|
|
200
|
-
}) => {
|
|
201
|
-
return createElement(AuthorField, {
|
|
202
|
-
item: item
|
|
203
|
-
});
|
|
204
|
-
},
|
|
205
|
-
enableHiding: false,
|
|
206
|
-
type: ENUMERATION_TYPE,
|
|
207
|
-
elements: authors
|
|
208
|
-
}], [authors, view]);
|
|
209
|
-
const {
|
|
210
|
-
shownTemplates,
|
|
211
|
-
paginationInfo
|
|
212
|
-
} = useMemo(() => {
|
|
213
|
-
if (!allTemplates) {
|
|
214
|
-
return {
|
|
215
|
-
shownTemplates: EMPTY_ARRAY,
|
|
216
|
-
paginationInfo: {
|
|
217
|
-
totalItems: 0,
|
|
218
|
-
totalPages: 0
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
let filteredTemplates = [...allTemplates];
|
|
223
|
-
// Handle global search.
|
|
224
|
-
if (view.search) {
|
|
225
|
-
const normalizedSearch = normalizeSearchInput(view.search);
|
|
226
|
-
filteredTemplates = filteredTemplates.filter(item => {
|
|
227
|
-
const title = item.title?.rendered || item.slug;
|
|
228
|
-
return normalizeSearchInput(title).includes(normalizedSearch) || normalizeSearchInput(item.description).includes(normalizedSearch);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// Handle filters.
|
|
233
|
-
if (view.filters.length > 0) {
|
|
234
|
-
view.filters.forEach(filter => {
|
|
235
|
-
if (filter.field === 'author' && filter.operator === OPERATOR_IN && !!filter.value) {
|
|
236
|
-
filteredTemplates = filteredTemplates.filter(item => {
|
|
237
|
-
return item.author_text === filter.value;
|
|
238
|
-
});
|
|
239
|
-
} else if (filter.field === 'author' && filter.operator === OPERATOR_NOT_IN && !!filter.value) {
|
|
240
|
-
filteredTemplates = filteredTemplates.filter(item => {
|
|
241
|
-
return item.author_text !== filter.value;
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// Handle sorting.
|
|
248
|
-
if (view.sort) {
|
|
249
|
-
const stringSortingFields = ['title', 'author'];
|
|
250
|
-
const fieldId = view.sort.field;
|
|
251
|
-
if (stringSortingFields.includes(fieldId)) {
|
|
252
|
-
const fieldToSort = fields.find(field => {
|
|
253
|
-
return field.id === fieldId;
|
|
254
|
-
});
|
|
255
|
-
filteredTemplates.sort((a, b) => {
|
|
256
|
-
var _fieldToSort$getValue, _fieldToSort$getValue2;
|
|
257
|
-
const valueA = (_fieldToSort$getValue = fieldToSort.getValue({
|
|
258
|
-
item: a
|
|
259
|
-
})) !== null && _fieldToSort$getValue !== void 0 ? _fieldToSort$getValue : '';
|
|
260
|
-
const valueB = (_fieldToSort$getValue2 = fieldToSort.getValue({
|
|
261
|
-
item: b
|
|
262
|
-
})) !== null && _fieldToSort$getValue2 !== void 0 ? _fieldToSort$getValue2 : '';
|
|
263
|
-
return view.sort.direction === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA);
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// Handle pagination.
|
|
269
|
-
const start = (view.page - 1) * view.perPage;
|
|
270
|
-
const totalItems = filteredTemplates?.length || 0;
|
|
271
|
-
filteredTemplates = filteredTemplates?.slice(start, start + view.perPage);
|
|
272
|
-
return {
|
|
273
|
-
shownTemplates: filteredTemplates,
|
|
274
|
-
paginationInfo: {
|
|
275
|
-
totalItems,
|
|
276
|
-
totalPages: Math.ceil(totalItems / view.perPage)
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
}, [allTemplates, view, fields]);
|
|
280
|
-
const resetTemplateAction = useResetTemplateAction();
|
|
281
|
-
const actions = useMemo(() => [resetTemplateAction, deleteTemplateAction, renameTemplateAction], [resetTemplateAction]);
|
|
282
|
-
const onChangeView = useCallback(viewUpdater => {
|
|
283
|
-
let updatedView = typeof viewUpdater === 'function' ? viewUpdater(view) : viewUpdater;
|
|
284
|
-
if (updatedView.type !== view.type) {
|
|
285
|
-
updatedView = {
|
|
286
|
-
...updatedView,
|
|
287
|
-
layout: {
|
|
288
|
-
...defaultConfigPerViewType[updatedView.type]
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
setView(updatedView);
|
|
293
|
-
}, [view, setView]);
|
|
294
|
-
return createElement(Page, {
|
|
295
|
-
title: __('Templates')
|
|
296
|
-
}, createElement(DataViews, {
|
|
297
|
-
paginationInfo: paginationInfo,
|
|
298
|
-
fields: fields,
|
|
299
|
-
actions: actions,
|
|
300
|
-
data: shownTemplates,
|
|
301
|
-
getItemId: item => item.id,
|
|
302
|
-
isLoading: isLoadingData,
|
|
303
|
-
view: view,
|
|
304
|
-
onChangeView: onChangeView,
|
|
305
|
-
supportedLayouts: [LAYOUT_TABLE, LAYOUT_GRID],
|
|
306
|
-
deferredRendering: !view.hiddenFields?.includes('preview')
|
|
307
|
-
}));
|
|
308
|
-
}
|
|
309
|
-
//# sourceMappingURL=dataviews-templates.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["removeAccents","Icon","__experimentalView","View","__experimentalText","Text","__experimentalHStack","HStack","__experimentalVStack","VStack","VisuallyHidden","__","_x","useState","useMemo","useCallback","useEntityRecords","decodeEntities","parse","BlockPreview","privateApis","blockEditorPrivateApis","DataViews","Page","Link","useAddedBy","AvatarImage","TEMPLATE_POST_TYPE","ENUMERATION_TYPE","OPERATOR_IN","OPERATOR_NOT_IN","LAYOUT_GRID","LAYOUT_TABLE","useResetTemplateAction","deleteTemplateAction","renameTemplateAction","usePatternSettings","unlock","ExperimentalBlockEditorProvider","useGlobalStyle","EMPTY_ARRAY","defaultConfigPerViewType","mediaField","primaryField","DEFAULT_VIEW","type","search","page","perPage","hiddenFields","layout","filters","normalizeSearchInput","input","trim","toLowerCase","TemplateTitle","item","isCustomized","id","createElement","spacing","as","className","params","postId","postType","canvas","title","rendered","slug","AuthorField","text","icon","imageUrl","alignment","TemplatePreview","content","viewType","settings","backgroundColor","blocks","length","style","DataviewsTemplates","view","setView","records","allTemplates","isResolving","isLoadingData","per_page","authors","authorsSet","Set","forEach","template","add","author_text","Array","from","map","author","value","label","fields","header","render","raw","minWidth","maxWidth","enableSorting","getValue","enableHiding","description","Fragment","variant","elements","shownTemplates","paginationInfo","totalItems","totalPages","filteredTemplates","normalizedSearch","filter","includes","field","operator","sort","stringSortingFields","fieldId","fieldToSort","find","a","b","_fieldToSort$getValue","_fieldToSort$getValue2","valueA","valueB","direction","localeCompare","start","slice","Math","ceil","resetTemplateAction","actions","onChangeView","viewUpdater","updatedView","data","getItemId","isLoading","supportedLayouts","deferredRendering"],"sources":["@wordpress/edit-site/src/components/page-templates/dataviews-templates.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tIcon,\n\t__experimentalView as View,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useState, useMemo, useCallback } from '@wordpress/element';\nimport { useEntityRecords } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { parse } from '@wordpress/blocks';\nimport {\n\tBlockPreview,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { DataViews } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport Page from '../page';\nimport Link from '../routes/link';\nimport { useAddedBy, AvatarImage } from '../list/added-by';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tENUMERATION_TYPE,\n\tOPERATOR_IN,\n\tOPERATOR_NOT_IN,\n\tLAYOUT_GRID,\n\tLAYOUT_TABLE,\n} from '../../utils/constants';\nimport {\n\tuseResetTemplateAction,\n\tdeleteTemplateAction,\n\trenameTemplateAction,\n} from './template-actions';\nimport usePatternSettings from '../page-patterns/use-pattern-settings';\nimport { unlock } from '../../lock-unlock';\n\nconst { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(\n\tblockEditorPrivateApis\n);\n\nconst EMPTY_ARRAY = [];\n\nconst defaultConfigPerViewType = {\n\t[ LAYOUT_TABLE ]: {},\n\t[ LAYOUT_GRID ]: {\n\t\tmediaField: 'preview',\n\t\tprimaryField: 'title',\n\t},\n};\n\nconst DEFAULT_VIEW = {\n\ttype: LAYOUT_TABLE,\n\tsearch: '',\n\tpage: 1,\n\tperPage: 20,\n\t// All fields are visible by default, so it's\n\t// better to keep track of the hidden ones.\n\thiddenFields: [ 'preview' ],\n\tlayout: {},\n\tfilters: [],\n};\n\nfunction normalizeSearchInput( input = '' ) {\n\treturn removeAccents( input.trim().toLowerCase() );\n}\n\n// TODO: these are going to be reused in the template part list.\n// That's the reason for leaving the template parts code for now.\nfunction TemplateTitle( { item } ) {\n\tconst { isCustomized } = useAddedBy( item.type, item.id );\n\treturn (\n\t\t<VStack spacing={ 1 }>\n\t\t\t<View as=\"span\" className=\"edit-site-list-title__customized-info\">\n\t\t\t\t<Link\n\t\t\t\t\tparams={ {\n\t\t\t\t\t\tpostId: item.id,\n\t\t\t\t\t\tpostType: item.type,\n\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ decodeEntities( item.title?.rendered || item.slug ) ||\n\t\t\t\t\t\t__( '(no title)' ) }\n\t\t\t\t</Link>\n\t\t\t</View>\n\t\t\t{ isCustomized && (\n\t\t\t\t<span className=\"edit-site-list-added-by__customized-info\">\n\t\t\t\t\t{ item.type === TEMPLATE_POST_TYPE\n\t\t\t\t\t\t? _x( 'Customized', 'template' )\n\t\t\t\t\t\t: _x( 'Customized', 'template part' ) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n\nfunction AuthorField( { item } ) {\n\tconst { text, icon, imageUrl } = useAddedBy( item.type, item.id );\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 1 }>\n\t\t\t{ imageUrl ? (\n\t\t\t\t<AvatarImage imageUrl={ imageUrl } />\n\t\t\t) : (\n\t\t\t\t<div className=\"edit-site-list-added-by__icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ text }</span>\n\t\t</HStack>\n\t);\n}\n\nfunction TemplatePreview( { content, viewType } ) {\n\tconst settings = usePatternSettings();\n\tconst [ backgroundColor = 'white' ] = useGlobalStyle( 'color.background' );\n\tconst blocks = useMemo( () => {\n\t\treturn parse( content );\n\t}, [ content ] );\n\tif ( ! blocks?.length ) {\n\t\treturn null;\n\t}\n\t// Wrap everything in a block editor provider to ensure 'styles' that are needed\n\t// for the previews are synced between the site editor store and the block editor store.\n\t// Additionally we need to have the `__experimentalBlockPatterns` setting in order to\n\t// render patterns inside the previews.\n\t// TODO: Same approach is used in the patterns list and it becomes obvious that some of\n\t// the block editor settings are needed in context where we don't have the block editor.\n\t// Explore how we can solve this in a better way.\n\treturn (\n\t\t<ExperimentalBlockEditorProvider settings={ settings }>\n\t\t\t<div\n\t\t\t\tclassName={ `page-templates-preview-field is-viewtype-${ viewType }` }\n\t\t\t\tstyle={ { backgroundColor } }\n\t\t\t>\n\t\t\t\t<BlockPreview blocks={ blocks } />\n\t\t\t</div>\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n}\n\nexport default function DataviewsTemplates() {\n\tconst [ view, setView ] = useState( DEFAULT_VIEW );\n\tconst { records: allTemplates, isResolving: isLoadingData } =\n\t\tuseEntityRecords( 'postType', TEMPLATE_POST_TYPE, {\n\t\t\tper_page: -1,\n\t\t} );\n\n\tconst authors = useMemo( () => {\n\t\tif ( ! allTemplates ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\t\tconst authorsSet = new Set();\n\t\tallTemplates.forEach( ( template ) => {\n\t\t\tauthorsSet.add( template.author_text );\n\t\t} );\n\t\treturn Array.from( authorsSet ).map( ( author ) => ( {\n\t\t\tvalue: author,\n\t\t\tlabel: author,\n\t\t} ) );\n\t}, [ allTemplates ] );\n\n\tconst fields = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\theader: __( 'Preview' ),\n\t\t\t\tid: 'preview',\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TemplatePreview\n\t\t\t\t\t\t\tcontent={ item.content.raw }\n\t\t\t\t\t\t\tviewType={ view.type }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tminWidth: 120,\n\t\t\t\tmaxWidth: 120,\n\t\t\t\tenableSorting: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Template' ),\n\t\t\t\tid: 'title',\n\t\t\t\tgetValue: ( { item } ) => item.title?.rendered || item.slug,\n\t\t\t\trender: ( { item } ) => <TemplateTitle item={ item } />,\n\t\t\t\tmaxWidth: 400,\n\t\t\t\tenableHiding: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Description' ),\n\t\t\t\tid: 'description',\n\t\t\t\tgetValue: ( { item } ) => item.description,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn item.description ? (\n\t\t\t\t\t\tdecodeEntities( item.description )\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<Text variant=\"muted\" aria-hidden=\"true\">\n\t\t\t\t\t\t\t\t—\n\t\t\t\t\t\t\t</Text>\n\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t{ __( 'No description.' ) }\n\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t</>\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tmaxWidth: 200,\n\t\t\t\tenableSorting: false,\n\t\t\t},\n\t\t\t{\n\t\t\t\theader: __( 'Author' ),\n\t\t\t\tid: 'author',\n\t\t\t\tgetValue: ( { item } ) => item.author_text,\n\t\t\t\trender: ( { item } ) => {\n\t\t\t\t\treturn <AuthorField item={ item } />;\n\t\t\t\t},\n\t\t\t\tenableHiding: false,\n\t\t\t\ttype: ENUMERATION_TYPE,\n\t\t\t\telements: authors,\n\t\t\t},\n\t\t],\n\t\t[ authors, view ]\n\t);\n\n\tconst { shownTemplates, paginationInfo } = useMemo( () => {\n\t\tif ( ! allTemplates ) {\n\t\t\treturn {\n\t\t\t\tshownTemplates: EMPTY_ARRAY,\n\t\t\t\tpaginationInfo: { totalItems: 0, totalPages: 0 },\n\t\t\t};\n\t\t}\n\t\tlet filteredTemplates = [ ...allTemplates ];\n\t\t// Handle global search.\n\t\tif ( view.search ) {\n\t\t\tconst normalizedSearch = normalizeSearchInput( view.search );\n\t\t\tfilteredTemplates = filteredTemplates.filter( ( item ) => {\n\t\t\t\tconst title = item.title?.rendered || item.slug;\n\t\t\t\treturn (\n\t\t\t\t\tnormalizeSearchInput( title ).includes(\n\t\t\t\t\t\tnormalizedSearch\n\t\t\t\t\t) ||\n\t\t\t\t\tnormalizeSearchInput( item.description ).includes(\n\t\t\t\t\t\tnormalizedSearch\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} );\n\t\t}\n\n\t\t// Handle filters.\n\t\tif ( view.filters.length > 0 ) {\n\t\t\tview.filters.forEach( ( filter ) => {\n\t\t\t\tif (\n\t\t\t\t\tfilter.field === 'author' &&\n\t\t\t\t\tfilter.operator === OPERATOR_IN &&\n\t\t\t\t\t!! filter.value\n\t\t\t\t) {\n\t\t\t\t\tfilteredTemplates = filteredTemplates.filter( ( item ) => {\n\t\t\t\t\t\treturn item.author_text === filter.value;\n\t\t\t\t\t} );\n\t\t\t\t} else if (\n\t\t\t\t\tfilter.field === 'author' &&\n\t\t\t\t\tfilter.operator === OPERATOR_NOT_IN &&\n\t\t\t\t\t!! filter.value\n\t\t\t\t) {\n\t\t\t\t\tfilteredTemplates = filteredTemplates.filter( ( item ) => {\n\t\t\t\t\t\treturn item.author_text !== filter.value;\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t// Handle sorting.\n\t\tif ( view.sort ) {\n\t\t\tconst stringSortingFields = [ 'title', 'author' ];\n\t\t\tconst fieldId = view.sort.field;\n\t\t\tif ( stringSortingFields.includes( fieldId ) ) {\n\t\t\t\tconst fieldToSort = fields.find( ( field ) => {\n\t\t\t\t\treturn field.id === fieldId;\n\t\t\t\t} );\n\t\t\t\tfilteredTemplates.sort( ( a, b ) => {\n\t\t\t\t\tconst valueA = fieldToSort.getValue( { item: a } ) ?? '';\n\t\t\t\t\tconst valueB = fieldToSort.getValue( { item: b } ) ?? '';\n\t\t\t\t\treturn view.sort.direction === 'asc'\n\t\t\t\t\t\t? valueA.localeCompare( valueB )\n\t\t\t\t\t\t: valueB.localeCompare( valueA );\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\n\t\t// Handle pagination.\n\t\tconst start = ( view.page - 1 ) * view.perPage;\n\t\tconst totalItems = filteredTemplates?.length || 0;\n\t\tfilteredTemplates = filteredTemplates?.slice(\n\t\t\tstart,\n\t\t\tstart + view.perPage\n\t\t);\n\t\treturn {\n\t\t\tshownTemplates: filteredTemplates,\n\t\t\tpaginationInfo: {\n\t\t\t\ttotalItems,\n\t\t\t\ttotalPages: Math.ceil( totalItems / view.perPage ),\n\t\t\t},\n\t\t};\n\t}, [ allTemplates, view, fields ] );\n\n\tconst resetTemplateAction = useResetTemplateAction();\n\tconst actions = useMemo(\n\t\t() => [\n\t\t\tresetTemplateAction,\n\t\t\tdeleteTemplateAction,\n\t\t\trenameTemplateAction,\n\t\t],\n\t\t[ resetTemplateAction ]\n\t);\n\tconst onChangeView = useCallback(\n\t\t( viewUpdater ) => {\n\t\t\tlet updatedView =\n\t\t\t\ttypeof viewUpdater === 'function'\n\t\t\t\t\t? viewUpdater( view )\n\t\t\t\t\t: viewUpdater;\n\t\t\tif ( updatedView.type !== view.type ) {\n\t\t\t\tupdatedView = {\n\t\t\t\t\t...updatedView,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...defaultConfigPerViewType[ updatedView.type ],\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tsetView( updatedView );\n\t\t},\n\t\t[ view, setView ]\n\t);\n\treturn (\n\t\t<Page title={ __( 'Templates' ) }>\n\t\t\t<DataViews\n\t\t\t\tpaginationInfo={ paginationInfo }\n\t\t\t\tfields={ fields }\n\t\t\t\tactions={ actions }\n\t\t\t\tdata={ shownTemplates }\n\t\t\t\tgetItemId={ ( item ) => item.id }\n\t\t\t\tisLoading={ isLoadingData }\n\t\t\t\tview={ view }\n\t\t\t\tonChangeView={ onChangeView }\n\t\t\t\tsupportedLayouts={ [ LAYOUT_TABLE, LAYOUT_GRID ] }\n\t\t\t\tdeferredRendering={ ! view.hiddenFields?.includes( 'preview' ) }\n\t\t\t/>\n\t\t</Page>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA,SACCC,IAAI,EACJC,kBAAkB,IAAIC,IAAI,EAC1BC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,cAAc,QACR,uBAAuB;AAC9B,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,QAAQ,EAAEC,OAAO,EAAEC,WAAW,QAAQ,oBAAoB;AACnE,SAASC,gBA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AGpI,OAAO,CACtB,MAAM,CACLmI,mBAAmB,EACnB/G,oBAAoB,EACpBC,oBAAoB,CACpB,EACD,CAAE8G,mBAAmB,CACtB,CAAC;EACD,MAAME,YAAY,GAAGpI,WAAW,CAC7BqI,WAAW,IAAM;IAClB,IAAIC,WAAW,GACd,OAAOD,WAAW,KAAK,UAAU,GAC9BA,WAAW,CAAE/D,IAAK,CAAC,GACnB+D,WAAW;IACf,IAAKC,WAAW,CAACxG,IAAI,KAAKwC,IAAI,CAACxC,IAAI,EAAG;MACrCwG,WAAW,GAAG;QACb,GAAGA,WAAW;QACdnG,MAAM,EAAE;UACP,GAAGT,wBAAwB,CAAE4G,WAAW,CAACxG,IAAI;QAC9C;MACD,CAAC;IACF;IAEAyC,OAAO,CAAE+D,WAAY,CAAC;EACvB,CAAC,EACD,CAAEhE,IAAI,EAAEC,OAAO,CAChB,CAAC;EACD,OACC1B,aAAA,CAACrC,IAAI;IAAC6C,KAAK,EAAGzD,EAAE,CAAE,WAAY;EAAG,GAChCiD,aAAA,CAACtC,SAAS;IACTiG,cAAc,EAAGA,cAAgB;IACjCd,MAAM,EAAGA,MAAQ;IACjByC,OAAO,EAAGA,OAAS;IACnBI,IAAI,EAAGhC,cAAgB;IACvBiC,SAAS,EAAK9F,IAAI,IAAMA,IAAI,CAACE,EAAI;IACjC6F,SAAS,EAAG9D,aAAe;IAC3BL,IAAI,EAAGA,IAAM;IACb8D,YAAY,EAAGA,YAAc;IAC7BM,gBAAgB,EAAG,CAAEzH,YAAY,EAAED,WAAW,CAAI;IAClD2H,iBAAiB,EAAG,CAAErE,IAAI,CAACpC,YAAY,EAAE4E,QAAQ,CAAE,SAAU;EAAG,CAChE,CACI,CAAC;AAET"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
-
import { Button, VisuallyHidden } from '@wordpress/components';
|
|
7
|
-
import { __experimentalLibrary as Library } from '@wordpress/block-editor';
|
|
8
|
-
import { close } from '@wordpress/icons';
|
|
9
|
-
import { useViewportMatch, __experimentalUseDialog as useDialog } from '@wordpress/compose';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { useEffect, useRef } from '@wordpress/element';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { store as editSiteStore } from '../../store';
|
|
17
|
-
export default function InserterSidebar() {
|
|
18
|
-
const {
|
|
19
|
-
setIsInserterOpened
|
|
20
|
-
} = useDispatch(editSiteStore);
|
|
21
|
-
const insertionPoint = useSelect(select => select(editSiteStore).__experimentalGetInsertionPoint(), []);
|
|
22
|
-
const isMobile = useViewportMatch('medium', '<');
|
|
23
|
-
const TagName = !isMobile ? VisuallyHidden : 'div';
|
|
24
|
-
const [inserterDialogRef, inserterDialogProps] = useDialog({
|
|
25
|
-
onClose: () => setIsInserterOpened(false),
|
|
26
|
-
focusOnMount: null
|
|
27
|
-
});
|
|
28
|
-
const libraryRef = useRef();
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
libraryRef.current.focusSearch();
|
|
31
|
-
}, []);
|
|
32
|
-
return createElement("div", {
|
|
33
|
-
ref: inserterDialogRef,
|
|
34
|
-
...inserterDialogProps,
|
|
35
|
-
className: "edit-site-editor__inserter-panel"
|
|
36
|
-
}, createElement(TagName, {
|
|
37
|
-
className: "edit-site-editor__inserter-panel-header"
|
|
38
|
-
}, createElement(Button, {
|
|
39
|
-
icon: close,
|
|
40
|
-
label: __('Close block inserter'),
|
|
41
|
-
onClick: () => setIsInserterOpened(false)
|
|
42
|
-
})), createElement("div", {
|
|
43
|
-
className: "edit-site-editor__inserter-panel-content"
|
|
44
|
-
}, createElement(Library, {
|
|
45
|
-
showInserterHelpPanel: true,
|
|
46
|
-
shouldFocusBlock: isMobile,
|
|
47
|
-
rootClientId: insertionPoint.rootClientId,
|
|
48
|
-
__experimentalInsertionIndex: insertionPoint.insertionIndex,
|
|
49
|
-
__experimentalFilterValue: insertionPoint.filterValue,
|
|
50
|
-
ref: libraryRef
|
|
51
|
-
})));
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=inserter-sidebar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","Button","VisuallyHidden","__experimentalLibrary","Library","close","useViewportMatch","__experimentalUseDialog","useDialog","__","useEffect","useRef","store","editSiteStore","InserterSidebar","setIsInserterOpened","insertionPoint","select","__experimentalGetInsertionPoint","isMobile","TagName","inserterDialogRef","inserterDialogProps","onClose","focusOnMount","libraryRef","current","focusSearch","createElement","ref","className","icon","label","onClick","showInserterHelpPanel","shouldFocusBlock","rootClientId","__experimentalInsertionIndex","insertionIndex","__experimentalFilterValue","filterValue"],"sources":["@wordpress/edit-site/src/components/secondary-sidebar/inserter-sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { __experimentalLibrary as Library } from '@wordpress/block-editor';\nimport { close } from '@wordpress/icons';\nimport {\n\tuseViewportMatch,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function InserterSidebar() {\n\tconst { setIsInserterOpened } = useDispatch( editSiteStore );\n\tconst insertionPoint = useSelect(\n\t\t( select ) => select( editSiteStore ).__experimentalGetInsertionPoint(),\n\t\t[]\n\t);\n\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst TagName = ! isMobile ? VisuallyHidden : 'div';\n\tconst [ inserterDialogRef, inserterDialogProps ] = useDialog( {\n\t\tonClose: () => setIsInserterOpened( false ),\n\t\tfocusOnMount: null,\n\t} );\n\n\tconst libraryRef = useRef();\n\tuseEffect( () => {\n\t\tlibraryRef.current.focusSearch();\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ inserterDialogRef }\n\t\t\t{ ...inserterDialogProps }\n\t\t\tclassName=\"edit-site-editor__inserter-panel\"\n\t\t>\n\t\t\t<TagName className=\"edit-site-editor__inserter-panel-header\">\n\t\t\t\t<Button\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Close block inserter' ) }\n\t\t\t\t\tonClick={ () => setIsInserterOpened( false ) }\n\t\t\t\t/>\n\t\t\t</TagName>\n\t\t\t<div className=\"edit-site-editor__inserter-panel-content\">\n\t\t\t\t<Library\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tshouldFocusBlock={ isMobile }\n\t\t\t\t\trootClientId={ insertionPoint.rootClientId }\n\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\tinsertionPoint.insertionIndex\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFilterValue={ insertionPoint.filterValue }\n\t\t\t\t\tref={ libraryRef }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,MAAM,EAAEC,cAAc,QAAQ,uBAAuB;AAC9D,SAASC,qBAAqB,IAAIC,OAAO,QAAQ,yBAAyB;AAC1E,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SACCC,gBAAgB,EAChBC,uBAAuB,IAAIC,SAAS,QAC9B,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;;AAEtD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,aAAa;AAEpD,eAAe,SAASC,eAAeA,CAAA,EAAG;EACzC,MAAM;IAAEC;EAAoB,CAAC,GAAGf,WAAW,CAAEa,aA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,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
6
|
-
import { Button } from '@wordpress/components';
|
|
7
|
-
import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
|
|
8
|
-
import { useDispatch } from '@wordpress/data';
|
|
9
|
-
import { useCallback, useRef, useState } from '@wordpress/element';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { closeSmall } from '@wordpress/icons';
|
|
12
|
-
import { ESCAPE } from '@wordpress/keycodes';
|
|
13
|
-
import { focus } from '@wordpress/dom';
|
|
14
|
-
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
import { store as editSiteStore } from '../../store';
|
|
20
|
-
import { unlock } from '../../lock-unlock';
|
|
21
|
-
const {
|
|
22
|
-
PrivateListView
|
|
23
|
-
} = unlock(blockEditorPrivateApis);
|
|
24
|
-
export default function ListViewSidebar({
|
|
25
|
-
listViewToggleElement
|
|
26
|
-
}) {
|
|
27
|
-
const {
|
|
28
|
-
setIsListViewOpened
|
|
29
|
-
} = useDispatch(editSiteStore);
|
|
30
|
-
|
|
31
|
-
// This hook handles focus when the sidebar first renders.
|
|
32
|
-
const focusOnMountRef = useFocusOnMount('firstElement');
|
|
33
|
-
|
|
34
|
-
// When closing the list view, focus should return to the toggle button.
|
|
35
|
-
const closeListView = useCallback(() => {
|
|
36
|
-
setIsListViewOpened(false);
|
|
37
|
-
listViewToggleElement?.focus();
|
|
38
|
-
}, [listViewToggleElement, setIsListViewOpened]);
|
|
39
|
-
const closeOnEscape = useCallback(event => {
|
|
40
|
-
if (event.keyCode === ESCAPE && !event.defaultPrevented) {
|
|
41
|
-
event.preventDefault();
|
|
42
|
-
closeListView();
|
|
43
|
-
}
|
|
44
|
-
}, [closeListView]);
|
|
45
|
-
|
|
46
|
-
// Use internal state instead of a ref to make sure that the component
|
|
47
|
-
// re-renders when the dropZoneElement updates.
|
|
48
|
-
const [dropZoneElement, setDropZoneElement] = useState(null);
|
|
49
|
-
|
|
50
|
-
// This ref refers to the sidebar as a whole.
|
|
51
|
-
const sidebarRef = useRef();
|
|
52
|
-
// This ref refers to the close button.
|
|
53
|
-
const sidebarCloseButtonRef = useRef();
|
|
54
|
-
// This ref refers to the list view application area.
|
|
55
|
-
const listViewRef = useRef();
|
|
56
|
-
|
|
57
|
-
/*
|
|
58
|
-
* Callback function to handle list view or close button focus.
|
|
59
|
-
*
|
|
60
|
-
* @return void
|
|
61
|
-
*/
|
|
62
|
-
function handleSidebarFocus() {
|
|
63
|
-
// Either focus the list view or the sidebar close button. Must have a fallback because the list view does not render when there are no blocks.
|
|
64
|
-
const listViewApplicationFocus = focus.tabbable.find(listViewRef.current)[0];
|
|
65
|
-
const listViewFocusArea = sidebarRef.current.contains(listViewApplicationFocus) ? listViewApplicationFocus : sidebarCloseButtonRef.current;
|
|
66
|
-
listViewFocusArea.focus();
|
|
67
|
-
}
|
|
68
|
-
const handleToggleListViewShortcut = useCallback(() => {
|
|
69
|
-
// If the sidebar has focus, it is safe to close.
|
|
70
|
-
if (sidebarRef.current.contains(sidebarRef.current.ownerDocument.activeElement)) {
|
|
71
|
-
closeListView();
|
|
72
|
-
} else {
|
|
73
|
-
// If the list view or close button does not have focus, focus should be moved to it.
|
|
74
|
-
handleSidebarFocus();
|
|
75
|
-
}
|
|
76
|
-
}, [closeListView]);
|
|
77
|
-
|
|
78
|
-
// This only fires when the sidebar is open because of the conditional rendering.
|
|
79
|
-
// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
|
|
80
|
-
useShortcut('core/edit-site/toggle-list-view', handleToggleListViewShortcut);
|
|
81
|
-
return (
|
|
82
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
83
|
-
createElement("div", {
|
|
84
|
-
className: "edit-site-editor__list-view-panel",
|
|
85
|
-
onKeyDown: closeOnEscape,
|
|
86
|
-
ref: sidebarRef
|
|
87
|
-
}, createElement("div", {
|
|
88
|
-
className: "edit-site-editor__list-view-panel-header"
|
|
89
|
-
}, createElement("strong", null, __('List View')), createElement(Button, {
|
|
90
|
-
icon: closeSmall,
|
|
91
|
-
label: __('Close'),
|
|
92
|
-
onClick: closeListView,
|
|
93
|
-
ref: sidebarCloseButtonRef
|
|
94
|
-
})), createElement("div", {
|
|
95
|
-
className: "edit-site-editor__list-view-panel-content",
|
|
96
|
-
ref: useMergeRefs([focusOnMountRef, setDropZoneElement, listViewRef])
|
|
97
|
-
}, createElement(PrivateListView, {
|
|
98
|
-
dropZoneElement: dropZoneElement
|
|
99
|
-
})))
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=list-view-sidebar.js.map
|