admin管理员组文章数量:1122846
I'm trying to identify where I could find this information but I've not been able til the present moment, to achieve it.
I've been looking in core/block-editor
and core/editor
. I've been researching in the data modules reference with no success.
Can someone point me to the right direction? I'll use it in the edit.js
of a block plugin as a starting value of a FontFamilyControl
component:
<FontFamilyControl>
value={ buttonFontFamily || fontFamily }
onChange={ ( newFontFamily ) => {
setAttributes({ buttonFontFamily: newFontFamily })
} }
</FontFamilyControl>
I'm trying to identify where I could find this information but I've not been able til the present moment, to achieve it.
I've been looking in core/block-editor
and core/editor
. I've been researching in the data modules reference with no success.
Can someone point me to the right direction? I'll use it in the edit.js
of a block plugin as a starting value of a FontFamilyControl
component:
<FontFamilyControl>
value={ buttonFontFamily || fontFamily }
onChange={ ( newFontFamily ) => {
setAttributes({ buttonFontFamily: newFontFamily })
} }
</FontFamilyControl>
Share
Improve this question
asked Jul 15, 2024 at 18:17
IoguiIogui
1416 bronze badges
1 Answer
Reset to default 0It 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.
本文标签: plugin developmentHow to use useSelect to retrieve the currently default fontFamily
版权声明:本文标题:plugin development - How to use useSelect to retrieve the currently default fontFamily? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736300785a1930940.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论