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
Add a comment  | 

1 Answer 1

Reset to default 0

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.

本文标签: plugin developmentHow to use useSelect to retrieve the currently default fontFamily