[lexical] Bug Fix : Prevent from adding element.style.textAlign when formatType is unset (#7536)

Co-authored-by: Baptiste Jamin <baptiste@crisp.chat>
This commit is contained in:
Baptiste Jamin
2025-05-15 20:46:38 +02:00
committed by GitHub
parent b8df1e0959
commit c6097c6bfc
3 changed files with 16 additions and 4 deletions

View File

@ -173,11 +173,17 @@ export class ListItemNode extends ElementNode {
exportDOM(editor: LexicalEditor): DOMExportOutput {
const element = this.createDOM(editor._config);
element.style.textAlign = this.getFormatType();
const formatType = this.getFormatType();
if (formatType) {
element.style.textAlign = formatType;
}
const direction = this.getDirection();
if (direction) {
element.dir = direction;
}
return {
element,
};

View File

@ -159,7 +159,9 @@ export class QuoteNode extends ElementNode {
}
const formatType = this.getFormatType();
element.style.textAlign = formatType;
if (formatType) {
element.style.textAlign = formatType;
}
const direction = this.getDirection();
if (direction) {
@ -320,7 +322,9 @@ export class HeadingNode extends ElementNode {
}
const formatType = this.getFormatType();
element.style.textAlign = formatType;
if (formatType) {
element.style.textAlign = formatType;
}
const direction = this.getDirection();
if (direction) {

View File

@ -90,7 +90,9 @@ export class ParagraphNode extends ElementNode {
}
const formatType = this.getFormatType();
element.style.textAlign = formatType;
if (formatType) {
element.style.textAlign = formatType;
}
}
return {