When text align is default, don't add a style attribute

This commit is contained in:
Robert Guthrie 2021-05-03 11:54:03 +12:00 committed by GitHub
parent 3e14f24ef5
commit 5bb499eba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,9 +37,13 @@ export const TextAlign = Extension.create<TextAlignOptions>({
attributes: {
textAlign: {
default: this.options.defaultAlignment,
renderHTML: attributes => ({
style: `text-align: ${attributes.textAlign}`,
}),
renderHTML: attributes => {
if (attributes.textAlign == this.options.defaultAlignment){
return {}
} else {
return { style: `text-align: ${attributes.textAlign}` }
}
},
parseHTML: element => ({
textAlign: element.style.textAlign || this.options.defaultAlignment,
}),