Merge pull request #1251 from robguthrie/patch-1

When text align is default, don't add a style attribute
This commit is contained in:
Philipp Kühn
2021-05-11 17:04:30 +02:00
committed by GitHub

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 {}
}
return { style: `text-align: ${attributes.textAlign}` }
},
parseHTML: element => ({
textAlign: element.style.textAlign || this.options.defaultAlignment,
}),