@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":["privateApis","blockEditorPrivateApis","Button","useFocusOnMount","useMergeRefs","useDispatch","useCallback","useRef","useState","__","closeSmall","ESCAPE","focus","useShortcut","store","editSiteStore","unlock","PrivateListView","ListViewSidebar","listViewToggleElement","setIsListViewOpened","focusOnMountRef","closeListView","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","dropZoneElement","setDropZoneElement","sidebarRef","sidebarCloseButtonRef","listViewRef","handleSidebarFocus","listViewApplicationFocus","tabbable","find","current","listViewFocusArea","contains","handleToggleListViewShortcut","ownerDocument","activeElement","createElement","className","onKeyDown","ref","icon","label","onClick"],"sources":["@wordpress/edit-site/src/components/secondary-sidebar/list-view-sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { useFocusOnMount, useMergeRefs } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { PrivateListView } = unlock( blockEditorPrivateApis );\n\nexport default function ListViewSidebar( { listViewToggleElement } ) {\n\tconst { setIsListViewOpened } = useDispatch( editSiteStore );\n\n\t// This hook handles focus when the sidebar first renders.\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\t// When closing the list view, focus should return to the toggle button.\n\tconst closeListView = useCallback( () => {\n\t\tsetIsListViewOpened( false );\n\t\tlistViewToggleElement?.focus();\n\t}, [ listViewToggleElement, setIsListViewOpened ] );\n\n\tconst closeOnEscape = useCallback(\n\t\t( event ) => {\n\t\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcloseListView();\n\t\t\t}\n\t\t},\n\t\t[ closeListView ]\n\t);\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the dropZoneElement updates.\n\tconst [ dropZoneElement, setDropZoneElement ] = useState( null );\n\n\t// This ref refers to the sidebar as a whole.\n\tconst sidebarRef = useRef();\n\t// This ref refers to the close button.\n\tconst sidebarCloseButtonRef = useRef();\n\t// This ref refers to the list view application area.\n\tconst listViewRef = useRef();\n\n\t/*\n\t * Callback function to handle list view or close button focus.\n\t *\n\t * @return void\n\t */\n\tfunction handleSidebarFocus() {\n\t\t// 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.\n\t\tconst listViewApplicationFocus = focus.tabbable.find(\n\t\t\tlistViewRef.current\n\t\t)[ 0 ];\n\t\tconst listViewFocusArea = sidebarRef.current.contains(\n\t\t\tlistViewApplicationFocus\n\t\t)\n\t\t\t? listViewApplicationFocus\n\t\t\t: sidebarCloseButtonRef.current;\n\t\tlistViewFocusArea.focus();\n\t}\n\n\tconst handleToggleListViewShortcut = useCallback( () => {\n\t\t// If the sidebar has focus, it is safe to close.\n\t\tif (\n\t\t\tsidebarRef.current.contains(\n\t\t\t\tsidebarRef.current.ownerDocument.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcloseListView();\n\t\t} else {\n\t\t\t// If the list view or close button does not have focus, focus should be moved to it.\n\t\t\thandleSidebarFocus();\n\t\t}\n\t}, [ closeListView ] );\n\n\t// This only fires when the sidebar is open because of the conditional rendering.\n\t// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.\n\tuseShortcut(\n\t\t'core/edit-site/toggle-list-view',\n\t\thandleToggleListViewShortcut\n\t);\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName=\"edit-site-editor__list-view-panel\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t\tref={ sidebarRef }\n\t\t>\n\t\t\t<div className=\"edit-site-editor__list-view-panel-header\">\n\t\t\t\t<strong>{ __( 'List View' ) }</strong>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\tonClick={ closeListView }\n\t\t\t\t\tref={ sidebarCloseButtonRef }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-editor__list-view-panel-content\"\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t\tsetDropZoneElement,\n\t\t\t\t\tlistViewRef,\n\t\t\t\t] ) }\n\t\t\t>\n\t\t\t\t<PrivateListView dropZoneElement={ dropZoneElement } />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,sBAAsB,QAAQ,yBAAyB;AAC/E,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,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AG,EAAG1C,YAAY,CAAE,CACnBiB,eAAe,EACfQ,kBAAkB,EAClBG,WAAW,CACV;IAAG,GAELW,aAAA,CAAC1B,eAAe;MAACW,eAAe,EAAGA;IAAiB,CAAE,CAClD,CACD;EAAC;AAER"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { unlock } from '../../lock-unlock';
|
|
11
|
-
const {
|
|
12
|
-
createPrivateSlotFill
|
|
13
|
-
} = unlock(componentsPrivateApis);
|
|
14
|
-
const SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME = 'SidebarFixedBottom';
|
|
15
|
-
const {
|
|
16
|
-
Slot: SidebarFixedBottomSlot,
|
|
17
|
-
Fill: SidebarFixedBottomFill
|
|
18
|
-
} = createPrivateSlotFill(SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME);
|
|
19
|
-
export default function SidebarFixedBottom({
|
|
20
|
-
children
|
|
21
|
-
}) {
|
|
22
|
-
return createElement(SidebarFixedBottomFill, null, createElement("div", {
|
|
23
|
-
className: "edit-site-sidebar-fixed-bottom-slot"
|
|
24
|
-
}, children));
|
|
25
|
-
}
|
|
26
|
-
export { SidebarFixedBottomSlot };
|
|
27
|
-
//# sourceMappingURL=sidebar-fixed-bottom.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["privateApis","componentsPrivateApis","unlock","createPrivateSlotFill","SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME","Slot","SidebarFixedBottomSlot","Fill","SidebarFixedBottomFill","SidebarFixedBottom","children","createElement","className"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/sidebar-fixed-bottom.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { createPrivateSlotFill } = unlock( componentsPrivateApis );\nconst SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME = 'SidebarFixedBottom';\nconst { Slot: SidebarFixedBottomSlot, Fill: SidebarFixedBottomFill } =\n\tcreatePrivateSlotFill( SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME );\n\nexport default function SidebarFixedBottom( { children } ) {\n\treturn (\n\t\t<SidebarFixedBottomFill>\n\t\t\t<div className=\"edit-site-sidebar-fixed-bottom-slot\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</SidebarFixedBottomFill>\n\t);\n}\n\nexport { SidebarFixedBottomSlot };\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,IAAIC,qBAAqB,QAAQ,uBAAuB;;AAE5E;AACA;AACA;AACA,SAASC,MAAM,QAAQ,mBAAmB;AAE1C,MAAM;EAAEC;AAAsB,CAAC,GAAGD,MAAM,CAAED,qBAAsB,CAAC;AACjE,MAAMG,mCAAmC,GAAG,oBAAoB;AAChE,MAAM;EAAEC,IAAI,EAAEC,sBAAsB;EAAEC,IAAI,EAAEC;AAAuB,CAAC,GACnEL,qBAAqB,CAAEC,mCAAoC,CAAC;AAE7D,eAAe,SAASK,kBAAkBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC1D,OACCC,aAAA,CAACH,sBAAsB,QACtBG,aAAA;IAAKC,SAAS,EAAC;EAAqC,GACjDF,QACE,CACkB,CAAC;AAE3B;AAEA,SAASJ,sBAAsB"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { Button, PanelRow } from '@wordpress/components';
|
|
6
|
-
import { sprintf, _n, __ } from '@wordpress/i18n';
|
|
7
|
-
import { backup } from '@wordpress/icons';
|
|
8
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
9
|
-
import { PostTypeSupportCheck } from '@wordpress/editor';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import useEditedEntityRecord from '../../use-edited-entity-record';
|
|
15
|
-
const useRevisionData = () => {
|
|
16
|
-
var _currentTemplate$_lin, _currentTemplate$_lin2;
|
|
17
|
-
const {
|
|
18
|
-
record: currentTemplate
|
|
19
|
-
} = useEditedEntityRecord();
|
|
20
|
-
const lastRevisionId = (_currentTemplate$_lin = currentTemplate?._links?.['predecessor-version']?.[0]?.id) !== null && _currentTemplate$_lin !== void 0 ? _currentTemplate$_lin : null;
|
|
21
|
-
const revisionsCount = (_currentTemplate$_lin2 = currentTemplate?._links?.['version-history']?.[0]?.count) !== null && _currentTemplate$_lin2 !== void 0 ? _currentTemplate$_lin2 : 0;
|
|
22
|
-
return {
|
|
23
|
-
currentTemplate,
|
|
24
|
-
lastRevisionId,
|
|
25
|
-
revisionsCount
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
function PostLastRevisionCheck({
|
|
29
|
-
children
|
|
30
|
-
}) {
|
|
31
|
-
const {
|
|
32
|
-
lastRevisionId,
|
|
33
|
-
revisionsCount
|
|
34
|
-
} = useRevisionData();
|
|
35
|
-
if (!process.env.IS_GUTENBERG_PLUGIN) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
if (!lastRevisionId || revisionsCount < 2) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
return createElement(PostTypeSupportCheck, {
|
|
42
|
-
supportKeys: "revisions"
|
|
43
|
-
}, children);
|
|
44
|
-
}
|
|
45
|
-
const PostLastRevision = () => {
|
|
46
|
-
const {
|
|
47
|
-
lastRevisionId,
|
|
48
|
-
revisionsCount
|
|
49
|
-
} = useRevisionData();
|
|
50
|
-
return createElement(PostLastRevisionCheck, null, createElement(PanelRow, {
|
|
51
|
-
header: __('Editing history'),
|
|
52
|
-
className: "edit-site-template-revisions"
|
|
53
|
-
}, createElement(Button, {
|
|
54
|
-
href: addQueryArgs('revision.php', {
|
|
55
|
-
revision: lastRevisionId
|
|
56
|
-
}),
|
|
57
|
-
className: "edit-site-template-last-revision__title",
|
|
58
|
-
icon: backup
|
|
59
|
-
}, sprintf( /* translators: %d: number of revisions */
|
|
60
|
-
_n('%d Revision', '%d Revisions', revisionsCount), revisionsCount))));
|
|
61
|
-
};
|
|
62
|
-
export default function LastRevision() {
|
|
63
|
-
return createElement(PostLastRevisionCheck, null, createElement(PostLastRevision, null));
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=last-revision.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Button","PanelRow","sprintf","_n","__","backup","addQueryArgs","PostTypeSupportCheck","useEditedEntityRecord","useRevisionData","_currentTemplate$_lin","_currentTemplate$_lin2","record","currentTemplate","lastRevisionId","_links","id","revisionsCount","count","PostLastRevisionCheck","children","process","env","IS_GUTENBERG_PLUGIN","createElement","supportKeys","PostLastRevision","header","className","href","revision","icon","LastRevision"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-panel/last-revision.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, PanelRow } from '@wordpress/components';\nimport { sprintf, _n, __ } from '@wordpress/i18n';\nimport { backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { PostTypeSupportCheck } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useEditedEntityRecord from '../../use-edited-entity-record';\n\nconst useRevisionData = () => {\n\tconst { record: currentTemplate } = useEditedEntityRecord();\n\n\tconst lastRevisionId =\n\t\tcurrentTemplate?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\n\tconst revisionsCount =\n\t\tcurrentTemplate?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\n\treturn {\n\t\tcurrentTemplate,\n\t\tlastRevisionId,\n\t\trevisionsCount,\n\t};\n};\n\nfunction PostLastRevisionCheck( { children } ) {\n\tconst { lastRevisionId, revisionsCount } = useRevisionData();\n\n\tif ( ! process.env.IS_GUTENBERG_PLUGIN ) {\n\t\treturn null;\n\t}\n\n\tif ( ! lastRevisionId || revisionsCount < 2 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"revisions\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n\nconst PostLastRevision = () => {\n\tconst { lastRevisionId, revisionsCount } = useRevisionData();\n\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<PanelRow\n\t\t\t\theader={ __( 'Editing history' ) }\n\t\t\t\tclassName=\"edit-site-template-revisions\"\n\t\t\t>\n\t\t\t\t<Button\n\t\t\t\t\thref={ addQueryArgs( 'revision.php', {\n\t\t\t\t\t\trevision: lastRevisionId,\n\t\t\t\t\t} ) }\n\t\t\t\t\tclassName=\"edit-site-template-last-revision__title\"\n\t\t\t\t\ticon={ backup }\n\t\t\t\t>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of revisions */\n\t\t\t\t\t\t_n( '%d Revision', '%d Revisions', revisionsCount ),\n\t\t\t\t\t\trevisionsCount\n\t\t\t\t\t) }\n\t\t\t\t</Button>\n\t\t\t</PanelRow>\n\t\t</PostLastRevisionCheck>\n\t);\n};\n\nexport default function LastRevision() {\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<PostLastRevision />\n\t\t</PostLastRevisionCheck>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,QAAQ,QAAQ,uBAAuB;AACxD,SAASC,OAAO,EAAEC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACjD,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,oBAAoB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B,MAAM;IACN6B,IAAI,EAAGvB,YAAY,CAAE,cAAc,EAAE;MACpCwB,QAAQ,EAAEhB;IACX,CAAE,CAAG;IACLc,SAAS,EAAC,yCAAyC;IACnDG,IAAI,EAAG1B;EAAQ,GAEbH,OAAO,EACR;EACAC,EAAE,CAAE,aAAa,EAAE,cAAc,EAAEc,cAAe,CAAC,EACnDA,cACD,CACO,CACC,CACY,CAAC;AAE1B,CAAC;AAED,eAAe,SAASe,YAAYA,CAAA,EAAG;EACtC,OACCR,aAAA,CAACL,qBAAqB,QACrBK,aAAA,CAACE,gBAAgB,MAAE,CACG,CAAC;AAE1B"}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
6
|
-
import { useEffect, useMemo, useState } from '@wordpress/element';
|
|
7
|
-
import { FormTokenField, FlexBlock, PanelRow } from '@wordpress/components';
|
|
8
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
9
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
-
import { useDebounce } from '@wordpress/compose';
|
|
11
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
12
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
import { PATTERN_TYPES } from '../../../utils/constants';
|
|
18
|
-
export const unescapeString = arg => {
|
|
19
|
-
return decodeEntities(arg);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Returns a term object with name unescaped.
|
|
24
|
-
*
|
|
25
|
-
* @param {Object} term The term object to unescape.
|
|
26
|
-
*
|
|
27
|
-
* @return {Object} Term object with name property unescaped.
|
|
28
|
-
*/
|
|
29
|
-
export const unescapeTerm = term => {
|
|
30
|
-
return {
|
|
31
|
-
...term,
|
|
32
|
-
name: unescapeString(term.name)
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Shared reference to an empty array for cases where it is important to avoid
|
|
38
|
-
* returning a new array reference on every invocation.
|
|
39
|
-
*
|
|
40
|
-
* @type {Array<any>}
|
|
41
|
-
*/
|
|
42
|
-
const EMPTY_ARRAY = [];
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Module constants
|
|
46
|
-
*/
|
|
47
|
-
const MAX_TERMS_SUGGESTIONS = 20;
|
|
48
|
-
const DEFAULT_QUERY = {
|
|
49
|
-
per_page: MAX_TERMS_SUGGESTIONS,
|
|
50
|
-
_fields: 'id,name',
|
|
51
|
-
context: 'view'
|
|
52
|
-
};
|
|
53
|
-
const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
|
|
54
|
-
const termNamesToIds = (names, terms) => {
|
|
55
|
-
return names.map(termName => terms.find(term => isSameTermName(term.name, termName)).id);
|
|
56
|
-
};
|
|
57
|
-
export default function PatternCategories({
|
|
58
|
-
post
|
|
59
|
-
}) {
|
|
60
|
-
var _taxonomy$labels$sing;
|
|
61
|
-
const slug = 'wp_pattern_category';
|
|
62
|
-
const [values, setValues] = useState([]);
|
|
63
|
-
const [search, setSearch] = useState('');
|
|
64
|
-
const debouncedSearch = useDebounce(setSearch, 500);
|
|
65
|
-
const {
|
|
66
|
-
terms,
|
|
67
|
-
taxonomy,
|
|
68
|
-
hasAssignAction,
|
|
69
|
-
hasCreateAction,
|
|
70
|
-
hasResolvedTerms
|
|
71
|
-
} = useSelect(select => {
|
|
72
|
-
var _post$_links, _post$_links2;
|
|
73
|
-
const {
|
|
74
|
-
getEntityRecords,
|
|
75
|
-
getTaxonomy,
|
|
76
|
-
hasFinishedResolution
|
|
77
|
-
} = select(coreStore);
|
|
78
|
-
const _taxonomy = getTaxonomy(slug);
|
|
79
|
-
const _termIds = post?.wp_pattern_category?.length > 0 ? post?.wp_pattern_category : EMPTY_ARRAY;
|
|
80
|
-
const query = {
|
|
81
|
-
...DEFAULT_QUERY,
|
|
82
|
-
include: _termIds?.join(','),
|
|
83
|
-
per_page: -1
|
|
84
|
-
};
|
|
85
|
-
return {
|
|
86
|
-
hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
|
|
87
|
-
hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
|
|
88
|
-
taxonomy: _taxonomy,
|
|
89
|
-
termIds: _termIds,
|
|
90
|
-
terms: _termIds?.length ? getEntityRecords('taxonomy', slug, query) : EMPTY_ARRAY,
|
|
91
|
-
hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query])
|
|
92
|
-
};
|
|
93
|
-
}, [slug, post]);
|
|
94
|
-
const {
|
|
95
|
-
searchResults
|
|
96
|
-
} = useSelect(select => {
|
|
97
|
-
const {
|
|
98
|
-
getEntityRecords
|
|
99
|
-
} = select(coreStore);
|
|
100
|
-
return {
|
|
101
|
-
searchResults: !!search ? getEntityRecords('taxonomy', slug, {
|
|
102
|
-
...DEFAULT_QUERY,
|
|
103
|
-
search
|
|
104
|
-
}) : EMPTY_ARRAY
|
|
105
|
-
};
|
|
106
|
-
}, [search, slug]);
|
|
107
|
-
|
|
108
|
-
// Update terms state only after the selectors are resolved.
|
|
109
|
-
// We're using this to avoid terms temporarily disappearing on slow networks
|
|
110
|
-
// while core data makes REST API requests.
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if (hasResolvedTerms) {
|
|
113
|
-
const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
|
|
114
|
-
setValues(newValues);
|
|
115
|
-
}
|
|
116
|
-
}, [terms, hasResolvedTerms]);
|
|
117
|
-
const suggestions = useMemo(() => {
|
|
118
|
-
return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name));
|
|
119
|
-
}, [searchResults]);
|
|
120
|
-
const {
|
|
121
|
-
saveEntityRecord,
|
|
122
|
-
editEntityRecord,
|
|
123
|
-
invalidateResolution
|
|
124
|
-
} = useDispatch(coreStore);
|
|
125
|
-
const {
|
|
126
|
-
createErrorNotice
|
|
127
|
-
} = useDispatch(noticesStore);
|
|
128
|
-
if (!hasAssignAction) {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
async function findOrCreateTerm(term) {
|
|
132
|
-
try {
|
|
133
|
-
const newTerm = await saveEntityRecord('taxonomy', slug, term, {
|
|
134
|
-
throwOnError: true
|
|
135
|
-
});
|
|
136
|
-
invalidateResolution('getUserPatternCategories');
|
|
137
|
-
return unescapeTerm(newTerm);
|
|
138
|
-
} catch (error) {
|
|
139
|
-
if (error.code !== 'term_exists') {
|
|
140
|
-
throw error;
|
|
141
|
-
}
|
|
142
|
-
return {
|
|
143
|
-
id: error.data.term_id,
|
|
144
|
-
name: term.name
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function onUpdateTerms(newTermIds) {
|
|
149
|
-
editEntityRecord('postType', PATTERN_TYPES.user, post.id, {
|
|
150
|
-
wp_pattern_category: newTermIds
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
function onChange(termNames) {
|
|
154
|
-
const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
|
|
155
|
-
const uniqueTerms = termNames.reduce((acc, name) => {
|
|
156
|
-
if (!acc.some(n => n.toLowerCase() === name.toLowerCase())) {
|
|
157
|
-
acc.push(name);
|
|
158
|
-
}
|
|
159
|
-
return acc;
|
|
160
|
-
}, []);
|
|
161
|
-
const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName)));
|
|
162
|
-
|
|
163
|
-
// Optimistically update term values.
|
|
164
|
-
// The selector will always re-fetch terms later.
|
|
165
|
-
setValues(uniqueTerms);
|
|
166
|
-
if (newTermNames.length === 0) {
|
|
167
|
-
return onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
|
|
168
|
-
}
|
|
169
|
-
if (!hasCreateAction) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
Promise.all(newTermNames.map(termName => findOrCreateTerm({
|
|
173
|
-
name: termName
|
|
174
|
-
}))).then(newTerms => {
|
|
175
|
-
const newAvailableTerms = availableTerms.concat(newTerms);
|
|
176
|
-
return onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
|
|
177
|
-
}).catch(error => {
|
|
178
|
-
createErrorNotice(error.message, {
|
|
179
|
-
type: 'snackbar'
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
const singularName = (_taxonomy$labels$sing = taxonomy?.labels?.singular_name) !== null && _taxonomy$labels$sing !== void 0 ? _taxonomy$labels$sing : slug === 'post_tag' ? __('Tag') : __('Term');
|
|
184
|
-
const termAddedLabel = sprintf( /* translators: %s: term name. */
|
|
185
|
-
_x('%s added', 'term'), singularName);
|
|
186
|
-
const termRemovedLabel = sprintf( /* translators: %s: term name. */
|
|
187
|
-
_x('%s removed', 'term'), singularName);
|
|
188
|
-
const removeTermLabel = sprintf( /* translators: %s: term name. */
|
|
189
|
-
_x('Remove %s', 'term'), singularName);
|
|
190
|
-
return createElement(PanelRow, {
|
|
191
|
-
initialOpen: true,
|
|
192
|
-
title: __('Categories')
|
|
193
|
-
}, createElement(FlexBlock, null, createElement(FormTokenField, {
|
|
194
|
-
__next40pxDefaultSize: true,
|
|
195
|
-
value: values,
|
|
196
|
-
suggestions: suggestions,
|
|
197
|
-
onChange: onChange,
|
|
198
|
-
onInputChange: debouncedSearch,
|
|
199
|
-
maxSuggestions: MAX_TERMS_SUGGESTIONS,
|
|
200
|
-
label: __('Pattern categories'),
|
|
201
|
-
messages: {
|
|
202
|
-
added: termAddedLabel,
|
|
203
|
-
removed: termRemovedLabel,
|
|
204
|
-
remove: removeTermLabel
|
|
205
|
-
},
|
|
206
|
-
tokenizeOnBlur: true
|
|
207
|
-
})));
|
|
208
|
-
}
|
|
209
|
-
//# sourceMappingURL=pattern-categories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__","_x","sprintf","useEffect","useMemo","useState","FormTokenField","FlexBlock","PanelRow","useSelect","useDispatch","store","coreStore","useDebounce","noticesStore","decodeEntities","PATTERN_TYPES","unescapeString","arg","unescapeTerm","term","name","EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","find","id","PatternCategories","post","_taxonomy$labels$sing","slug","values","setValues","search","setSearch","debouncedSearch","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","select","_post$_links","_post$_links2","getEntityRecords","getTaxonomy","hasFinishedResolution","_taxonomy","_termIds","wp_pattern_category","length","query","include","join","_links","rest_base","termIds","searchResults","newValues","suggestions","saveEntityRecord","editEntityRecord","invalidateResolution","createErrorNotice","findOrCreateTerm","newTerm","throwOnError","error","code","data","term_id","onUpdateTerms","newTermIds","user","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","Promise","all","then","newTerms","newAvailableTerms","concat","catch","message","type","singularName","labels","singular_name","termAddedLabel","termRemovedLabel","removeTermLabel","createElement","initialOpen","title","__next40pxDefaultSize","value","onInputChange","maxSuggestions","label","messages","added","removed","remove","tokenizeOnBlur"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-panel/pattern-categories.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, FlexBlock, PanelRow } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { PATTERN_TYPES } from '../../../utils/constants';\n\nexport const unescapeString = ( arg ) => {\n\treturn decodeEntities( arg );\n};\n\n/**\n * Returns a term object with name unescaped.\n *\n * @param {Object} term The term object to unescape.\n *\n * @return {Object} Term object with name property unescaped.\n */\nexport const unescapeTerm = ( term ) => {\n\treturn {\n\t\t...term,\n\t\tname: unescapeString( term.name ),\n\t};\n};\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\nexport default function PatternCategories( { post } ) {\n\tconst slug = 'wp_pattern_category';\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds =\n\t\t\t\tpost?.wp_pattern_category?.length > 0\n\t\t\t\t\t? post?.wp_pattern_category\n\t\t\t\t\t: EMPTY_ARRAY;\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds?.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds?.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug, post ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search, slug ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { saveEntityRecord, editEntityRecord, invalidateResolution } =\n\t\tuseDispatch( coreStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tasync function findOrCreateTerm( term ) {\n\t\ttry {\n\t\t\tconst newTerm = await saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\t\t\tinvalidateResolution( 'getUserPatternCategories' );\n\t\t\treturn unescapeTerm( newTerm );\n\t\t} catch ( error ) {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: term.name,\n\t\t\t};\n\t\t}\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditEntityRecord( 'postType', PATTERN_TYPES.user, post.id, {\n\t\t\twp_pattern_category: newTermIds,\n\t\t} );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( { name: termName } )\n\t\t\t)\n\t\t)\n\t\t\t.then( ( newTerms ) => {\n\t\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\t\treturn onUpdateTerms(\n\t\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t} );\n\t}\n\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<PanelRow initialOpen={ true } title={ __( 'Categories' ) }>\n\t\t\t<FlexBlock>\n\t\t\t\t<FormTokenField\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvalue={ values }\n\t\t\t\t\tsuggestions={ suggestions }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\t\tlabel={ __( 'Pattern categories' ) }\n\t\t\t\t\tmessages={ {\n\t\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t\t} }\n\t\t\t\t\ttokenizeOnBlur\n\t\t\t\t/>\n\t\t\t</FlexBlock>\n\t\t</PanelRow>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACjE,SAASC,cAAc,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AAC3E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASF,KAAK,IAAIG,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;AACA,SAASC,aAAa,QAAQ,0BAA0B;AAExD,OAAO,MAAMC,cAAc,GAAKC,GAAG,IAAM;EACxC,OAAOH,cAAc,CAAEG,GAAI,CAAC;AAC7B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GAAKC,IAAI,IAAM;EACvC,OAAO;IACN,GAAGA,IAAI;IACPC,IAAI,EAAEJ,cAAc,CAAEG,IAAI,CAACC,IAAK;EACjC,CAAC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;AACA,MAAMC,qBAAqB,GAAG,EAAE;AAChC,MAAMC,aAAa,GAAG;EACrBC,QAAQ,EAAEF,qBAAqB;EAC/BG,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE;AACV,CAAC;AAED,MAAMC,cAAc,GAAGA,CAAEC,KAAK,EAAE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|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { makeFormDataFromFontFamilies } from '../index';
|
|
5
|
-
|
|
6
|
-
/* global File */
|
|
7
|
-
|
|
8
|
-
describe( 'makeFormDataFromFontFamilies', () => {
|
|
9
|
-
it( 'should process fontFamilies and return FormData', () => {
|
|
10
|
-
const mockFontFamilies = [
|
|
11
|
-
{
|
|
12
|
-
slug: 'bebas',
|
|
13
|
-
name: 'Bebas',
|
|
14
|
-
fontFamily: 'Bebas',
|
|
15
|
-
fontFace: [
|
|
16
|
-
{
|
|
17
|
-
file: new File( [ 'content' ], 'test-font1.woff2' ),
|
|
18
|
-
fontWeight: '500',
|
|
19
|
-
fontStyle: 'normal',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
file: new File( [ 'content' ], 'test-font2.woff2' ),
|
|
23
|
-
fontWeight: '400',
|
|
24
|
-
fontStyle: 'normal',
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
const formData = makeFormDataFromFontFamilies( mockFontFamilies );
|
|
31
|
-
|
|
32
|
-
expect( formData instanceof FormData ).toBeTruthy();
|
|
33
|
-
|
|
34
|
-
// Check if files are added correctly
|
|
35
|
-
expect( formData.get( 'file-0-0' ).name ).toBe( 'test-font1.woff2' );
|
|
36
|
-
expect( formData.get( 'file-0-1' ).name ).toBe( 'test-font2.woff2' );
|
|
37
|
-
|
|
38
|
-
// Check if 'fontFamilies' key in FormData is correct
|
|
39
|
-
const expectedFontFamilies = [
|
|
40
|
-
{
|
|
41
|
-
fontFace: [
|
|
42
|
-
{
|
|
43
|
-
fontWeight: '500',
|
|
44
|
-
fontStyle: 'normal',
|
|
45
|
-
uploadedFile: 'file-0-0',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
fontWeight: '400',
|
|
49
|
-
fontStyle: 'normal',
|
|
50
|
-
uploadedFile: 'file-0-1',
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
slug: 'bebas',
|
|
54
|
-
name: 'Bebas',
|
|
55
|
-
fontFamily: 'Bebas',
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
expect( JSON.parse( formData.get( 'font_families' ) ) ).toEqual(
|
|
59
|
-
expectedFontFamilies
|
|
60
|
-
);
|
|
61
|
-
} );
|
|
62
|
-
} );
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { wpKebabCase } from '../index';
|
|
5
|
-
|
|
6
|
-
describe( 'wpKebabCase', () => {
|
|
7
|
-
it( 'should insert a dash between a letter and a digit', () => {
|
|
8
|
-
const input = 'abc1def';
|
|
9
|
-
const expectedOutput = 'abc-1def';
|
|
10
|
-
expect( wpKebabCase( input ) ).toEqual( expectedOutput );
|
|
11
|
-
|
|
12
|
-
const input2 = 'abc1def2ghi';
|
|
13
|
-
const expectedOutput2 = 'abc-1def-2ghi';
|
|
14
|
-
expect( wpKebabCase( input2 ) ).toEqual( expectedOutput2 );
|
|
15
|
-
} );
|
|
16
|
-
|
|
17
|
-
it( 'should not insert a dash between two letters', () => {
|
|
18
|
-
const input = 'abcdef';
|
|
19
|
-
const expectedOutput = 'abcdef';
|
|
20
|
-
expect( wpKebabCase( input ) ).toEqual( expectedOutput );
|
|
21
|
-
} );
|
|
22
|
-
|
|
23
|
-
it( 'should not insert a dash between a digit and a hyphen', () => {
|
|
24
|
-
const input = 'abc1-def';
|
|
25
|
-
const expectedOutput = 'abc-1-def';
|
|
26
|
-
expect( wpKebabCase( input ) ).toEqual( expectedOutput );
|
|
27
|
-
} );
|
|
28
|
-
} );
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
5
|
-
|
|
6
|
-
const globalStylesChangesCache = new Map();
|
|
7
|
-
const EMPTY_ARRAY = [];
|
|
8
|
-
|
|
9
|
-
const translationMap = {
|
|
10
|
-
caption: __( 'Caption' ),
|
|
11
|
-
link: __( 'Link' ),
|
|
12
|
-
button: __( 'Button' ),
|
|
13
|
-
heading: __( 'Heading' ),
|
|
14
|
-
'settings.color': __( 'Color settings' ),
|
|
15
|
-
'settings.typography': __( 'Typography settings' ),
|
|
16
|
-
'styles.color': __( 'Colors' ),
|
|
17
|
-
'styles.spacing': __( 'Spacing' ),
|
|
18
|
-
'styles.typography': __( 'Typography' ),
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const isObject = ( obj ) => obj !== null && typeof obj === 'object';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get the translation for a given global styles key.
|
|
25
|
-
* @param {string} key A key representing a path to a global style property or setting.
|
|
26
|
-
* @param {Record<string,string>} blockNames A key/value pair object of block names and their rendered titles.
|
|
27
|
-
* @return {string|undefined} A translated key or undefined if no translation exists.
|
|
28
|
-
*/
|
|
29
|
-
function getTranslation( key, blockNames ) {
|
|
30
|
-
if ( translationMap[ key ] ) {
|
|
31
|
-
return translationMap[ key ];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const keyArray = key.split( '.' );
|
|
35
|
-
|
|
36
|
-
if ( keyArray?.[ 0 ] === 'blocks' ) {
|
|
37
|
-
const blockName = blockNames[ keyArray[ 1 ] ];
|
|
38
|
-
return blockName
|
|
39
|
-
? sprintf(
|
|
40
|
-
// translators: %s: block name.
|
|
41
|
-
__( '%s block' ),
|
|
42
|
-
blockName
|
|
43
|
-
)
|
|
44
|
-
: keyArray[ 1 ];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if ( keyArray?.[ 0 ] === 'elements' ) {
|
|
48
|
-
return sprintf(
|
|
49
|
-
// translators: %s: element name, e.g., heading button, link, caption.
|
|
50
|
-
__( '%s element' ),
|
|
51
|
-
translationMap[ keyArray[ 1 ] ]
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* A deep comparison of two objects, optimized for comparing global styles.
|
|
60
|
-
* @param {Object} changedObject The changed object to compare.
|
|
61
|
-
* @param {Object} originalObject The original object to compare against.
|
|
62
|
-
* @param {string} parentPath A key/value pair object of block names and their rendered titles.
|
|
63
|
-
* @return {string[]} An array of paths whose values have changed.
|
|
64
|
-
*/
|
|
65
|
-
function deepCompare( changedObject, originalObject, parentPath = '' ) {
|
|
66
|
-
// We have two non-object values to compare.
|
|
67
|
-
if ( ! isObject( changedObject ) && ! isObject( originalObject ) ) {
|
|
68
|
-
/*
|
|
69
|
-
* Only return a path if the value has changed.
|
|
70
|
-
* And then only the path name up to 2 levels deep.
|
|
71
|
-
*/
|
|
72
|
-
return changedObject !== originalObject
|
|
73
|
-
? parentPath.split( '.' ).slice( 0, 2 ).join( '.' )
|
|
74
|
-
: undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Enable comparison when an object doesn't have a corresponding property to compare.
|
|
78
|
-
changedObject = isObject( changedObject ) ? changedObject : {};
|
|
79
|
-
originalObject = isObject( originalObject ) ? originalObject : {};
|
|
80
|
-
|
|
81
|
-
const allKeys = new Set( [
|
|
82
|
-
...Object.keys( changedObject ),
|
|
83
|
-
...Object.keys( originalObject ),
|
|
84
|
-
] );
|
|
85
|
-
|
|
86
|
-
let diffs = [];
|
|
87
|
-
for ( const key of allKeys ) {
|
|
88
|
-
const path = parentPath ? parentPath + '.' + key : key;
|
|
89
|
-
const changedPath = deepCompare(
|
|
90
|
-
changedObject[ key ],
|
|
91
|
-
originalObject[ key ],
|
|
92
|
-
path
|
|
93
|
-
);
|
|
94
|
-
if ( changedPath ) {
|
|
95
|
-
diffs = diffs.concat( changedPath );
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return diffs;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Get an array of translated summarized global styles changes.
|
|
103
|
-
* Results are cached using a Map() key of `JSON.stringify( { revision, previousRevision } )`.
|
|
104
|
-
*
|
|
105
|
-
* @param {Object} revision The changed object to compare.
|
|
106
|
-
* @param {Object} previousRevision The original object to compare against.
|
|
107
|
-
* @param {Record<string,string>} blockNames A key/value pair object of block names and their rendered titles.
|
|
108
|
-
* @return {string[]} An array of translated changes.
|
|
109
|
-
*/
|
|
110
|
-
export default function getRevisionChanges(
|
|
111
|
-
revision,
|
|
112
|
-
previousRevision,
|
|
113
|
-
blockNames
|
|
114
|
-
) {
|
|
115
|
-
const cacheKey = JSON.stringify( { revision, previousRevision } );
|
|
116
|
-
|
|
117
|
-
if ( globalStylesChangesCache.has( cacheKey ) ) {
|
|
118
|
-
return globalStylesChangesCache.get( cacheKey );
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/*
|
|
122
|
-
* Compare the two revisions with normalized keys.
|
|
123
|
-
* The order of these keys determines the order in which
|
|
124
|
-
* they'll appear in the results.
|
|
125
|
-
*/
|
|
126
|
-
const changedValueTree = deepCompare(
|
|
127
|
-
{
|
|
128
|
-
styles: {
|
|
129
|
-
color: revision?.styles?.color,
|
|
130
|
-
typography: revision?.styles?.typography,
|
|
131
|
-
spacing: revision?.styles?.spacing,
|
|
132
|
-
},
|
|
133
|
-
blocks: revision?.styles?.blocks,
|
|
134
|
-
elements: revision?.styles?.elements,
|
|
135
|
-
settings: revision?.settings,
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
styles: {
|
|
139
|
-
color: previousRevision?.styles?.color,
|
|
140
|
-
typography: previousRevision?.styles?.typography,
|
|
141
|
-
spacing: previousRevision?.styles?.spacing,
|
|
142
|
-
},
|
|
143
|
-
blocks: previousRevision?.styles?.blocks,
|
|
144
|
-
elements: previousRevision?.styles?.elements,
|
|
145
|
-
settings: previousRevision?.settings,
|
|
146
|
-
}
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
if ( ! changedValueTree.length ) {
|
|
150
|
-
globalStylesChangesCache.set( cacheKey, EMPTY_ARRAY );
|
|
151
|
-
return EMPTY_ARRAY;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Remove duplicate results.
|
|
155
|
-
const result = [ ...new Set( changedValueTree ) ]
|
|
156
|
-
/*
|
|
157
|
-
* Translate the keys.
|
|
158
|
-
* Remove duplicate or empty translations.
|
|
159
|
-
*/
|
|
160
|
-
.reduce( ( acc, curr ) => {
|
|
161
|
-
const translation = getTranslation( curr, blockNames );
|
|
162
|
-
if ( translation && ! acc.includes( translation ) ) {
|
|
163
|
-
acc.push( translation );
|
|
164
|
-
}
|
|
165
|
-
return acc;
|
|
166
|
-
}, [] );
|
|
167
|
-
|
|
168
|
-
globalStylesChangesCache.set( cacheKey, result );
|
|
169
|
-
|
|
170
|
-
return result;
|
|
171
|
-
}
|