-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try/font family optionally upload assets #57989
base: trunk
Are you sure you want to change the base?
Conversation
…arent (#57867) Co-authored-by: Sarah Norris <1645628+mikachan@users.noreply.github.com>
…ised API (#57844) * Add batchInstallFontFaces function and related plumbing. * Fix resolver name. * Add embedding and rebuild theme.json settings for fontFamily. * Handle responses directly, add to collection before activating. Remove unused test. * Remove getIntersectingFontFaces. * Check for existing font family before installing. * Reference src, not uploadedFile key. Co-authored-by: Matias Benedetto <matias.benedetto@gmail.com> * Check for existing font family using GET /font-families?slug=. * Filter already installed font faces (determined by matching fontWeight AND fontStyle) --------- Co-authored-by: Matias Benedetto <matias.benedetto@gmail.com> Co-authored-by: Jason Crist <jcrist@pbking.com>
* Add batchInstallFontFaces function and related plumbing. * Fix resolver name. * Add embedding and rebuild theme.json settings for fontFamily. * Handle responses directly, add to collection before activating. Remove unused test. * Remove getIntersectingFontFaces. * Check for existing font family before installing. * Reference src, not uploadedFile key. Co-authored-by: Matias Benedetto <matias.benedetto@gmail.com> * Check for existing font family using GET /font-families?slug=. * Filter already installed font faces (determined by matching fontWeight AND fontStyle) * moved response processing into the resolver for fetchGetFontFamilyBySlug * Moved response processing for font family installation to the resolver * Refactored font face installation process to handle errors more cleanly * Cleanup error handling for font library view * Add i18n function to error messages * Add TODO comment for uninstall notice --------- Co-authored-by: Jeff Ong <jonger4@gmail.com> Co-authored-by: Matias Benedetto <matias.benedetto@gmail.com> Co-authored-by: Sarah Norris <sarah@sekai.co.uk>
* Fix delete endpoint * Update fetchUninstallFontFamily to match new format * Update uninstallFont * Add uninstall notice back in * Tidy up comments * Re-word uninstall notices * Add spacing to error message * Refactored how font family values were processed so they would retain their id, which is now used to delete a font family without fetching data via slug * Rename uninstallFont to uninstallFontFamily * Throw uninstall errors rather than returning them --------- Co-authored-by: Jason Crist <jcrist@pbking.com>
…odal/local-fonts.js Co-authored-by: Jonny Harris <spacedmonkey@users.noreply.github.com>
…fontLibraryAssetInstall and a font collection's require_download value
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests as expected according to the instructions. I have a few comments:
- I'm pretty confused at the naming. (It's a tricky one!) In particular —
fontFamilyAssetInstall
=allow
andrequire_download
=false
means that the font face's src will be copied from the collection, as is. That feels pretty opaque. - If we do go with one editor setting with three options, could the names be present tense and consistent? I.e.
allow
,deny
,require
. - I think this will conflict with Font Library: font collection refactor to use the new schema #57884, particularly the removal of the
getFontCollection
function, so perhaps that one should come in first.
const fontFamily = fontsToInstall[ 0 ]; | ||
let fontFamily = fontsToInstall[ 0 ]; | ||
|
||
//NOTE: This is only necessary while the collection potentially includes the depreciated 'downloadFromUrl' property. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//NOTE: This is only necessary while the collection potentially includes the depreciated 'downloadFromUrl' property. | |
// TODO: Remove mapping once 'downloadFromUrl' property is deprecated. |
return fontFace; | ||
} ); | ||
} | ||
//////////// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to indicate what chunk of code can be removed once downloadFromURL
is deprecated? I think it's clear enough without it.
@@ -153,34 +140,67 @@ function FontCollection( { id } ) { | |||
setFontsToInstall( [] ); | |||
}; | |||
|
|||
const handleFontDownload = async ( fontFamily ) => { | |||
return Promise.all( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the last discussion we had about async, does this need to await?
return Promise.all( | |
return await Promise.all( |
export async function fetchFontCollection( id ) { | ||
const config = { | ||
path: `/wp/v2/font-collections/${ id }`, | ||
method: 'GET', | ||
}; | ||
return apiFetch( config ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this function being removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh I found why in this comment:
NOTE: While working on this, I noticed that the calls to load individual Font Collections were unnecessary (that data is loaded when all of the font collections are loaded) and have been removed.
I think that should not be like that because the initial /font-collections/
request would be unnecessarily heavy.
5d160f2
to
1320d20
Compare
What?
Update the Font Collection object to contain a
require_download
propertyAdd an editor setting of
fontLibraryAssetInstall
Install (download, then upload) fonts when appropriate
Use hosted font face assets when appropriate
Hide Tabs (upload or specific font collections) when appropriate
The
fontLibraryAssetInstall
can be set to the values:require
: Require all Font Faces to be installed. This is the default. All Font Faces will always be installed.allow
: Allow Font Faces to be installed. Font Collections that can be hosted (require_download
===FALSE
) will be hosted, Font Collections that must be installed (require_download
===TRUE
) will be installed.denied
: Font Faces are not allowed to be installed into the system. The UPLOAD tab will be hidden. Any Font Collections that require installation (require_download
===TRUE
) will not be shown.The value of
fontLibraryAssetInstall
can be set like this in PHP:Each Font Collection
require_download
property is set when the collection is created.Testing Instructions
When
fontLibraryAssetInstall
isdenied
the UPLOAD tab is hidden
any collection with
require_download
set toTRUE
is hiddenWhen
fontLibraryAssetInstall
isrequired
:the UPLOAD tab is available
All font assets are installed from any font collection
When
fontLibraryAssetInstall
isallowed
:the UPLOAD tab is available
any font faces installed from a collection with
require_download
set toTRUE
is installedany font faces installed from a collection with
require_download
set toFALSE
is NOT installedNOTE: While working on this I noticed that the calls to load individual Font Collections was unnecessary (that data is loaded when all of the font collections are loaded) and has been removed.