@wordpress/edit-site 6.3.0 → 6.4.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/add-new-pattern/index.js +8 -2
- package/build/components/add-new-pattern/index.js.map +1 -1
- package/build/components/add-new-template/index.js +3 -1
- package/build/components/add-new-template/index.js.map +1 -1
- package/build/components/block-editor/use-site-editor-settings.js +1 -82
- package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build/components/global-styles/block-preview-panel.js +14 -5
- package/build/components/global-styles/block-preview-panel.js.map +1 -1
- package/build/components/global-styles/font-families.js +42 -23
- package/build/components/global-styles/font-families.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +4 -4
- package/build/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js +58 -10
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +39 -0
- package/build/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js.map +1 -0
- package/build/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +39 -0
- package/build/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-size-preview.js +44 -0
- package/build/components/global-styles/font-sizes/font-size-preview.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-size.js +213 -0
- package/build/components/global-styles/font-sizes/font-size.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-sizes-count.js +50 -0
- package/build/components/global-styles/font-sizes/font-sizes-count.js.map +1 -0
- package/build/components/global-styles/font-sizes/font-sizes.js +163 -0
- package/build/components/global-styles/font-sizes/font-sizes.js.map +1 -0
- package/build/components/global-styles/font-sizes/rename-font-size-dialog.js +67 -0
- package/build/components/global-styles/font-sizes/rename-font-size-dialog.js.map +1 -0
- package/build/components/global-styles/screen-block.js +10 -8
- package/build/components/global-styles/screen-block.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +2 -2
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/global-styles/screen-typography.js +3 -2
- package/build/components/global-styles/screen-typography.js.map +1 -1
- package/build/components/global-styles/size-control/index.js +85 -0
- package/build/components/global-styles/size-control/index.js.map +1 -0
- package/build/components/global-styles/style-variations-container.js +3 -0
- package/build/components/global-styles/style-variations-container.js.map +1 -1
- package/build/components/global-styles/ui.js +8 -0
- package/build/components/global-styles/ui.js.map +1 -1
- package/build/components/global-styles/variations/variations-color.js.map +1 -1
- package/build/components/global-styles/variations/variations-typography.js +1 -1
- package/build/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build/components/layout/index.js +6 -0
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/router.js +14 -6
- package/build/components/layout/router.js.map +1 -1
- package/build/components/page-patterns/header.js +1 -1
- package/build/components/page-patterns/header.js.map +1 -1
- package/build/components/page-patterns/index.js +23 -11
- package/build/components/page-patterns/index.js.map +1 -1
- package/build/components/page-templates/index.js +41 -34
- package/build/components/page-templates/index.js.map +1 -1
- package/build/components/post-edit/index.js +105 -0
- package/build/components/post-edit/index.js.map +1 -0
- package/build/components/post-fields/index.js +314 -0
- package/build/components/post-fields/index.js.map +1 -0
- package/build/components/post-list/index.js +281 -0
- package/build/components/post-list/index.js.map +1 -0
- package/build/components/posts-app/router.js +3 -3
- package/build/components/posts-app/router.js.map +1 -1
- package/build/components/sidebar-dataviews/default-views.js +22 -10
- package/build/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build/components/sidebar-dataviews/index.js +40 -1
- package/build/components/sidebar-dataviews/index.js.map +1 -1
- package/build/components/sidebar-navigation-screen-global-styles/content.js +64 -0
- package/build/components/sidebar-navigation-screen-global-styles/content.js.map +1 -0
- package/build/components/sidebar-navigation-screen-global-styles/index.js +2 -47
- package/build/components/sidebar-navigation-screen-global-styles/index.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/index.js +5 -1
- package/build/index.js.map +1 -1
- package/build/store/selectors.js +34 -6
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-filtered-template-parts.js +64 -0
- package/build/utils/get-filtered-template-parts.js.map +1 -0
- package/build-module/components/add-new-pattern/index.js +8 -2
- package/build-module/components/add-new-pattern/index.js.map +1 -1
- package/build-module/components/add-new-template/index.js +3 -1
- package/build-module/components/add-new-template/index.js.map +1 -1
- package/build-module/components/block-editor/use-site-editor-settings.js +1 -82
- package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
- package/build-module/components/global-styles/block-preview-panel.js +14 -5
- package/build-module/components/global-styles/block-preview-panel.js.map +1 -1
- package/build-module/components/global-styles/font-families.js +44 -25
- package/build-module/components/global-styles/font-families.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +4 -4
- package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js +61 -13
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +32 -0
- package/build-module/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +32 -0
- package/build-module/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-size-preview.js +37 -0
- package/build-module/components/global-styles/font-sizes/font-size-preview.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-size.js +207 -0
- package/build-module/components/global-styles/font-sizes/font-size.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-sizes-count.js +43 -0
- package/build-module/components/global-styles/font-sizes/font-sizes-count.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/font-sizes.js +157 -0
- package/build-module/components/global-styles/font-sizes/font-sizes.js.map +1 -0
- package/build-module/components/global-styles/font-sizes/rename-font-size-dialog.js +61 -0
- package/build-module/components/global-styles/font-sizes/rename-font-size-dialog.js.map +1 -0
- package/build-module/components/global-styles/screen-block.js +10 -8
- package/build-module/components/global-styles/screen-block.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +2 -2
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/global-styles/screen-typography.js +3 -2
- package/build-module/components/global-styles/screen-typography.js.map +1 -1
- package/build-module/components/global-styles/size-control/index.js +79 -0
- package/build-module/components/global-styles/size-control/index.js.map +1 -0
- package/build-module/components/global-styles/style-variations-container.js +3 -0
- package/build-module/components/global-styles/style-variations-container.js.map +1 -1
- package/build-module/components/global-styles/ui.js +8 -0
- package/build-module/components/global-styles/ui.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-color.js +1 -1
- package/build-module/components/global-styles/variations/variations-color.js.map +1 -1
- package/build-module/components/global-styles/variations/variations-typography.js +1 -2
- package/build-module/components/global-styles/variations/variations-typography.js.map +1 -1
- package/build-module/components/layout/index.js +6 -0
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/router.js +14 -6
- package/build-module/components/layout/router.js.map +1 -1
- package/build-module/components/page-patterns/header.js +1 -1
- package/build-module/components/page-patterns/header.js.map +1 -1
- package/build-module/components/page-patterns/index.js +23 -11
- package/build-module/components/page-patterns/index.js.map +1 -1
- package/build-module/components/page-templates/index.js +43 -37
- package/build-module/components/page-templates/index.js.map +1 -1
- package/build-module/components/post-edit/index.js +98 -0
- package/build-module/components/post-edit/index.js.map +1 -0
- package/build-module/components/post-fields/index.js +306 -0
- package/build-module/components/post-fields/index.js.map +1 -0
- package/build-module/components/post-list/index.js +275 -0
- package/build-module/components/post-list/index.js.map +1 -0
- package/build-module/components/posts-app/router.js +3 -3
- package/build-module/components/posts-app/router.js.map +1 -1
- package/build-module/components/sidebar-dataviews/default-views.js +21 -9
- package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
- package/build-module/components/sidebar-dataviews/index.js +42 -3
- package/build-module/components/sidebar-dataviews/index.js.map +1 -1
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js +57 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/content.js.map +1 -0
- package/build-module/components/sidebar-navigation-screen-global-styles/index.js +2 -47
- package/build-module/components/sidebar-navigation-screen-global-styles/index.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/index.js +5 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/selectors.js +35 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-filtered-template-parts.js +57 -0
- package/build-module/utils/get-filtered-template-parts.js.map +1 -0
- package/build-style/posts-rtl.css +581 -503
- package/build-style/posts.css +581 -503
- package/build-style/style-rtl.css +621 -519
- package/build-style/style.css +621 -519
- package/package.json +41 -41
- package/src/components/add-new-pattern/index.js +8 -2
- package/src/components/add-new-template/index.js +4 -1
- package/src/components/add-new-template/style.scss +4 -6
- package/src/components/block-editor/use-site-editor-settings.js +15 -111
- package/src/components/global-styles/block-preview-panel.js +22 -9
- package/src/components/global-styles/font-families.js +66 -31
- package/src/components/global-styles/font-library-modal/index.js +4 -2
- package/src/components/global-styles/font-library-modal/installed-fonts.js +92 -11
- package/src/components/global-styles/font-library-modal/style.scss +9 -0
- package/src/components/global-styles/font-sizes/confirm-delete-font-size-dialog.js +43 -0
- package/src/components/global-styles/font-sizes/confirm-reset-font-sizes-dialog.js +37 -0
- package/src/components/global-styles/font-sizes/font-size-preview.js +43 -0
- package/src/components/global-styles/font-sizes/font-size.js +250 -0
- package/src/components/global-styles/font-sizes/font-sizes-count.js +40 -0
- package/src/components/global-styles/font-sizes/font-sizes.js +263 -0
- package/src/components/global-styles/font-sizes/rename-font-size-dialog.js +70 -0
- package/src/components/global-styles/screen-block.js +12 -14
- package/src/components/global-styles/screen-style-variations.js +2 -2
- package/src/components/global-styles/screen-typography.js +3 -2
- package/src/components/global-styles/size-control/index.js +86 -0
- package/src/components/global-styles/style-variations-container.js +4 -0
- package/src/components/global-styles/style.scss +13 -3
- package/src/components/global-styles/ui.js +10 -0
- package/src/components/global-styles/variations/variations-color.js +1 -1
- package/src/components/global-styles/variations/variations-typography.js +1 -2
- package/src/components/layout/index.js +11 -0
- package/src/components/layout/router.js +13 -5
- package/src/components/layout/style.scss +26 -8
- package/src/components/page-patterns/header.js +1 -1
- package/src/components/page-patterns/index.js +15 -8
- package/src/components/page-templates/index.js +51 -46
- package/src/components/page-templates/style.scss +5 -3
- package/src/components/post-edit/index.js +96 -0
- package/src/components/post-edit/style.scss +9 -0
- package/src/components/post-fields/index.js +345 -0
- package/src/components/post-list/index.js +326 -0
- package/src/components/{posts-app → post-list}/style.scss +12 -9
- package/src/components/posts-app/router.js +3 -3
- package/src/components/sidebar-dataviews/default-views.js +21 -9
- package/src/components/sidebar-dataviews/index.js +36 -1
- package/src/components/sidebar-navigation-screen-global-styles/content.js +55 -0
- package/src/components/sidebar-navigation-screen-global-styles/index.js +1 -55
- package/src/hooks/push-changes-to-global-styles/index.js +1 -1
- package/src/index.js +7 -1
- package/src/posts.scss +1 -1
- package/src/store/selectors.js +53 -14
- package/src/store/test/selectors.js +1 -26
- package/src/style.scss +2 -1
- package/src/utils/get-filtered-template-parts.js +61 -0
- package/src/utils/test/get-filtered-template-parts.js +127 -0
- package/build/components/global-styles/screen-background.js +0 -36
- package/build/components/global-styles/screen-background.js.map +0 -1
- package/build/components/posts-app/posts-list.js +0 -568
- package/build/components/posts-app/posts-list.js.map +0 -1
- package/build-module/components/global-styles/screen-background.js +0 -30
- package/build-module/components/global-styles/screen-background.js.map +0 -1
- package/build-module/components/posts-app/posts-list.js +0 -560
- package/build-module/components/posts-app/posts-list.js.map +0 -1
- package/src/components/global-styles/screen-background.js +0 -29
- package/src/components/posts-app/posts-list.js +0 -651
|
@@ -16,11 +16,12 @@ import {
|
|
|
16
16
|
Flex,
|
|
17
17
|
Notice,
|
|
18
18
|
ProgressBar,
|
|
19
|
+
CheckboxControl,
|
|
19
20
|
} from '@wordpress/components';
|
|
20
21
|
import { useEntityRecord, store as coreStore } from '@wordpress/core-data';
|
|
21
22
|
import { useSelect } from '@wordpress/data';
|
|
22
23
|
import { useContext, useEffect, useState } from '@wordpress/element';
|
|
23
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
24
|
+
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
24
25
|
import { chevronLeft } from '@wordpress/icons';
|
|
25
26
|
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
26
27
|
|
|
@@ -31,7 +32,12 @@ import { FontLibraryContext } from './context';
|
|
|
31
32
|
import FontCard from './font-card';
|
|
32
33
|
import LibraryFontVariant from './library-font-variant';
|
|
33
34
|
import { sortFontFaces } from './utils/sort-font-faces';
|
|
34
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
setUIValuesNeeded,
|
|
37
|
+
loadFontFaceInBrowser,
|
|
38
|
+
unloadFontFaceInBrowser,
|
|
39
|
+
getDisplaySrcFromFontFace,
|
|
40
|
+
} from './utils';
|
|
35
41
|
import { unlock } from '../../../lock-unlock';
|
|
36
42
|
|
|
37
43
|
const { useGlobalSetting } = unlock( blockEditorPrivateApis );
|
|
@@ -49,8 +55,11 @@ function InstalledFonts() {
|
|
|
49
55
|
getFontFacesActivated,
|
|
50
56
|
notice,
|
|
51
57
|
setNotice,
|
|
52
|
-
fontFamilies,
|
|
53
58
|
} = useContext( FontLibraryContext );
|
|
59
|
+
|
|
60
|
+
const [ fontFamilies, setFontFamilies ] = useGlobalSetting(
|
|
61
|
+
'typography.fontFamilies'
|
|
62
|
+
);
|
|
54
63
|
const [ isConfirmDeleteOpen, setIsConfirmDeleteOpen ] = useState( false );
|
|
55
64
|
const [ baseFontFamilies ] = useGlobalSetting(
|
|
56
65
|
'typography.fontFamilies',
|
|
@@ -61,7 +70,6 @@ function InstalledFonts() {
|
|
|
61
70
|
const { __experimentalGetCurrentGlobalStylesId } = select( coreStore );
|
|
62
71
|
return __experimentalGetCurrentGlobalStylesId();
|
|
63
72
|
} );
|
|
64
|
-
|
|
65
73
|
const globalStyles = useEntityRecord(
|
|
66
74
|
'root',
|
|
67
75
|
'globalStyles',
|
|
@@ -93,7 +101,11 @@ function InstalledFonts() {
|
|
|
93
101
|
const { canUser } = select( coreStore );
|
|
94
102
|
return (
|
|
95
103
|
customFontFamilyId &&
|
|
96
|
-
canUser( 'delete',
|
|
104
|
+
canUser( 'delete', {
|
|
105
|
+
kind: 'postType',
|
|
106
|
+
name: 'wp_font_family',
|
|
107
|
+
id: customFontFamilyId,
|
|
108
|
+
} )
|
|
97
109
|
);
|
|
98
110
|
},
|
|
99
111
|
[ customFontFamilyId ]
|
|
@@ -144,6 +156,56 @@ function InstalledFonts() {
|
|
|
144
156
|
refreshLibrary();
|
|
145
157
|
}, [] );
|
|
146
158
|
|
|
159
|
+
// Get activated fonts count.
|
|
160
|
+
const activeFontsCount = libraryFontSelected
|
|
161
|
+
? getFontFacesActivated(
|
|
162
|
+
libraryFontSelected.slug,
|
|
163
|
+
libraryFontSelected.source
|
|
164
|
+
).length
|
|
165
|
+
: 0;
|
|
166
|
+
|
|
167
|
+
const selectedFontsCount =
|
|
168
|
+
libraryFontSelected?.fontFace?.length ??
|
|
169
|
+
( libraryFontSelected?.fontFamily ? 1 : 0 );
|
|
170
|
+
|
|
171
|
+
// Check if any fonts are selected.
|
|
172
|
+
const isIndeterminate =
|
|
173
|
+
activeFontsCount > 0 && activeFontsCount !== selectedFontsCount;
|
|
174
|
+
|
|
175
|
+
// Check if all fonts are selected.
|
|
176
|
+
const isSelectAllChecked = activeFontsCount === selectedFontsCount;
|
|
177
|
+
|
|
178
|
+
// Toggle select all fonts.
|
|
179
|
+
const toggleSelectAll = () => {
|
|
180
|
+
const initialFonts =
|
|
181
|
+
fontFamilies?.[ libraryFontSelected.source ]?.filter(
|
|
182
|
+
( f ) => f.slug !== libraryFontSelected.slug
|
|
183
|
+
) ?? [];
|
|
184
|
+
const newFonts = isSelectAllChecked
|
|
185
|
+
? initialFonts
|
|
186
|
+
: [ ...initialFonts, libraryFontSelected ];
|
|
187
|
+
|
|
188
|
+
setFontFamilies( {
|
|
189
|
+
...fontFamilies,
|
|
190
|
+
[ libraryFontSelected.source ]: newFonts,
|
|
191
|
+
} );
|
|
192
|
+
|
|
193
|
+
if ( libraryFontSelected.fontFace ) {
|
|
194
|
+
libraryFontSelected.fontFace.forEach( ( face ) => {
|
|
195
|
+
if ( isSelectAllChecked ) {
|
|
196
|
+
unloadFontFaceInBrowser( face, 'all' );
|
|
197
|
+
} else {
|
|
198
|
+
loadFontFaceInBrowser(
|
|
199
|
+
face,
|
|
200
|
+
getDisplaySrcFromFontFace( face?.src ),
|
|
201
|
+
'all'
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
} );
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const hasFonts = baseThemeFonts.length > 0 || baseCustomFonts.length > 0;
|
|
147
209
|
return (
|
|
148
210
|
<div className="font-library-modal__tabpanel-layout">
|
|
149
211
|
{ isResolvingLibrary && (
|
|
@@ -169,10 +231,18 @@ function InstalledFonts() {
|
|
|
169
231
|
{ notice.message }
|
|
170
232
|
</Notice>
|
|
171
233
|
) }
|
|
172
|
-
{
|
|
234
|
+
{ ! hasFonts && (
|
|
235
|
+
<Text as="p">
|
|
236
|
+
{ __( 'No fonts installed.' ) }
|
|
237
|
+
</Text>
|
|
238
|
+
) }
|
|
239
|
+
{ baseThemeFonts.length > 0 && (
|
|
173
240
|
<VStack>
|
|
174
241
|
<h2 className="font-library-modal__fonts-title">
|
|
175
|
-
{
|
|
242
|
+
{
|
|
243
|
+
/* translators: Heading for a list of fonts provided by the theme. */
|
|
244
|
+
_x( 'Theme', 'font source' )
|
|
245
|
+
}
|
|
176
246
|
</h2>
|
|
177
247
|
{ /*
|
|
178
248
|
* Disable reason: The `list` ARIA role is redundant but
|
|
@@ -183,7 +253,7 @@ function InstalledFonts() {
|
|
|
183
253
|
role="list"
|
|
184
254
|
className="font-library-modal__fonts-list"
|
|
185
255
|
>
|
|
186
|
-
{
|
|
256
|
+
{ baseThemeFonts.map( ( font ) => (
|
|
187
257
|
<li
|
|
188
258
|
key={ font.slug }
|
|
189
259
|
className="font-library-modal__fonts-list-item"
|
|
@@ -206,10 +276,13 @@ function InstalledFonts() {
|
|
|
206
276
|
{ /* eslint-enable jsx-a11y/no-redundant-roles */ }
|
|
207
277
|
</VStack>
|
|
208
278
|
) }
|
|
209
|
-
{
|
|
279
|
+
{ baseCustomFonts.length > 0 && (
|
|
210
280
|
<VStack>
|
|
211
281
|
<h2 className="font-library-modal__fonts-title">
|
|
212
|
-
{
|
|
282
|
+
{
|
|
283
|
+
/* translators: Heading for a list of fonts installed by the user. */
|
|
284
|
+
_x( 'Custom', 'font source' )
|
|
285
|
+
}
|
|
213
286
|
</h2>
|
|
214
287
|
{ /*
|
|
215
288
|
* Disable reason: The `list` ARIA role is redundant but
|
|
@@ -220,7 +293,7 @@ function InstalledFonts() {
|
|
|
220
293
|
role="list"
|
|
221
294
|
className="font-library-modal__fonts-list"
|
|
222
295
|
>
|
|
223
|
-
{
|
|
296
|
+
{ baseCustomFonts.map( ( font ) => (
|
|
224
297
|
<li
|
|
225
298
|
key={ font.slug }
|
|
226
299
|
className="font-library-modal__fonts-list-item"
|
|
@@ -295,6 +368,14 @@ function InstalledFonts() {
|
|
|
295
368
|
</Text>
|
|
296
369
|
<Spacer margin={ 4 } />
|
|
297
370
|
<VStack spacing={ 0 }>
|
|
371
|
+
<CheckboxControl
|
|
372
|
+
className="font-library-modal__select-all"
|
|
373
|
+
label={ __( 'Select all' ) }
|
|
374
|
+
checked={ isSelectAllChecked }
|
|
375
|
+
onChange={ toggleSelectAll }
|
|
376
|
+
indeterminate={ isIndeterminate }
|
|
377
|
+
__nextHasNoMarginBottom
|
|
378
|
+
/>
|
|
298
379
|
<Spacer margin={ 8 } />
|
|
299
380
|
{ getFontFacesToDisplay(
|
|
300
381
|
libraryFontSelected
|
|
@@ -186,3 +186,12 @@ button.font-library-modal__upload-area {
|
|
|
186
186
|
justify-content: center;
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
+
|
|
190
|
+
.font-library-modal__select-all {
|
|
191
|
+
padding: $grid-unit-20 $grid-unit-20 $grid-unit-20 $grid-unit-20 + $border-width;
|
|
192
|
+
|
|
193
|
+
.components-checkbox-control__label {
|
|
194
|
+
padding-left: $grid-unit-20;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
function ConfirmDeleteFontSizeDialog( {
|
|
8
|
+
fontSize,
|
|
9
|
+
isOpen,
|
|
10
|
+
toggleOpen,
|
|
11
|
+
handleRemoveFontSize,
|
|
12
|
+
} ) {
|
|
13
|
+
const handleConfirm = async () => {
|
|
14
|
+
toggleOpen();
|
|
15
|
+
handleRemoveFontSize( fontSize );
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const handleCancel = () => {
|
|
19
|
+
toggleOpen();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<ConfirmDialog
|
|
24
|
+
isOpen={ isOpen }
|
|
25
|
+
cancelButtonText={ __( 'Cancel' ) }
|
|
26
|
+
confirmButtonText={ __( 'Delete' ) }
|
|
27
|
+
onCancel={ handleCancel }
|
|
28
|
+
onConfirm={ handleConfirm }
|
|
29
|
+
size="medium"
|
|
30
|
+
>
|
|
31
|
+
{ fontSize &&
|
|
32
|
+
sprintf(
|
|
33
|
+
/* translators: %s: Name of the font size preset. */
|
|
34
|
+
__(
|
|
35
|
+
'Are you sure you want to delete "%s" font size preset?'
|
|
36
|
+
),
|
|
37
|
+
fontSize.name
|
|
38
|
+
) }
|
|
39
|
+
</ConfirmDialog>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default ConfirmDeleteFontSizeDialog;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
function ConfirmResetFontSizesDialog( {
|
|
8
|
+
text,
|
|
9
|
+
confirmButtonText,
|
|
10
|
+
isOpen,
|
|
11
|
+
toggleOpen,
|
|
12
|
+
onConfirm,
|
|
13
|
+
} ) {
|
|
14
|
+
const handleConfirm = async () => {
|
|
15
|
+
toggleOpen();
|
|
16
|
+
onConfirm();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const handleCancel = () => {
|
|
20
|
+
toggleOpen();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ConfirmDialog
|
|
25
|
+
isOpen={ isOpen }
|
|
26
|
+
cancelButtonText={ __( 'Cancel' ) }
|
|
27
|
+
confirmButtonText={ confirmButtonText }
|
|
28
|
+
onCancel={ handleCancel }
|
|
29
|
+
onConfirm={ handleConfirm }
|
|
30
|
+
size="medium"
|
|
31
|
+
>
|
|
32
|
+
{ text }
|
|
33
|
+
</ConfirmDialog>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default ConfirmResetFontSizesDialog;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
getComputedFluidTypographyValue,
|
|
6
|
+
privateApis as blockEditorPrivateApis,
|
|
7
|
+
} from '@wordpress/block-editor';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { unlock } from '../../../lock-unlock';
|
|
14
|
+
const { useGlobalStyle } = unlock( blockEditorPrivateApis );
|
|
15
|
+
|
|
16
|
+
function FontSizePreview( { fontSize } ) {
|
|
17
|
+
const [ font ] = useGlobalStyle( 'typography' );
|
|
18
|
+
|
|
19
|
+
const input =
|
|
20
|
+
fontSize?.fluid?.min && fontSize?.fluid?.max
|
|
21
|
+
? {
|
|
22
|
+
minimumFontSize: fontSize.fluid.min,
|
|
23
|
+
maximumFontSize: fontSize.fluid.max,
|
|
24
|
+
}
|
|
25
|
+
: {
|
|
26
|
+
fontSize: fontSize.size,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const computedFontSize = getComputedFluidTypographyValue( input );
|
|
30
|
+
return (
|
|
31
|
+
<div
|
|
32
|
+
className="edit-site-typography-preview"
|
|
33
|
+
style={ {
|
|
34
|
+
fontSize: computedFontSize,
|
|
35
|
+
fontFamily: font?.fontFamily ?? 'serif',
|
|
36
|
+
} }
|
|
37
|
+
>
|
|
38
|
+
{ __( 'Aa' ) }
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default FontSizePreview;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import {
|
|
7
|
+
__experimentalSpacer as Spacer,
|
|
8
|
+
__experimentalUseNavigator as useNavigator,
|
|
9
|
+
__experimentalView as View,
|
|
10
|
+
__experimentalHStack as HStack,
|
|
11
|
+
__experimentalVStack as VStack,
|
|
12
|
+
privateApis as componentsPrivateApis,
|
|
13
|
+
Button,
|
|
14
|
+
FlexItem,
|
|
15
|
+
ToggleControl,
|
|
16
|
+
} from '@wordpress/components';
|
|
17
|
+
import { moreVertical } from '@wordpress/icons';
|
|
18
|
+
import { useState } from '@wordpress/element';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
import { unlock } from '../../../lock-unlock';
|
|
24
|
+
const {
|
|
25
|
+
DropdownMenuV2: DropdownMenu,
|
|
26
|
+
DropdownMenuItemV2: DropdownMenuItem,
|
|
27
|
+
DropdownMenuItemLabelV2: DropdownMenuItemLabel,
|
|
28
|
+
} = unlock( componentsPrivateApis );
|
|
29
|
+
const { useGlobalSetting } = unlock( blockEditorPrivateApis );
|
|
30
|
+
import ScreenHeader from '../header';
|
|
31
|
+
import FontSizePreview from './font-size-preview';
|
|
32
|
+
import ConfirmDeleteFontSizeDialog from './confirm-delete-font-size-dialog';
|
|
33
|
+
import RenameFontSizeDialog from './rename-font-size-dialog';
|
|
34
|
+
import SizeControl from '../size-control';
|
|
35
|
+
|
|
36
|
+
function FontSize() {
|
|
37
|
+
const [ isDeleteConfirmOpen, setIsDeleteConfirmOpen ] = useState( false );
|
|
38
|
+
const [ isRenameDialogOpen, setIsRenameDialogOpen ] = useState( false );
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
params: { origin, slug },
|
|
42
|
+
goBack,
|
|
43
|
+
goTo,
|
|
44
|
+
} = useNavigator();
|
|
45
|
+
|
|
46
|
+
const [ fontSizes, setFontSizes ] = useGlobalSetting(
|
|
47
|
+
'typography.fontSizes'
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Get the font sizes from the origin, default to empty array.
|
|
51
|
+
const sizes = fontSizes[ origin ] ?? [];
|
|
52
|
+
|
|
53
|
+
// Get the font size by slug.
|
|
54
|
+
const fontSize = sizes.find( ( size ) => size.slug === slug );
|
|
55
|
+
|
|
56
|
+
// Whether fluid is true or an object, set it to true, otherwise false.
|
|
57
|
+
const isFluid = !! fontSize.fluid ?? false;
|
|
58
|
+
|
|
59
|
+
// Whether custom fluid values are used.
|
|
60
|
+
const isCustomFluid = typeof fontSize.fluid === 'object';
|
|
61
|
+
|
|
62
|
+
const handleNameChange = ( value ) => {
|
|
63
|
+
updateFontSize( 'name', value );
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const handleFontSizeChange = ( value ) => {
|
|
67
|
+
updateFontSize( 'size', value );
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const handleFluidChange = ( value ) => {
|
|
71
|
+
updateFontSize( 'fluid', value );
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleCustomFluidValues = ( value ) => {
|
|
75
|
+
if ( value ) {
|
|
76
|
+
// If custom values are used, init the values with the current ones.
|
|
77
|
+
updateFontSize( 'fluid', {
|
|
78
|
+
min: fontSize.size,
|
|
79
|
+
max: fontSize.size,
|
|
80
|
+
} );
|
|
81
|
+
} else {
|
|
82
|
+
// If custom fluid values are disabled, set fluid to true.
|
|
83
|
+
updateFontSize( 'fluid', true );
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleMinChange = ( value ) => {
|
|
88
|
+
updateFontSize( 'fluid', { ...fontSize.fluid, min: value } );
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const handleMaxChange = ( value ) => {
|
|
92
|
+
updateFontSize( 'fluid', { ...fontSize.fluid, max: value } );
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const updateFontSize = ( key, value ) => {
|
|
96
|
+
const newFontSizes = sizes.map( ( size ) => {
|
|
97
|
+
if ( size.slug === slug ) {
|
|
98
|
+
return { ...size, [ key ]: value }; // Create a new object with updated key
|
|
99
|
+
}
|
|
100
|
+
return size;
|
|
101
|
+
} );
|
|
102
|
+
|
|
103
|
+
setFontSizes( {
|
|
104
|
+
...fontSizes,
|
|
105
|
+
[ origin ]: newFontSizes,
|
|
106
|
+
} );
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const handleRemoveFontSize = () => {
|
|
110
|
+
// Navigate to the font sizes list.
|
|
111
|
+
goBack();
|
|
112
|
+
|
|
113
|
+
const newFontSizes = sizes.filter( ( size ) => size.slug !== slug );
|
|
114
|
+
setFontSizes( {
|
|
115
|
+
...fontSizes,
|
|
116
|
+
[ origin ]: newFontSizes,
|
|
117
|
+
} );
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const toggleDeleteConfirm = () => {
|
|
121
|
+
setIsDeleteConfirmOpen( ! isDeleteConfirmOpen );
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const toggleRenameDialog = () => {
|
|
125
|
+
setIsRenameDialogOpen( ! isRenameDialogOpen );
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<>
|
|
130
|
+
<ConfirmDeleteFontSizeDialog
|
|
131
|
+
fontSize={ fontSize }
|
|
132
|
+
isOpen={ isDeleteConfirmOpen }
|
|
133
|
+
toggleOpen={ toggleDeleteConfirm }
|
|
134
|
+
handleRemoveFontSize={ handleRemoveFontSize }
|
|
135
|
+
/>
|
|
136
|
+
|
|
137
|
+
{ isRenameDialogOpen && (
|
|
138
|
+
<RenameFontSizeDialog
|
|
139
|
+
fontSize={ fontSize }
|
|
140
|
+
toggleOpen={ toggleRenameDialog }
|
|
141
|
+
handleRename={ handleNameChange }
|
|
142
|
+
/>
|
|
143
|
+
) }
|
|
144
|
+
|
|
145
|
+
<VStack spacing={ 4 }>
|
|
146
|
+
<HStack justify="space-between" align="flex-start">
|
|
147
|
+
<ScreenHeader
|
|
148
|
+
title={ fontSize.name }
|
|
149
|
+
description={ sprintf(
|
|
150
|
+
/* translators: %s: font size preset name. */
|
|
151
|
+
__( 'Manage the font size %s.' ),
|
|
152
|
+
fontSize.name
|
|
153
|
+
) }
|
|
154
|
+
onBack={ () => goTo( '/typography/font-sizes/' ) }
|
|
155
|
+
/>
|
|
156
|
+
{ origin === 'custom' && (
|
|
157
|
+
<FlexItem>
|
|
158
|
+
<Spacer
|
|
159
|
+
marginTop={ 3 }
|
|
160
|
+
marginBottom={ 0 }
|
|
161
|
+
paddingX={ 4 }
|
|
162
|
+
>
|
|
163
|
+
<DropdownMenu
|
|
164
|
+
trigger={
|
|
165
|
+
<Button
|
|
166
|
+
size="small"
|
|
167
|
+
icon={ moreVertical }
|
|
168
|
+
label={ __( 'Font size options' ) }
|
|
169
|
+
/>
|
|
170
|
+
}
|
|
171
|
+
>
|
|
172
|
+
<DropdownMenuItem
|
|
173
|
+
onClick={ toggleRenameDialog }
|
|
174
|
+
>
|
|
175
|
+
<DropdownMenuItemLabel>
|
|
176
|
+
{ __( 'Rename' ) }
|
|
177
|
+
</DropdownMenuItemLabel>
|
|
178
|
+
</DropdownMenuItem>
|
|
179
|
+
<DropdownMenuItem
|
|
180
|
+
onClick={ toggleDeleteConfirm }
|
|
181
|
+
>
|
|
182
|
+
<DropdownMenuItemLabel>
|
|
183
|
+
{ __( 'Delete' ) }
|
|
184
|
+
</DropdownMenuItemLabel>
|
|
185
|
+
</DropdownMenuItem>
|
|
186
|
+
</DropdownMenu>
|
|
187
|
+
</Spacer>
|
|
188
|
+
</FlexItem>
|
|
189
|
+
) }
|
|
190
|
+
</HStack>
|
|
191
|
+
|
|
192
|
+
<View>
|
|
193
|
+
<Spacer paddingX={ 4 }>
|
|
194
|
+
<VStack spacing={ 4 }>
|
|
195
|
+
<FlexItem>
|
|
196
|
+
<FontSizePreview fontSize={ fontSize } />
|
|
197
|
+
</FlexItem>
|
|
198
|
+
|
|
199
|
+
<SizeControl
|
|
200
|
+
label={ __( 'Size' ) }
|
|
201
|
+
value={ ! isCustomFluid ? fontSize.size : '' }
|
|
202
|
+
onChange={ handleFontSizeChange }
|
|
203
|
+
disabled={ isCustomFluid }
|
|
204
|
+
/>
|
|
205
|
+
|
|
206
|
+
<ToggleControl
|
|
207
|
+
label={ __( 'Fluid typography' ) }
|
|
208
|
+
help={ __(
|
|
209
|
+
'Scale the font size dynamically to fit the screen or viewport.'
|
|
210
|
+
) }
|
|
211
|
+
checked={ isFluid }
|
|
212
|
+
onChange={ handleFluidChange }
|
|
213
|
+
__nextHasNoMarginBottom
|
|
214
|
+
/>
|
|
215
|
+
|
|
216
|
+
{ isFluid && (
|
|
217
|
+
<ToggleControl
|
|
218
|
+
label={ __( 'Custom fluid values' ) }
|
|
219
|
+
help={ __(
|
|
220
|
+
'Set custom min and max values for the fluid font size.'
|
|
221
|
+
) }
|
|
222
|
+
checked={ isCustomFluid }
|
|
223
|
+
onChange={ handleCustomFluidValues }
|
|
224
|
+
__nextHasNoMarginBottom
|
|
225
|
+
/>
|
|
226
|
+
) }
|
|
227
|
+
|
|
228
|
+
{ isCustomFluid && (
|
|
229
|
+
<>
|
|
230
|
+
<SizeControl
|
|
231
|
+
label={ __( 'Minimum' ) }
|
|
232
|
+
value={ fontSize.fluid?.min }
|
|
233
|
+
onChange={ handleMinChange }
|
|
234
|
+
/>
|
|
235
|
+
<SizeControl
|
|
236
|
+
label={ __( 'Maximum' ) }
|
|
237
|
+
value={ fontSize.fluid?.max }
|
|
238
|
+
onChange={ handleMaxChange }
|
|
239
|
+
/>
|
|
240
|
+
</>
|
|
241
|
+
) }
|
|
242
|
+
</VStack>
|
|
243
|
+
</Spacer>
|
|
244
|
+
</View>
|
|
245
|
+
</VStack>
|
|
246
|
+
</>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export default FontSize;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __, isRTL } from '@wordpress/i18n';
|
|
5
|
+
import {
|
|
6
|
+
__experimentalItemGroup as ItemGroup,
|
|
7
|
+
__experimentalVStack as VStack,
|
|
8
|
+
__experimentalHStack as HStack,
|
|
9
|
+
FlexItem,
|
|
10
|
+
} from '@wordpress/components';
|
|
11
|
+
import { Icon, chevronLeft, chevronRight } from '@wordpress/icons';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import Subtitle from '../subtitle';
|
|
17
|
+
import { NavigationButtonAsItem } from '../navigation-button';
|
|
18
|
+
|
|
19
|
+
function FontSizes() {
|
|
20
|
+
return (
|
|
21
|
+
<VStack spacing={ 2 }>
|
|
22
|
+
<HStack justify="space-between">
|
|
23
|
+
<Subtitle level={ 3 }>{ __( 'Font Sizes' ) }</Subtitle>
|
|
24
|
+
</HStack>
|
|
25
|
+
<ItemGroup isBordered isSeparated>
|
|
26
|
+
<NavigationButtonAsItem
|
|
27
|
+
path="/typography/font-sizes/"
|
|
28
|
+
aria-label={ __( 'Edit font size presets' ) }
|
|
29
|
+
>
|
|
30
|
+
<HStack direction="row">
|
|
31
|
+
<FlexItem>{ __( 'Font size presets' ) }</FlexItem>
|
|
32
|
+
<Icon icon={ isRTL() ? chevronLeft : chevronRight } />
|
|
33
|
+
</HStack>
|
|
34
|
+
</NavigationButtonAsItem>
|
|
35
|
+
</ItemGroup>
|
|
36
|
+
</VStack>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default FontSizes;
|