@wordpress/edit-site 5.28.4 → 5.28.6
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 +63 -59
- package/build/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build/components/global-styles/font-library-modal/font-collection.js +6 -6
- package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build/components/global-styles/font-library-modal/index.js +17 -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 +10 -1
- package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build/components/global-styles/font-library-modal/upload-fonts.js +46 -20
- 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 +39 -5
- package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/global.js +17 -3
- package/build/components/keyboard-shortcuts/global.js.map +1 -1
- package/build/components/resizable-frame/index.js +2 -1
- package/build/components/resizable-frame/index.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 +65 -61
- package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/font-collection.js +6 -6
- package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/index.js +17 -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 +10 -1
- package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
- package/build-module/components/global-styles/font-library-modal/upload-fonts.js +46 -20
- 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 +38 -5
- package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/global.js +17 -3
- package/build-module/components/keyboard-shortcuts/global.js.map +1 -1
- package/build-module/components/resizable-frame/index.js +2 -1
- package/build-module/components/resizable-frame/index.js.map +1 -1
- package/build-style/style-rtl.css +20 -11
- package/build-style/style.css +20 -11
- package/package.json +19 -19
- package/src/components/block-editor/use-site-editor-settings.js +0 -2
- package/src/components/global-styles/font-library-modal/context.js +122 -107
- package/src/components/global-styles/font-library-modal/font-collection.js +10 -8
- package/src/components/global-styles/font-library-modal/index.js +21 -14
- package/src/components/global-styles/font-library-modal/installed-fonts.js +18 -1
- package/src/components/global-styles/font-library-modal/upload-fonts.js +56 -21
- package/src/components/global-styles/font-library-modal/utils/index.js +45 -5
- package/src/components/global-styles/font-library-modal/utils/test/getDisplaySrcFromFontFace.spec.js +7 -18
- package/src/components/keyboard-shortcuts/global.js +16 -4
- package/src/components/resizable-frame/index.js +1 -0
package/build-style/style.css
CHANGED
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
--wp-admin-border-width-focus: 2px;
|
|
97
97
|
--wp-block-synced-color: #7a00df;
|
|
98
98
|
--wp-block-synced-color--rgb: 122, 0, 223;
|
|
99
|
+
--wp-bound-block-color: #9747ff;
|
|
99
100
|
}
|
|
100
101
|
@media (min-resolution: 192dpi) {
|
|
101
102
|
:root {
|
|
@@ -494,12 +495,13 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
494
495
|
box-sizing: border-box;
|
|
495
496
|
scroll-padding-bottom: 64px;
|
|
496
497
|
}
|
|
497
|
-
.dataviews-wrapper > div {
|
|
498
|
-
min-height: 100%;
|
|
499
|
-
}
|
|
500
498
|
|
|
501
499
|
.dataviews-filters__view-actions {
|
|
502
500
|
padding: 12px 32px 0;
|
|
501
|
+
margin-bottom: 12px;
|
|
502
|
+
flex-shrink: 0;
|
|
503
|
+
position: sticky;
|
|
504
|
+
left: 0;
|
|
503
505
|
}
|
|
504
506
|
.dataviews-filters__view-actions .components-search-control .components-base-control__field {
|
|
505
507
|
max-width: 240px;
|
|
@@ -514,15 +516,14 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
514
516
|
}
|
|
515
517
|
|
|
516
518
|
.dataviews-pagination {
|
|
517
|
-
margin-top: auto;
|
|
518
519
|
position: sticky;
|
|
519
520
|
bottom: 0;
|
|
520
|
-
|
|
521
|
-
-
|
|
522
|
-
backdrop-filter: blur(6px);
|
|
521
|
+
left: 0;
|
|
522
|
+
background-color: #fff;
|
|
523
523
|
padding: 12px 32px;
|
|
524
524
|
border-top: 1px solid #f0f0f0;
|
|
525
525
|
color: #757575;
|
|
526
|
+
flex-shrink: 0;
|
|
526
527
|
}
|
|
527
528
|
|
|
528
529
|
.dataviews-pagination__page-selection {
|
|
@@ -618,17 +619,19 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
618
619
|
.dataviews-view-table tr.is-selected:hover {
|
|
619
620
|
background-color: rgba(var(--wp-admin-theme-color--rgb), 0.08);
|
|
620
621
|
}
|
|
622
|
+
.dataviews-view-table thead {
|
|
623
|
+
position: sticky;
|
|
624
|
+
inset-block-start: 0;
|
|
625
|
+
z-index: 1;
|
|
626
|
+
}
|
|
621
627
|
.dataviews-view-table thead tr {
|
|
622
628
|
border: 0;
|
|
623
629
|
}
|
|
624
630
|
.dataviews-view-table thead th {
|
|
625
|
-
position: sticky;
|
|
626
|
-
top: -1px;
|
|
627
631
|
background-color: #fff;
|
|
628
632
|
box-shadow: inset 0 -1px 0 #f0f0f0;
|
|
629
633
|
padding-top: 8px;
|
|
630
634
|
padding-bottom: 8px;
|
|
631
|
-
z-index: 1;
|
|
632
635
|
font-size: 11px;
|
|
633
636
|
text-transform: uppercase;
|
|
634
637
|
font-weight: 500;
|
|
@@ -678,7 +681,6 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
678
681
|
color: #1e1e1e;
|
|
679
682
|
text-overflow: ellipsis;
|
|
680
683
|
white-space: nowrap;
|
|
681
|
-
overflow: hidden;
|
|
682
684
|
display: block;
|
|
683
685
|
width: 100%;
|
|
684
686
|
}
|
|
@@ -698,6 +700,13 @@ body.is-fullscreen-mode .interface-interface-skeleton {
|
|
|
698
700
|
.dataviews-view-table__primary-field a:hover {
|
|
699
701
|
color: #1e1e1e;
|
|
700
702
|
}
|
|
703
|
+
.dataviews-view-list__primary-field a:focus,
|
|
704
|
+
.dataviews-view-grid__primary-field a:focus,
|
|
705
|
+
.dataviews-view-table__primary-field a:focus {
|
|
706
|
+
color: var(--wp-admin-theme-color--rgb);
|
|
707
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color, #007cba);
|
|
708
|
+
border-radius: 2px;
|
|
709
|
+
}
|
|
701
710
|
.dataviews-view-list__primary-field button.components-button.is-link,
|
|
702
711
|
.dataviews-view-grid__primary-field button.components-button.is-link,
|
|
703
712
|
.dataviews-view-table__primary-field button.components-button.is-link {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-site",
|
|
3
|
-
"version": "5.28.
|
|
3
|
+
"version": "5.28.6",
|
|
4
4
|
"description": "Edit Site Page module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -30,42 +30,42 @@
|
|
|
30
30
|
"@wordpress/a11y": "^3.51.1",
|
|
31
31
|
"@wordpress/api-fetch": "^6.48.1",
|
|
32
32
|
"@wordpress/blob": "^3.51.1",
|
|
33
|
-
"@wordpress/block-editor": "^12.19.
|
|
34
|
-
"@wordpress/block-library": "^8.28.
|
|
35
|
-
"@wordpress/blocks": "^12.28.
|
|
36
|
-
"@wordpress/commands": "^0.22.
|
|
37
|
-
"@wordpress/components": "^26.0.
|
|
33
|
+
"@wordpress/block-editor": "^12.19.6",
|
|
34
|
+
"@wordpress/block-library": "^8.28.6",
|
|
35
|
+
"@wordpress/blocks": "^12.28.6",
|
|
36
|
+
"@wordpress/commands": "^0.22.5",
|
|
37
|
+
"@wordpress/components": "^26.0.5",
|
|
38
38
|
"@wordpress/compose": "^6.28.1",
|
|
39
|
-
"@wordpress/core-commands": "^0.20.
|
|
40
|
-
"@wordpress/core-data": "^6.28.
|
|
39
|
+
"@wordpress/core-commands": "^0.20.6",
|
|
40
|
+
"@wordpress/core-data": "^6.28.6",
|
|
41
41
|
"@wordpress/data": "^9.21.1",
|
|
42
|
-
"@wordpress/dataviews": "^0.5.
|
|
42
|
+
"@wordpress/dataviews": "^0.5.6",
|
|
43
43
|
"@wordpress/date": "^4.51.1",
|
|
44
44
|
"@wordpress/deprecated": "^3.51.1",
|
|
45
45
|
"@wordpress/dom": "^3.51.1",
|
|
46
|
-
"@wordpress/editor": "^13.28.
|
|
46
|
+
"@wordpress/editor": "^13.28.6",
|
|
47
47
|
"@wordpress/element": "^5.28.1",
|
|
48
48
|
"@wordpress/escape-html": "^2.51.1",
|
|
49
49
|
"@wordpress/hooks": "^3.51.1",
|
|
50
50
|
"@wordpress/html-entities": "^3.51.1",
|
|
51
51
|
"@wordpress/i18n": "^4.51.1",
|
|
52
|
-
"@wordpress/icons": "^9.42.
|
|
53
|
-
"@wordpress/interface": "^5.28.
|
|
52
|
+
"@wordpress/icons": "^9.42.4",
|
|
53
|
+
"@wordpress/interface": "^5.28.5",
|
|
54
54
|
"@wordpress/keyboard-shortcuts": "^4.28.1",
|
|
55
55
|
"@wordpress/keycodes": "^3.51.1",
|
|
56
|
-
"@wordpress/media-utils": "^4.42.
|
|
56
|
+
"@wordpress/media-utils": "^4.42.2",
|
|
57
57
|
"@wordpress/notices": "^4.19.1",
|
|
58
|
-
"@wordpress/patterns": "^1.12.
|
|
59
|
-
"@wordpress/plugins": "^6.19.
|
|
60
|
-
"@wordpress/preferences": "^3.28.
|
|
58
|
+
"@wordpress/patterns": "^1.12.6",
|
|
59
|
+
"@wordpress/plugins": "^6.19.5",
|
|
60
|
+
"@wordpress/preferences": "^3.28.5",
|
|
61
61
|
"@wordpress/primitives": "^3.49.1",
|
|
62
62
|
"@wordpress/private-apis": "^0.33.1",
|
|
63
|
-
"@wordpress/reusable-blocks": "^4.28.
|
|
63
|
+
"@wordpress/reusable-blocks": "^4.28.6",
|
|
64
64
|
"@wordpress/router": "^0.20.1",
|
|
65
65
|
"@wordpress/style-engine": "^1.34.1",
|
|
66
66
|
"@wordpress/url": "^3.52.1",
|
|
67
67
|
"@wordpress/viewport": "^5.28.1",
|
|
68
|
-
"@wordpress/widgets": "^3.28.
|
|
68
|
+
"@wordpress/widgets": "^3.28.6",
|
|
69
69
|
"@wordpress/wordcount": "^3.51.1",
|
|
70
70
|
"change-case": "^4.1.2",
|
|
71
71
|
"classnames": "^2.3.1",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"publishConfig": {
|
|
86
86
|
"access": "public"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "7d2a00f1998a0a696694802725e523628f994cfc"
|
|
89
89
|
}
|
|
@@ -101,8 +101,6 @@ function useNavigateToPreviousEntityRecord() {
|
|
|
101
101
|
( location.params.postId &&
|
|
102
102
|
FOCUSABLE_ENTITIES.includes( location.params.postType ) );
|
|
103
103
|
const didComeFromEditorCanvas =
|
|
104
|
-
previousLocation?.params.postId &&
|
|
105
|
-
previousLocation?.params.postType &&
|
|
106
104
|
previousLocation?.params.canvas === 'edit';
|
|
107
105
|
const showBackButton = isFocusMode && didComeFromEditorCanvas;
|
|
108
106
|
return showBackButton ? () => history.back() : undefined;
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
useEntityRecords,
|
|
10
10
|
store as coreStore,
|
|
11
11
|
} from '@wordpress/core-data';
|
|
12
|
-
import { __
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
setUIValuesNeeded,
|
|
28
28
|
mergeFontFamilies,
|
|
29
29
|
loadFontFaceInBrowser,
|
|
30
|
+
unloadFontFaceInBrowser,
|
|
30
31
|
getDisplaySrcFromFontFace,
|
|
31
32
|
makeFontFacesFormData,
|
|
32
33
|
makeFontFamilyFormData,
|
|
@@ -162,16 +163,6 @@ function FontLibraryProvider( { children } ) {
|
|
|
162
163
|
// Demo
|
|
163
164
|
const [ loadedFontUrls ] = useState( new Set() );
|
|
164
165
|
|
|
165
|
-
// Theme data
|
|
166
|
-
const { site, currentTheme } = useSelect( ( select ) => {
|
|
167
|
-
return {
|
|
168
|
-
site: select( coreStore ).getSite(),
|
|
169
|
-
currentTheme: select( coreStore ).getCurrentTheme(),
|
|
170
|
-
};
|
|
171
|
-
} );
|
|
172
|
-
const themeUrl =
|
|
173
|
-
site?.url + '/wp-content/themes/' + currentTheme?.stylesheet;
|
|
174
|
-
|
|
175
166
|
const getAvailableFontsOutline = ( availableFontFamilies ) => {
|
|
176
167
|
const outline = availableFontFamilies.reduce( ( acc, font ) => {
|
|
177
168
|
const availableFontFaces =
|
|
@@ -210,115 +201,120 @@ function FontLibraryProvider( { children } ) {
|
|
|
210
201
|
return getActivatedFontsOutline( source )[ slug ] || [];
|
|
211
202
|
};
|
|
212
203
|
|
|
213
|
-
async function
|
|
204
|
+
async function installFonts( fontFamiliesToInstall ) {
|
|
214
205
|
setIsInstalling( true );
|
|
215
206
|
try {
|
|
216
|
-
|
|
217
|
-
let
|
|
218
|
-
|
|
219
|
-
)
|
|
207
|
+
const fontFamiliesToActivate = [];
|
|
208
|
+
let installationErrors = [];
|
|
209
|
+
|
|
210
|
+
for ( const fontFamilyToInstall of fontFamiliesToInstall ) {
|
|
211
|
+
let isANewFontFamily = false;
|
|
220
212
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
installedFontFamily = await fetchInstallFontFamily(
|
|
225
|
-
makeFontFamilyFormData( fontFamilyToInstall )
|
|
213
|
+
// Get the font family if it already exists.
|
|
214
|
+
let installedFontFamily = await fetchGetFontFamilyBySlug(
|
|
215
|
+
fontFamilyToInstall.slug
|
|
226
216
|
);
|
|
227
|
-
}
|
|
228
217
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
218
|
+
// Otherwise create it.
|
|
219
|
+
if ( ! installedFontFamily ) {
|
|
220
|
+
isANewFontFamily = true;
|
|
221
|
+
// Prepare font family form data to install.
|
|
222
|
+
installedFontFamily = await fetchInstallFontFamily(
|
|
223
|
+
makeFontFamilyFormData( fontFamilyToInstall )
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Collect font faces that have already been installed (to be activated later)
|
|
228
|
+
const alreadyInstalledFontFaces =
|
|
229
|
+
installedFontFamily.fontFace && fontFamilyToInstall.fontFace
|
|
230
|
+
? installedFontFamily.fontFace.filter(
|
|
231
|
+
( fontFaceToInstall ) =>
|
|
232
|
+
checkFontFaceInstalled(
|
|
233
|
+
fontFaceToInstall,
|
|
234
|
+
fontFamilyToInstall.fontFace
|
|
235
|
+
)
|
|
236
|
+
)
|
|
237
|
+
: [];
|
|
238
|
+
|
|
239
|
+
// Filter out Font Faces that have already been installed (so that they are not re-installed)
|
|
240
|
+
if (
|
|
241
|
+
installedFontFamily.fontFace &&
|
|
242
|
+
fontFamilyToInstall.fontFace
|
|
243
|
+
) {
|
|
244
|
+
fontFamilyToInstall.fontFace =
|
|
245
|
+
fontFamilyToInstall.fontFace.filter(
|
|
233
246
|
( fontFaceToInstall ) =>
|
|
234
|
-
checkFontFaceInstalled(
|
|
247
|
+
! checkFontFaceInstalled(
|
|
235
248
|
fontFaceToInstall,
|
|
236
|
-
|
|
249
|
+
installedFontFamily.fontFace
|
|
237
250
|
)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
fontFamilyToInstall
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
( fontFaceToInstall ) =>
|
|
249
|
-
! checkFontFaceInstalled(
|
|
250
|
-
fontFaceToInstall,
|
|
251
|
-
installedFontFamily.fontFace
|
|
252
|
-
)
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Install the fonts (upload the font files to the server and create the post in the database).
|
|
255
|
+
let sucessfullyInstalledFontFaces = [];
|
|
256
|
+
let unsucessfullyInstalledFontFaces = [];
|
|
257
|
+
if ( fontFamilyToInstall?.fontFace?.length > 0 ) {
|
|
258
|
+
const response = await batchInstallFontFaces(
|
|
259
|
+
installedFontFamily.id,
|
|
260
|
+
makeFontFacesFormData( fontFamilyToInstall )
|
|
253
261
|
);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
262
|
+
sucessfullyInstalledFontFaces = response?.successes;
|
|
263
|
+
unsucessfullyInstalledFontFaces = response?.errors;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Use the sucessfully installed font faces
|
|
267
|
+
// As well as any font faces that were already installed (those will be activated)
|
|
268
|
+
if (
|
|
269
|
+
sucessfullyInstalledFontFaces?.length > 0 ||
|
|
270
|
+
alreadyInstalledFontFaces?.length > 0
|
|
271
|
+
) {
|
|
272
|
+
fontFamilyToInstall.fontFace = [
|
|
273
|
+
...sucessfullyInstalledFontFaces,
|
|
274
|
+
...alreadyInstalledFontFaces,
|
|
275
|
+
];
|
|
276
|
+
fontFamiliesToActivate.push( fontFamilyToInstall );
|
|
277
|
+
} else if ( isANewFontFamily ) {
|
|
278
|
+
// If the font family is new, delete it to avoid having font families without font faces.
|
|
279
|
+
await fetchUninstallFontFamily( installedFontFamily.id );
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
installationErrors = installationErrors.concat(
|
|
283
|
+
unsucessfullyInstalledFontFaces
|
|
263
284
|
);
|
|
264
|
-
sucessfullyInstalledFontFaces = response?.successes;
|
|
265
|
-
unsucessfullyInstalledFontFaces = response?.errors;
|
|
266
285
|
}
|
|
267
286
|
|
|
268
|
-
|
|
269
|
-
(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
287
|
+
installationErrors = installationErrors.reduce(
|
|
288
|
+
( unique, item ) =>
|
|
289
|
+
unique.includes( item.message )
|
|
290
|
+
? unique
|
|
291
|
+
: [ ...unique, item.message ],
|
|
292
|
+
[]
|
|
273
293
|
);
|
|
274
294
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
detailedErrorMessage
|
|
286
|
-
)
|
|
295
|
+
if ( fontFamiliesToActivate.length > 0 ) {
|
|
296
|
+
// Activate the font family (add the font family to the global styles).
|
|
297
|
+
activateCustomFontFamilies( fontFamiliesToActivate );
|
|
298
|
+
|
|
299
|
+
// Save the global styles to the database.
|
|
300
|
+
await saveSpecifiedEntityEdits(
|
|
301
|
+
'root',
|
|
302
|
+
'globalStyles',
|
|
303
|
+
globalStylesId,
|
|
304
|
+
[ 'settings.typography.fontFamilies' ]
|
|
287
305
|
);
|
|
288
|
-
}
|
|
289
306
|
|
|
290
|
-
|
|
291
|
-
// As well as any font faces that were already installed (those will be activated)
|
|
292
|
-
if (
|
|
293
|
-
sucessfullyInstalledFontFaces?.length > 0 ||
|
|
294
|
-
alreadyInstalledFontFaces?.length > 0
|
|
295
|
-
) {
|
|
296
|
-
fontFamilyToInstall.fontFace = [
|
|
297
|
-
...sucessfullyInstalledFontFaces,
|
|
298
|
-
...alreadyInstalledFontFaces,
|
|
299
|
-
];
|
|
307
|
+
refreshLibrary();
|
|
300
308
|
}
|
|
301
309
|
|
|
302
|
-
|
|
303
|
-
|
|
310
|
+
if ( installationErrors.length > 0 ) {
|
|
311
|
+
const installError = new Error(
|
|
312
|
+
__( 'There was an error installing fonts.' )
|
|
313
|
+
);
|
|
304
314
|
|
|
305
|
-
|
|
306
|
-
saveSpecifiedEntityEdits( 'root', 'globalStyles', globalStylesId, [
|
|
307
|
-
'settings.typography.fontFamilies',
|
|
308
|
-
] );
|
|
315
|
+
installError.installationErrors = installationErrors;
|
|
309
316
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if ( unsucessfullyInstalledFontFaces.length > 0 ) {
|
|
313
|
-
throw new Error(
|
|
314
|
-
sprintf(
|
|
315
|
-
/* translators: %s: Specific error message returned from server. */
|
|
316
|
-
__(
|
|
317
|
-
'Some font faces were installed. There were some errors. %s'
|
|
318
|
-
),
|
|
319
|
-
detailedErrorMessage
|
|
320
|
-
)
|
|
321
|
-
);
|
|
317
|
+
throw installError;
|
|
322
318
|
}
|
|
323
319
|
} finally {
|
|
324
320
|
setIsInstalling( false );
|
|
@@ -371,18 +367,20 @@ function FontLibraryProvider( { children } ) {
|
|
|
371
367
|
...fontFamilies,
|
|
372
368
|
[ font.source ]: newCustomFonts,
|
|
373
369
|
} );
|
|
370
|
+
|
|
371
|
+
if ( font.fontFace ) {
|
|
372
|
+
font.fontFace.forEach( ( face ) => {
|
|
373
|
+
unloadFontFaceInBrowser( face, 'all' );
|
|
374
|
+
} );
|
|
375
|
+
}
|
|
374
376
|
};
|
|
375
377
|
|
|
376
378
|
const activateCustomFontFamilies = ( fontsToAdd ) => {
|
|
377
379
|
// Merge the existing custom fonts with the new fonts.
|
|
378
|
-
const newCustomFonts = mergeFontFamilies(
|
|
379
|
-
fontFamilies?.custom,
|
|
380
|
-
fontsToAdd
|
|
381
|
-
);
|
|
382
380
|
// Activate the fonts by set the new custom fonts array.
|
|
383
381
|
setFontFamilies( {
|
|
384
382
|
...fontFamilies,
|
|
385
|
-
custom:
|
|
383
|
+
custom: mergeFontFamilies( fontFamilies?.custom, fontsToAdd ),
|
|
386
384
|
} );
|
|
387
385
|
// Add custom fonts to the browser.
|
|
388
386
|
fontsToAdd.forEach( ( font ) => {
|
|
@@ -410,13 +408,30 @@ function FontLibraryProvider( { children } ) {
|
|
|
410
408
|
...fontFamilies,
|
|
411
409
|
[ font.source ]: newFonts,
|
|
412
410
|
} );
|
|
411
|
+
|
|
412
|
+
const isFaceActivated = isFontActivated(
|
|
413
|
+
font.slug,
|
|
414
|
+
face.fontStyle,
|
|
415
|
+
face.fontWeight,
|
|
416
|
+
font.source
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
if ( isFaceActivated ) {
|
|
420
|
+
loadFontFaceInBrowser(
|
|
421
|
+
face,
|
|
422
|
+
getDisplaySrcFromFontFace( face.src ),
|
|
423
|
+
'all'
|
|
424
|
+
);
|
|
425
|
+
} else {
|
|
426
|
+
unloadFontFaceInBrowser( face, 'all' );
|
|
427
|
+
}
|
|
413
428
|
};
|
|
414
429
|
|
|
415
430
|
const loadFontFaceAsset = async ( fontFace ) => {
|
|
416
431
|
// If the font doesn't have a src, don't load it.
|
|
417
432
|
if ( ! fontFace.src ) return;
|
|
418
433
|
// Get the src of the font.
|
|
419
|
-
const src = getDisplaySrcFromFontFace( fontFace.src
|
|
434
|
+
const src = getDisplaySrcFromFontFace( fontFace.src );
|
|
420
435
|
// If the font is already loaded, don't load it again.
|
|
421
436
|
if ( ! src || loadedFontUrls.has( src ) ) return;
|
|
422
437
|
// Load the font in the browser.
|
|
@@ -467,7 +482,7 @@ function FontLibraryProvider( { children } ) {
|
|
|
467
482
|
isFontActivated,
|
|
468
483
|
getFontFacesActivated,
|
|
469
484
|
loadFontFaceAsset,
|
|
470
|
-
|
|
485
|
+
installFonts,
|
|
471
486
|
uninstallFontFamily,
|
|
472
487
|
toggleActivateFont,
|
|
473
488
|
getAvailableFontsOutline,
|
|
@@ -77,7 +77,7 @@ function FontCollection( { slug } ) {
|
|
|
77
77
|
const {
|
|
78
78
|
collections,
|
|
79
79
|
getFontCollection,
|
|
80
|
-
|
|
80
|
+
installFonts,
|
|
81
81
|
isInstalling,
|
|
82
82
|
notice,
|
|
83
83
|
setNotice,
|
|
@@ -214,7 +214,7 @@ function FontCollection( { slug } ) {
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
try {
|
|
217
|
-
await
|
|
217
|
+
await installFonts( [ fontFamily ] );
|
|
218
218
|
setNotice( {
|
|
219
219
|
type: 'success',
|
|
220
220
|
message: __( 'Fonts were installed successfully.' ),
|
|
@@ -277,12 +277,14 @@ function FontCollection( { slug } ) {
|
|
|
277
277
|
>
|
|
278
278
|
<NavigatorScreen path="/">
|
|
279
279
|
<HStack justify="space-between">
|
|
280
|
-
<
|
|
281
|
-
{
|
|
282
|
-
|
|
280
|
+
<VStack>
|
|
281
|
+
<Heading level={ 2 } size={ 13 }>
|
|
282
|
+
{ selectedCollection.name }
|
|
283
|
+
</Heading>
|
|
284
|
+
<Text>{ selectedCollection.description }</Text>
|
|
285
|
+
</VStack>
|
|
283
286
|
<ActionsComponent />
|
|
284
287
|
</HStack>
|
|
285
|
-
<Text>{ selectedCollection.description }</Text>
|
|
286
288
|
<Spacer margin={ 4 } />
|
|
287
289
|
<Flex>
|
|
288
290
|
<FlexItem>
|
|
@@ -456,13 +458,13 @@ function FontCollection( { slug } ) {
|
|
|
456
458
|
sprintf(
|
|
457
459
|
// translators: %s: Total number of pages.
|
|
458
460
|
_x(
|
|
459
|
-
'Page <
|
|
461
|
+
'Page <CurrentPageControl /> of %s',
|
|
460
462
|
'paging'
|
|
461
463
|
),
|
|
462
464
|
totalPages
|
|
463
465
|
),
|
|
464
466
|
{
|
|
465
|
-
|
|
467
|
+
CurrentPageControl: (
|
|
466
468
|
<SelectControl
|
|
467
469
|
aria-label={ __( 'Current page' ) }
|
|
468
470
|
value={ page }
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
Modal,
|
|
7
7
|
privateApis as componentsPrivateApis,
|
|
8
8
|
} from '@wordpress/components';
|
|
9
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
9
11
|
import { useContext } from '@wordpress/element';
|
|
10
12
|
|
|
11
13
|
/**
|
|
@@ -19,16 +21,15 @@ import { unlock } from '../../../lock-unlock';
|
|
|
19
21
|
|
|
20
22
|
const { Tabs } = unlock( componentsPrivateApis );
|
|
21
23
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
];
|
|
24
|
+
const DEFAULT_TAB = {
|
|
25
|
+
id: 'installed-fonts',
|
|
26
|
+
title: __( 'Library' ),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const UPLOAD_TAB = {
|
|
30
|
+
id: 'upload-fonts',
|
|
31
|
+
title: __( 'Upload' ),
|
|
32
|
+
};
|
|
32
33
|
|
|
33
34
|
const tabsFromCollections = ( collections ) =>
|
|
34
35
|
collections.map( ( { slug, name } ) => ( {
|
|
@@ -44,11 +45,17 @@ function FontLibraryModal( {
|
|
|
44
45
|
initialTabId = 'installed-fonts',
|
|
45
46
|
} ) {
|
|
46
47
|
const { collections, setNotice } = useContext( FontLibraryContext );
|
|
48
|
+
const canUserCreate = useSelect( ( select ) => {
|
|
49
|
+
const { canUser } = select( coreStore );
|
|
50
|
+
return canUser( 'create', 'font-families' );
|
|
51
|
+
}, [] );
|
|
52
|
+
|
|
53
|
+
const tabs = [ DEFAULT_TAB ];
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
...tabsFromCollections( collections || [] )
|
|
51
|
-
|
|
55
|
+
if ( canUserCreate ) {
|
|
56
|
+
tabs.push( UPLOAD_TAB );
|
|
57
|
+
tabs.push( ...tabsFromCollections( collections || [] ) );
|
|
58
|
+
}
|
|
52
59
|
|
|
53
60
|
// Reset notice when new tab is selected.
|
|
54
61
|
const onSelect = () => {
|
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
Spinner,
|
|
19
19
|
privateApis as componentsPrivateApis,
|
|
20
20
|
} from '@wordpress/components';
|
|
21
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
22
|
+
import { useSelect } from '@wordpress/data';
|
|
21
23
|
import { useContext, useEffect, useState } from '@wordpress/element';
|
|
22
24
|
import { __, sprintf } from '@wordpress/i18n';
|
|
23
25
|
import { chevronLeft } from '@wordpress/icons';
|
|
@@ -49,9 +51,24 @@ function InstalledFonts() {
|
|
|
49
51
|
setNotice,
|
|
50
52
|
} = useContext( FontLibraryContext );
|
|
51
53
|
const [ isConfirmDeleteOpen, setIsConfirmDeleteOpen ] = useState( false );
|
|
54
|
+
const customFontFamilyId =
|
|
55
|
+
libraryFontSelected?.source === 'custom' && libraryFontSelected?.id;
|
|
56
|
+
|
|
57
|
+
const canUserDelete = useSelect(
|
|
58
|
+
( select ) => {
|
|
59
|
+
const { canUser } = select( coreStore );
|
|
60
|
+
return (
|
|
61
|
+
customFontFamilyId &&
|
|
62
|
+
canUser( 'delete', 'font-families', customFontFamilyId )
|
|
63
|
+
);
|
|
64
|
+
},
|
|
65
|
+
[ customFontFamilyId ]
|
|
66
|
+
);
|
|
52
67
|
|
|
53
68
|
const shouldDisplayDeleteButton =
|
|
54
|
-
!! libraryFontSelected &&
|
|
69
|
+
!! libraryFontSelected &&
|
|
70
|
+
libraryFontSelected?.source !== 'theme' &&
|
|
71
|
+
canUserDelete;
|
|
55
72
|
|
|
56
73
|
const handleUninstallClick = () => {
|
|
57
74
|
setIsConfirmDeleteOpen( true );
|