lexical
lexical copied to clipboard
Feature: Add css class to horizontal rule node for targeted styling
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">
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 }
Can I Work On It.
@Rbcoder1 Sure!
Can i work on it?
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
hi @madhusudhand ,are you talking about api page ?
I can fix this issue
can you assign me
@acywatson I am interested to work on it.
I want to work on this, can you assign me this issue?
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
I want to work on it, assign me
so i want to add a class in Horizontal Rule when it converted into HTML/DOM