FortAwesome / wordpress-fontawesome

Font Awesome Official WordPress Plugin
Other
57 stars 19 forks source link

"Font Awesome Icon" is not displayed in the widget block editor. #150

Closed asako08 closed 2 years ago

asako08 commented 2 years ago

"Font Awesome Icon" is not displayed in the widget block editor. Is this a specification?

I hope it can be used in the widget block editor as well.

mlwilkerson commented 2 years ago

The plugin currently does not support this.

While investigating what it might take to support, I found an important notice in the blog post that announced the block editor support in widgets:

Don’t use @wordpress/editor Many legacy widgets call the wp.editor.initialize() JavaScript function to instantiate a TinyMCE editor. If a plugin or block uses the @wordpress/editor package and enqueues wp-editor as a script dependency, this will re-define the wp.editor global, often resulting in a wp.editor.initialize is undefined error.

This was the root cause of a previous bug that we resolved. The solution for now has been to only enable the Icon Chooser when it's either clearly a Gutenberg page, or clearly a Tiny MCE editor instance.

If there's some mixture on the same page, that's when this collision happens. And that warning in the feature announcement blog makes clear that we can expect such collisions to occur in the widget editor.

So we're stuck at this point: if we enable it in this context, it's going to end up breaking for someone--anyone who uses such legacy widgets.

I'm not yet sure how we're supposed to both:

  1. integrate with the block editor (so you can activate the FA Icon Chooser from the block editor's format menu), AND
  2. not use @wordpress/editor

It may require finding (or creating) an example of such a legacy Widget that instantiates a TinyMCE editor in order to understand how it might work.

Unfortunately, I think the best that can be done for now is to type an [icon] shortcode into those widget blocks without the help of the Icon Chooser.

asako08 commented 2 years ago

Understand. Thank you very much. I'm selecting from Icon Chooser in a post and pasting it into a widget.