diff --git a/cypress/e2e/shortcuts.spec.js b/cypress/e2e/shortcuts.spec.js index 24bd3dd2e32..2b0f3272dd5 100644 --- a/cypress/e2e/shortcuts.spec.js +++ b/cypress/e2e/shortcuts.spec.js @@ -62,7 +62,7 @@ describe('keyboard shortcuts', () => { it('codeblock', () => testShortcut(`${modKey}{alt}c`, 'pre')) it('ordered-list', () => testShortcut(`${modKey}{shift}7`, 'ol')) it('unordered-list', () => testShortcut(`${modKey}{shift}8`, 'ul')) - it('task-list', () => testShortcut(`${modKey}{shift}9`, 'ul[data-type="taskList"]')) + it('task-list', () => testShortcut(`${modKey}{shift}9`, 'ul.contains-task-list')) // Headings const levels = [1, 2, 3, 4, 5, 6] diff --git a/cypress/e2e/workspace.spec.js b/cypress/e2e/workspace.spec.js index b55b6ddfd18..1e1e0a65287 100644 --- a/cypress/e2e/workspace.spec.js +++ b/cypress/e2e/workspace.spec.js @@ -128,7 +128,7 @@ describe('Workspace', function() { ;[ ['unordered-list', 'ul'], ['ordered-list', 'ol'], - ['task-list', 'ul[data-type="taskList"]'], + ['task-list', 'ul.contains-task-list'], ].forEach(([button, tag]) => testButton(button, tag, 'List me')) }) diff --git a/src/nodes/TaskItem.js b/src/nodes/TaskItem.js index eae2980dca8..678f0736490 100644 --- a/src/nodes/TaskItem.js +++ b/src/nodes/TaskItem.js @@ -59,7 +59,7 @@ const TaskItem = TipTapTaskItem.extend({ ], renderHTML({ node, HTMLAttributes }) { - const listAttributes = { class: 'checkbox-item' } + const listAttributes = { class: 'task-list-item checkbox-item' } const checkboxAttributes = { type: 'checkbox', class: '', contenteditable: false } if (node.attrs.checked) { checkboxAttributes.checked = true @@ -87,7 +87,7 @@ const TaskItem = TipTapTaskItem.extend({ state.renderContent(node) }, - addInputRules() { + addInputRules() { return [ ...this.parent(), wrappingInputRule({ diff --git a/src/nodes/TaskList.js b/src/nodes/TaskList.js index e7ac7362a0b..4839ac9f924 100644 --- a/src/nodes/TaskList.js +++ b/src/nodes/TaskList.js @@ -21,6 +21,7 @@ */ import TiptapTaskList from '@tiptap/extension-task-list' +import { mergeAttributes } from '@tiptap/core' const TaskList = TiptapTaskList.extend({ @@ -31,6 +32,10 @@ const TaskList = TiptapTaskList.extend({ }, ], + renderHTML({ HTMLAttributes }) { + return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { class: 'contains-task-list' }), 0] + }, + addAttributes() { return { ...this.parent?.(), diff --git a/src/tests/tiptap.spec.js b/src/tests/tiptap.spec.js index 1a5fbb27a97..f8312312489 100644 --- a/src/tests/tiptap.spec.js +++ b/src/tests/tiptap.spec.js @@ -20,4 +20,9 @@ describe('TipTap', () => { const markdown = 'Hard line break \nNext Paragraph' expect(renderedHTML(markdown)).toEqual('
Hard line break
Next Paragraph