-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[lexical-playground][lexical-react][lexical] Feature: Theme class added to horizontal rule node #6090
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic!
return document.createElement('hr'); | ||
createDOM(config: EditorConfig): HTMLElement { | ||
const element = document.createElement('hr'); | ||
addClassNamesToElement(element, config.theme.hr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it's better to use getCachedClassNameArray(config.theme, 'hr')
here as it runs normalizeClassNames
fn against classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to do that. It looks like getCachedClassNameArray
is only in the lexicalUtils
file, though, so the import would dig into lexical/src
:
import {getCachedClassNameArray} from 'packages/lexical/src/LexicalUtils';
Would it be better to move that function to the @lexical/utils
package or is that import ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can't move it to @lexical/utils
as lexical
can't depend on @lexical/utils
...
Mmm, I think we can keep it as is :)
Description
This PR adds theme class support to
HorizontalRuleNode
so that it can be targeted from the theme object in the editor config instead of through CSS workarounds. Theselected
class is still added/removed upon selecting the HR node and relevant tests have been updated to include the theme class.Closes: #4336