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

[lexical-playground][lexical-react][lexical] Feature: Theme class added to horizontal rule node #6090

Merged
merged 3 commits into from
May 16, 2024

Conversation

daltnd
Copy link
Contributor

@daltnd daltnd commented May 12, 2024

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. The selected class is still added/removed upon selecting the HR node and relevant tests have been updated to include the theme class.

Closes: #4336

Copy link

vercel bot commented May 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2024 6:59am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 12, 2024 6:59am

Copy link
Contributor

@StyleT StyleT left a 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);
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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 :)

@StyleT StyleT enabled auto-merge May 14, 2024 23:03
@StyleT StyleT disabled auto-merge May 14, 2024 23:04
@StyleT StyleT added the extended-tests Run extended e2e tests on a PR label May 16, 2024
@StyleT StyleT added this pull request to the merge queue May 16, 2024
Merged via the queue into facebook:main with commit 04ecbb4 May 16, 2024
82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants