@wordpress/edit-site 5.28.0 → 5.28.2
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/build/components/block-editor/use-site-editor-settings.js +1 -1
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/global-styles/font-library-modal/context.js +1 -10
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js +10 -1
- package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -1
- package/build/components/global-styles/font-library-modal/upload-fonts.js +6 -0
- package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js +1 -1
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/make-families-from-faces.js +14 -1
- package/build/components/global-styles/font-library-modal/utils/make-families-from-faces.js.map +1 -1
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js +64 -8
- package/build/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build/components/global-styles/screen-revisions/revisions-buttons.js +6 -4
- package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build/components/media/index.js +3 -3
- package/build/components/media/index.js.map +1 -1
- package/build/components/sidebar/index.js +7 -2
- 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/start-template-options/index.js +3 -5
- package/build/components/start-template-options/index.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +8 -8
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/context.js +1 -10
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js +10 -1
- package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js +6 -0
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/index.js +2 -2
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/make-families-from-faces.js +13 -1
- package/build-module/components/global-styles/font-library-modal/utils/make-families-from-faces.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js +63 -8
- package/build-module/components/global-styles/font-library-modal/utils/preview-styles.js.map +1 -1
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +6 -4
- package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
- package/build-module/components/media/index.js +3 -3
- package/build-module/components/media/index.js.map +1 -1
- package/build-module/components/sidebar/index.js +7 -2
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +2 -2
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/start-template-options/index.js +4 -6
- package/build-module/components/start-template-options/index.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +8 -8
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-style/style-rtl.css +9 -13
- package/build-style/style.css +9 -13
- package/package.json +42 -42
- package/src/components/block-editor/use-site-editor-settings.js +3 -1
- package/src/components/global-styles/font-library-modal/context.js +1 -10
- package/src/components/global-styles/font-library-modal/tab-panel-layout.js +9 -1
- package/src/components/global-styles/font-library-modal/upload-fonts.js +6 -0
- package/src/components/global-styles/font-library-modal/utils/index.js +2 -2
- package/src/components/global-styles/font-library-modal/utils/make-families-from-faces.js +13 -1
- package/src/components/global-styles/font-library-modal/utils/preview-styles.js +72 -15
- package/src/components/global-styles/font-library-modal/utils/test/preview-styles.spec.js +60 -5
- package/src/components/global-styles/screen-revisions/revisions-buttons.js +7 -5
- package/src/components/global-styles/screen-revisions/style.scss +11 -6
- package/src/components/media/index.js +7 -9
- package/src/components/sidebar/index.js +7 -2
- package/src/components/sidebar-dataviews/default-views.js +2 -2
- package/src/components/sidebar-edit-mode/page-panels/style.scss +0 -1
- package/src/components/start-template-options/index.js +3 -7
- package/src/hooks/commands/use-edit-mode-commands.js +14 -14
- package/build/components/sidebar-navigation-screen-pages-dataviews/index.js +0 -92
- package/build/components/sidebar-navigation-screen-pages-dataviews/index.js.map +0 -1
- package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js +0 -84
- package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js.map +0 -1
- package/src/components/sidebar-navigation-screen-pages-dataviews/index.js +0 -103
|
@@ -30,22 +30,79 @@ function extractFontWeights( fontFaces ) {
|
|
|
30
30
|
return result;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/*
|
|
34
|
+
* Format the font family to use in the CSS font-family property of a CSS rule.
|
|
35
|
+
*
|
|
36
|
+
* The input can be a string with the font family name or a string with multiple font family names separated by commas.
|
|
37
|
+
* It follows the recommendations from the CSS Fonts Module Level 4.
|
|
38
|
+
* https://www.w3.org/TR/css-fonts-4/#font-family-prop
|
|
39
|
+
*
|
|
40
|
+
* @param {string} input - The font family.
|
|
41
|
+
* @return {string} The formatted font family.
|
|
42
|
+
*
|
|
43
|
+
* Example:
|
|
44
|
+
* formatFontFamily( "Open Sans, Font+Name, sans-serif" ) => '"Open Sans", "Font+Name", sans-serif'
|
|
45
|
+
* formatFontFamily( "'Open Sans', generic(kai), sans-serif" ) => '"Open Sans", sans-serif'
|
|
46
|
+
* formatFontFamily( "DotGothic16, Slabo 27px, serif" ) => '"DotGothic16","Slabo 27px",serif'
|
|
47
|
+
* formatFontFamily( "Mine's, Moe's Typography" ) => `"mine's","Moe's Typography"`
|
|
48
|
+
*/
|
|
33
49
|
export function formatFontFamily( input ) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
// Matches strings that are not exclusively alphabetic characters or hyphens, and do not exactly follow the pattern generic(alphabetic characters or hyphens).
|
|
51
|
+
const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/;
|
|
52
|
+
const output = input.trim();
|
|
53
|
+
|
|
54
|
+
const formatItem = ( item ) => {
|
|
55
|
+
item = item.trim();
|
|
56
|
+
if ( item.match( regex ) ) {
|
|
57
|
+
// removes leading and trailing quotes.
|
|
58
|
+
item = item.replace( /^["']|["']$/g, '' );
|
|
59
|
+
return `"${ item }"`;
|
|
60
|
+
}
|
|
61
|
+
return item;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if ( output.includes( ',' ) ) {
|
|
65
|
+
return output
|
|
66
|
+
.split( ',' )
|
|
67
|
+
.map( formatItem )
|
|
68
|
+
.filter( ( item ) => item !== '' )
|
|
69
|
+
.join( ', ' );
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return formatItem( output );
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
* Format the font face name to use in the font-family property of a font face.
|
|
77
|
+
*
|
|
78
|
+
* The input can be a string with the font face name or a string with multiple font face names separated by commas.
|
|
79
|
+
* It removes the leading and trailing quotes from the font face name.
|
|
80
|
+
*
|
|
81
|
+
* @param {string} input - The font face name.
|
|
82
|
+
* @return {string} The formatted font face name.
|
|
83
|
+
*
|
|
84
|
+
* Example:
|
|
85
|
+
* formatFontFaceName("Open Sans") => "Open Sans"
|
|
86
|
+
* formatFontFaceName("'Open Sans', sans-serif") => "Open Sans"
|
|
87
|
+
* formatFontFaceName(", 'Open Sans', 'Helvetica Neue', sans-serif") => "Open Sans"
|
|
88
|
+
*/
|
|
89
|
+
export function formatFontFaceName( input ) {
|
|
90
|
+
let output = input.trim();
|
|
91
|
+
if ( output.includes( ',' ) ) {
|
|
92
|
+
output = output
|
|
93
|
+
.split( ',' )
|
|
94
|
+
// finds the first item that is not an empty string.
|
|
95
|
+
.find( ( item ) => item.trim() !== '' )
|
|
96
|
+
.trim();
|
|
97
|
+
}
|
|
98
|
+
// removes leading and trailing quotes.
|
|
99
|
+
output = output.replace( /^["']|["']$/g, '' );
|
|
100
|
+
|
|
101
|
+
// Firefox needs the font name to be wrapped in double quotes meanwhile other browsers don't.
|
|
102
|
+
if ( window.navigator.userAgent.toLowerCase().includes( 'firefox' ) ) {
|
|
103
|
+
output = `"${ output }"`;
|
|
104
|
+
}
|
|
105
|
+
return output;
|
|
49
106
|
}
|
|
50
107
|
|
|
51
108
|
export function getFamilyPreviewStyle( family ) {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getFamilyPreviewStyle,
|
|
6
|
+
formatFontFamily,
|
|
7
|
+
formatFontFaceName,
|
|
8
|
+
} from '../preview-styles';
|
|
5
9
|
|
|
6
10
|
describe( 'getFamilyPreviewStyle', () => {
|
|
7
11
|
it( 'should return default fontStyle and fontWeight if fontFace is not provided', () => {
|
|
@@ -139,7 +143,7 @@ describe( 'formatFontFamily', () => {
|
|
|
139
143
|
"Seravek, 'Gill Sans Nova', Ubuntu, Calibri, 'DejaVu Sans', source-sans-pro, sans-serif"
|
|
140
144
|
)
|
|
141
145
|
).toBe(
|
|
142
|
-
|
|
146
|
+
'Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", source-sans-pro, sans-serif'
|
|
143
147
|
);
|
|
144
148
|
} );
|
|
145
149
|
|
|
@@ -153,9 +157,60 @@ describe( 'formatFontFamily', () => {
|
|
|
153
157
|
);
|
|
154
158
|
} );
|
|
155
159
|
|
|
156
|
-
it( 'should wrap
|
|
157
|
-
expect(
|
|
158
|
-
|
|
160
|
+
it( 'should wrap names with special characters in quotes', () => {
|
|
161
|
+
expect(
|
|
162
|
+
formatFontFamily(
|
|
163
|
+
'Font+Name, Font*Name, _Font_Name_, generic(kai), sans-serif'
|
|
164
|
+
)
|
|
165
|
+
).toBe(
|
|
166
|
+
'"Font+Name", "Font*Name", "_Font_Name_", generic(kai), sans-serif'
|
|
167
|
+
);
|
|
168
|
+
} );
|
|
169
|
+
|
|
170
|
+
it( 'should fix empty wrong formatted font family', () => {
|
|
171
|
+
expect( formatFontFamily( ', Abril Fatface,Times,serif' ) ).toBe(
|
|
172
|
+
'"Abril Fatface", Times, serif'
|
|
173
|
+
);
|
|
174
|
+
} );
|
|
175
|
+
|
|
176
|
+
it( 'should not add quotes to generic names', () => {
|
|
177
|
+
expect(
|
|
178
|
+
formatFontFamily(
|
|
179
|
+
'Paren(thesis)Font, generic(kai), generic(fasongsong), generic( abc ), Helvetica Neue'
|
|
180
|
+
)
|
|
181
|
+
).toBe(
|
|
182
|
+
'"Paren(thesis)Font", generic(kai), generic(fasongsong), generic( abc ), "Helvetica Neue"'
|
|
159
183
|
);
|
|
160
184
|
} );
|
|
161
185
|
} );
|
|
186
|
+
|
|
187
|
+
describe( 'formatFontFaceName', () => {
|
|
188
|
+
it( 'should remove leading and trailing quotes', () => {
|
|
189
|
+
expect( formatFontFaceName( '"Open Sans"' ) ).toBe( 'Open Sans' );
|
|
190
|
+
} );
|
|
191
|
+
|
|
192
|
+
it( 'should remove leading and trailing quotes from multiple font face names', () => {
|
|
193
|
+
expect(
|
|
194
|
+
formatFontFaceName( "'Open Sans', 'Helvetica Neue', sans-serif" )
|
|
195
|
+
).toBe( 'Open Sans' );
|
|
196
|
+
} );
|
|
197
|
+
|
|
198
|
+
it( 'should remove leading and trailing quotes even from names with spaces and special characters', () => {
|
|
199
|
+
expect( formatFontFaceName( "'Font+Name 24', sans-serif" ) ).toBe(
|
|
200
|
+
'Font+Name 24'
|
|
201
|
+
);
|
|
202
|
+
} );
|
|
203
|
+
|
|
204
|
+
it( 'should ouput the font face name with quotes on Firefox', () => {
|
|
205
|
+
const mockUserAgent =
|
|
206
|
+
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0';
|
|
207
|
+
|
|
208
|
+
// Mock the userAgent for this test
|
|
209
|
+
Object.defineProperty( window.navigator, 'userAgent', {
|
|
210
|
+
value: mockUserAgent,
|
|
211
|
+
configurable: true,
|
|
212
|
+
} );
|
|
213
|
+
|
|
214
|
+
expect( formatFontFaceName( 'Open Sans' ) ).toBe( '"Open Sans"' );
|
|
215
|
+
} );
|
|
216
|
+
} );
|
|
@@ -25,19 +25,20 @@ function ChangesSummary( { revision, previousRevision } ) {
|
|
|
25
25
|
const changes = getGlobalStylesChanges( revision, previousRevision, {
|
|
26
26
|
maxResults: 7,
|
|
27
27
|
} );
|
|
28
|
-
const changesLength = changes.length;
|
|
29
28
|
|
|
30
|
-
if ( !
|
|
29
|
+
if ( ! changes.length ) {
|
|
31
30
|
return null;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
return (
|
|
35
|
-
<
|
|
34
|
+
<ul
|
|
36
35
|
data-testid="global-styles-revision-changes"
|
|
37
36
|
className="edit-site-global-styles-screen-revisions__changes"
|
|
38
37
|
>
|
|
39
|
-
{ changes.
|
|
40
|
-
|
|
38
|
+
{ changes.map( ( change ) => (
|
|
39
|
+
<li key={ change }>{ change }</li>
|
|
40
|
+
) ) }
|
|
41
|
+
</ul>
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -219,6 +220,7 @@ function RevisionsButtons( {
|
|
|
219
220
|
) : (
|
|
220
221
|
<Button
|
|
221
222
|
disabled={ areStylesEqual }
|
|
223
|
+
size="compact"
|
|
222
224
|
variant="primary"
|
|
223
225
|
className="edit-site-global-styles-screen-revisions__apply-button"
|
|
224
226
|
onClick={ onApplyRevision }
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
background: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
.edit-site-global-styles-screen-revisions__changes,
|
|
67
|
+
.edit-site-global-styles-screen-revisions__changes > li,
|
|
68
68
|
.edit-site-global-styles-screen-revisions__meta,
|
|
69
69
|
.edit-site-global-styles-screen-revisions__applied-text {
|
|
70
70
|
color: $gray-900;
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
width: 100%;
|
|
93
93
|
height: auto;
|
|
94
94
|
display: block;
|
|
95
|
-
padding: $grid-unit-15 $grid-unit-15 $grid-unit-
|
|
95
|
+
padding: $grid-unit-15 $grid-unit-15 $grid-unit-05 $grid-unit-50;
|
|
96
96
|
z-index: 1;
|
|
97
97
|
position: relative;
|
|
98
98
|
outline-offset: -2px;
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
.edit-site-global-styles-screen-revisions__applied-text {
|
|
104
104
|
align-self: flex-start;
|
|
105
105
|
// Left margin = left padding of .edit-site-global-styles-screen-revisions__revision-button.
|
|
106
|
-
margin:
|
|
106
|
+
margin: $grid-unit-05 $grid-unit-15 $grid-unit-15 $grid-unit-50;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
.edit-site-global-styles-screen-revisions__changes,
|
|
@@ -125,13 +125,14 @@
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
.edit-site-global-styles-screen-revisions__changes,
|
|
129
128
|
.edit-site-global-styles-screen-revisions__meta {
|
|
130
129
|
display: flex;
|
|
131
130
|
justify-content: start;
|
|
132
131
|
width: 100%;
|
|
133
132
|
align-items: flex-start;
|
|
134
133
|
text-align: left;
|
|
134
|
+
margin-bottom: $grid-unit-05;
|
|
135
|
+
|
|
135
136
|
img {
|
|
136
137
|
width: $grid-unit-20;
|
|
137
138
|
height: $grid-unit-20;
|
|
@@ -145,10 +146,14 @@
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
.edit-site-global-styles-screen-revisions__changes {
|
|
148
|
-
margin-bottom: $grid-unit-05;
|
|
149
149
|
text-align: left;
|
|
150
|
-
color: $gray-900;
|
|
151
150
|
line-height: $default-line-height;
|
|
151
|
+
margin-left: $grid-unit-15;
|
|
152
|
+
list-style: disc;
|
|
153
|
+
|
|
154
|
+
li {
|
|
155
|
+
margin-bottom: $grid-unit-05;
|
|
156
|
+
}
|
|
152
157
|
}
|
|
153
158
|
|
|
154
159
|
.edit-site-global-styles-screen-revisions__pagination.edit-site-global-styles-screen-revisions__pagination {
|
|
@@ -8,18 +8,16 @@ function Media( { id, size = [ 'large', 'medium', 'thumbnail' ], ...props } ) {
|
|
|
8
8
|
const currentSize = size.find(
|
|
9
9
|
( s ) => !! media?.media_details?.sizes[ s ]
|
|
10
10
|
);
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
|
|
12
|
+
const mediaUrl =
|
|
13
|
+
media?.media_details?.sizes[ currentSize ]?.source_url ||
|
|
14
|
+
media?.source_url;
|
|
15
|
+
|
|
16
|
+
if ( ! mediaUrl ) {
|
|
13
17
|
return null;
|
|
14
18
|
}
|
|
15
19
|
|
|
16
|
-
return
|
|
17
|
-
<img
|
|
18
|
-
{ ...props }
|
|
19
|
-
src={ mediaDetails.source_url }
|
|
20
|
-
alt={ media.alt_text }
|
|
21
|
-
/>
|
|
22
|
-
);
|
|
20
|
+
return <img { ...props } src={ mediaUrl } alt={ media.alt_text } />;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
export default Media;
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
__experimentalNavigatorScreen as NavigatorScreen,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
15
|
+
import { __ } from '@wordpress/i18n';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Internal dependencies
|
|
@@ -31,7 +32,8 @@ import SidebarNavigationScreenTemplatesBrowse from '../sidebar-navigation-screen
|
|
|
31
32
|
import SaveHub from '../save-hub';
|
|
32
33
|
import { unlock } from '../../lock-unlock';
|
|
33
34
|
import SidebarNavigationScreenPages from '../sidebar-navigation-screen-pages';
|
|
34
|
-
import
|
|
35
|
+
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
36
|
+
import DataViewsSidebarContent from '../sidebar-dataviews';
|
|
35
37
|
import SidebarNavigationScreenPage from '../sidebar-navigation-screen-page';
|
|
36
38
|
|
|
37
39
|
const { useLocation } = unlock( routerPrivateApis );
|
|
@@ -69,7 +71,10 @@ function SidebarScreens() {
|
|
|
69
71
|
<SidebarNavigationScreenPages />
|
|
70
72
|
</SidebarScreenWrapper>
|
|
71
73
|
<SidebarScreenWrapper path="/pages">
|
|
72
|
-
<
|
|
74
|
+
<SidebarNavigationScreen
|
|
75
|
+
title={ __( 'Pages' ) }
|
|
76
|
+
content={ <DataViewsSidebarContent /> }
|
|
77
|
+
/>
|
|
73
78
|
</SidebarScreenWrapper>
|
|
74
79
|
<SidebarScreenWrapper path="/page/:postId">
|
|
75
80
|
<SidebarNavigationScreenPage />
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { __
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { trash } from '@wordpress/icons';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -49,7 +49,7 @@ const DEFAULT_PAGE_BASE = {
|
|
|
49
49
|
export const DEFAULT_VIEWS = {
|
|
50
50
|
page: [
|
|
51
51
|
{
|
|
52
|
-
title:
|
|
52
|
+
title: __( 'All pages' ),
|
|
53
53
|
slug: 'all',
|
|
54
54
|
view: DEFAULT_PAGE_BASE,
|
|
55
55
|
},
|
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
import { Modal, Flex, FlexItem, Button } from '@wordpress/components';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { useState, useMemo } from '@wordpress/element';
|
|
7
|
-
import {
|
|
8
|
-
__experimentalBlockPatternsList as BlockPatternsList,
|
|
9
|
-
store as blockEditorStore,
|
|
10
|
-
} from '@wordpress/block-editor';
|
|
7
|
+
import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
|
|
11
8
|
import { useSelect } from '@wordpress/data';
|
|
12
9
|
import { useAsyncList } from '@wordpress/compose';
|
|
13
10
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
@@ -42,14 +39,13 @@ function useFallbackTemplateContent( slug, isCustom = false ) {
|
|
|
42
39
|
function useStartPatterns( fallbackContent ) {
|
|
43
40
|
const { slug, patterns } = useSelect( ( select ) => {
|
|
44
41
|
const { getEditedPostType, getEditedPostId } = select( editSiteStore );
|
|
45
|
-
const { getEntityRecord } = select( coreStore );
|
|
42
|
+
const { getEntityRecord, getBlockPatterns } = select( coreStore );
|
|
46
43
|
const postId = getEditedPostId();
|
|
47
44
|
const postType = getEditedPostType();
|
|
48
45
|
const record = getEntityRecord( 'postType', postType, postId );
|
|
49
|
-
const { getSettings } = select( blockEditorStore );
|
|
50
46
|
return {
|
|
51
47
|
slug: record.slug,
|
|
52
|
-
patterns:
|
|
48
|
+
patterns: getBlockPatterns(),
|
|
53
49
|
};
|
|
54
50
|
}, [] );
|
|
55
51
|
|
|
@@ -77,9 +77,9 @@ function usePageContentFocusCommands() {
|
|
|
77
77
|
if ( currentPostType !== 'wp_template' ) {
|
|
78
78
|
commands.push( {
|
|
79
79
|
name: 'core/switch-to-template-focus',
|
|
80
|
-
/* translators: %1$s: template title */
|
|
81
80
|
label: sprintf(
|
|
82
|
-
|
|
81
|
+
/* translators: %s: template title */
|
|
82
|
+
__( 'Edit template: %s' ),
|
|
83
83
|
decodeEntities( template.title )
|
|
84
84
|
),
|
|
85
85
|
icon: layout,
|
|
@@ -154,14 +154,14 @@ function useManipulateDocumentCommands() {
|
|
|
154
154
|
if ( isTemplateRevertable( template ) && ! isEditingPage ) {
|
|
155
155
|
const label =
|
|
156
156
|
template.type === TEMPLATE_POST_TYPE
|
|
157
|
-
?
|
|
158
|
-
|
|
159
|
-
'Reset template: %s',
|
|
157
|
+
? sprintf(
|
|
158
|
+
/* translators: %s: template title */
|
|
159
|
+
__( 'Reset template: %s' ),
|
|
160
160
|
decodeEntities( template.title )
|
|
161
161
|
)
|
|
162
|
-
:
|
|
163
|
-
|
|
164
|
-
'Reset template part: %s',
|
|
162
|
+
: sprintf(
|
|
163
|
+
/* translators: %s: template part title */
|
|
164
|
+
__( 'Reset template part: %s' ),
|
|
165
165
|
decodeEntities( template.title )
|
|
166
166
|
);
|
|
167
167
|
commands.push( {
|
|
@@ -178,14 +178,14 @@ function useManipulateDocumentCommands() {
|
|
|
178
178
|
if ( isTemplateRemovable( template ) && ! isEditingPage ) {
|
|
179
179
|
const label =
|
|
180
180
|
template.type === TEMPLATE_POST_TYPE
|
|
181
|
-
?
|
|
182
|
-
|
|
183
|
-
'Delete template: %s',
|
|
181
|
+
? sprintf(
|
|
182
|
+
/* translators: %s: template title */
|
|
183
|
+
__( 'Delete template: %s' ),
|
|
184
184
|
decodeEntities( template.title )
|
|
185
185
|
)
|
|
186
|
-
:
|
|
187
|
-
|
|
188
|
-
'Delete template part: %s',
|
|
186
|
+
: sprintf(
|
|
187
|
+
/* translators: %s: template part title */
|
|
188
|
+
__( 'Delete template part: %s' ),
|
|
189
189
|
decodeEntities( template.title )
|
|
190
190
|
);
|
|
191
191
|
const path =
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = SidebarNavigationScreenPagesDataViews;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _components = require("@wordpress/components");
|
|
10
|
-
var _icons = require("@wordpress/icons");
|
|
11
|
-
var _element = require("@wordpress/element");
|
|
12
|
-
var _coreData = require("@wordpress/core-data");
|
|
13
|
-
var _htmlEntities = require("@wordpress/html-entities");
|
|
14
|
-
var _i18n = require("@wordpress/i18n");
|
|
15
|
-
var _data = require("@wordpress/data");
|
|
16
|
-
var _link = require("../routes/link");
|
|
17
|
-
var _constants = require("../../utils/constants");
|
|
18
|
-
var _sidebarNavigationItem = _interopRequireDefault(require("../sidebar-navigation-item"));
|
|
19
|
-
var _sidebarNavigationScreen = _interopRequireDefault(require("../sidebar-navigation-screen"));
|
|
20
|
-
var _sidebarDataviews = _interopRequireDefault(require("../sidebar-dataviews"));
|
|
21
|
-
/**
|
|
22
|
-
* WordPress dependencies
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Internal dependencies
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
const PageItem = ({
|
|
30
|
-
postType = 'page',
|
|
31
|
-
postId,
|
|
32
|
-
...props
|
|
33
|
-
}) => {
|
|
34
|
-
const linkInfo = (0, _link.useLink)({
|
|
35
|
-
postType,
|
|
36
|
-
postId
|
|
37
|
-
}, {
|
|
38
|
-
backPath: '/page'
|
|
39
|
-
});
|
|
40
|
-
return (0, _react.createElement)(_sidebarNavigationItem.default, {
|
|
41
|
-
...linkInfo,
|
|
42
|
-
...props
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
function SidebarNavigationScreenPagesDataViews() {
|
|
46
|
-
const {
|
|
47
|
-
records: templateRecords
|
|
48
|
-
} = (0, _coreData.useEntityRecords)('postType', _constants.TEMPLATE_POST_TYPE, {
|
|
49
|
-
per_page: -1
|
|
50
|
-
});
|
|
51
|
-
const {
|
|
52
|
-
frontPage,
|
|
53
|
-
postsPage
|
|
54
|
-
} = (0, _data.useSelect)(select => {
|
|
55
|
-
const {
|
|
56
|
-
getEntityRecord
|
|
57
|
-
} = select(_coreData.store);
|
|
58
|
-
const siteSettings = getEntityRecord('root', 'site');
|
|
59
|
-
return {
|
|
60
|
-
frontPage: siteSettings?.page_on_front,
|
|
61
|
-
postsPage: siteSettings?.page_for_posts
|
|
62
|
-
};
|
|
63
|
-
}, []);
|
|
64
|
-
const templates = (0, _element.useMemo)(() => {
|
|
65
|
-
if (!templateRecords) {
|
|
66
|
-
return [];
|
|
67
|
-
}
|
|
68
|
-
const isHomePageBlog = frontPage === postsPage;
|
|
69
|
-
const homeTemplate = templateRecords?.find(template => template.slug === 'front-page') || templateRecords?.find(template => template.slug === 'home') || templateRecords?.find(template => template.slug === 'index');
|
|
70
|
-
return [isHomePageBlog ? homeTemplate : null, ...templateRecords?.filter(({
|
|
71
|
-
slug
|
|
72
|
-
}) => ['404', 'search'].includes(slug))].filter(Boolean);
|
|
73
|
-
}, [templateRecords, frontPage, postsPage]);
|
|
74
|
-
return (0, _react.createElement)(_sidebarNavigationScreen.default, {
|
|
75
|
-
title: (0, _i18n.__)('Pages'),
|
|
76
|
-
description: (0, _i18n.__)('Browse and manage pages.'),
|
|
77
|
-
content: (0, _react.createElement)(_sidebarDataviews.default, null),
|
|
78
|
-
backPath: "/page",
|
|
79
|
-
footer: (0, _react.createElement)(_components.__experimentalVStack, {
|
|
80
|
-
spacing: 0
|
|
81
|
-
}, templates?.map(item => (0, _react.createElement)(PageItem, {
|
|
82
|
-
postType: _constants.TEMPLATE_POST_TYPE,
|
|
83
|
-
postId: item.id,
|
|
84
|
-
key: item.id,
|
|
85
|
-
icon: _icons.layout,
|
|
86
|
-
withChevron: true
|
|
87
|
-
}, (0, _react.createElement)(_components.__experimentalTruncate, {
|
|
88
|
-
numberOfLines: 1
|
|
89
|
-
}, (0, _htmlEntities.decodeEntities)(item.title?.rendered || (0, _i18n.__)('(no title)'))))))
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_icons","_element","_coreData","_htmlEntities","_i18n","_data","_link","_constants","_sidebarNavigationItem","_interopRequireDefault","_sidebarNavigationScreen","_sidebarDataviews","PageItem","postType","postId","props","linkInfo","useLink","backPath","_react","createElement","default","SidebarNavigationScreenPagesDataViews","records","templateRecords","useEntityRecords","TEMPLATE_POST_TYPE","per_page","frontPage","postsPage","useSelect","select","getEntityRecord","coreStore","siteSettings","page_on_front","page_for_posts","templates","useMemo","isHomePageBlog","homeTemplate","find","template","slug","filter","includes","Boolean","title","__","description","content","footer","__experimentalVStack","spacing","map","item","id","key","icon","layout","withChevron","__experimentalTruncate","numberOfLines","decodeEntities","rendered"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pages-dataviews/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { layout } from '@wordpress/icons';\nimport { useMemo } from '@wordpress/element';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useLink } from '../routes/link';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport DataViewsSidebarContent from '../sidebar-dataviews';\n\nconst PageItem = ( { postType = 'page', postId, ...props } ) => {\n\tconst linkInfo = useLink(\n\t\t{\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t},\n\t\t{\n\t\t\tbackPath: '/page',\n\t\t}\n\t);\n\treturn <SidebarNavigationItem { ...linkInfo } { ...props } />;\n};\n\nexport default function SidebarNavigationScreenPagesDataViews() {\n\tconst { records: templateRecords } = useEntityRecords(\n\t\t'postType',\n\t\tTEMPLATE_POST_TYPE,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\n\tconst { frontPage, postsPage } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\treturn {\n\t\t\tfrontPage: siteSettings?.page_on_front,\n\t\t\tpostsPage: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\n\tconst templates = useMemo( () => {\n\t\tif ( ! templateRecords ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst isHomePageBlog = frontPage === postsPage;\n\t\tconst homeTemplate =\n\t\t\ttemplateRecords?.find(\n\t\t\t\t( template ) => template.slug === 'front-page'\n\t\t\t) ||\n\t\t\ttemplateRecords?.find( ( template ) => template.slug === 'home' ) ||\n\t\t\ttemplateRecords?.find( ( template ) => template.slug === 'index' );\n\n\t\treturn [\n\t\t\tisHomePageBlog ? homeTemplate : null,\n\t\t\t...templateRecords?.filter( ( { slug } ) =>\n\t\t\t\t[ '404', 'search' ].includes( slug )\n\t\t\t),\n\t\t].filter( Boolean );\n\t}, [ templateRecords, frontPage, postsPage ] );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ __( 'Pages' ) }\n\t\t\tdescription={ __( 'Browse and manage pages.' ) }\n\t\t\tcontent={ <DataViewsSidebarContent /> }\n\t\t\tbackPath=\"/page\"\n\t\t\tfooter={\n\t\t\t\t<VStack spacing={ 0 }>\n\t\t\t\t\t{ templates?.map( ( item ) => (\n\t\t\t\t\t\t<PageItem\n\t\t\t\t\t\t\tpostType={ TEMPLATE_POST_TYPE }\n\t\t\t\t\t\t\tpostId={ item.id }\n\t\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\titem.title?.rendered || __( '(no title)' )\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</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IAAAhC,MAAA,CAAAC,aAAA,EAACtB,WAAA,CAAAsD,oBAAM;MAACC,OAAO,EAAG;IAAG,GAClBhB,SAAS,EAAEiB,GAAG,CAAIC,IAAI,IACvB,IAAApC,MAAA,CAAAC,aAAA,EAACR,QAAQ;MACRC,QAAQ,EAAGa,6BAAoB;MAC/BZ,MAAM,EAAGyC,IAAI,CAACC,EAAI;MAClBC,GAAG,EAAGF,IAAI,CAACC,EAAI;MACfE,IAAI,EAAGC,aAAQ;MACfC,WAAW;IAAA,GAEX,IAAAzC,MAAA,CAAAC,aAAA,EAACtB,WAAA,CAAA+D,sBAAQ;MAACC,aAAa,EAAG;IAAG,GAC1B,IAAAC,4BAAc,EACfR,IAAI,CAACR,KAAK,EAAEiB,QAAQ,IAAI,IAAAhB,QAAE,EAAE,YAAa,CAC1C,CACS,CACD,CACT,CACK;EACR,CACD,CAAC;AAEJ"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { __experimentalTruncate as Truncate, __experimentalVStack as VStack } from '@wordpress/components';
|
|
6
|
-
import { layout } from '@wordpress/icons';
|
|
7
|
-
import { useMemo } from '@wordpress/element';
|
|
8
|
-
import { useEntityRecords, store as coreStore } from '@wordpress/core-data';
|
|
9
|
-
import { decodeEntities } from '@wordpress/html-entities';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { useSelect } from '@wordpress/data';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { useLink } from '../routes/link';
|
|
17
|
-
import { TEMPLATE_POST_TYPE } from '../../utils/constants';
|
|
18
|
-
import SidebarNavigationItem from '../sidebar-navigation-item';
|
|
19
|
-
import SidebarNavigationScreen from '../sidebar-navigation-screen';
|
|
20
|
-
import DataViewsSidebarContent from '../sidebar-dataviews';
|
|
21
|
-
const PageItem = ({
|
|
22
|
-
postType = 'page',
|
|
23
|
-
postId,
|
|
24
|
-
...props
|
|
25
|
-
}) => {
|
|
26
|
-
const linkInfo = useLink({
|
|
27
|
-
postType,
|
|
28
|
-
postId
|
|
29
|
-
}, {
|
|
30
|
-
backPath: '/page'
|
|
31
|
-
});
|
|
32
|
-
return createElement(SidebarNavigationItem, {
|
|
33
|
-
...linkInfo,
|
|
34
|
-
...props
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
export default function SidebarNavigationScreenPagesDataViews() {
|
|
38
|
-
const {
|
|
39
|
-
records: templateRecords
|
|
40
|
-
} = useEntityRecords('postType', TEMPLATE_POST_TYPE, {
|
|
41
|
-
per_page: -1
|
|
42
|
-
});
|
|
43
|
-
const {
|
|
44
|
-
frontPage,
|
|
45
|
-
postsPage
|
|
46
|
-
} = useSelect(select => {
|
|
47
|
-
const {
|
|
48
|
-
getEntityRecord
|
|
49
|
-
} = select(coreStore);
|
|
50
|
-
const siteSettings = getEntityRecord('root', 'site');
|
|
51
|
-
return {
|
|
52
|
-
frontPage: siteSettings?.page_on_front,
|
|
53
|
-
postsPage: siteSettings?.page_for_posts
|
|
54
|
-
};
|
|
55
|
-
}, []);
|
|
56
|
-
const templates = useMemo(() => {
|
|
57
|
-
if (!templateRecords) {
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
const isHomePageBlog = frontPage === postsPage;
|
|
61
|
-
const homeTemplate = templateRecords?.find(template => template.slug === 'front-page') || templateRecords?.find(template => template.slug === 'home') || templateRecords?.find(template => template.slug === 'index');
|
|
62
|
-
return [isHomePageBlog ? homeTemplate : null, ...templateRecords?.filter(({
|
|
63
|
-
slug
|
|
64
|
-
}) => ['404', 'search'].includes(slug))].filter(Boolean);
|
|
65
|
-
}, [templateRecords, frontPage, postsPage]);
|
|
66
|
-
return createElement(SidebarNavigationScreen, {
|
|
67
|
-
title: __('Pages'),
|
|
68
|
-
description: __('Browse and manage pages.'),
|
|
69
|
-
content: createElement(DataViewsSidebarContent, null),
|
|
70
|
-
backPath: "/page",
|
|
71
|
-
footer: createElement(VStack, {
|
|
72
|
-
spacing: 0
|
|
73
|
-
}, templates?.map(item => createElement(PageItem, {
|
|
74
|
-
postType: TEMPLATE_POST_TYPE,
|
|
75
|
-
postId: item.id,
|
|
76
|
-
key: item.id,
|
|
77
|
-
icon: layout,
|
|
78
|
-
withChevron: true
|
|
79
|
-
}, createElement(Truncate, {
|
|
80
|
-
numberOfLines: 1
|
|
81
|
-
}, decodeEntities(item.title?.rendered || __('(no title)'))))))
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalTruncate","Truncate","__experimentalVStack","VStack","layout","useMemo","useEntityRecords","store","coreStore","decodeEntities","__","useSelect","useLink","TEMPLATE_POST_TYPE","SidebarNavigationItem","SidebarNavigationScreen","DataViewsSidebarContent","PageItem","postType","postId","props","linkInfo","backPath","createElement","SidebarNavigationScreenPagesDataViews","records","templateRecords","per_page","frontPage","postsPage","select","getEntityRecord","siteSettings","page_on_front","page_for_posts","templates","isHomePageBlog","homeTemplate","find","template","slug","filter","includes","Boolean","title","description","content","footer","spacing","map","item","id","key","icon","withChevron","numberOfLines","rendered"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pages-dataviews/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTruncate as Truncate,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { layout } from '@wordpress/icons';\nimport { useMemo } from '@wordpress/element';\nimport { useEntityRecords, store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useLink } from '../routes/link';\nimport { TEMPLATE_POST_TYPE } from '../../utils/constants';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\nimport SidebarNavigationScreen from '../sidebar-navigation-screen';\nimport DataViewsSidebarContent from '../sidebar-dataviews';\n\nconst PageItem = ( { postType = 'page', postId, ...props } ) => {\n\tconst linkInfo = useLink(\n\t\t{\n\t\t\tpostType,\n\t\t\tpostId,\n\t\t},\n\t\t{\n\t\t\tbackPath: '/page',\n\t\t}\n\t);\n\treturn <SidebarNavigationItem { ...linkInfo } { ...props } />;\n};\n\nexport default function SidebarNavigationScreenPagesDataViews() {\n\tconst { records: templateRecords } = useEntityRecords(\n\t\t'postType',\n\t\tTEMPLATE_POST_TYPE,\n\t\t{\n\t\t\tper_page: -1,\n\t\t}\n\t);\n\n\tconst { frontPage, postsPage } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord } = select( coreStore );\n\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\treturn {\n\t\t\tfrontPage: siteSettings?.page_on_front,\n\t\t\tpostsPage: siteSettings?.page_for_posts,\n\t\t};\n\t}, [] );\n\n\tconst templates = useMemo( () => {\n\t\tif ( ! templateRecords ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst isHomePageBlog = frontPage === postsPage;\n\t\tconst homeTemplate =\n\t\t\ttemplateRecords?.find(\n\t\t\t\t( template ) => template.slug === 'front-page'\n\t\t\t) ||\n\t\t\ttemplateRecords?.find( ( template ) => template.slug === 'home' ) ||\n\t\t\ttemplateRecords?.find( ( template ) => template.slug === 'index' );\n\n\t\treturn [\n\t\t\tisHomePageBlog ? homeTemplate : null,\n\t\t\t...templateRecords?.filter( ( { slug } ) =>\n\t\t\t\t[ '404', 'search' ].includes( slug )\n\t\t\t),\n\t\t].filter( Boolean );\n\t}, [ templateRecords, frontPage, postsPage ] );\n\n\treturn (\n\t\t<SidebarNavigationScreen\n\t\t\ttitle={ __( 'Pages' ) }\n\t\t\tdescription={ __( 'Browse and manage pages.' ) }\n\t\t\tcontent={ <DataViewsSidebarContent /> }\n\t\t\tbackPath=\"/page\"\n\t\t\tfooter={\n\t\t\t\t<VStack spacing={ 0 }>\n\t\t\t\t\t{ templates?.map( ( item ) => (\n\t\t\t\t\t\t<PageItem\n\t\t\t\t\t\t\tpostType={ TEMPLATE_POST_TYPE }\n\t\t\t\t\t\t\tpostId={ item.id }\n\t\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\t\ticon={ layout }\n\t\t\t\t\t\t\twithChevron\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Truncate numberOfLines={ 1 }>\n\t\t\t\t\t\t\t\t{ decodeEntities(\n\t\t\t\t\t\t\t\t\titem.title?.rendered || __( '(no title)' )\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</PageItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</VStack>\n\t\t\t}\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,sBAAsB,IAAIC,QAAQ,EAClCC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,gBAAgB,EAAEC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAC3E,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,OAAO,QAAQ,gBAAgB;AACxC,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,uBAAuB,MAAM,8BAA8B;AAClE,OAAOC,uBAAuB,MAAM,sBAAsB;AAE1D,MAAMC,QAAQ,GAAGA,CAAE;EAAEC,QAAQ,GAAG,MAAM;EAAEC,MAAM;EAAE,GAAGC;AAAM,CAAC,KAAM;EAC/D,MAAMC,QAAQ,GAAGT,OAAO,CACvB;IACCM,QAAQ;IACRC;EACD,CAAC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