Skip to content

Commit

Permalink
Merge pull request #1251 from robguthrie/patch-1
Browse files Browse the repository at this point in the history
When text align is default, don't add a style attribute
  • Loading branch information
philippkuehn authored May 11, 2021
2 parents 2a79f59 + 3d0226f commit 8a245f5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/extension-text-align/src/text-align.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand Down

0 comments on commit 8a245f5

Please sign in to comment.