From 5bb499eba882645ced195c8013dfb955a6029533 Mon Sep 17 00:00:00 2001 From: Robert Guthrie Date: Mon, 3 May 2021 11:54:03 +1200 Subject: [PATCH] When text align is default, don't add a style attribute --- packages/extension-text-align/src/text-align.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/extension-text-align/src/text-align.ts b/packages/extension-text-align/src/text-align.ts index bb41d312c..966f772d5 100644 --- a/packages/extension-text-align/src/text-align.ts +++ b/packages/extension-text-align/src/text-align.ts @@ -37,9 +37,13 @@ export const TextAlign = Extension.create({ 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, }),