diff --git a/docs/src/demos/Examples/Formatting/index.vue b/docs/src/demos/Examples/Formatting/index.vue index f113efd8..2d54b041 100644 --- a/docs/src/demos/Examples/Formatting/index.vue +++ b/docs/src/demos/Examples/Formatting/index.vue @@ -19,16 +19,16 @@ paragraph - + left - + center - + right - + justify diff --git a/docs/src/demos/Extensions/TextAlign/index.vue b/docs/src/demos/Extensions/TextAlign/index.vue index c7ff0694..53564e23 100644 --- a/docs/src/demos/Extensions/TextAlign/index.vue +++ b/docs/src/demos/Extensions/TextAlign/index.vue @@ -1,15 +1,15 @@ - + left - + center - + right - + justify diff --git a/packages/extension-text-align/src/index.ts b/packages/extension-text-align/src/index.ts index 63fb2279..cecf0414 100644 --- a/packages/extension-text-align/src/index.ts +++ b/packages/extension-text-align/src/index.ts @@ -35,15 +35,21 @@ const TextAlign = Extension.create({ addCommands() { return { /** - * Update the text align attribute + * Set the text align attribute */ - textAlign: (alignment: string): Command => ({ commands }) => { + setTextAlign: (alignment: string): Command => ({ commands }) => { if (!this.options.alignments.includes(alignment)) { return false } return commands.updateNodeAttributes({ textAlign: alignment }) }, + /** + * Unset the text align attribute + */ + unsetTextAlign: (): Command => ({ commands }) => { + return commands.updateNodeAttributes({ textAlign: null }) + }, } }, @@ -55,10 +61,10 @@ const TextAlign = Extension.create({ Enter: () => this.editor.commands.splitBlock({ withAttributes: true, }), - 'Ctrl-Shift-l': () => this.editor.commands.textAlign('left'), - 'Ctrl-Shift-e': () => this.editor.commands.textAlign('center'), - 'Ctrl-Shift-r': () => this.editor.commands.textAlign('right'), - 'Ctrl-Shift-j': () => this.editor.commands.textAlign('justify'), + 'Ctrl-Shift-l': () => this.editor.commands.setTextAlign('left'), + 'Ctrl-Shift-e': () => this.editor.commands.setTextAlign('center'), + 'Ctrl-Shift-r': () => this.editor.commands.setTextAlign('right'), + 'Ctrl-Shift-j': () => this.editor.commands.setTextAlign('justify'), } }, })