From 43dc14b9fca194ad52b2421b628fe665845a13dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Wed, 6 Jan 2021 13:33:11 +0100 Subject: [PATCH] improve textAlign behavior within lists, see #72 --- packages/extension-text-align/src/text-align.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/extension-text-align/src/text-align.ts b/packages/extension-text-align/src/text-align.ts index 9387814d..7d766eba 100644 --- a/packages/extension-text-align/src/text-align.ts +++ b/packages/extension-text-align/src/text-align.ts @@ -59,10 +59,14 @@ export const TextAlign = Extension.create({ return { // TODO: re-use only 'textAlign' attribute // TODO: use custom splitBlock only for `this.options.types` - // TODO: use complete default enter handler (chainCommand) with custom splitBlock - Enter: () => this.editor.commands.splitBlock({ - withAttributes: true, - }), + Enter: () => this.editor.commands.first(({ commands }) => [ + () => commands.newlineInCode(), + () => commands.createParagraphNear(), + () => commands.liftEmptyBlock(), + () => commands.splitBlock({ + withAttributes: true, + }), + ]), 'Mod-Shift-l': () => this.editor.commands.setTextAlign('left'), 'Mod-Shift-e': () => this.editor.commands.setTextAlign('center'), 'Mod-Shift-r': () => this.editor.commands.setTextAlign('right'),