fix: parse only available configured text-align values (#5169)

---------

Co-authored-by: volar <stanislav.volar@petitpress.sk>
Co-authored-by: Nick Perez <nicholas.perez@tiptap.dev>
This commit is contained in:
Stanislav Volar 2024-05-30 17:09:44 +02:00 committed by GitHub
parent b5a7814446
commit 8d1af5fbe5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -63,7 +63,11 @@ export const TextAlign = Extension.create<TextAlignOptions>({
attributes: {
textAlign: {
default: this.options.defaultAlignment,
parseHTML: element => element.style.textAlign || this.options.defaultAlignment,
parseHTML: element => {
const alignment = element.style.textAlign || this.options.defaultAlignment
return this.options.alignments.includes(alignment) ? alignment : this.options.defaultAlignment
},
renderHTML: attributes => {
if (attributes.textAlign === this.options.defaultAlignment) {
return {}