@wordpress/edit-site 5.27.1 → 5.27.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.
Files changed (109) hide show
  1. package/build/components/block-editor/back-button.js +2 -3
  2. package/build/components/block-editor/back-button.js.map +1 -1
  3. package/build/components/block-editor/site-editor-canvas.js +8 -2
  4. package/build/components/block-editor/site-editor-canvas.js.map +1 -1
  5. package/build/components/block-editor/use-post-link-props.js +5 -1
  6. package/build/components/block-editor/use-post-link-props.js.map +1 -1
  7. package/build/components/editor/index.js +7 -7
  8. package/build/components/editor/index.js.map +1 -1
  9. package/build/components/global-styles/font-library-modal/context.js +14 -0
  10. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  11. package/build/components/global-styles/font-library-modal/font-collection.js +17 -33
  12. package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  13. package/build/components/global-styles/font-library-modal/font-demo.js +1 -1
  14. package/build/components/global-styles/font-library-modal/font-demo.js.map +1 -1
  15. package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +1 -1
  16. package/build/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
  17. package/build/components/global-styles/font-library-modal/index.js +10 -3
  18. package/build/components/global-styles/font-library-modal/index.js.map +1 -1
  19. package/build/components/global-styles/font-library-modal/installed-fonts.js +8 -21
  20. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  21. package/build/components/global-styles/font-library-modal/library-font-variant.js +2 -2
  22. package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  23. package/build/components/global-styles/font-library-modal/resolvers.js +1 -1
  24. package/build/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  25. package/build/components/global-styles/font-library-modal/tab-panel-layout.js +9 -1
  26. package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -1
  27. package/build/components/global-styles/font-library-modal/upload-fonts.js +160 -4
  28. package/build/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
  29. package/build/components/global-styles/font-library-modal/utils/index.js +33 -31
  30. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  31. package/build/components/routes/link.js +1 -1
  32. package/build/components/routes/link.js.map +1 -1
  33. package/build/components/sidebar-edit-mode/index.js +1 -2
  34. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  35. package/build/components/sidebar-edit-mode/settings-header/index.js +7 -36
  36. package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
  37. package/build/components/welcome-guide/template.js +2 -2
  38. package/build/components/welcome-guide/template.js.map +1 -1
  39. package/build/hooks/commands/use-edit-mode-commands.js +16 -6
  40. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  41. package/build-module/components/block-editor/back-button.js +2 -3
  42. package/build-module/components/block-editor/back-button.js.map +1 -1
  43. package/build-module/components/block-editor/site-editor-canvas.js +8 -2
  44. package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
  45. package/build-module/components/block-editor/use-post-link-props.js +5 -1
  46. package/build-module/components/block-editor/use-post-link-props.js.map +1 -1
  47. package/build-module/components/editor/index.js +7 -7
  48. package/build-module/components/editor/index.js.map +1 -1
  49. package/build-module/components/global-styles/font-library-modal/context.js +14 -0
  50. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  51. package/build-module/components/global-styles/font-library-modal/font-collection.js +19 -35
  52. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  53. package/build-module/components/global-styles/font-library-modal/font-demo.js +1 -1
  54. package/build-module/components/global-styles/font-library-modal/font-demo.js.map +1 -1
  55. package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +1 -1
  56. package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
  57. package/build-module/components/global-styles/font-library-modal/index.js +10 -3
  58. package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
  59. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +9 -22
  60. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  61. package/build-module/components/global-styles/font-library-modal/library-font-variant.js +2 -2
  62. package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  63. package/build-module/components/global-styles/font-library-modal/resolvers.js +1 -1
  64. package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  65. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js +10 -2
  66. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -1
  67. package/build-module/components/global-styles/font-library-modal/upload-fonts.js +162 -6
  68. package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
  69. package/build-module/components/global-styles/font-library-modal/utils/index.js +32 -30
  70. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  71. package/build-module/components/routes/link.js +1 -1
  72. package/build-module/components/routes/link.js.map +1 -1
  73. package/build-module/components/sidebar-edit-mode/index.js +1 -2
  74. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  75. package/build-module/components/sidebar-edit-mode/settings-header/index.js +7 -36
  76. package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
  77. package/build-module/components/welcome-guide/template.js +2 -2
  78. package/build-module/components/welcome-guide/template.js.map +1 -1
  79. package/build-module/hooks/commands/use-edit-mode-commands.js +16 -6
  80. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  81. package/build-style/style-rtl.css +4 -6
  82. package/build-style/style.css +4 -6
  83. package/package.json +11 -11
  84. package/src/components/block-editor/back-button.js +6 -3
  85. package/src/components/block-editor/site-editor-canvas.js +19 -12
  86. package/src/components/block-editor/use-post-link-props.js +5 -1
  87. package/src/components/editor/index.js +4 -9
  88. package/src/components/global-styles/font-library-modal/context.js +14 -0
  89. package/src/components/global-styles/font-library-modal/font-collection.js +16 -40
  90. package/src/components/global-styles/font-library-modal/font-demo.js +1 -1
  91. package/src/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +1 -1
  92. package/src/components/global-styles/font-library-modal/index.js +8 -3
  93. package/src/components/global-styles/font-library-modal/installed-fonts.js +12 -31
  94. package/src/components/global-styles/font-library-modal/library-font-variant.js +2 -2
  95. package/src/components/global-styles/font-library-modal/resolvers.js +1 -1
  96. package/src/components/global-styles/font-library-modal/style.scss +0 -10
  97. package/src/components/global-styles/font-library-modal/tab-panel-layout.js +15 -0
  98. package/src/components/global-styles/font-library-modal/upload-fonts.js +201 -6
  99. package/src/components/global-styles/font-library-modal/utils/index.js +44 -38
  100. package/src/components/routes/link.js +1 -1
  101. package/src/components/sidebar-edit-mode/index.js +1 -4
  102. package/src/components/sidebar-edit-mode/settings-header/index.js +12 -34
  103. package/src/components/welcome-guide/template.js +2 -2
  104. package/src/hooks/commands/use-edit-mode-commands.js +26 -14
  105. package/build/components/global-styles/font-library-modal/local-fonts.js +0 -196
  106. package/build/components/global-styles/font-library-modal/local-fonts.js.map +0 -1
  107. package/build-module/components/global-styles/font-library-modal/local-fonts.js +0 -187
  108. package/build-module/components/global-styles/font-library-modal/local-fonts.js.map +0 -1
  109. package/src/components/global-styles/font-library-modal/local-fonts.js +0 -239
