@wordpress/edit-site 5.31.0 → 5.32.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/build/components/block-editor/editor-canvas.js +8 -1
- package/build/components/block-editor/editor-canvas.js.map +1 -1
- package/build/components/block-editor/site-editor-canvas.js +15 -4
- package/build/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build/components/editor/index.js +12 -3
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-canvas-container/index.js +1 -2
- package/build/components/editor-canvas-container/index.js.map +1 -1
- package/build/components/global-styles/background-panel.js +38 -0
- package/build/components/global-styles/background-panel.js.map +1 -0
- package/build/components/global-styles/font-families.js +1 -1
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +38 -9
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +20 -2
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/palette.js +3 -1
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview-colors.js +2 -2
- package/build/components/global-styles/preview-colors.js.map +1 -1
- package/build/components/global-styles/root-menu.js +8 -2
- package/build/components/global-styles/root-menu.js.map +1 -1
- package/build/components/global-styles/screen-background.js +34 -0
- package/build/components/global-styles/screen-background.js.map +1 -0
- package/build/components/global-styles/screen-color-palette.js +2 -2
- package/build/components/global-styles/screen-color-palette.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +6 -4
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +3 -37
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +6 -6
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/style-variations-container.js +5 -2
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/ui.js +4 -1
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js +10 -3
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles/variations/variations-typography.js +9 -2
- package/build/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +3 -0
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/layout/animation.js +129 -0
- package/build/components/layout/animation.js.map +1 -0
- package/build/components/layout/index.js +9 -17
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +21 -18
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-pages/index.js +19 -17
- package/build/components/page-pages/index.js.map +1 -1
- package/build/components/page-patterns/index.js +18 -28
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-patterns/search-items.js +16 -58
- package/build/components/page-patterns/search-items.js.map +1 -1
- package/build/components/page-templates-template-parts/actions.js +54 -41
- package/build/components/page-templates-template-parts/actions.js.map +1 -1
- package/build/components/page-templates-template-parts/index.js +26 -59
- package/build/components/page-templates-template-parts/index.js.map +1 -1
- package/build/components/plugin-template-setting-panel/index.js +12 -1
- package/build/components/plugin-template-setting-panel/index.js.map +1 -1
- package/build/components/save-button/index.js +45 -16
- package/build/components/save-button/index.js.map +1 -1
- package/build/components/save-hub/index.js +8 -112
- package/build/components/save-hub/index.js.map +1 -1
- package/build/components/sidebar/index.js +1 -5
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +1 -1
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +1 -1
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/index.js +1 -2
- package/build/components/sidebar-edit-mode/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/index.js +5 -15
- package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
- package/build/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build/components/sidebar-edit-mode/template-panel/index.js +10 -16
- package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-details-footer/index.js +5 -1
- package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/index.js +10 -5
- package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-patterns/index.js +1 -5
- package/build/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build/components/style-book/index.js +1 -1
- package/build/components/style-book/index.js.map +1 -1
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
- package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
- package/build/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build/hooks/index.js +0 -1
- package/build/hooks/index.js.map +1 -1
- package/build/store/selectors.js +1 -9
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-editor/editor-canvas.js +8 -1
- package/build-module/components/block-editor/editor-canvas.js.map +1 -1
- package/build-module/components/block-editor/site-editor-canvas.js +15 -4
- package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
- package/build-module/components/editor/index.js +13 -4
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-canvas-container/index.js +1 -2
- package/build-module/components/editor-canvas-container/index.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +31 -0
- package/build-module/components/global-styles/background-panel.js.map +1 -0
- package/build-module/components/global-styles/font-families.js +1 -1
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +38 -9
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +20 -2
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/palette.js +3 -1
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview-colors.js +2 -2
- package/build-module/components/global-styles/preview-colors.js.map +1 -1
- package/build-module/components/global-styles/root-menu.js +9 -3
- package/build-module/components/global-styles/root-menu.js.map +1 -1
- package/build-module/components/global-styles/screen-background.js +26 -0
- package/build-module/components/global-styles/screen-background.js.map +1 -0
- package/build-module/components/global-styles/screen-color-palette.js +2 -2
- package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +6 -4
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +4 -38
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +6 -6
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/style-variations-container.js +5 -2
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/ui.js +4 -1
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +10 -3
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-typography.js +9 -2
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +3 -0
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/layout/animation.js +122 -0
- package/build-module/components/layout/animation.js.map +1 -0
- package/build-module/components/layout/index.js +9 -17
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +21 -18
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-pages/index.js +19 -17
- package/build-module/components/page-pages/index.js.map +1 -1
- package/build-module/components/page-patterns/index.js +20 -30
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-patterns/search-items.js +14 -55
- package/build-module/components/page-patterns/search-items.js.map +1 -1
- package/build-module/components/page-templates-template-parts/actions.js +54 -40
- package/build-module/components/page-templates-template-parts/actions.js.map +1 -1
- package/build-module/components/page-templates-template-parts/index.js +29 -62
- package/build-module/components/page-templates-template-parts/index.js.map +1 -1
- package/build-module/components/plugin-template-setting-panel/index.js +12 -1
- package/build-module/components/plugin-template-setting-panel/index.js.map +1 -1
- package/build-module/components/save-button/index.js +46 -17
- package/build-module/components/save-button/index.js.map +1 -1
- package/build-module/components/save-hub/index.js +10 -114
- package/build-module/components/save-hub/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +1 -5
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +1 -1
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/index.js +1 -2
- package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/index.js +8 -18
- package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js +7 -5
- package/build-module/components/sidebar-edit-mode/page-panels/page-content.js.map +1 -1
- package/build-module/components/sidebar-edit-mode/template-panel/index.js +11 -17
- 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 +5 -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 +10 -5
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-patterns/index.js +1 -5
- package/build-module/components/sidebar-navigation-screen-patterns/index.js.map +1 -1
- package/build-module/components/style-book/index.js +1 -1
- 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 +2 -2
- package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
- package/build-module/components/sync-state-with-url/use-sync-path-with-url.js.map +1 -1
- package/build-module/hooks/index.js +0 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/store/selectors.js +1 -9
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +116 -104
- package/build-style/style.css +116 -104
- package/package.json +44 -44
- package/src/components/block-editor/editor-canvas.js +14 -2
- package/src/components/block-editor/site-editor-canvas.js +10 -7
- package/src/components/editor/index.js +11 -4
- package/src/components/editor-canvas-container/index.js +0 -1
- package/src/components/global-styles/background-panel.js +34 -0
- package/src/components/global-styles/font-families.js +1 -1
- package/src/components/global-styles/font-library-modal/context.js +43 -14
- package/src/components/global-styles/font-library-modal/style.scss +1 -1
- package/src/components/global-styles/font-library-modal/utils/index.js +17 -4
- package/src/components/global-styles/palette.js +3 -1
- package/src/components/global-styles/preview-colors.js +2 -2
- package/src/components/global-styles/root-menu.js +12 -1
- package/src/components/global-styles/screen-background.js +29 -0
- package/src/components/global-styles/screen-color-palette.js +2 -2
- package/src/components/global-styles/screen-colors.js +4 -4
- package/src/components/global-styles/screen-style-variations.js +4 -36
- package/src/components/global-styles/screen-typography.js +6 -9
- package/src/components/global-styles/style-variations-container.js +2 -1
- package/src/components/global-styles/style.scss +14 -12
- package/src/components/global-styles/ui.js +5 -0
- package/src/components/global-styles/variations/style.scss +32 -17
- package/src/components/global-styles/variations/variations-color.js +4 -2
- package/src/components/global-styles/variations/variations-typography.js +4 -1
- package/src/components/header-edit-mode/style.scss +28 -17
- package/src/components/keyboard-shortcut-help-modal/index.js +4 -0
- package/src/components/layout/animation.js +122 -0
- package/src/components/layout/index.js +12 -27
- package/src/components/layout/router.js +25 -19
- package/src/components/layout/style.scss +2 -0
- package/src/components/page-pages/index.js +27 -43
- package/src/components/page-patterns/index.js +20 -28
- package/src/components/page-patterns/search-items.js +13 -58
- package/src/components/page-templates-template-parts/actions.js +106 -91
- package/src/components/page-templates-template-parts/index.js +34 -78
- package/src/components/page-templates-template-parts/style.scss +5 -0
- package/src/components/plugin-template-setting-panel/index.js +14 -1
- package/src/components/save-button/index.js +55 -26
- package/src/components/save-hub/index.js +20 -164
- package/src/components/sidebar/index.js +0 -5
- package/src/components/sidebar-dataviews/default-views.js +1 -1
- package/src/components/sidebar-dataviews/index.js +1 -1
- package/src/components/sidebar-edit-mode/index.js +0 -2
- package/src/components/sidebar-edit-mode/page-panels/index.js +29 -60
- package/src/components/sidebar-edit-mode/page-panels/page-content.js +10 -10
- package/src/components/sidebar-edit-mode/template-panel/index.js +23 -33
- package/src/components/sidebar-edit-mode/template-panel/style.scss +1 -29
- package/src/components/sidebar-navigation-screen/style.scss +12 -9
- package/src/components/sidebar-navigation-screen-details-footer/index.js +6 -2
- package/src/components/sidebar-navigation-screen-global-styles/index.js +7 -13
- package/src/components/sidebar-navigation-screen-patterns/index.js +0 -7
- package/src/components/style-book/index.js +1 -3
- package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +2 -2
- package/src/components/sync-state-with-url/use-sync-path-with-url.js +1 -1
- package/src/hooks/index.js +0 -1
- package/src/store/selectors.js +3 -15
- package/src/style.scss +0 -1
- package/build/components/actions/index.js +0 -319
- package/build/components/actions/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/sidebar-card/index.js +0 -48
- package/build/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
- package/build/components/sidebar-edit-mode/template-panel/template-areas.js +0 -70
- package/build/components/sidebar-edit-mode/template-panel/template-areas.js.map +0 -1
- package/build/components/sidebar-navigation-screen-pages/index.js +0 -175
- package/build/components/sidebar-navigation-screen-pages/index.js.map +0 -1
- package/build/hooks/template-part-edit.js +0 -82
- package/build/hooks/template-part-edit.js.map +0 -1
- package/build/store/utils.js +0 -71
- package/build/store/utils.js.map +0 -1
- package/build-module/components/actions/index.js +0 -308
- package/build-module/components/actions/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/sidebar-card/index.js +0 -40
- package/build-module/components/sidebar-edit-mode/sidebar-card/index.js.map +0 -1
- package/build-module/components/sidebar-edit-mode/template-panel/template-areas.js +0 -63
- package/build-module/components/sidebar-edit-mode/template-panel/template-areas.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-pages/index.js +0 -167
- package/build-module/components/sidebar-navigation-screen-pages/index.js.map +0 -1
- package/build-module/hooks/template-part-edit.js +0 -75
- package/build-module/hooks/template-part-edit.js.map +0 -1
- package/build-module/store/utils.js +0 -64
- package/build-module/store/utils.js.map +0 -1
- package/src/components/actions/index.js +0 -409
- package/src/components/sidebar-edit-mode/sidebar-card/index.js +0 -53
- package/src/components/sidebar-edit-mode/sidebar-card/style.scss +0 -36
- package/src/components/sidebar-edit-mode/template-panel/template-areas.js +0 -86
- package/src/components/sidebar-navigation-screen-pages/index.js +0 -238
- package/src/hooks/template-part-edit.js +0 -89
- package/src/store/test/utils.js +0 -191
- package/src/store/utils.js +0 -69
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { unlock } from '../../lock-unlock';
|
|
10
|
+
|
|
11
|
+
const { extractWords, getNormalizedSearchTerms, normalizeString } = unlock(
|
|
12
|
+
blockEditorPrivateApis
|
|
13
|
+
);
|
|
6
14
|
|
|
7
15
|
/**
|
|
8
16
|
* Internal dependencies
|
|
@@ -20,59 +28,6 @@ const defaultGetDescription = ( item ) => item.description || '';
|
|
|
20
28
|
const defaultGetKeywords = ( item ) => item.keywords || [];
|
|
21
29
|
const defaultHasCategory = () => false;
|
|
22
30
|
|
|
23
|
-
/**
|
|
24
|
-
* Extracts words from an input string.
|
|
25
|
-
*
|
|
26
|
-
* @param {string} input The input string.
|
|
27
|
-
*
|
|
28
|
-
* @return {Array} Words, extracted from the input string.
|
|
29
|
-
*/
|
|
30
|
-
function extractWords( input = '' ) {
|
|
31
|
-
return noCase( input, {
|
|
32
|
-
splitRegexp: [
|
|
33
|
-
/([\p{Ll}\p{Lo}\p{N}])([\p{Lu}\p{Lt}])/gu, // One lowercase or digit, followed by one uppercase.
|
|
34
|
-
/([\p{Lu}\p{Lt}])([\p{Lu}\p{Lt}][\p{Ll}\p{Lo}])/gu, // One uppercase followed by one uppercase and one lowercase.
|
|
35
|
-
],
|
|
36
|
-
stripRegexp: /(\p{C}|\p{P}|\p{S})+/giu, // Anything that's not a punctuation, symbol or control/format character.
|
|
37
|
-
} )
|
|
38
|
-
.split( ' ' )
|
|
39
|
-
.filter( Boolean );
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Sanitizes the search input string.
|
|
44
|
-
*
|
|
45
|
-
* @param {string} input The search input to normalize.
|
|
46
|
-
*
|
|
47
|
-
* @return {string} The normalized search input.
|
|
48
|
-
*/
|
|
49
|
-
function normalizeSearchInput( input = '' ) {
|
|
50
|
-
// Disregard diacritics.
|
|
51
|
-
// Input: "média"
|
|
52
|
-
input = removeAccents( input );
|
|
53
|
-
|
|
54
|
-
// Accommodate leading slash, matching autocomplete expectations.
|
|
55
|
-
// Input: "/media"
|
|
56
|
-
input = input.replace( /^\//, '' );
|
|
57
|
-
|
|
58
|
-
// Lowercase.
|
|
59
|
-
// Input: "MEDIA"
|
|
60
|
-
input = input.toLowerCase();
|
|
61
|
-
|
|
62
|
-
return input;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Converts the search term into a list of normalized terms.
|
|
67
|
-
*
|
|
68
|
-
* @param {string} input The search term to normalize.
|
|
69
|
-
*
|
|
70
|
-
* @return {string[]} The normalized list of search terms.
|
|
71
|
-
*/
|
|
72
|
-
export const getNormalizedSearchTerms = ( input = '' ) => {
|
|
73
|
-
return extractWords( normalizeSearchInput( input ) );
|
|
74
|
-
};
|
|
75
|
-
|
|
76
31
|
const removeMatchingTerms = ( unmatchedTerms, unprocessedTerms ) => {
|
|
77
32
|
return unmatchedTerms.filter(
|
|
78
33
|
( term ) =>
|
|
@@ -162,8 +117,8 @@ function getItemSearchRank( item, searchTerm, config ) {
|
|
|
162
117
|
const description = getDescription( item );
|
|
163
118
|
const keywords = getKeywords( item );
|
|
164
119
|
|
|
165
|
-
const normalizedSearchInput =
|
|
166
|
-
const normalizedTitle =
|
|
120
|
+
const normalizedSearchInput = normalizeString( searchTerm );
|
|
121
|
+
const normalizedTitle = normalizeString( title );
|
|
167
122
|
|
|
168
123
|
// Prefers exact matches
|
|
169
124
|
// Then prefers if the beginning of the title matches the search term
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { backup, trash } from '@wordpress/icons';
|
|
5
4
|
import { __, sprintf, _n } from '@wordpress/i18n';
|
|
6
5
|
import { useDispatch } from '@wordpress/data';
|
|
7
|
-
import {
|
|
6
|
+
import { useState } from '@wordpress/element';
|
|
8
7
|
import { store as coreStore } from '@wordpress/core-data';
|
|
9
8
|
import { store as noticesStore } from '@wordpress/notices';
|
|
10
9
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
@@ -25,95 +24,106 @@ import isTemplateRevertable from '../../utils/is-template-revertable';
|
|
|
25
24
|
import isTemplateRemovable from '../../utils/is-template-removable';
|
|
26
25
|
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
27
26
|
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
template.type,
|
|
50
|
-
template.id
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
createSuccessNotice(
|
|
55
|
-
templates.length > 1
|
|
56
|
-
? sprintf(
|
|
57
|
-
/* translators: The number of items. */
|
|
58
|
-
__( '%s items reverted.' ),
|
|
59
|
-
templates.length
|
|
60
|
-
)
|
|
61
|
-
: sprintf(
|
|
62
|
-
/* translators: The template/part's name. */
|
|
63
|
-
__( '"%s" reverted.' ),
|
|
64
|
-
decodeEntities(
|
|
65
|
-
templates[ 0 ].title.rendered
|
|
66
|
-
)
|
|
67
|
-
),
|
|
68
|
-
{
|
|
69
|
-
type: 'snackbar',
|
|
70
|
-
id: 'edit-site-template-reverted',
|
|
71
|
-
}
|
|
27
|
+
export const resetTemplateAction = {
|
|
28
|
+
id: 'reset-template',
|
|
29
|
+
label: __( 'Clear customizations' ),
|
|
30
|
+
isEligible: isTemplateRevertable,
|
|
31
|
+
supportsBulk: true,
|
|
32
|
+
hideModalHeader: true,
|
|
33
|
+
RenderModal: ( { items, closeModal, onPerform } ) => {
|
|
34
|
+
const { revertTemplate } = useDispatch( editSiteStore );
|
|
35
|
+
const { saveEditedEntityRecord } = useDispatch( coreStore );
|
|
36
|
+
const { createSuccessNotice, createErrorNotice } =
|
|
37
|
+
useDispatch( noticesStore );
|
|
38
|
+
const onConfirm = async () => {
|
|
39
|
+
try {
|
|
40
|
+
for ( const template of items ) {
|
|
41
|
+
await revertTemplate( template, {
|
|
42
|
+
allowUndo: false,
|
|
43
|
+
} );
|
|
44
|
+
await saveEditedEntityRecord(
|
|
45
|
+
'postType',
|
|
46
|
+
template.type,
|
|
47
|
+
template.id
|
|
72
48
|
);
|
|
73
|
-
}
|
|
74
|
-
let fallbackErrorMessage;
|
|
75
|
-
if ( templates[ 0 ].type === TEMPLATE_POST_TYPE ) {
|
|
76
|
-
fallbackErrorMessage =
|
|
77
|
-
templates.length === 1
|
|
78
|
-
? __(
|
|
79
|
-
'An error occurred while reverting the template.'
|
|
80
|
-
)
|
|
81
|
-
: __(
|
|
82
|
-
'An error occurred while reverting the templates.'
|
|
83
|
-
);
|
|
84
|
-
} else {
|
|
85
|
-
fallbackErrorMessage =
|
|
86
|
-
templates.length === 1
|
|
87
|
-
? __(
|
|
88
|
-
'An error occurred while reverting the template part.'
|
|
89
|
-
)
|
|
90
|
-
: __(
|
|
91
|
-
'An error occurred while reverting the template parts.'
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
const errorMessage =
|
|
95
|
-
error.message && error.code !== 'unknown_error'
|
|
96
|
-
? error.message
|
|
97
|
-
: fallbackErrorMessage;
|
|
49
|
+
}
|
|
98
50
|
|
|
99
|
-
|
|
51
|
+
createSuccessNotice(
|
|
52
|
+
items.length > 1
|
|
53
|
+
? sprintf(
|
|
54
|
+
/* translators: The number of items. */
|
|
55
|
+
__( '%s items reverted.' ),
|
|
56
|
+
items.length
|
|
57
|
+
)
|
|
58
|
+
: sprintf(
|
|
59
|
+
/* translators: The template/part's name. */
|
|
60
|
+
__( '"%s" reverted.' ),
|
|
61
|
+
decodeEntities( items[ 0 ].title.rendered )
|
|
62
|
+
),
|
|
63
|
+
{
|
|
64
|
+
type: 'snackbar',
|
|
65
|
+
id: 'edit-site-template-reverted',
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
} catch ( error ) {
|
|
69
|
+
let fallbackErrorMessage;
|
|
70
|
+
if ( items[ 0 ].type === TEMPLATE_POST_TYPE ) {
|
|
71
|
+
fallbackErrorMessage =
|
|
72
|
+
items.length === 1
|
|
73
|
+
? __(
|
|
74
|
+
'An error occurred while reverting the template.'
|
|
75
|
+
)
|
|
76
|
+
: __(
|
|
77
|
+
'An error occurred while reverting the templates.'
|
|
78
|
+
);
|
|
79
|
+
} else {
|
|
80
|
+
fallbackErrorMessage =
|
|
81
|
+
items.length === 1
|
|
82
|
+
? __(
|
|
83
|
+
'An error occurred while reverting the template part.'
|
|
84
|
+
)
|
|
85
|
+
: __(
|
|
86
|
+
'An error occurred while reverting the template parts.'
|
|
87
|
+
);
|
|
100
88
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
89
|
+
const errorMessage =
|
|
90
|
+
error.message && error.code !== 'unknown_error'
|
|
91
|
+
? error.message
|
|
92
|
+
: fallbackErrorMessage;
|
|
93
|
+
|
|
94
|
+
createErrorNotice( errorMessage, { type: 'snackbar' } );
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return (
|
|
98
|
+
<VStack spacing="5">
|
|
99
|
+
<Text>
|
|
100
|
+
{ __(
|
|
101
|
+
'Are you sure you want to clear these customizations?'
|
|
102
|
+
) }
|
|
103
|
+
</Text>
|
|
104
|
+
<HStack justify="right">
|
|
105
|
+
<Button variant="tertiary" onClick={ closeModal }>
|
|
106
|
+
{ __( 'Cancel' ) }
|
|
107
|
+
</Button>
|
|
108
|
+
<Button
|
|
109
|
+
variant="primary"
|
|
110
|
+
onClick={ async () => {
|
|
111
|
+
await onConfirm( items );
|
|
112
|
+
onPerform?.();
|
|
113
|
+
closeModal();
|
|
114
|
+
} }
|
|
115
|
+
>
|
|
116
|
+
{ __( 'Clear' ) }
|
|
117
|
+
</Button>
|
|
118
|
+
</HStack>
|
|
119
|
+
</VStack>
|
|
120
|
+
);
|
|
121
|
+
},
|
|
122
|
+
};
|
|
111
123
|
|
|
112
124
|
export const deleteTemplateAction = {
|
|
113
125
|
id: 'delete-template',
|
|
114
126
|
label: __( 'Delete' ),
|
|
115
|
-
isPrimary: true,
|
|
116
|
-
icon: trash,
|
|
117
127
|
isEligible: isTemplateRemovable,
|
|
118
128
|
supportsBulk: true,
|
|
119
129
|
hideModalHeader: true,
|
|
@@ -150,9 +160,7 @@ export const deleteTemplateAction = {
|
|
|
150
160
|
await removeTemplates( templates, {
|
|
151
161
|
allowUndo: false,
|
|
152
162
|
} );
|
|
153
|
-
|
|
154
|
-
onPerform();
|
|
155
|
-
}
|
|
163
|
+
onPerform?.();
|
|
156
164
|
closeModal();
|
|
157
165
|
} }
|
|
158
166
|
>
|
|
@@ -212,8 +220,6 @@ export const renameTemplateAction = {
|
|
|
212
220
|
throwOnError: true,
|
|
213
221
|
}
|
|
214
222
|
);
|
|
215
|
-
// TODO: this action will be reused in template parts list, so
|
|
216
|
-
// let's keep this for a bit, even it's always a `template` now.
|
|
217
223
|
createSuccessNotice(
|
|
218
224
|
template.type === TEMPLATE_POST_TYPE
|
|
219
225
|
? __( 'Template renamed.' )
|
|
@@ -242,16 +248,25 @@ export const renameTemplateAction = {
|
|
|
242
248
|
<VStack spacing="5">
|
|
243
249
|
<TextControl
|
|
244
250
|
__nextHasNoMarginBottom
|
|
251
|
+
__next40pxDefaultSize
|
|
245
252
|
label={ __( 'Name' ) }
|
|
246
253
|
value={ editedTitle }
|
|
247
254
|
onChange={ setEditedTitle }
|
|
248
255
|
required
|
|
249
256
|
/>
|
|
250
257
|
<HStack justify="right">
|
|
251
|
-
<Button
|
|
258
|
+
<Button
|
|
259
|
+
variant="tertiary"
|
|
260
|
+
onClick={ closeModal }
|
|
261
|
+
__next40pxDefaultSize
|
|
262
|
+
>
|
|
252
263
|
{ __( 'Cancel' ) }
|
|
253
264
|
</Button>
|
|
254
|
-
<Button
|
|
265
|
+
<Button
|
|
266
|
+
variant="primary"
|
|
267
|
+
type="submit"
|
|
268
|
+
__next40pxDefaultSize
|
|
269
|
+
>
|
|
255
270
|
{ __( 'Save' ) }
|
|
256
271
|
</Button>
|
|
257
272
|
</HStack>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import removeAccents from 'remove-accents';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -22,12 +21,9 @@ import {
|
|
|
22
21
|
BlockPreview,
|
|
23
22
|
privateApis as blockEditorPrivateApis,
|
|
24
23
|
} from '@wordpress/block-editor';
|
|
25
|
-
import {
|
|
26
|
-
DataViews,
|
|
27
|
-
sortByTextFields,
|
|
28
|
-
getPaginationResults,
|
|
29
|
-
} from '@wordpress/dataviews';
|
|
24
|
+
import { DataViews, filterSortAndPaginate } from '@wordpress/dataviews';
|
|
30
25
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
26
|
+
import { privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
31
27
|
|
|
32
28
|
/**
|
|
33
29
|
* Internal dependencies
|
|
@@ -41,21 +37,21 @@ import {
|
|
|
41
37
|
TEMPLATE_PART_POST_TYPE,
|
|
42
38
|
ENUMERATION_TYPE,
|
|
43
39
|
OPERATOR_IS_ANY,
|
|
44
|
-
OPERATOR_IS_NONE,
|
|
45
40
|
LAYOUT_GRID,
|
|
46
41
|
LAYOUT_TABLE,
|
|
47
42
|
LAYOUT_LIST,
|
|
48
43
|
} from '../../utils/constants';
|
|
49
44
|
import {
|
|
50
|
-
|
|
45
|
+
resetTemplateAction,
|
|
51
46
|
deleteTemplateAction,
|
|
52
47
|
renameTemplateAction,
|
|
53
48
|
} from './actions';
|
|
54
|
-
import { postRevisionsAction } from '../actions';
|
|
55
49
|
import usePatternSettings from '../page-patterns/use-pattern-settings';
|
|
56
50
|
import { unlock } from '../../lock-unlock';
|
|
57
51
|
import AddNewTemplatePart from './add-new-template-part';
|
|
58
52
|
|
|
53
|
+
const { usePostActions } = unlock( editorPrivateApis );
|
|
54
|
+
|
|
59
55
|
const { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(
|
|
60
56
|
blockEditorPrivateApis
|
|
61
57
|
);
|
|
@@ -70,6 +66,7 @@ const defaultConfigPerViewType = {
|
|
|
70
66
|
[ LAYOUT_GRID ]: {
|
|
71
67
|
mediaField: 'preview',
|
|
72
68
|
primaryField: 'title',
|
|
69
|
+
displayAsColumnFields: [ 'description' ],
|
|
73
70
|
},
|
|
74
71
|
[ LAYOUT_LIST ]: {
|
|
75
72
|
primaryField: 'title',
|
|
@@ -93,10 +90,6 @@ const DEFAULT_VIEW = {
|
|
|
93
90
|
filters: [],
|
|
94
91
|
};
|
|
95
92
|
|
|
96
|
-
function normalizeSearchInput( input = '' ) {
|
|
97
|
-
return removeAccents( input.trim().toLowerCase() );
|
|
98
|
-
}
|
|
99
|
-
|
|
100
93
|
function Title( { item, viewType } ) {
|
|
101
94
|
if ( viewType === LAYOUT_LIST ) {
|
|
102
95
|
return decodeEntities( item.title?.rendered ) || __( '(no title)' );
|
|
@@ -148,7 +141,7 @@ function AuthorField( { item, viewType } ) {
|
|
|
148
141
|
<Icon icon={ icon } />
|
|
149
142
|
</div>
|
|
150
143
|
) }
|
|
151
|
-
<span>{ text }</span>
|
|
144
|
+
<span className="page-templates-author-field__name">{ text }</span>
|
|
152
145
|
</HStack>
|
|
153
146
|
);
|
|
154
147
|
}
|
|
@@ -297,6 +290,7 @@ export default function PageTemplatesTemplateParts( { postType } ) {
|
|
|
297
290
|
),
|
|
298
291
|
maxWidth: 400,
|
|
299
292
|
enableHiding: false,
|
|
293
|
+
enableGlobalSearch: true,
|
|
300
294
|
},
|
|
301
295
|
];
|
|
302
296
|
if ( postType === TEMPLATE_POST_TYPE ) {
|
|
@@ -324,6 +318,7 @@ export default function PageTemplatesTemplateParts( { postType } ) {
|
|
|
324
318
|
maxWidth: 400,
|
|
325
319
|
minWidth: 320,
|
|
326
320
|
enableSorting: false,
|
|
321
|
+
enableGlobalSearch: true,
|
|
327
322
|
} );
|
|
328
323
|
}
|
|
329
324
|
// TODO: The plan is to support fields reordering, which would require an API like `order` or something
|
|
@@ -343,77 +338,35 @@ export default function PageTemplatesTemplateParts( { postType } ) {
|
|
|
343
338
|
}, [ postType, authors, view.type ] );
|
|
344
339
|
|
|
345
340
|
const { data, paginationInfo } = useMemo( () => {
|
|
346
|
-
|
|
347
|
-
return {
|
|
348
|
-
data: EMPTY_ARRAY,
|
|
349
|
-
paginationInfo: { totalItems: 0, totalPages: 0 },
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
let filteredData = [ ...records ];
|
|
353
|
-
// Handle global search.
|
|
354
|
-
if ( view.search ) {
|
|
355
|
-
const normalizedSearch = normalizeSearchInput( view.search );
|
|
356
|
-
filteredData = filteredData.filter( ( item ) => {
|
|
357
|
-
const title = item.title?.rendered || item.slug;
|
|
358
|
-
return (
|
|
359
|
-
normalizeSearchInput( title ).includes(
|
|
360
|
-
normalizedSearch
|
|
361
|
-
) ||
|
|
362
|
-
normalizeSearchInput( item.description ).includes(
|
|
363
|
-
normalizedSearch
|
|
364
|
-
)
|
|
365
|
-
);
|
|
366
|
-
} );
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// Handle filters.
|
|
370
|
-
if ( view.filters.length > 0 ) {
|
|
371
|
-
view.filters.forEach( ( filter ) => {
|
|
372
|
-
if (
|
|
373
|
-
filter.field === 'author' &&
|
|
374
|
-
filter.operator === OPERATOR_IS_ANY &&
|
|
375
|
-
filter?.value?.length > 0
|
|
376
|
-
) {
|
|
377
|
-
filteredData = filteredData.filter( ( item ) => {
|
|
378
|
-
return filter.value.includes( item.author_text );
|
|
379
|
-
} );
|
|
380
|
-
} else if (
|
|
381
|
-
filter.field === 'author' &&
|
|
382
|
-
filter.operator === OPERATOR_IS_NONE &&
|
|
383
|
-
filter?.value?.length > 0
|
|
384
|
-
) {
|
|
385
|
-
filteredData = filteredData.filter( ( item ) => {
|
|
386
|
-
return ! filter.value.includes( item.author_text );
|
|
387
|
-
} );
|
|
388
|
-
}
|
|
389
|
-
} );
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// Handle sorting.
|
|
393
|
-
if ( view.sort ) {
|
|
394
|
-
filteredData = sortByTextFields( {
|
|
395
|
-
data: filteredData,
|
|
396
|
-
view,
|
|
397
|
-
fields,
|
|
398
|
-
textFields: [ 'title', 'author' ],
|
|
399
|
-
} );
|
|
400
|
-
}
|
|
401
|
-
// Handle pagination.
|
|
402
|
-
return getPaginationResults( {
|
|
403
|
-
data: filteredData,
|
|
404
|
-
view,
|
|
405
|
-
} );
|
|
341
|
+
return filterSortAndPaginate( records, view, fields );
|
|
406
342
|
}, [ records, view, fields ] );
|
|
407
343
|
|
|
408
|
-
const
|
|
344
|
+
const onActionPerformed = useCallback(
|
|
345
|
+
( actionId, items ) => {
|
|
346
|
+
if ( actionId === 'edit-post' ) {
|
|
347
|
+
const post = items[ 0 ];
|
|
348
|
+
history.push( {
|
|
349
|
+
postId: post.id,
|
|
350
|
+
postType: post.type,
|
|
351
|
+
canvas: 'edit',
|
|
352
|
+
} );
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
[ history ]
|
|
356
|
+
);
|
|
357
|
+
const [ editAction, viewRevisionsAction ] = usePostActions(
|
|
358
|
+
onActionPerformed,
|
|
359
|
+
[ 'edit-post', 'view-post-revisions' ]
|
|
360
|
+
);
|
|
409
361
|
const actions = useMemo(
|
|
410
362
|
() => [
|
|
363
|
+
editAction,
|
|
411
364
|
resetTemplateAction,
|
|
412
365
|
renameTemplateAction,
|
|
413
|
-
|
|
366
|
+
viewRevisionsAction,
|
|
414
367
|
deleteTemplateAction,
|
|
415
368
|
],
|
|
416
|
-
[
|
|
369
|
+
[ editAction, viewRevisionsAction ]
|
|
417
370
|
);
|
|
418
371
|
|
|
419
372
|
const onChangeView = useCallback(
|
|
@@ -466,7 +419,10 @@ export default function PageTemplatesTemplateParts( { postType } ) {
|
|
|
466
419
|
view={ view }
|
|
467
420
|
onChangeView={ onChangeView }
|
|
468
421
|
onSelectionChange={ onSelectionChange }
|
|
469
|
-
deferredRendering={
|
|
422
|
+
deferredRendering={
|
|
423
|
+
view.type === LAYOUT_GRID ||
|
|
424
|
+
! view.hiddenFields?.includes( 'preview' )
|
|
425
|
+
}
|
|
470
426
|
/>
|
|
471
427
|
</Page>
|
|
472
428
|
);
|
|
@@ -103,6 +103,11 @@
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
.page-templates-author-field__name {
|
|
107
|
+
text-overflow: ellipsis;
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
}
|
|
110
|
+
|
|
106
111
|
.edit-site-list__rename-modal {
|
|
107
112
|
// The rename dropdown popover is open at the same time as the rename modal. The latter has to be higher.
|
|
108
113
|
z-index: z-index(".edit-site-list__rename-modal");
|
|
@@ -5,11 +5,24 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
8
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
8
10
|
import { createSlotFill } from '@wordpress/components';
|
|
9
11
|
|
|
10
12
|
const { Fill, Slot } = createSlotFill( 'PluginTemplateSettingPanel' );
|
|
11
13
|
|
|
12
|
-
const PluginTemplateSettingPanel =
|
|
14
|
+
const PluginTemplateSettingPanel = ( { children } ) => {
|
|
15
|
+
const isCurrentEntityTemplate = useSelect(
|
|
16
|
+
( select ) =>
|
|
17
|
+
select( editorStore ).getCurrentPostType() === 'wp_template',
|
|
18
|
+
[]
|
|
19
|
+
);
|
|
20
|
+
if ( ! isCurrentEntityTemplate ) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return <Fill>{ children }</Fill>;
|
|
24
|
+
};
|
|
25
|
+
|
|
13
26
|
PluginTemplateSettingPanel.Slot = Slot;
|
|
14
27
|
|
|
15
28
|
/**
|