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?
- add_action hook for completely new post?
- How to include jQuery and JavaScript files correctly?
- How can I run AJAX on a button click event?
- WordPress Hook for user register
- Test to see if jQuery or Prototype is queued by another plugin?
- Extend core block in Gutenberg
- jQuery in header or footer
- Adding pre-publish checks with Gutenberg
- How to make repeated component/block in Gutenberg
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- wp_localize_script $handle
- How to check if certain plugin exists and in expected version
- How do I only load js on the post-new.php and post.php pages in admin?
- What’s the Right Way to get and save remote data for a Gutenberg block?
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- Is it possible to modify the media library admin screen?
- What function to hook for changes made in status and visibility of a post
- Create custom blocks for bootstrap
- Passing select control value to block
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- Hook to get image filename when it is uploaded
- How to display a message about updates in the plugin list
- How to delete an user including data from custom database tables
- Should action callbacks start with a verb?
- How insert negative values in Gutenberg box-control
- What filter should I use to insert a button inside on Media>Add New
- Are block templates incompatible with serialize_blocks?
- ServerSideRender and Media Object: attributes passing image data object to php renderer even though it’s not set
- How to use a hook to override an update_post_meta call in a plugin?
- External Authentication, session_tokens not destroyed on logout
- correct way to call javascript into hook function
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- JSX in WordPress Plugin Development
- Send push when new post is published in a certain category
- javascript datatables in a plugin
- Force HTTPS 301 redirect with hook
- Plugin uninstall function is not working
- should i be checking for jquery before enqueing it in a plugin
- Loading custom js file on the admin page through plugin
- Catching Gutenberg sidebar switch event
- Hook add_attachment error
- Use npm and wp-env to make production bundle
- Passing the name of selected color from the custom component to `render_callback`
- hook update_option/updated_option empty $old_value and $value
- How to add a panel/box/widget/are/screen to the right side of edit post/page confusion
- Can I Hook Into the TinyMCE Insert/Edit Link Button to Use Shortlink For Post?
- Referencing files in JavaScript in WordPress Plugin
- Should I put my plugin javascript inline?
- WordPress – Get Posts with Category data
- var(–text-color) in style.scss works once but not twitch
- How to enhance a self developed plugin by its own plugin architecture
- `registration_errors` filter doesn’t seem to be called
- How to grab data after wp user search is complete
- jQueryUI draggable doesn’t work in WordPress plugin
- 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?
- Replace the WordPress Media Library Uploader
- 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
- How to display archive by selecting year and then selecting month
- plugin modal/popup integration best practice
- Get user logged in status from within a plugin. $current_user not defined
- Custom plugin not appearing
- Gutenberg’s Popover component position relative to the focused element
- wp_head is not fired from the hook I have used in my plugin
- How react js and other Javascript Technologies works on WordPress plugin?
- Add custom data-attribute to core Gutenberg block within an template
- Remove Gutenberg Buttons Block