@@ -164,20 +164,24 @@ export function makeFontFacesFormData( font ) {
164
164
  const fontFacesFormData = font.fontFace.map( ( face, faceIndex ) => {
165
165
  const formData = new FormData();
166
166
  if ( face.file ) {
167
- // Slugified file name because the it might contain spaces or characters treated differently on the server.
168
- const fileId = `file-${ faceIndex }`;
169
- // Add the files to the formData
170
- formData.append( fileId, face.file, face.file.name );
171
- // remove the file object from the face object the file is referenced in src
172
- const { file, ...faceWithoutFileProperty } = face;
173
- const fontFaceSettings = {
174
- ...faceWithoutFileProperty,
175
- src: fileId,
176
- };
177
- formData.append(
178
- 'font_face_settings',
179
- JSON.stringify( fontFaceSettings )
180
- );
167
+ // Normalize to an array, since face.file may be a single file or an array of files.
168
+ const files = Array.isArray( face.file )
169
+ ? face.file
170
+ : [ face.file ];
171
+ const src = [];
172
+
173
+ files.forEach( ( file, key ) => {
174
+ // Slugified file name because the it might contain spaces or characters treated differently on the server.
175
+ const fileId = `file-${ faceIndex }-${ key }`;
176
+ // Add the files to the formData
177
+ formData.append( fileId, file, file.name );
178
+ src.push( fileId );
179
+ } );
180
+
181
+ face.src = src.length === 1 ? src[ 0 ] : src;
182
+ delete face.file;
183
+
184
+ formData.append( 'font_face_settings', JSON.stringify( face ) );
181
185
  } else {
182
186
  formData.append( 'font_face_settings', JSON.stringify( face ) );
183
187
  }
@@ -225,31 +229,33 @@ export async function batchInstallFontFaces( fontFamilyId, fontFacesData ) {
225
229
  /*
226
230
  * Downloads a font face asset from a URL to the client and returns a File object.
227
231
  */
228
- export async function downloadFontFaceAsset( url ) {
229
- return fetch( new Request( url ) )
230
- .then( ( response ) => {
231
- if ( ! response.ok ) {
232
- throw new Error(
233
- `Error downloading font face asset from ${ url }. Server responded with status: ${ response.status }`
234
- );
235
- }
236
- return response.blob();
237
- } )
238
- .then( ( blob ) => {
239
- const filename = url.split( '/' ).pop();
240
- const file = new File( [ blob ], filename, {
241
- type: blob.type,
242
- } );
243
- return file;
232
+ export async function downloadFontFaceAssets( src ) {
233
+ // Normalize to an array, since `src` could be a string or array.
234
+ src = Array.isArray( src ) ? src : [ src ];
235
+
236
+ const files = await Promise.all(
237
+ src.map( async ( url ) => {
238
+ return fetch( new Request( url ) )
239
+ .then( ( response ) => {
240
+ if ( ! response.ok ) {
241
+ throw new Error(
242
+ `Error downloading font face asset from ${ url }. Server responded with status: ${ response.status }`
243
+ );
244
+ }
245
+ return response.blob();
246
+ } )
247
+ .then( ( blob ) => {
248
+ const filename = url.split( '/' ).pop();
249
+ const file = new File( [ blob ], filename, {
250
+ type: blob.type,
251
+ } );
252
+ return file;
253
+ } );
244
254
  } )
245
- .catch( ( error ) => {
246
- // eslint-disable-next-line no-console
247
- console.error(
248
- `Error downloading font face asset from ${ url }:`,
249
- error
250
- );
251
- throw error;
252
- } );
255
+ );
256
+
257
+ // If we only have one file return it (not the array). Otherwise return all of them in the array.
258
+ return files.length === 1 ? files[ 0 ] : files;
253
259
  }
254
260
 
255
261
  /*
@@ -22,7 +22,7 @@ export function getPostLinkProps(
22
22
  shouldReplace = false
23
23
  ) {
24
24
  function onClick( event ) {
25
- event.preventDefault();
25
+ event?.preventDefault();
26
26
 
27
27
  if ( shouldReplace ) {
28
28
  history.replace( params, state );
@@ -8,7 +8,6 @@ import { useEffect } from '@wordpress/element';
8
8
  import { useSelect, useDispatch } from '@wordpress/data';
9
9
  import { store as interfaceStore } from '@wordpress/interface';
10
10
  import { store as blockEditorStore } from '@wordpress/block-editor';
11
- import { store as editorStore } from '@wordpress/editor';
12
11
 
13
12
  /**
14
13
  * Internal dependencies
@@ -49,9 +48,7 @@ export function SidebarComplementaryAreaFills() {
49
48
  hasBlockSelection:
50
49
  !! select( blockEditorStore ).getBlockSelectionStart(),
51
50
  supportsGlobalStyles: ! settings?.supportsTemplatePartsMode,
52
- isEditingPage:
53
- select( editSiteStore ).isPage() &&
54
- select( editorStore ).getRenderingMode() !== 'template-only',
51
+ isEditingPage: select( editSiteStore ).isPage(),
55
52
  };
56
53
  }, [] );
57
54
  const { enableComplementaryArea } = useDispatch( interfaceStore );
@@ -17,23 +17,12 @@ import { store as editorStore } from '@wordpress/editor';
17
17
  */
18
18
  import { STORE_NAME } from '../../../store/constants';
19
19
  import { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from '../constants';
20
- import { store as editSiteStore } from '../../../store';
21
- import { POST_TYPE_LABELS, TEMPLATE_POST_TYPE } from '../../../utils/constants';
22
20
 
23
21
  const SettingsHeader = ( { sidebarName } ) => {
24
- const { isEditingPage, entityType } = useSelect( ( select ) => {
25
- const { getEditedPostType, isPage } = select( editSiteStore );
26
- const { getRenderingMode } = select( editorStore );
27
-
28
- return {
29
- isEditingPage: isPage() && getRenderingMode() !== 'template-only',
30
- entityType: getEditedPostType(),
31
- };
32
- } );
33
-
34
- const entityLabel =
35
- POST_TYPE_LABELS[ entityType ] ||
36
- POST_TYPE_LABELS[ TEMPLATE_POST_TYPE ];
22
+ const postTypeLabel = useSelect(
23
+ ( select ) => select( editorStore ).getPostTypeLabel(),
24
+ []
25
+ );
37
26
 
38
27
  const { enableComplementaryArea } = useDispatch( interfaceStore );
39
28
  const openTemplateSettings = () =>
@@ -41,22 +30,11 @@ const SettingsHeader = ( { sidebarName } ) => {
41
30
  const openBlockSettings = () =>
42
31
  enableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );
43
32
 
44
- let templateAriaLabel;
45
- if ( isEditingPage ) {
46
- templateAriaLabel =
47
- sidebarName === SIDEBAR_TEMPLATE
48
- ? // translators: ARIA label for the Template sidebar tab, selected.
49
- __( 'Page (selected)' )
50
- : // translators: ARIA label for the Template Settings Sidebar tab, not selected.
51
- __( 'Page' );
52
- } else {
53
- templateAriaLabel =
54
- sidebarName === SIDEBAR_TEMPLATE
55
- ? // translators: ARIA label for the Template sidebar tab, selected.
56
- sprintf( __( '%s (selected)' ), entityLabel )
57
- : // translators: ARIA label for the Template Settings Sidebar tab, not selected.
58
- entityLabel;
59
- }
33
+ const documentAriaLabel =
34
+ sidebarName === SIDEBAR_TEMPLATE
35
+ ? // translators: ARIA label for the Template sidebar tab, selected.
36
+ sprintf( __( '%s (selected)' ), postTypeLabel )
37
+ : postTypeLabel;
60
38
 
61
39
  /* Use a list so screen readers will announce how many tabs there are. */
62
40
  return (
@@ -70,10 +48,10 @@ const SettingsHeader = ( { sidebarName } ) => {
70
48
  'is-active': sidebarName === SIDEBAR_TEMPLATE,
71
49
  }
72
50
  ) }
73
- aria-label={ templateAriaLabel }
74
- data-label={ isEditingPage ? __( 'Page' ) : entityLabel }
51
+ aria-label={ documentAriaLabel }
52
+ data-label={ postTypeLabel }
75
53
  >
76
- { isEditingPage ? __( 'Page' ) : entityLabel }
54
+ { postTypeLabel }
77
55
  </Button>
78
56
  </li>
79
57
  <li>
@@ -25,12 +25,12 @@ export default function WelcomeGuideTemplate() {
25
25
  'welcomeGuide'
26
26
  );
27
27
  const { isPage } = select( editSiteStore );
28
- const { getRenderingMode } = select( editorStore );
28
+ const { getCurrentPostType } = select( editorStore );
29
29
  return (
30
30
  isTemplateActive &&
31
31
  ! isEditorActive &&
32
32
  isPage() &&
33
- getRenderingMode() === 'template-only'
33
+ getCurrentPostType() === 'wp_template'
34
34
  );
35
35
  }, [] );
36
36
 
@@ -38,22 +38,34 @@ import { PREFERENCES_MODAL_NAME } from '../../components/preferences-modal';
38
38
  import { PATTERN_MODALS } from '../../components/pattern-modal';
39
39
  import { unlock } from '../../lock-unlock';
40
40
  import { TEMPLATE_POST_TYPE } from '../../utils/constants';
41
+ import { useLink } from '../../components/routes/link';
41
42
 
42
43
  const { useHistory } = unlock( routerPrivateApis );
43
44
 
44
45
  function usePageContentFocusCommands() {
45
46
  const { record: template } = useEditedEntityRecord();
46
- const { isPage, canvasMode, renderingMode } = useSelect( ( select ) => {
47
- const { isPage: _isPage, getCanvasMode } = unlock(
48
- select( editSiteStore )
49
- );
50
- const { getRenderingMode } = select( editorStore );
51
- return {
52
- isPage: _isPage(),
53
- canvasMode: getCanvasMode(),
54
- renderingMode: getRenderingMode(),
55
- };
56
- }, [] );
47
+ const { isPage, canvasMode, templateId, currentPostType } = useSelect(
48
+ ( select ) => {
49
+ const { isPage: _isPage, getCanvasMode } = unlock(
50
+ select( editSiteStore )
51
+ );
52
+ const { getCurrentPostType, getCurrentTemplateId } =
53
+ select( editorStore );
54
+ return {
55
+ isPage: _isPage(),
56
+ canvasMode: getCanvasMode(),
57
+ templateId: getCurrentTemplateId(),
58
+ currentPostType: getCurrentPostType(),
59
+ };
60
+ },
61
+ []
62
+ );
63
+
64
+ const { onClick: editTemplate } = useLink( {
65
+ postType: 'wp_template',
66
+ postId: templateId,
67
+ } );
68
+
57
69
  const { setRenderingMode } = useDispatch( editorStore );
58
70
 
59
71
  if ( ! isPage || canvasMode !== 'edit' ) {
@@ -62,7 +74,7 @@ function usePageContentFocusCommands() {
62
74
 
63
75
  const commands = [];
64
76
 
65
- if ( renderingMode !== 'template-only' ) {
77
+ if ( currentPostType !== 'wp_template' ) {
66
78
  commands.push( {
67
79
  name: 'core/switch-to-template-focus',
68
80
  /* translators: %1$s: template title */
@@ -72,7 +84,7 @@ function usePageContentFocusCommands() {
72
84
  ),
73
85
  icon: layout,
74
86
  callback: ( { close } ) => {
75
- setRenderingMode( 'template-only' );
87
+ editTemplate();
76
88
  close();
77
89
  },
78
90
  } );
@@ -129,7 +141,7 @@ function useManipulateDocumentCommands() {
129
141
  const isEditingPage = useSelect(
130
142
  ( select ) =>
131
143
  select( editSiteStore ).isPage() &&
132
- select( editorStore ).getRenderingMode() !== 'template-only',
144
+ select( editorStore ).getCurrentPostType() !== 'wp_template',
133
145
  []
134
146
  );
135
147
 
@@ -1,196 +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 = void 0;
8
- var _react = require("react");
9
- var _i18n = require("@wordpress/i18n");
10
- var _components = require("@wordpress/components");
11
- var _element = require("@wordpress/element");
12
- var _constants = require("./utils/constants");
13
- var _context = require("./context");
14
- var _libFont = require("../../../../lib/lib-font.browser");
15
- var _makeFamiliesFromFaces = _interopRequireDefault(require("./utils/make-families-from-faces"));
16
- var _utils = require("./utils");
17
- var _lockUnlock = require("../../../lock-unlock");
18
- /**
19
- * WordPress dependencies
20
- */
21
-
22
- /**
23
- * Internal dependencies
24
- */
25
-
26
- const {
27
- ProgressBar
28
- } = (0, _lockUnlock.unlock)(_components.privateApis);
29
- function LocalFonts() {
30
- const {
31
- installFont
32
- } = (0, _element.useContext)(_context.FontLibraryContext);
33
- const [notice, setNotice] = (0, _element.useState)(null);
34
- const [isUploading, setIsUploading] = (0, _element.useState)(false);
35
- const supportedFormats = _constants.ALLOWED_FILE_EXTENSIONS.slice(0, -1).map(extension => `.${extension}`).join(', ') + ` ${(0, _i18n.__)('and')} .${_constants.ALLOWED_FILE_EXTENSIONS.slice(-1)}`;
36
- const handleDropZone = files => {
37
- handleFilesUpload(files);
38
- };
39
- const onFilesUpload = event => {
40
- handleFilesUpload(event.target.files);
41
- };
42
-
43
- // Reset notice after 5 seconds
44
- (0, _element.useEffect)(() => {
45
- if (notice) {
46
- const timeout = setTimeout(() => {
47
- setNotice(null);
48
- }, 5000);
49
- return () => clearTimeout(timeout);
50
- }
51
- }, [notice]);
52
-
53
- /**
54
- * Filters the selected files to only allow the ones with the allowed extensions
55
- *
56
- * @param {Array} files The files to be filtered
57
- * @return {void}
58
- */
59
- const handleFilesUpload = files => {
60
- setNotice(null);
61
- setIsUploading(true);
62
- const uniqueFilenames = new Set();
63
- const selectedFiles = [...files];
64
- const allowedFiles = selectedFiles.filter(file => {
65
- if (uniqueFilenames.has(file.name)) {
66
- return false; // Discard duplicates
67
- }
68
- // Eliminates files that are not allowed
69
- const fileExtension = file.name.split('.').pop().toLowerCase();
70
- if (_constants.ALLOWED_FILE_EXTENSIONS.includes(fileExtension)) {
71
- uniqueFilenames.add(file.name);
72
- return true; // Keep file if the extension is allowed
73
- }
74
-
75
- return false; // Discard file extension not allowed
76
- });
77
-
78
- if (allowedFiles.length > 0) {
79
- loadFiles(allowedFiles);
80
- }
81
- };
82
-
83
- /**
84
- * Loads the selected files and reads the font metadata
85
- *
86
- * @param {Array} files The files to be loaded
87
- * @return {void}
88
- */
89
- const loadFiles = async files => {
90
- const fontFacesLoaded = await Promise.all(files.map(async fontFile => {
91
- const fontFaceData = await getFontFaceMetadata(fontFile);
92
- await (0, _utils.loadFontFaceInBrowser)(fontFaceData, fontFaceData.file, 'all');
93
- return fontFaceData;
94
- }));
95
- await handleInstall(fontFacesLoaded);
96
- };
97
-
98
- // Create a function to read the file as array buffer
99
- async function readFileAsArrayBuffer(file) {
100
- return new Promise((resolve, reject) => {
101
- const reader = new window.FileReader();
102
- reader.readAsArrayBuffer(file);
103
- reader.onload = () => resolve(reader.result);
104
- reader.onerror = reject;
105
- });
106
- }
107
- const getFontFaceMetadata = async fontFile => {
108
- const buffer = await readFileAsArrayBuffer(fontFile);
109
- const fontObj = new _libFont.Font('Uploaded Font');
110
- fontObj.fromDataBuffer(buffer, fontFile.name);
111
- // Assuming that fromDataBuffer triggers onload event and returning a Promise
112
- const onloadEvent = await new Promise(resolve => fontObj.onload = resolve);
113
- const font = onloadEvent.detail.font;
114
- const {
115
- name
116
- } = font.opentype.tables;
117
- const fontName = name.get(16) || name.get(1);
118
- const isItalic = name.get(2).toLowerCase().includes('italic');
119
- const fontWeight = font.opentype.tables['OS/2'].usWeightClass || 'normal';
120
- const isVariable = !!font.opentype.tables.fvar;
121
- const weightAxis = isVariable && font.opentype.tables.fvar.axes.find(({
122
- tag
123
- }) => tag === 'wght');
124
- const weightRange = weightAxis ? `${weightAxis.minValue} ${weightAxis.maxValue}` : null;
125
- return {
126
- file: fontFile,
127
- fontFamily: fontName,
128
- fontStyle: isItalic ? 'italic' : 'normal',
129
- fontWeight: weightRange || fontWeight
130
- };
131
- };
132
-
133
- /**
134
- * Creates the font family definition and sends it to the server
135
- *
136
- * @param {Array} fontFaces The font faces to be installed
137
- * @return {void}
138
- */
139
- const handleInstall = async fontFaces => {
140
- const fontFamilies = (0, _makeFamiliesFromFaces.default)(fontFaces);
141
- if (fontFamilies.length > 1) {
142
- setNotice({
143
- type: 'error',
144
- message: (0, _i18n.__)('Variants from only one font family can be uploaded at a time.')
145
- });
146
- setIsUploading(false);
147
- return;
148
- }
149
- try {
150
- await installFont(fontFamilies[0]);
151
- setNotice({
152
- type: 'success',
153
- message: (0, _i18n.__)('Fonts were installed successfully.')
154
- });
155
- } catch (error) {
156
- setNotice({
157
- type: 'error',
158
- message: error.message
159
- });
160
- }
161
- setIsUploading(false);
162
- };
163
- return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_components.__experimentalSpacer, {
164
- margin: 16
165
- }), (0, _react.createElement)(_components.DropZone, {
166
- onFilesDrop: handleDropZone
167
- }), (0, _react.createElement)(_components.__experimentalVStack, {
168
- className: "font-library-modal__local-fonts"
169
- }, !isUploading && (0, _react.createElement)(_components.FormFileUpload, {
170
- accept: _constants.ALLOWED_FILE_EXTENSIONS.map(ext => `.${ext}`).join(','),
171
- multiple: true,
172
- onChange: onFilesUpload,
173
- render: ({
174
- openFileDialog
175
- }) => (0, _react.createElement)(_components.Button, {
176
- className: "font-library-modal__upload-area",
177
- onClick: openFileDialog
178
- }, (0, _react.createElement)("span", null, (0, _i18n.__)('Upload font')))
179
- }), isUploading && (0, _react.createElement)(_components.FlexItem, null, (0, _react.createElement)("div", {
180
- className: "font-library-modal__upload-area"
181
- }, (0, _react.createElement)(ProgressBar, null))), (0, _react.createElement)(_components.__experimentalSpacer, {
182
- margin: 2
183
- }), (0, _react.createElement)(_components.__experimentalText, {
184
- className: "font-library-modal__upload-area__text"
185
- }, (0, _i18n.sprintf)( /* translators: %s: supported font formats: ex: .ttf, .woff and .woff2 */
186
- (0, _i18n.__)('Uploaded fonts appear in your library and can be used in your theme. Supported formats: %s.'), supportedFormats)), !isUploading && notice && (0, _react.createElement)(_components.FlexItem, null, (0, _react.createElement)(_components.__experimentalSpacer, {
187
- margin: 2
188
- }), (0, _react.createElement)(_components.Notice, {
189
- isDismissible: false,
190
- status: notice.type,
191
- className: "font-library-modal__upload-area__notice"
192
- }, notice.message))));
193
- }
194
- var _default = LocalFonts;
195
- exports.default = _default;
196
- //# sourceMappingURL=local-fonts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_i18n","require","_components","_element","_constants","_context","_libFont","_makeFamiliesFromFaces","_interopRequireDefault","_utils","_lockUnlock","ProgressBar","unlock","componentsPrivateApis","LocalFonts","installFont","useContext","FontLibraryContext","notice","setNotice","useState","isUploading","setIsUploading","supportedFormats","ALLOWED_FILE_EXTENSIONS","slice","map","extension","join","__","handleDropZone","files","handleFilesUpload","onFilesUpload","event","target","useEffect","timeout","setTimeout","clearTimeout","uniqueFilenames","Set","selectedFiles","allowedFiles","filter","file","has","name","fileExtension","split","pop","toLowerCase","includes","add","length","loadFiles","fontFacesLoaded","Promise","all","fontFile","fontFaceData","getFontFaceMetadata","loadFontFaceInBrowser","handleInstall","readFileAsArrayBuffer","resolve","reject","reader","window","FileReader","readAsArrayBuffer","onload","result","onerror","buffer","fontObj","Font","fromDataBuffer","onloadEvent","font","detail","opentype","tables","fontName","get","isItalic","fontWeight","usWeightClass","isVariable","fvar","weightAxis","axes","find","tag","weightRange","minValue","maxValue","fontFamily","fontStyle","fontFaces","fontFamilies","makeFamiliesFromFaces","type","message","error","_react","createElement","Fragment","__experimentalSpacer","margin","DropZone","onFilesDrop","__experimentalVStack","className","FormFileUpload","accept","ext","multiple","onChange","render","openFileDialog","Button","onClick","FlexItem","__experimentalText","sprintf","Notice","isDismissible","status","_default","exports","default"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/local-fonts.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tDropZone,\n\t__experimentalSpacer as Spacer,\n\t__experimentalText as Text,\n\t__experimentalVStack as VStack,\n\tFormFileUpload,\n\tNotice,\n\tFlexItem,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useContext, useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ALLOWED_FILE_EXTENSIONS } from './utils/constants';\nimport { FontLibraryContext } from './context';\nimport { Font } from '../../../../lib/lib-font.browser';\nimport makeFamiliesFromFaces from './utils/make-families-from-faces';\nimport { loadFontFaceInBrowser } from './utils';\nimport { unlock } from '../../../lock-unlock';\n\nconst { ProgressBar } = unlock( componentsPrivateApis );\n\nfunction LocalFonts() {\n\tconst { installFont } = useContext( FontLibraryContext );\n\tconst [ notice, setNotice ] = useState( null );\n\tconst [ isUploading, setIsUploading ] = useState( false );\n\tconst supportedFormats =\n\t\tALLOWED_FILE_EXTENSIONS.slice( 0, -1 )\n\t\t\t.map( ( extension ) => `.${ extension }` )\n\t\t\t.join( ', ' ) +\n\t\t` ${ __( 'and' ) } .${ ALLOWED_FILE_EXTENSIONS.slice( -1 ) }`;\n\n\tconst handleDropZone = ( files ) => {\n\t\thandleFilesUpload( files );\n\t};\n\tconst onFilesUpload = ( event ) => {\n\t\thandleFilesUpload( event.target.files );\n\t};\n\n\t// Reset notice after 5 seconds\n\tuseEffect( () => {\n\t\tif ( notice ) {\n\t\t\tconst timeout = setTimeout( () => {\n\t\t\t\tsetNotice( null );\n\t\t\t}, 5000 );\n\t\t\treturn () => clearTimeout( timeout );\n\t\t}\n\t}, [ notice ] );\n\n\t/**\n\t * Filters the selected files to only allow the ones with the allowed extensions\n\t *\n\t * @param {Array} files The files to be filtered\n\t * @return {void}\n\t */\n\tconst handleFilesUpload = ( files ) => {\n\t\tsetNotice( null );\n\t\tsetIsUploading( true );\n\t\tconst uniqueFilenames = new Set();\n\t\tconst selectedFiles = [ ...files ];\n\t\tconst allowedFiles = selectedFiles.filter( ( file ) => {\n\t\t\tif ( uniqueFilenames.has( file.name ) ) {\n\t\t\t\treturn false; // Discard duplicates\n\t\t\t}\n\t\t\t// Eliminates files that are not allowed\n\t\t\tconst fileExtension = file.name.split( '.' ).pop().toLowerCase();\n\t\t\tif ( ALLOWED_FILE_EXTENSIONS.includes( fileExtension ) ) {\n\t\t\t\tuniqueFilenames.add( file.name );\n\t\t\t\treturn true; // Keep file if the extension is allowed\n\t\t\t}\n\t\t\treturn false; // Discard file extension not allowed\n\t\t} );\n\t\tif ( allowedFiles.length > 0 ) {\n\t\t\tloadFiles( allowedFiles );\n\t\t}\n\t};\n\n\t/**\n\t * Loads the selected files and reads the font metadata\n\t *\n\t * @param {Array} files The files to be loaded\n\t * @return {void}\n\t */\n\tconst loadFiles = async ( files ) => {\n\t\tconst fontFacesLoaded = await Promise.all(\n\t\t\tfiles.map( async ( fontFile ) => {\n\t\t\t\tconst fontFaceData = await getFontFaceMetadata( fontFile );\n\t\t\t\tawait loadFontFaceInBrowser(\n\t\t\t\t\tfontFaceData,\n\t\t\t\t\tfontFaceData.file,\n\t\t\t\t\t'all'\n\t\t\t\t);\n\t\t\t\treturn fontFaceData;\n\t\t\t} )\n\t\t);\n\t\tawait handleInstall( fontFacesLoaded );\n\t};\n\n\t// Create a function to read the file as array buffer\n\tasync function readFileAsArrayBuffer( file ) {\n\t\treturn new Promise( ( resolve, reject ) => {\n\t\t\tconst reader = new window.FileReader();\n\t\t\treader.readAsArrayBuffer( file );\n\t\t\treader.onload = () => resolve( reader.result );\n\t\t\treader.onerror = reject;\n\t\t} );\n\t}\n\n\tconst getFontFaceMetadata = async ( fontFile ) => {\n\t\tconst buffer = await readFileAsArrayBuffer( fontFile );\n\t\tconst fontObj = new Font( 'Uploaded Font' );\n\t\tfontObj.fromDataBuffer( buffer, fontFile.name );\n\t\t// Assuming that fromDataBuffer triggers onload event and returning a Promise\n\t\tconst onloadEvent = await new Promise(\n\t\t\t( resolve ) => ( fontObj.onload = resolve )\n\t\t);\n\t\tconst font = onloadEvent.detail.font;\n\t\tconst { name } = font.opentype.tables;\n\t\tconst fontName = name.get( 16 ) || name.get( 1 );\n\t\tconst isItalic = name.get( 2 ).toLowerCase().includes( 'italic' );\n\t\tconst fontWeight =\n\t\t\tfont.opentype.tables[ 'OS/2' ].usWeightClass || 'normal';\n\t\tconst isVariable = !! font.opentype.tables.fvar;\n\t\tconst weightAxis =\n\t\t\tisVariable &&\n\t\t\tfont.opentype.tables.fvar.axes.find(\n\t\t\t\t( { tag } ) => tag === 'wght'\n\t\t\t);\n\t\tconst weightRange = weightAxis\n\t\t\t? `${ weightAxis.minValue } ${ weightAxis.maxValue }`\n\t\t\t: null;\n\t\treturn {\n\t\t\tfile: fontFile,\n\t\t\tfontFamily: fontName,\n\t\t\tfontStyle: isItalic ? 'italic' : 'normal',\n\t\t\tfontWeight: weightRange || fontWeight,\n\t\t};\n\t};\n\n\t/**\n\t * Creates the font family definition and sends it to the server\n\t *\n\t * @param {Array} fontFaces The font faces to be installed\n\t * @return {void}\n\t */\n\tconst handleInstall = async ( fontFaces ) => {\n\t\tconst fontFamilies = makeFamiliesFromFaces( fontFaces );\n\n\t\tif ( fontFamilies.length > 1 ) {\n\t\t\tsetNotice( {\n\t\t\t\ttype: 'error',\n\t\t\t\tmessage: __(\n\t\t\t\t\t'Variants from only one font family can be uploaded at a time.'\n\t\t\t\t),\n\t\t\t} );\n\t\t\tsetIsUploading( false );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait installFont( fontFamilies[ 0 ] );\n\t\t\tsetNotice( {\n\t\t\t\ttype: 'success',\n\t\t\t\tmessage: __( 'Fonts were installed successfully.' ),\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tsetNotice( {\n\t\t\t\ttype: 'error',\n\t\t\t\tmessage: error.message,\n\t\t\t} );\n\t\t}\n\n\t\tsetIsUploading( false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Spacer margin={ 16 } />\n\t\t\t<DropZone onFilesDrop={ handleDropZone } />\n\t\t\t<VStack className=\"font-library-modal__local-fonts\">\n\t\t\t\t{ ! isUploading && (\n\t\t\t\t\t<FormFileUpload\n\t\t\t\t\t\taccept={ ALLOWED_FILE_EXTENSIONS.map(\n\t\t\t\t\t\t\t( ext ) => `.${ ext }`\n\t\t\t\t\t\t).join( ',' ) }\n\t\t\t\t\t\tmultiple={ true }\n\t\t\t\t\t\tonChange={ onFilesUpload }\n\t\t\t\t\t\trender={ ( { openFileDialog } ) => (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"font-library-modal__upload-area\"\n\t\t\t\t\t\t\t\tonClick={ openFileDialog }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<span>{ __( 'Upload font' ) }</span>\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ isUploading && (\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<div className=\"font-library-modal__upload-area\">\n\t\t\t\t\t\t\t<ProgressBar />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t\t<Spacer margin={ 2 } />\n\t\t\t\t<Text className=\"font-library-modal__upload-area__text\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: supported font formats: ex: .ttf, .woff and .woff2 */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Uploaded fonts appear in your library and can be used in your theme. Supported formats: %s.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tsupportedFormats\n\t\t\t\t\t) }\n\t\t\t\t</Text>\n\t\t\t\t{ ! isUploading && notice && (\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Spacer margin={ 2 } />\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\tstatus={ notice.type }\n\t\t\t\t\t\t\tclassName=\"font-library-modal__upload-area__notice\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ notice.message }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</>\n\t);\n}\n\nexport default LocalFonts;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAWA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AAzBA;AACA;AACA;;AAeA;AACA;AACA;;AAQA,MAAM;EAAEU;AAAY,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAEvD,SAASC,UAAUA,CAAA,EAAG;EACrB,MAAM;IAAEC;EA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