From c94d2b0517e62afea84cb9dd6999874abf0bf3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Mon, 8 Nov 2021 20:52:42 +0100 Subject: [PATCH] fix: add checkboxes to TaskItem HTML output, fix #2037 --- packages/extension-task-item/src/task-item.ts | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/packages/extension-task-item/src/task-item.ts b/packages/extension-task-item/src/task-item.ts index 5b513812e..f6e2e8595 100644 --- a/packages/extension-task-item/src/task-item.ts +++ b/packages/extension-task-item/src/task-item.ts @@ -45,12 +45,32 @@ export const TaskItem = Node.create({ ] }, - renderHTML({ HTMLAttributes }) { - return ['li', mergeAttributes( - this.options.HTMLAttributes, - HTMLAttributes, - { 'data-type': 'taskItem' }, - ), 0] + renderHTML({ node, HTMLAttributes }) { + return [ + 'li', + mergeAttributes( + this.options.HTMLAttributes, + HTMLAttributes, + { 'data-type': 'taskItem' }, + ), + [ + 'label', + [ + 'input', + { + type: 'checkbox', + checked: node.attrs.checked + ? 'checked' + : null, + }, + ], + ['span'], + ], + [ + 'div', + 0, + ], + ] }, addKeyboardShortcuts() {