@wordpress/edit-site 5.27.0 → 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 (114) 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 +14 -2
  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/global-styles/screen-block.js +10 -0
  32. package/build/components/global-styles/screen-block.js.map +1 -1
  33. package/build/components/routes/link.js +1 -1
  34. package/build/components/routes/link.js.map +1 -1
  35. package/build/components/sidebar-edit-mode/index.js +1 -2
  36. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  37. package/build/components/sidebar-edit-mode/settings-header/index.js +7 -36
  38. package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
  39. package/build/components/welcome-guide/template.js +2 -2
  40. package/build/components/welcome-guide/template.js.map +1 -1
  41. package/build/hooks/commands/use-edit-mode-commands.js +16 -6
  42. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  43. package/build-module/components/block-editor/back-button.js +2 -3
  44. package/build-module/components/block-editor/back-button.js.map +1 -1
  45. package/build-module/components/block-editor/site-editor-canvas.js +8 -2
  46. package/build-module/components/block-editor/site-editor-canvas.js.map +1 -1
  47. package/build-module/components/block-editor/use-post-link-props.js +5 -1
  48. package/build-module/components/block-editor/use-post-link-props.js.map +1 -1
  49. package/build-module/components/editor/index.js +7 -7
  50. package/build-module/components/editor/index.js.map +1 -1
  51. package/build-module/components/global-styles/font-library-modal/context.js +14 -0
  52. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  53. package/build-module/components/global-styles/font-library-modal/font-collection.js +19 -35
  54. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  55. package/build-module/components/global-styles/font-library-modal/font-demo.js +1 -1
  56. package/build-module/components/global-styles/font-library-modal/font-demo.js.map +1 -1
  57. package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +1 -1
  58. package/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js.map +1 -1
  59. package/build-module/components/global-styles/font-library-modal/index.js +10 -3
  60. package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
  61. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +9 -22
  62. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  63. package/build-module/components/global-styles/font-library-modal/library-font-variant.js +2 -2
  64. package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  65. package/build-module/components/global-styles/font-library-modal/resolvers.js +1 -1
  66. package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  67. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js +15 -3
  68. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -1
  69. package/build-module/components/global-styles/font-library-modal/upload-fonts.js +162 -6
  70. package/build-module/components/global-styles/font-library-modal/upload-fonts.js.map +1 -1
  71. package/build-module/components/global-styles/font-library-modal/utils/index.js +32 -30
  72. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  73. package/build-module/components/global-styles/screen-block.js +10 -0
  74. package/build-module/components/global-styles/screen-block.js.map +1 -1
  75. package/build-module/components/routes/link.js +1 -1
  76. package/build-module/components/routes/link.js.map +1 -1
  77. package/build-module/components/sidebar-edit-mode/index.js +1 -2
  78. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  79. package/build-module/components/sidebar-edit-mode/settings-header/index.js +7 -36
  80. package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -1
  81. package/build-module/components/welcome-guide/template.js +2 -2
  82. package/build-module/components/welcome-guide/template.js.map +1 -1
  83. package/build-module/hooks/commands/use-edit-mode-commands.js +16 -6
  84. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  85. package/build-style/style-rtl.css +16 -31
  86. package/build-style/style.css +16 -31
  87. package/package.json +13 -13
  88. package/src/components/block-editor/back-button.js +6 -3
  89. package/src/components/block-editor/site-editor-canvas.js +19 -12
  90. package/src/components/block-editor/use-post-link-props.js +5 -1
  91. package/src/components/editor/index.js +4 -9
  92. package/src/components/global-styles/font-library-modal/context.js +14 -0
  93. package/src/components/global-styles/font-library-modal/font-collection.js +16 -40
  94. package/src/components/global-styles/font-library-modal/font-demo.js +1 -1
  95. package/src/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js +1 -1
  96. package/src/components/global-styles/font-library-modal/index.js +8 -3
  97. package/src/components/global-styles/font-library-modal/installed-fonts.js +12 -31
  98. package/src/components/global-styles/font-library-modal/library-font-variant.js +2 -2
  99. package/src/components/global-styles/font-library-modal/resolvers.js +1 -1
  100. package/src/components/global-styles/font-library-modal/style.scss +20 -43
  101. package/src/components/global-styles/font-library-modal/tab-panel-layout.js +45 -26
  102. package/src/components/global-styles/font-library-modal/upload-fonts.js +201 -6
  103. package/src/components/global-styles/font-library-modal/utils/index.js +44 -38
  104. package/src/components/global-styles/screen-block.js +10 -0
  105. package/src/components/routes/link.js +1 -1
  106. package/src/components/sidebar-edit-mode/index.js +1 -4
  107. package/src/components/sidebar-edit-mode/settings-header/index.js +12 -34
  108. package/src/components/welcome-guide/template.js +2 -2
  109. package/src/hooks/commands/use-edit-mode-commands.js +26 -14
  110. package/build/components/global-styles/font-library-modal/local-fonts.js +0 -196
  111. package/build/components/global-styles/font-library-modal/local-fonts.js.map +0 -1
  112. package/build-module/components/global-styles/font-library-modal/local-fonts.js +0 -187
  113. package/build-module/components/global-styles/font-library-modal/local-fonts.js.map +0 -1
  114. package/src/components/global-styles/font-library-modal/local-fonts.js +0 -239
