From 617ab34ad1df0cc56324fc622d454aa89984ab41 Mon Sep 17 00:00:00 2001 From: Sibiraj <20282546+sibiraj-s@users.noreply.github.com> Date: Wed, 15 May 2024 12:10:34 +0530 Subject: [PATCH] fix: toggle text align marks --- projects/ngx-editor/src/lib/commands/TextAlign.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; });