lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Feature: Add css class to horizontal rule node for targeted styling

Open madhusudhand opened this issue 1 year ago • 11 comments

A horizontal rule element is not given any editor specific class name to target the styling. Adding a class similar to other nodes would allow to target the hr inside editor without effecting all other hr elements of the application.

<hr class="" data-lexical-decorator="true" contenteditable="false">

madhusudhand avatar Apr 17 '23 06:04 madhusudhand

Yep, makes sense. PR welcome here. You can also do this using pure CSS by just using selectors specific to your editor contentEditable.

.my-editor hr { // my styles }

acywatson avatar Apr 17 '23 15:04 acywatson

Can I Work On It.

Rbcoder1 avatar May 03 '23 11:05 Rbcoder1

@Rbcoder1 Sure!

acywatson avatar May 04 '23 16:05 acywatson

Can i work on it?

Clintonojo avatar Sep 02 '23 13:09 Clintonojo

Hi @madhusudhand and @acywatson , can you give me the file/directory of the code responsible for rendering the horizontal rule so I can work on it? Thanks

alhridoy avatar Oct 05 '23 23:10 alhridoy

hi @madhusudhand ,are you talking about api page ? image I can fix this issue can you assign me

gupt-mudit avatar Oct 21 '23 06:10 gupt-mudit

@acywatson I am interested to work on it.

suprabhat15 avatar Nov 18 '23 21:11 suprabhat15

I want to work on this, can you assign me this issue?

joanjeremiah avatar Jan 20 '24 08:01 joanjeremiah

Issue description: A horizontal rule element when exported to HTML/DOM is not given any editor specific class name to target the styling, additionally it does not work consistently with paragraph element.

Workaround: Use pure CSS by just using selectors specific to your editor contentEditable.

.my-editor hr {
// my styles
}

Expected result:

When converting horizontal rule node to HTML (or using exportDOM()) <hr /> element shall have class based on the applied theme. Ex: <hr class="PlaygroundEditorTheme__horizontalrule">

Code refs:

  • HR code: https://github.com/facebook/lexical/blob/4c30b5215f0269c069c6c01f5eea973163a77321/packages/lexical-react/src/LexicalHorizontalRuleNode.tsx#L104
  • Paragraph code: https://github.com/facebook/lexical/blob/4c30b5215f0269c069c6c01f5eea973163a77321/packages/lexical/src/nodes/LexicalParagraphNode.ts#L46

StyleT avatar Apr 05 '24 19:04 StyleT

I want to work on it, assign me

Rbcoder1 avatar Apr 06 '24 02:04 Rbcoder1

so i want to add a class in Horizontal Rule when it converted into HTML/DOM

Rbcoder1 avatar Apr 06 '24 16:04 Rbcoder1