diff --git a/projects/ngx-editor/src/lib/commands/TextAlign.ts b/projects/ngx-editor/src/lib/commands/TextAlign.ts index 8522e58a..53c0d0fd 100644 --- a/projects/ngx-editor/src/lib/commands/TextAlign.ts +++ b/projects/ngx-editor/src/lib/commands/TextAlign.ts @@ -25,7 +25,8 @@ class TextAlign implements ToggleCommand { const nodeType = node.type; if ([schema.nodes['paragraph'], schema.nodes['heading']].includes(nodeType)) { applicable = true; - tr.setNodeMarkup(pos, nodeType, { ...node.attrs, align: this.align }); + const align = node.attrs['align'] === this.align ? null : this.align; + tr.setNodeMarkup(pos, nodeType, { ...node.attrs, align }); } return true; });