-
Notifications
You must be signed in to change notification settings - Fork 88
fix(text-editor): scale paragraph content font with the size prop #8147
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,6 +239,65 @@ describe("StyledSpanNode", () => { | |
| }); | ||
| }); | ||
|
|
||
| test("should not set inline font size or line height on paragraph nodes", () => { | ||
| editor?.update(() => { | ||
| const node = StyledSpanNode.createFromOption("paragraph", "Body text"); | ||
| const domElement = node.createDOM(staticConfig); | ||
|
|
||
| // eslint-disable-next-line jest-dom/prefer-to-have-style | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: I'm guessing we're having to ignore the linter here due to some weirdness of Lexical?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, exactly. It is not a Lexical bug, we are intentionally checking direct inline style values on |
||
| expect(domElement.style.fontSize).toBe(""); | ||
| // eslint-disable-next-line jest-dom/prefer-to-have-style | ||
| expect(domElement.style.lineHeight).toBe(""); | ||
| }); | ||
| }); | ||
|
|
||
| test("should keep bold on a paragraph node without setting an inline font size", () => { | ||
| editor?.update(() => { | ||
| const node = StyledSpanNode.createFromOption("paragraph", "Body text"); | ||
| node.toggleFormat("bold"); | ||
|
|
||
| const domElement = node.createDOM(staticConfig); | ||
|
|
||
| // eslint-disable-next-line jest-dom/prefer-to-have-style | ||
| expect(domElement.style.fontWeight).toBe("700"); | ||
| // eslint-disable-next-line jest-dom/prefer-to-have-style | ||
| expect(domElement.style.fontSize).toBe(""); | ||
| }); | ||
| }); | ||
|
|
||
| test("should apply inline styles when a paragraph node becomes a title", () => { | ||
| editor?.update(() => { | ||
| const prevNode = StyledSpanNode.createFromOption("paragraph", "Text"); | ||
| const currentNode = StyledSpanNode.createFromOption("title", "Text"); | ||
| const domElement = prevNode.createDOM(staticConfig); | ||
|
|
||
| currentNode.updateDOM(prevNode, domElement, staticConfig); | ||
|
|
||
| // eslint-disable-next-line jest-dom/prefer-to-have-style | ||
| expect(domElement.style.fontSize).toBe("24px"); | ||
| // eslint-disable-next-line jest-dom/prefer-to-have-style | ||
| expect(domElement.style.lineHeight).toBe("30px"); | ||
| }); | ||
| }); | ||
|
|
||
| test("should clear inline styles when a title node becomes a paragraph", () => { | ||
| editor?.update(() => { | ||
| const prevNode = StyledSpanNode.createFromOption("title", "Text"); | ||
| const currentNode = StyledSpanNode.createFromOption( | ||
| "paragraph", | ||
| "Text", | ||
| ); | ||
| const domElement = prevNode.createDOM(staticConfig); | ||
|
|
||
| currentNode.updateDOM(prevNode, domElement, staticConfig); | ||
|
|
||
| // eslint-disable-next-line jest-dom/prefer-to-have-style | ||
| expect(domElement.style.fontSize).toBe(""); | ||
| // eslint-disable-next-line jest-dom/prefer-to-have-style | ||
| expect(domElement.style.lineHeight).toBe(""); | ||
| }); | ||
| }); | ||
|
|
||
| test("should update DOM when styles change", () => { | ||
| editor?.update(() => { | ||
| const prevNode = new StyledSpanNode("Test", "400", "14px", "21px"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.