Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make TextAlign defaultAlignment setting work as expected #3460

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/extension-text-align/src/text-align.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ export const TextAlign = Extension.create<TextAlignOptions>({
default: this.options.defaultAlignment,
parseHTML: element => element.style.textAlign || this.options.defaultAlignment,
renderHTML: attributes => {
if (attributes.textAlign === this.options.defaultAlignment) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea here was to not add any style attributes to the element when the alignment is equal to the default alignment.

If we remove this, there's no way to get rid of alignment inline styles without removing a node first even though they are mostly not needed.

I think the only issue that could come up with this is, that the text alignment can diverge from the default because of a wrapping element that updates the text alignment and passes it down via inheritance but this is expected browser behaviour I'd say?

Open for discussion on this one.

return {}
}

return { style: `text-align: ${attributes.textAlign}` }
},
},
Expand Down