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
- useBlockProps() nests wrapper with class name inside block wrapper in the editor
- Is It Possible to Use the Block Editor’s Notification Feature to Send Another Notification After the Post Is Saved?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Set default image link target in Gutenberg image block
- Add async script
- WordPress Hook for user register
- API to trigger prompt on leaving page
- How to make repeated component/block in Gutenberg
- What’s the earliest point I can get the queried object ID?
- Using Primary Color in Plugin Block
- How to get data from WordPress $wpdb into React Gutenberg Blocks Frontend?
- wp_localize_script $handle
- How to prevent loading of all plugin’s resources?
- Plugin development, hooks, generate content
- Hook event for upload image in the menu
- Help with callback using do_action_ref_array
- What’s the Right Way to get and save remote data for a Gutenberg block?
- Making a custom widget that includes a tinymce and works in Site Origin Page Builder
- What’s the better way to add an inline script?
- Create custom blocks for bootstrap
- Woocommerce – Hide a Column in Cart Table
- how to include javascript file and css file in wordpress
- Namespaced action and filter tags
- Are block templates incompatible with serialize_blocks?
- WordPress Block Development – trouble importing from @wordpress/icons
- How to insert text at the current cursor position in Gutenberg?
- JSX in WordPress Plugin Development
- There is a problem in the gutenberg block I developed. Problem is with withInstanceId
- javascript datatables in a plugin
- WordPress custom taxonomy check box to dropdown
- Force HTTPS 301 redirect with hook
- use of do_action() without any functions attached
- Run JavaScript validation script on form submit in plugin
- Custom Plugin – CSS works, JS doesn’t
- Bind a function with its own argument to show something dynamically after every content
- What’s the hook for filtering every texts of site?
- Hook add_attachment error
- Update variable value via add_filter
- How to use apiFetch to get author information in Gutenberg properly?
- Gutenberg blocks error: Each child in a list should have a unique “key” prop
- 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
- Service Worker Uncaught (in promise) DOMException
- Setting global block attribute value
- How to find list of all functions bind to a particular hook from my plugin?
- About a programming language starts with [closed]
- Should I put my plugin javascript inline?
- Custom Block Not Shown in Block Inserter
- jQueryUI draggable doesn’t work in WordPress plugin
- Get value of custom checkbox from Gutenberg sidebar in plugin
- XMLHttpRequest to open PHP file responds with Missing Page
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- how to retrieve post_id under woocommerce_add_to_cart_validation hook?
- add_option_{$option} action hook not being called
- Insert plugin html content to a specific spot in the frontpage
- get_term_by() returning null on plugin
- How to get the value entered in the input field in wordpres
- Help interpreting @wordpress/create-block-tutorial-template usage error
- How can I add a custom button to the post editor?
- Block Development: hamburger module throwing error in save function
- Adding a navigation with wp_nav_menu() to a custom block in the site editor
- Why isn’t custom sidebar panel not showing up in the Gutenberg Editor?
- Ninja Forms: Front-End Forms, Post ID?
- How can I obtain an option (get_option) inside a block viewScript?
- How to customize password reset message page on success if no error in password reset
- Attributes array not saving values
- how to execute a function only when i send an order to trash [closed]