It turns out that it wasn’t really needed to find the default font as an empty string is interpreted as the default font. I just did it this way:
<FontFamilyControl>
value={ buttonFontFamily || '' }
onChange={ ( newFontFamily ) => {
setAttributes({ buttonFontFamily: newFontFamily })
} }
</FontFamilyControl>
Another important thing to notice here is that the FontFamilyControl
component is not a public API in Gutemberg so I had to copy it from the Gutemberg source code and adapt it to work from inside my plugin.
Related Posts:
- Trigger function on Remove block or add new block in Gutenberg JavaScript
- lodash dependency in a Gutenberg plugin
- creating elements/innerblocks via rangecontrol
- Looking for callback function after Gutenberg is rendered?
- Is there a better way to implement responsive images than what WordPress uses by default?
- Gutenberg: useDispatch is not a function – @wordpress/data included
- Make a list with header and subtext in Gutenberg blocks
- Gutenberg – What is the best way to save/update post meta?
- Why is my javascript not invoked in my hooks except wp_head?
- How to prevent UNDO on guternberg block editor
- Do I have to worry about useState causing a re-render?
- Creating a custom Gutenberg block with columns
- Gutenberg: import dependency or assign from global variable?
- How to control an elements classes from multiple Gutenberg sidebar controls?
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- Developing the save function in Gutenberg blocks
- Gutenberg – is it ok to load dependencies multiple times?
- Preventing double loading JS scripts (like React) when developing for Gutenberg
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- Rerender core Templates with with ToggleControl but it doesnt recognize block type
- HTMLCollection not counting right in editor? / for loop not working on elements in DOM
- What happens/fires when you select a block in the editor?
- Is “document loaded” different on admin side than public side?
- How to use setAttributes outside of the edit function return
- why is apiFetch throwing Unhandled Promise Rejection: TypeError: Object is not a function
- Reading plugin settings in esnext wordpress block
- How can i add insertion point between inner blocks in my custom block like core blocks
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Reinitiate Gutenburg’s blocks using javascript
- Insert text programmatically in WordPress Gutenberg Editor
- Javascript function defined in view.js not reachable from save.js
- How to move custom gutenberg block controls from settings to styles tab?
- Event when Modal is opened/visible
- Cannot call a class as a function in block plugin react component
- useBlockProps() nests wrapper with class name inside block wrapper in the editor
- Gutenberg move post/page title to Editor sidebar document panel
- configure additonal build files in the @wordpress/create-block
- Is It Possible to Use the Block Editor’s Notification Feature to Send Another Notification After the Post Is Saved?
- Is there any way to get post meta from publish_post hook?
- Where to save Gutenberg plugin data?
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- Add a custom submenu under submenu in a Custom WordPress Plugin
- Load script on frontend from widget plugin
- How do I ensure I can loop through every enqueued script and CSS?
- Gutenberg component in a plugin admin
- Hook for validating and rejecting frontend image upload
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Nested Hooks with do_action for performance reasons – safe/necessary?
- WordPress with React: Saving and Using Data Collected with fetch
- Append php file to footer
- XMLHttpRequest to open PHP file responds with Missing Page
- How to integrate plugins into block editor
- Javascript scroll eventHandler only working when I’m logged in in WordPress
- Problem in plugin debuging in wordpress
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- Add custom html classes to gutenberg wrapper
- How to get access the ID of all posts of custom post type in Gutenberg editor
- Replace the WordPress Media Library Uploader
- How to create save function for custom Gutenberg style block?
- OOP development and hooks
- Plugin Development – Call to undefined function comment_exists()
- Using JavaScript in WordPress page to call for server data using AJAX
- Pass javascript result to shortcode executer function
- Filterable posts using categories
- remove different admin menu for specific users
- Add a Script button in W3 Total Cache plugin not working due to conflicting jQuery version
- Add language localisation to javascript alert?
- Add_action not calling callback function
- replacing jquery google cdn with a new version dynamically
- Prevent plugin activation and add admin notice
- Uncaught ReferenceError: kpoejy is not defined
- how to retrieve post_id under woocommerce_add_to_cart_validation hook?
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- add_option_{$option} action hook not being called
- Unable to show a message after plugin activation
- How to display archive by selecting year and then selecting month
- plugin modal/popup integration best practice
- Remove from a div by class name from post page if post author role is not administrator
- Function not working on any file other than the main plugin file
- Does WordPress have something like timer hook?
- Multi hook deploiement
- Can I use a hook other than ‘init’ to handle form submissions?
- Template file structure , wordpress hook for altering the template
- woocommerce single product page hook not working
- How can I set a dynamic value for post_updated_messages based on return value of post_updated?
- What is the use of wp_schedule_event hook?
- How do I replace title with my plugin?
- Looking for Hook that is fired after a plugin or wp upgrade is installed/updated
- Get user logged in status from within a plugin. $current_user not defined
- On one of my sites a file is shown as 404 but the file IS there
- Woocommerce: block user removing cart item
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- how to insert content into wp_head after loop_end
- Insert plugin html content to a specific spot in the frontpage
- Apply function on all action hooks?
- Gutenberg and custom blocks messed up pagespeed score. What did I wrong?
- How can I get a plugin to hook ‘dbdelta_queries’ — a filter used during version update?
- Gutenberg text field validation
- Custom plugin not appearing
- Send retrieve password notification email with custom HTML email template