-
Notifications
You must be signed in to change notification settings - Fork 45
Description
I followed along the example of the Format API and but I was dumbfounded because I couldn't figure out how the icon was being imported and needed to import different one.
Action item:
Explicitly mention how the icon is being imported in the tutorial (or if the approach that I did more common, maybe include that )
Other buttons in the format bar were calling it in by importing WordPress' Icons package but that's not called in the format-api-f14b86 example.
I eventually figured out to import an existing WordPress icon by:
- installing the Icons package (
npm install @wordpress/icons --save), - in my js file, importing the package and then specifically importing the icon that i wanted to use
import { commentReplyLink } from "@wordpress/icons";List of icons is available at the storybook - within my RichTextToolbarButton component, adding the icon as an object like
icon={commentReplyLink}unlike the example which in format-api-f14b86 which brings in a text string.
(for anyone else finding this: if you wanted to import your own, you probably could do it through through https://wordpress.github.io/gutenberg/?path=/docs/components-icon--docs
Relatedly, the richtexttoolbarbutton component (which appears to be a wrapper or abstraction?) is could have its documentation improved by although that should go in the gutenberg repository; since all that exists is the example in the rich-text readme and a separate reference in https://github.com/WordPress/gutenberg/tree/1eb76440f7b86ca905ac875d4a2c6ed67fc48daf/packages/block-editor which says it's undocumented.