@wordpress/edit-site 6.1.0 → 6.3.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 +10 -6
- package/build/components/add-new-pattern/index.js +31 -16
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/{add-new-page → add-new-post}/index.js +28 -16
- package/build/components/add-new-post/index.js.map +1 -0
- package/build/components/block-editor/use-site-editor-settings.js +5 -3
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/editor/index.js +32 -7
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +18 -7
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +0 -5
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/font-families.js +17 -17
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +2 -2
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +13 -30
- package/build/components/global-styles/font-library-modal/font-collection.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/hooks.js +0 -40
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/preview-typography.js +47 -0
- package/build/components/global-styles/preview-typography.js.map +1 -0
- package/build/components/global-styles/screen-block.js +14 -0
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-layout.js +5 -1
- package/build/components/global-styles/screen-layout.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/global-styles/shadows-edit-panel.js +1 -2
- package/build/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +5 -5
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/typography-elements.js +0 -2
- package/build/components/global-styles/typography-elements.js.map +1 -1
- package/build/components/global-styles/variations/variation.js +28 -22
- package/build/components/global-styles/variations/variation.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js +5 -3
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles/variations/variations-typography.js +14 -27
- package/build/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build/components/global-styles-sidebar/index.js +2 -2
- package/build/components/global-styles-sidebar/index.js.map +1 -1
- package/build/components/layout/index.js +16 -8
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +20 -41
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-patterns/index.js +51 -41
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/rename-category-menu-item.js +3 -1
- package/build/components/page-patterns/rename-category-menu-item.js.map +1 -1
- package/build/components/page-patterns/search-items.js +29 -4
- package/build/components/page-patterns/search-items.js.map +1 -1
- package/build/components/page-patterns/use-patterns.js +22 -55
- package/build/components/page-patterns/use-patterns.js.map +1 -1
- package/build/components/page-templates/index.js +27 -21
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/pagination/index.js +4 -4
- package/build/components/pagination/index.js.map +1 -1
- package/build/components/posts-app/index.js +11 -17
- package/build/components/posts-app/index.js.map +1 -1
- package/build/components/{page-pages/index.js → posts-app/posts-list.js} +165 -38
- package/build/components/posts-app/posts-list.js.map +1 -0
- package/build/components/posts-app/router.js +85 -0
- package/build/components/posts-app/router.js.map +1 -0
- package/build/components/revisions/index.js +10 -7
- package/build/components/revisions/index.js.map +1 -1
- package/build/components/save-panel/index.js +1 -1
- package/build/components/save-panel/index.js.map +1 -1
- package/build/components/sidebar-dataviews/add-new-view.js +4 -1
- package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build/components/sidebar-dataviews/custom-dataviews-list.js +6 -2
- package/build/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +98 -84
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +4 -1
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +3 -3
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +5 -2
- package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +3 -2
- package/build/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build/components/site-hub/index.js +81 -1
- package/build/components/site-hub/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +3 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/deprecated.js +11 -0
- package/build/deprecated.js.map +1 -1
- package/build/hooks/commands/use-set-command-context.js +11 -0
- package/build/hooks/commands/use-set-command-context.js.map +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js +1 -1
- package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +65 -42
- package/build/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build/index.js +6 -0
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/posts.js +57 -2
- package/build/posts.js.map +1 -1
- package/build/store/private-actions.js +7 -2
- package/build/store/private-actions.js.map +1 -1
- package/build-module/components/add-new-pattern/index.js +31 -16
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/{add-new-page → add-new-post}/index.js +28 -16
- package/build-module/components/add-new-post/index.js.map +1 -0
- package/build-module/components/block-editor/use-site-editor-settings.js +5 -3
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/editor/index.js +33 -8
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +19 -8
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +0 -5
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +18 -18
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +2 -2
- 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 +14 -31
- package/build-module/components/global-styles/font-library-modal/font-collection.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/hooks.js +0 -38
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/preview-typography.js +39 -0
- package/build-module/components/global-styles/preview-typography.js.map +1 -0
- package/build-module/components/global-styles/screen-block.js +15 -0
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-layout.js +5 -1
- package/build-module/components/global-styles/screen-layout.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/global-styles/shadows-edit-panel.js +1 -2
- package/build-module/components/global-styles/shadows-edit-panel.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +6 -6
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/typography-elements.js +0 -2
- package/build-module/components/global-styles/typography-elements.js.map +1 -1
- package/build-module/components/global-styles/variations/variation.js +29 -23
- package/build-module/components/global-styles/variations/variation.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +5 -3
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-typography.js +16 -28
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build-module/components/global-styles-sidebar/index.js +2 -2
- package/build-module/components/global-styles-sidebar/index.js.map +1 -1
- package/build-module/components/layout/index.js +14 -8
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +20 -41
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-patterns/index.js +52 -42
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/rename-category-menu-item.js +3 -1
- package/build-module/components/page-patterns/rename-category-menu-item.js.map +1 -1
- package/build-module/components/page-patterns/search-items.js +28 -4
- package/build-module/components/page-patterns/search-items.js.map +1 -1
- package/build-module/components/page-patterns/use-patterns.js +23 -56
- package/build-module/components/page-patterns/use-patterns.js.map +1 -1
- package/build-module/components/page-templates/index.js +27 -21
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/pagination/index.js +4 -4
- package/build-module/components/pagination/index.js.map +1 -1
- package/build-module/components/posts-app/index.js +11 -17
- package/build-module/components/posts-app/index.js.map +1 -1
- package/build-module/components/{page-pages/index.js → posts-app/posts-list.js} +164 -37
- package/build-module/components/posts-app/posts-list.js.map +1 -0
- package/build-module/components/posts-app/router.js +77 -0
- package/build-module/components/posts-app/router.js.map +1 -0
- package/build-module/components/revisions/index.js +10 -7
- package/build-module/components/revisions/index.js.map +1 -1
- package/build-module/components/save-panel/index.js +1 -1
- package/build-module/components/save-panel/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js +4 -1
- package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js +6 -2
- package/build-module/components/sidebar-dataviews/custom-dataviews-list.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +97 -84
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +5 -2
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +3 -3
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +5 -2
- package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +3 -2
- package/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js.map +1 -1
- package/build-module/components/site-hub/index.js +81 -1
- package/build-module/components/site-hub/index.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +3 -1
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/deprecated.js +11 -0
- package/build-module/deprecated.js.map +1 -1
- package/build-module/hooks/commands/use-set-command-context.js +11 -0
- package/build-module/hooks/commands/use-set-command-context.js.map +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js +1 -1
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +61 -38
- package/build-module/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js.map +1 -1
- package/build-module/index.js +7 -2
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/posts.js +57 -2
- package/build-module/posts.js.map +1 -1
- package/build-module/store/private-actions.js +7 -2
- package/build-module/store/private-actions.js.map +1 -1
- package/build-style/posts-rtl.css +108 -28
- package/build-style/posts.css +108 -28
- package/build-style/style-rtl.css +127 -157
- package/build-style/style.css +127 -157
- package/lib/inflate.js +3188 -3937
- package/lib/lib-font.browser.js +32 -2
- package/lib/unbrotli.js +1818 -2458
- package/package.json +41 -41
- package/src/components/add-new-pattern/index.js +38 -23
- package/src/components/{add-new-page → add-new-post}/index.js +42 -18
- package/src/components/block-editor/style.scss +0 -11
- package/src/components/block-editor/use-site-editor-settings.js +33 -28
- package/src/components/editor/index.js +34 -20
- package/src/components/editor-canvas-container/index.js +20 -8
- package/src/components/global-styles/background-panel.js +0 -8
- package/src/components/global-styles/font-families.js +28 -19
- package/src/components/global-styles/font-library-modal/context.js +2 -2
- package/src/components/global-styles/font-library-modal/font-collection.js +17 -32
- package/src/components/global-styles/font-library-modal/installed-fonts.js +2 -2
- package/src/components/global-styles/font-library-modal/style.scss +17 -10
- package/src/components/global-styles/hooks.js +0 -41
- package/src/components/global-styles/preview-typography.js +39 -0
- package/src/components/global-styles/screen-block.js +22 -0
- package/src/components/global-styles/screen-layout.js +5 -1
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +1 -1
- package/src/components/global-styles/shadows-edit-panel.js +1 -2
- package/src/components/global-styles/style-variations-container.js +10 -7
- package/src/components/global-styles/style.scss +2 -1
- package/src/components/global-styles/typography-elements.js +0 -4
- package/src/components/global-styles/variations/variation.js +41 -26
- package/src/components/global-styles/variations/variations-color.js +6 -3
- package/src/components/global-styles/variations/variations-typography.js +16 -32
- package/src/components/global-styles-sidebar/index.js +2 -2
- package/src/components/layout/index.js +13 -4
- package/src/components/layout/router.js +20 -36
- package/src/components/layout/style.scss +12 -0
- package/src/components/page-patterns/index.js +55 -58
- package/src/components/page-patterns/rename-category-menu-item.js +2 -0
- package/src/components/page-patterns/search-items.js +37 -3
- package/src/components/page-patterns/style.scss +1 -8
- package/src/components/page-patterns/use-patterns.js +43 -82
- package/src/components/page-templates/index.js +26 -21
- package/src/components/page-templates/style.scss +1 -6
- package/src/components/pagination/index.js +4 -4
- package/src/components/posts-app/index.js +9 -11
- package/src/components/{page-pages/index.js → posts-app/posts-list.js} +163 -42
- package/src/components/posts-app/router.js +69 -0
- package/src/components/{page-pages → posts-app}/style.scss +22 -8
- package/src/components/revisions/index.js +9 -1
- package/src/components/save-panel/index.js +1 -1
- package/src/components/sidebar/style.scss +6 -0
- package/src/components/sidebar-dataviews/add-new-view.js +2 -1
- package/src/components/sidebar-dataviews/custom-dataviews-list.js +6 -2
- package/src/components/sidebar-dataviews/default-views.js +119 -98
- package/src/components/sidebar-dataviews/index.js +3 -3
- package/src/components/sidebar-navigation-screen-global-styles/index.js +7 -6
- package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +8 -2
- package/src/components/sidebar-navigation-screen-patterns/use-pattern-categories.js +10 -2
- package/src/components/site-hub/index.js +84 -1
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +3 -2
- package/src/deprecated.js +14 -0
- package/src/hooks/commands/use-set-command-context.js +12 -0
- package/src/hooks/push-changes-to-global-styles/index.js +1 -1
- package/src/hooks/use-theme-style-variations/test/use-theme-style-variations-by-property.js +28 -24
- package/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js +72 -47
- package/src/index.js +8 -1
- package/src/lock-unlock.js +1 -1
- package/src/posts.js +63 -2
- package/src/posts.scss +9 -0
- package/src/store/private-actions.js +7 -3
- package/src/style.scss +14 -2
- package/build/components/add-new-page/index.js.map +0 -1
- package/build/components/page-pages/index.js.map +0 -1
- package/build/components/table/index.js +0 -35
- package/build/components/table/index.js.map +0 -1
- package/build-module/components/add-new-page/index.js.map +0 -1
- package/build-module/components/page-pages/index.js.map +0 -1
- package/build-module/components/table/index.js +0 -30
- package/build-module/components/table/index.js.map +0 -1
- package/src/components/table/index.js +0 -33
- package/src/components/table/style.scss +0 -38
|
@@ -5,7 +5,6 @@ import { parse } from '@wordpress/blocks';
|
|
|
5
5
|
import { useSelect, createSelector } from '@wordpress/data';
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
7
|
import { store as editorStore } from '@wordpress/editor';
|
|
8
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Internal dependencies
|
|
@@ -16,7 +15,6 @@ import {
|
|
|
16
15
|
PATTERN_TYPES,
|
|
17
16
|
PATTERN_SYNC_TYPES,
|
|
18
17
|
TEMPLATE_PART_POST_TYPE,
|
|
19
|
-
TEMPLATE_ORIGINS,
|
|
20
18
|
TEMPLATE_PART_AREA_DEFAULT_CATEGORY,
|
|
21
19
|
} from '../../utils/constants';
|
|
22
20
|
import { unlock } from '../../lock-unlock';
|
|
@@ -25,38 +23,16 @@ import { store as editSiteStore } from '../../store';
|
|
|
25
23
|
|
|
26
24
|
const EMPTY_PATTERN_LIST = [];
|
|
27
25
|
|
|
28
|
-
const
|
|
29
|
-
theme && slug ? theme + '//' + slug : null;
|
|
30
|
-
|
|
31
|
-
const templatePartToPattern = ( templatePart ) => ( {
|
|
32
|
-
blocks: parse( templatePart.content.raw, {
|
|
33
|
-
__unstableSkipMigrationLogs: true,
|
|
34
|
-
} ),
|
|
35
|
-
categories: [ templatePart.area ],
|
|
36
|
-
description: templatePart.description || '',
|
|
37
|
-
isCustom: templatePart.source === TEMPLATE_ORIGINS.custom,
|
|
38
|
-
keywords: templatePart.keywords || [],
|
|
39
|
-
id: createTemplatePartId( templatePart.theme, templatePart.slug ),
|
|
40
|
-
name: createTemplatePartId( templatePart.theme, templatePart.slug ),
|
|
41
|
-
title: decodeEntities( templatePart.title.rendered ),
|
|
42
|
-
type: templatePart.type,
|
|
43
|
-
_links: templatePart._links,
|
|
44
|
-
templatePart,
|
|
45
|
-
} );
|
|
46
|
-
|
|
47
|
-
const selectTemplatePartsAsPatterns = createSelector(
|
|
26
|
+
const selectTemplateParts = createSelector(
|
|
48
27
|
( select, categoryId, search = '' ) => {
|
|
49
28
|
const { getEntityRecords, isResolving: isResolvingSelector } =
|
|
50
29
|
select( coreStore );
|
|
51
30
|
const { __experimentalGetDefaultTemplatePartAreas } =
|
|
52
31
|
select( editorStore );
|
|
53
32
|
const query = { per_page: -1 };
|
|
54
|
-
const
|
|
33
|
+
const templateParts =
|
|
55
34
|
getEntityRecords( 'postType', TEMPLATE_PART_POST_TYPE, query ) ??
|
|
56
35
|
EMPTY_PATTERN_LIST;
|
|
57
|
-
const templateParts = rawTemplateParts.map( ( templatePart ) =>
|
|
58
|
-
templatePartToPattern( templatePart )
|
|
59
|
-
);
|
|
60
36
|
|
|
61
37
|
// In the case where a custom template part area has been removed we need
|
|
62
38
|
// the current list of areas to cross check against so orphaned template
|
|
@@ -66,12 +42,12 @@ const selectTemplatePartsAsPatterns = createSelector(
|
|
|
66
42
|
|
|
67
43
|
const templatePartHasCategory = ( item, category ) => {
|
|
68
44
|
if ( category !== TEMPLATE_PART_AREA_DEFAULT_CATEGORY ) {
|
|
69
|
-
return item.
|
|
45
|
+
return item.area === category;
|
|
70
46
|
}
|
|
71
47
|
|
|
72
48
|
return (
|
|
73
|
-
item.
|
|
74
|
-
! templatePartAreas.includes( item.
|
|
49
|
+
item.area === category ||
|
|
50
|
+
! templatePartAreas.includes( item.area )
|
|
75
51
|
);
|
|
76
52
|
};
|
|
77
53
|
|
|
@@ -152,8 +128,11 @@ const selectPatterns = createSelector(
|
|
|
152
128
|
patterns: themePatterns,
|
|
153
129
|
isResolving: isResolvingThemePatterns,
|
|
154
130
|
} = selectThemePatterns( select );
|
|
155
|
-
const {
|
|
156
|
-
|
|
131
|
+
const {
|
|
132
|
+
patterns: userPatterns,
|
|
133
|
+
isResolving: isResolvingUserPatterns,
|
|
134
|
+
categories: userPatternCategories,
|
|
135
|
+
} = selectUserPatterns( select );
|
|
157
136
|
|
|
158
137
|
let patterns = [
|
|
159
138
|
...( themePatterns || [] ),
|
|
@@ -165,7 +144,8 @@ const selectPatterns = createSelector(
|
|
|
165
144
|
// Non-user patterns are all unsynced for the time being.
|
|
166
145
|
patterns = patterns.filter( ( pattern ) => {
|
|
167
146
|
return pattern.type === PATTERN_TYPES.user
|
|
168
|
-
? pattern.
|
|
147
|
+
? ( pattern.wp_pattern_sync_status ||
|
|
148
|
+
PATTERN_SYNC_TYPES.full ) === syncStatus
|
|
169
149
|
: syncStatus === PATTERN_SYNC_TYPES.unsynced;
|
|
170
150
|
} );
|
|
171
151
|
}
|
|
@@ -173,12 +153,35 @@ const selectPatterns = createSelector(
|
|
|
173
153
|
if ( categoryId ) {
|
|
174
154
|
patterns = searchItems( patterns, search, {
|
|
175
155
|
categoryId,
|
|
176
|
-
hasCategory: ( item, currentCategory ) =>
|
|
177
|
-
item.
|
|
156
|
+
hasCategory: ( item, currentCategory ) => {
|
|
157
|
+
if ( item.type === PATTERN_TYPES.user ) {
|
|
158
|
+
return item.wp_pattern_category.some(
|
|
159
|
+
( catId ) =>
|
|
160
|
+
userPatternCategories.find(
|
|
161
|
+
( cat ) => cat.id === catId
|
|
162
|
+
)?.slug === currentCategory
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
return item.categories?.includes( currentCategory );
|
|
166
|
+
},
|
|
178
167
|
} );
|
|
179
168
|
} else {
|
|
180
169
|
patterns = searchItems( patterns, search, {
|
|
181
|
-
hasCategory: ( item ) =>
|
|
170
|
+
hasCategory: ( item ) => {
|
|
171
|
+
if ( item.type === PATTERN_TYPES.user ) {
|
|
172
|
+
return (
|
|
173
|
+
userPatternCategories?.length &&
|
|
174
|
+
( ! item.wp_pattern_category?.length ||
|
|
175
|
+
! item.wp_pattern_category.some( ( catId ) =>
|
|
176
|
+
userPatternCategories.find(
|
|
177
|
+
( cat ) => cat.id === catId
|
|
178
|
+
)
|
|
179
|
+
) )
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return ! item.hasOwnProperty( 'categories' );
|
|
184
|
+
},
|
|
182
185
|
} );
|
|
183
186
|
}
|
|
184
187
|
return {
|
|
@@ -192,41 +195,6 @@ const selectPatterns = createSelector(
|
|
|
192
195
|
]
|
|
193
196
|
);
|
|
194
197
|
|
|
195
|
-
/**
|
|
196
|
-
* Converts a post of type `wp_block` to a 'pattern item' that more closely
|
|
197
|
-
* matches the structure of theme provided patterns.
|
|
198
|
-
*
|
|
199
|
-
* @param {Object} patternPost The `wp_block` record being normalized.
|
|
200
|
-
* @param {Map} categories A Map of user created categories.
|
|
201
|
-
*
|
|
202
|
-
* @return {Object} The normalized item.
|
|
203
|
-
*/
|
|
204
|
-
const convertPatternPostToItem = ( patternPost, categories ) => ( {
|
|
205
|
-
blocks: parse( patternPost.content.raw, {
|
|
206
|
-
__unstableSkipMigrationLogs: true,
|
|
207
|
-
} ),
|
|
208
|
-
...( patternPost.wp_pattern_category.length > 0 && {
|
|
209
|
-
categories: patternPost.wp_pattern_category.map(
|
|
210
|
-
( patternCategoryId ) =>
|
|
211
|
-
categories && categories.get( patternCategoryId )
|
|
212
|
-
? categories.get( patternCategoryId ).slug
|
|
213
|
-
: patternCategoryId
|
|
214
|
-
),
|
|
215
|
-
} ),
|
|
216
|
-
termLabels: patternPost.wp_pattern_category.map( ( patternCategoryId ) =>
|
|
217
|
-
categories?.get( patternCategoryId )
|
|
218
|
-
? categories.get( patternCategoryId ).label
|
|
219
|
-
: patternCategoryId
|
|
220
|
-
),
|
|
221
|
-
id: patternPost.id,
|
|
222
|
-
name: patternPost.slug,
|
|
223
|
-
syncStatus: patternPost.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full,
|
|
224
|
-
title: patternPost.title.raw,
|
|
225
|
-
type: patternPost.type,
|
|
226
|
-
description: patternPost.excerpt.raw,
|
|
227
|
-
patternPost,
|
|
228
|
-
} );
|
|
229
|
-
|
|
230
198
|
const selectUserPatterns = createSelector(
|
|
231
199
|
( select, syncStatus, search = '' ) => {
|
|
232
200
|
const {
|
|
@@ -246,12 +214,7 @@ const selectUserPatterns = createSelector(
|
|
|
246
214
|
userPatternCategories.forEach( ( userCategory ) =>
|
|
247
215
|
categories.set( userCategory.id, userCategory )
|
|
248
216
|
);
|
|
249
|
-
let patterns = patternPosts
|
|
250
|
-
? patternPosts.map( ( record ) =>
|
|
251
|
-
convertPatternPostToItem( record, categories )
|
|
252
|
-
)
|
|
253
|
-
: EMPTY_PATTERN_LIST;
|
|
254
|
-
|
|
217
|
+
let patterns = patternPosts ?? EMPTY_PATTERN_LIST;
|
|
255
218
|
const isResolving = isResolvingSelector( 'getEntityRecords', [
|
|
256
219
|
'postType',
|
|
257
220
|
PATTERN_TYPES.user,
|
|
@@ -260,7 +223,9 @@ const selectUserPatterns = createSelector(
|
|
|
260
223
|
|
|
261
224
|
if ( syncStatus ) {
|
|
262
225
|
patterns = patterns.filter(
|
|
263
|
-
( pattern ) =>
|
|
226
|
+
( pattern ) =>
|
|
227
|
+
pattern.wp_pattern_sync_status ||
|
|
228
|
+
PATTERN_SYNC_TYPES.full === syncStatus
|
|
264
229
|
);
|
|
265
230
|
}
|
|
266
231
|
|
|
@@ -298,11 +263,7 @@ export const usePatterns = (
|
|
|
298
263
|
return useSelect(
|
|
299
264
|
( select ) => {
|
|
300
265
|
if ( postType === TEMPLATE_PART_POST_TYPE ) {
|
|
301
|
-
return
|
|
302
|
-
select,
|
|
303
|
-
categoryId,
|
|
304
|
-
search
|
|
305
|
-
);
|
|
266
|
+
return selectTemplateParts( select, categoryId, search );
|
|
306
267
|
} else if ( postType === PATTERN_TYPES.user && !! categoryId ) {
|
|
307
268
|
const appliedCategory =
|
|
308
269
|
categoryId === 'uncategorized' ? '' : categoryId;
|
|
@@ -54,18 +54,24 @@ const { useHistory, useLocation } = unlock( routerPrivateApis );
|
|
|
54
54
|
|
|
55
55
|
const EMPTY_ARRAY = [];
|
|
56
56
|
|
|
57
|
-
const
|
|
57
|
+
const defaultLayouts = {
|
|
58
58
|
[ LAYOUT_TABLE ]: {
|
|
59
|
-
|
|
59
|
+
layout: {
|
|
60
|
+
primaryField: 'title',
|
|
61
|
+
},
|
|
60
62
|
},
|
|
61
63
|
[ LAYOUT_GRID ]: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
layout: {
|
|
65
|
+
mediaField: 'preview',
|
|
66
|
+
primaryField: 'title',
|
|
67
|
+
columnFields: [ 'description' ],
|
|
68
|
+
},
|
|
65
69
|
},
|
|
66
70
|
[ LAYOUT_LIST ]: {
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
layout: {
|
|
72
|
+
primaryField: 'title',
|
|
73
|
+
mediaField: 'preview',
|
|
74
|
+
},
|
|
69
75
|
},
|
|
70
76
|
};
|
|
71
77
|
|
|
@@ -78,10 +84,8 @@ const DEFAULT_VIEW = {
|
|
|
78
84
|
field: 'title',
|
|
79
85
|
direction: 'asc',
|
|
80
86
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
hiddenFields: [ 'preview' ],
|
|
84
|
-
layout: defaultConfigPerViewType[ LAYOUT_GRID ],
|
|
87
|
+
fields: [ 'title', 'description', 'author' ],
|
|
88
|
+
layout: defaultLayouts[ LAYOUT_GRID ].layout,
|
|
85
89
|
filters: [],
|
|
86
90
|
};
|
|
87
91
|
|
|
@@ -186,13 +190,15 @@ function Preview( { item, viewType } ) {
|
|
|
186
190
|
|
|
187
191
|
export default function PageTemplates() {
|
|
188
192
|
const { params } = useLocation();
|
|
189
|
-
const { activeView = 'all', layout } = params;
|
|
193
|
+
const { activeView = 'all', layout, postId } = params;
|
|
194
|
+
const [ selection, setSelection ] = useState( [ postId ] );
|
|
195
|
+
|
|
190
196
|
const defaultView = useMemo( () => {
|
|
191
197
|
const usedType = layout ?? DEFAULT_VIEW.type;
|
|
192
198
|
return {
|
|
193
199
|
...DEFAULT_VIEW,
|
|
194
200
|
type: usedType,
|
|
195
|
-
layout:
|
|
201
|
+
layout: defaultLayouts[ usedType ].layout,
|
|
196
202
|
filters:
|
|
197
203
|
activeView !== 'all'
|
|
198
204
|
? [
|
|
@@ -323,7 +329,10 @@ export default function PageTemplates() {
|
|
|
323
329
|
return filterSortAndPaginate( records, view, fields );
|
|
324
330
|
}, [ records, view, fields ] );
|
|
325
331
|
|
|
326
|
-
const postTypeActions = usePostActions(
|
|
332
|
+
const postTypeActions = usePostActions( {
|
|
333
|
+
postType: TEMPLATE_POST_TYPE,
|
|
334
|
+
context: 'list',
|
|
335
|
+
} );
|
|
327
336
|
const editAction = useEditPostAction();
|
|
328
337
|
const actions = useMemo(
|
|
329
338
|
() => [ editAction, ...postTypeActions ],
|
|
@@ -333,13 +342,6 @@ export default function PageTemplates() {
|
|
|
333
342
|
const onChangeView = useCallback(
|
|
334
343
|
( newView ) => {
|
|
335
344
|
if ( newView.type !== view.type ) {
|
|
336
|
-
newView = {
|
|
337
|
-
...newView,
|
|
338
|
-
layout: {
|
|
339
|
-
...defaultConfigPerViewType[ newView.type ],
|
|
340
|
-
},
|
|
341
|
-
};
|
|
342
|
-
|
|
343
345
|
history.push( {
|
|
344
346
|
...params,
|
|
345
347
|
layout: newView.type,
|
|
@@ -366,6 +368,9 @@ export default function PageTemplates() {
|
|
|
366
368
|
view={ view }
|
|
367
369
|
onChangeView={ onChangeView }
|
|
368
370
|
onSelectionChange={ onSelectionChange }
|
|
371
|
+
selection={ selection }
|
|
372
|
+
setSelection={ setSelection }
|
|
373
|
+
defaultLayouts={ defaultLayouts }
|
|
369
374
|
/>
|
|
370
375
|
</Page>
|
|
371
376
|
);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
height: 100%;
|
|
5
|
-
border-radius: 3px 3px 0 0;
|
|
6
5
|
|
|
7
6
|
.page-templates-preview-field__button {
|
|
8
7
|
box-shadow: none;
|
|
@@ -13,7 +12,7 @@
|
|
|
13
12
|
cursor: pointer;
|
|
14
13
|
overflow: hidden;
|
|
15
14
|
height: 100%;
|
|
16
|
-
border-radius:
|
|
15
|
+
border-radius: $grid-unit-05;
|
|
17
16
|
|
|
18
17
|
&:focus-visible {
|
|
19
18
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
@@ -32,10 +31,6 @@
|
|
|
32
31
|
.block-editor-block-preview__container {
|
|
33
32
|
height: 100%;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
.page-templates-preview-field__button {
|
|
37
|
-
border-radius: 3px 3px 0 0;
|
|
38
|
-
}
|
|
39
34
|
}
|
|
40
35
|
|
|
41
36
|
&.is-viewtype-table {
|
|
@@ -47,7 +47,7 @@ export default function Pagination( {
|
|
|
47
47
|
<Button
|
|
48
48
|
variant={ buttonVariant }
|
|
49
49
|
onClick={ () => changePage( 1 ) }
|
|
50
|
-
|
|
50
|
+
accessibleWhenDisabled
|
|
51
51
|
disabled={ disabled || currentPage === 1 }
|
|
52
52
|
label={ __( 'First page' ) }
|
|
53
53
|
icon={ previous }
|
|
@@ -56,7 +56,7 @@ export default function Pagination( {
|
|
|
56
56
|
<Button
|
|
57
57
|
variant={ buttonVariant }
|
|
58
58
|
onClick={ () => changePage( currentPage - 1 ) }
|
|
59
|
-
|
|
59
|
+
accessibleWhenDisabled
|
|
60
60
|
disabled={ disabled || currentPage === 1 }
|
|
61
61
|
label={ __( 'Previous page' ) }
|
|
62
62
|
icon={ chevronLeft }
|
|
@@ -75,7 +75,7 @@ export default function Pagination( {
|
|
|
75
75
|
<Button
|
|
76
76
|
variant={ buttonVariant }
|
|
77
77
|
onClick={ () => changePage( currentPage + 1 ) }
|
|
78
|
-
|
|
78
|
+
accessibleWhenDisabled
|
|
79
79
|
disabled={ disabled || currentPage === numPages }
|
|
80
80
|
label={ __( 'Next page' ) }
|
|
81
81
|
icon={ chevronRight }
|
|
@@ -84,7 +84,7 @@ export default function Pagination( {
|
|
|
84
84
|
<Button
|
|
85
85
|
variant={ buttonVariant }
|
|
86
86
|
onClick={ () => changePage( numPages ) }
|
|
87
|
-
|
|
87
|
+
accessibleWhenDisabled
|
|
88
88
|
disabled={ disabled || currentPage === numPages }
|
|
89
89
|
label={ __( 'Last page' ) }
|
|
90
90
|
icon={ next }
|
|
@@ -10,29 +10,27 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
|
+
import useInitEditedEntityFromURL from '../sync-state-with-url/use-init-edited-entity-from-url';
|
|
13
14
|
import Layout from '../layout';
|
|
14
|
-
import
|
|
15
|
+
import useLayoutAreas from './router';
|
|
15
16
|
import { unlock } from '../../lock-unlock';
|
|
16
17
|
|
|
17
18
|
const { RouterProvider } = unlock( routerPrivateApis );
|
|
18
19
|
const { GlobalStylesProvider } = unlock( editorPrivateApis );
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
mobile: <Page>Welcome to Posts</Page>,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
21
|
+
function PostsLayout() {
|
|
22
|
+
// This ensures the edited entity id and type are initialized properly.
|
|
23
|
+
useInitEditedEntityFromURL();
|
|
24
|
+
const route = useLayoutAreas();
|
|
25
|
+
return <Layout route={ route } />;
|
|
26
|
+
}
|
|
29
27
|
|
|
30
28
|
export default function PostsApp() {
|
|
31
29
|
return (
|
|
32
30
|
<GlobalStylesProvider>
|
|
33
31
|
<UnsavedChangesWarning />
|
|
34
32
|
<RouterProvider>
|
|
35
|
-
<
|
|
33
|
+
<PostsLayout />
|
|
36
34
|
</RouterProvider>
|
|
37
35
|
</GlobalStylesProvider>
|
|
38
36
|
);
|