@@ -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,OA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BAAM;IAACC,MAAM,EAAG;EAAG,CAAE,CAAC,EACvB,IAAAJ,MAAA,CAAAC,aAAA,EAACxG,WAAA,CAAA0H,kBAAI;IAACX,SAAS,EAAC;EAAuC,GACpD,IAAAY,aAAO,GACR;EACA,IAAAhG,QAAE,EACD,6FACD,CAAC,EACDN,gBACD,CACK,CAAC,EACL,CAAEF,WAAW,IAAIH,MAAM,IACxB,IAAAuF,MAAA,CAAAC,aAAA,EAACxG,WAAA,CAAAyH,QAAQ,QACR,IAAAlB,MAAA,CAAAC,aAAA,EAACxG,WAAA,CAAA0G,oBAAM;IAACC,MAAM,EAAG;EAAG,CAAE,CAAC,EACvB,IAAAJ,MAAA,CAAAC,aAAA,EAACxG,WAAA,CAAA4H,MAAM;IACNC,aAAa,EAAG,KAAO;IACvBC,MAAM,EAAG9G,MAAM,CAACoF,IAAM;IACtBW,SAAS,EAAC;EAAyC,GAEjD/F,MAAM,CAACqF,OACF,CACC,CAEJ,CACP,CAAC;AAEL;AAAC,IAAA0B,QAAA,GAEcnH,UAAU;AAAAoH,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -1,187 +0,0 @@
1
- import { createElement, Fragment } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { __, sprintf } from '@wordpress/i18n';
6
- import { Button, DropZone, __experimentalSpacer as Spacer, __experimentalText as Text, __experimentalVStack as VStack, FormFileUpload, Notice, FlexItem, privateApis as componentsPrivateApis } from '@wordpress/components';
7
- import { useContext, useState, useEffect } from '@wordpress/element';
8
-
9
- /**
10
- * Internal dependencies
11
- */
12
- import { ALLOWED_FILE_EXTENSIONS } from './utils/constants';
13
- import { FontLibraryContext } from './context';
14
- import { Font } from '../../../../lib/lib-font.browser';
15
- import makeFamiliesFromFaces from './utils/make-families-from-faces';
16
- import { loadFontFaceInBrowser } from './utils';
17
- import { unlock } from '../../../lock-unlock';
18
- const {
19
- ProgressBar
20
- } = unlock(componentsPrivateApis);
21
- function LocalFonts() {
22
- const {
23
- installFont
24
- } = useContext(FontLibraryContext);
25
- const [notice, setNotice] = useState(null);
26
- const [isUploading, setIsUploading] = useState(false);
27
- const supportedFormats = ALLOWED_FILE_EXTENSIONS.slice(0, -1).map(extension => `.${extension}`).join(', ') + ` ${__('and')} .${ALLOWED_FILE_EXTENSIONS.slice(-1)}`;
28
- const handleDropZone = files => {
29
- handleFilesUpload(files);
30
- };
31
- const onFilesUpload = event => {
32
- handleFilesUpload(event.target.files);
33
- };
34
-
35
- // Reset notice after 5 seconds
36
- useEffect(() => {
37
- if (notice) {
38
- const timeout = setTimeout(() => {
39
- setNotice(null);
40
- }, 5000);
41
- return () => clearTimeout(timeout);
42
- }
43
- }, [notice]);
44
-
45
- /**
46
- * Filters the selected files to only allow the ones with the allowed extensions
47
- *
48
- * @param {Array} files The files to be filtered
49
- * @return {void}
50
- */
51
- const handleFilesUpload = files => {
52
- setNotice(null);
53
- setIsUploading(true);
54
- const uniqueFilenames = new Set();
55
- const selectedFiles = [...files];
56
- const allowedFiles = selectedFiles.filter(file => {
57
- if (uniqueFilenames.has(file.name)) {
58
- return false; // Discard duplicates
59
- }
60
- // Eliminates files that are not allowed
61
- const fileExtension = file.name.split('.').pop().toLowerCase();
62
- if (ALLOWED_FILE_EXTENSIONS.includes(fileExtension)) {
63
- uniqueFilenames.add(file.name);
64
- return true; // Keep file if the extension is allowed
65
- }
66
-
67
- return false; // Discard file extension not allowed
68
- });
69
-
70
- if (allowedFiles.length > 0) {
71
- loadFiles(allowedFiles);
72
- }
73
- };
74
-
75
- /**
76
- * Loads the selected files and reads the font metadata
77
- *
78
- * @param {Array} files The files to be loaded
79
- * @return {void}
80
- */
81
- const loadFiles = async files => {
82
- const fontFacesLoaded = await Promise.all(files.map(async fontFile => {
83
- const fontFaceData = await getFontFaceMetadata(fontFile);
84
- await loadFontFaceInBrowser(fontFaceData, fontFaceData.file, 'all');
85
- return fontFaceData;
86
- }));
87
- await handleInstall(fontFacesLoaded);
88
- };
89
-
90
- // Create a function to read the file as array buffer
91
- async function readFileAsArrayBuffer(file) {
92
- return new Promise((resolve, reject) => {
93
- const reader = new window.FileReader();
94
- reader.readAsArrayBuffer(file);
95
- reader.onload = () => resolve(reader.result);
96
- reader.onerror = reject;
97
- });
98
- }
99
- const getFontFaceMetadata = async fontFile => {
100
- const buffer = await readFileAsArrayBuffer(fontFile);
101
- const fontObj = new Font('Uploaded Font');
102
- fontObj.fromDataBuffer(buffer, fontFile.name);
103
- // Assuming that fromDataBuffer triggers onload event and returning a Promise
104
- const onloadEvent = await new Promise(resolve => fontObj.onload = resolve);
105
- const font = onloadEvent.detail.font;
106
- const {
107
- name
108
- } = font.opentype.tables;
109
- const fontName = name.get(16) || name.get(1);
110
- const isItalic = name.get(2).toLowerCase().includes('italic');
111
- const fontWeight = font.opentype.tables['OS/2'].usWeightClass || 'normal';
112
- const isVariable = !!font.opentype.tables.fvar;
113
- const weightAxis = isVariable && font.opentype.tables.fvar.axes.find(({
114
- tag
115
- }) => tag === 'wght');
116
- const weightRange = weightAxis ? `${weightAxis.minValue} ${weightAxis.maxValue}` : null;
117
- return {
118
- file: fontFile,
119
- fontFamily: fontName,
120
- fontStyle: isItalic ? 'italic' : 'normal',
121
- fontWeight: weightRange || fontWeight
122
- };
123
- };
124
-
125
- /**
126
- * Creates the font family definition and sends it to the server
127
- *
128
- * @param {Array} fontFaces The font faces to be installed
129
- * @return {void}
130
- */
131
- const handleInstall = async fontFaces => {
132
- const fontFamilies = makeFamiliesFromFaces(fontFaces);
133
- if (fontFamilies.length > 1) {
134
- setNotice({
135
- type: 'error',
136
- message: __('Variants from only one font family can be uploaded at a time.')
137
- });
138
- setIsUploading(false);
139
- return;
140
- }
141
- try {
142
- await installFont(fontFamilies[0]);
143
- setNotice({
144
- type: 'success',
145
- message: __('Fonts were installed successfully.')
146
- });
147
- } catch (error) {
148
- setNotice({
149
- type: 'error',
150
- message: error.message
151
- });
152
- }
153
- setIsUploading(false);
154
- };
155
- return createElement(Fragment, null, createElement(Spacer, {
156
- margin: 16
157
- }), createElement(DropZone, {
158
- onFilesDrop: handleDropZone
159
- }), createElement(VStack, {
160
- className: "font-library-modal__local-fonts"
161
- }, !isUploading && createElement(FormFileUpload, {
162
- accept: ALLOWED_FILE_EXTENSIONS.map(ext => `.${ext}`).join(','),
163
- multiple: true,
164
- onChange: onFilesUpload,
165
- render: ({
166
- openFileDialog
167
- }) => createElement(Button, {
168
- className: "font-library-modal__upload-area",
169
- onClick: openFileDialog
170
- }, createElement("span", null, __('Upload font')))
171
- }), isUploading && createElement(FlexItem, null, createElement("div", {
172
- className: "font-library-modal__upload-area"
173
- }, createElement(ProgressBar, null))), createElement(Spacer, {
174
- margin: 2
175
- }), createElement(Text, {
176
- className: "font-library-modal__upload-area__text"
177
- }, sprintf( /* translators: %s: supported font formats: ex: .ttf, .woff and .woff2 */
178
- __('Uploaded fonts appear in your library and can be used in your theme. Supported formats: %s.'), supportedFormats)), !isUploading && notice && createElement(FlexItem, null, createElement(Spacer, {
179
- margin: 2
180
- }), createElement(Notice, {
181
- isDismissible: false,
182
- status: notice.type,
183
- className: "font-library-modal__upload-area__notice"
184
- }, notice.message))));
185
- }
186
- export default LocalFonts;
187
- //# sourceMappingURL=local-fonts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["__","sprintf","Button","DropZone","__experimentalSpacer","Spacer","__experimentalText","Text","__experimentalVStack","VStack","FormFileUpload","Notice","FlexItem","privateApis","componentsPrivateApis","useContext","useState","useEffect","ALLOWED_FILE_EXTENSIONS","FontLibraryContext","Font","makeFamiliesFromFaces","loadFontFaceInBrowser","unlock","ProgressBar","LocalFonts","installFont","notice","setNotice","isUploading","setIsUploading","supportedFormats","slice","map","extension","join","handleDropZone","files","handleFilesUpload","onFilesUpload","event","target","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","handleInstall","readFileAsArrayBuffer","resolve","reject","reader","window","FileReader","readAsArrayBuffer","onload","result","onerror","buffer","fontObj","fromDataBuffer","onloadEvent","font","detail","opentype","tables","fontName","get","isItalic","fontWeight","usWeightClass","isVariable","fvar","weightAxis","axes","find","tag","weightRange","minValue","maxValue","fontFamily","fontStyle","fontFaces","fontFamilies","type","message","error","createElement","Fragment","margin","onFilesDrop","className","accept","ext","multiple","onChange","render","openFileDialog","onClick","isDismissible","status"],"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":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SACCC,MAAM,EACNC,QAAQ,EACRC,oBAAoB,IAAIC,MAAM,EAC9BC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,EAC9BC,cAAc,EACdC,MAAM,EACNC,QAAQ,EACRC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;;AAEpE;AACA;AACA;AACA,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SAASC,IAAI,QAAQ,kCAAkC;AACvD,OAAOC,qBAAqB,MAAM,kCAAkC;AACpE,SAASC,qBAAqB,QAAQ,SAAS;AAC/C,SAASC,MAAM,QAAQ,sBAAsB;AAE7C,MAAM;EAAEC;AAAY,CAAC,GAAGD,MAAM,CAAET,qBAAsB,CAAC;AAEvD,SAASW,UAAUA,CAAA,EAAG;E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