Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RichText: registerFormatType should allow identification by style rule #15478

Open
ellatrix opened this issue May 7, 2019 · 2 comments
Open
Labels
Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts [Package] Format library /packages/format-library [Package] Rich text /packages/rich-text [Type] Enhancement A suggestion for improvement.

Comments

@ellatrix
Copy link
Member

ellatrix commented May 7, 2019

It seems only one formatType at a time can register itself for controlling a bare span element.

It looks like something went wrong implementing this in Gutenberg. The format should have received a class (maybe underline). Registering bare tags is meant for semantic elements, not span elements. Perhaps we need to allow identifying formats by style rules as well, when we want to avoid setting a class and detect existing formats in the content. Switching now would exclude previously applied formatting.

Automattic/wp-calypso#32808 (comment)

Currently formatting in the content is identified either by "bare" element name (e.g. strong) or by class (e.g. span.my-custom-format). This can be limiting in cases where you can ID formatting by a style property, so you can also ID formatting that existed before Gutenberg, or wasn't applied by your format type. E.g.: underline and color.

Rules when matching:

  • Should match the tagName first.
  • Should only have one CSS rule.
  • Should match the rule's property, and store that with the value as a format attribute.

In case of underline, the rule is text-decoration. It's just an implementation detail that we're always going to set it to underline. Someone could decide to re-register underline with some style options.

For this reason, I'd also rename core/underline to core/text-decoration.

For color the above matching also makes sense.

Seems like a good first issue to me for anyone wanting to start with rich text. Happy to review it.

@ellatrix ellatrix added Good First Issue An issue that's suitable for someone looking to contribute for the first time [Package] Format library /packages/format-library [Package] Rich text /packages/rich-text labels May 7, 2019
@swissspidy
Copy link
Member

It looks like something went wrong implementing this in Gutenberg. The format should have received a class (maybe underline).

I think this should be fixed instead.

@gziolo gziolo added the Needs Dev Ready for, and needs developer efforts label Oct 21, 2019
@jordesign
Copy link
Contributor

Hey @ellatrix just checking in on this old issue - is it one still present and relevant?

@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts [Package] Format library /packages/format-library [Package] Rich text /packages/rich-text [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants