mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-23 00:27:49 +08:00
39 lines
708 B
TypeScript
39 lines
708 B
TypeScript
import { Command, createNode, mergeAttributes } from '@tiptap/core'
|
|
|
|
const TaskList = createNode({
|
|
name: 'task_list',
|
|
|
|
group: 'block list',
|
|
|
|
content: 'taskItem+',
|
|
|
|
parseHTML() {
|
|
return [
|
|
{
|
|
tag: 'ul[data-type="task_list"]',
|
|
priority: 51,
|
|
},
|
|
]
|
|
},
|
|
|
|
renderHTML({ attributes }) {
|
|
return ['ul', mergeAttributes(attributes, { 'data-type': 'task_list' }), 0]
|
|
},
|
|
|
|
addCommands() {
|
|
return {
|
|
taskList: (): Command => ({ commands }) => {
|
|
return commands.toggleList('task_list', 'taskItem')
|
|
},
|
|
}
|
|
},
|
|
})
|
|
|
|
export default TaskList
|
|
|
|
declare module '@tiptap/core/src/Editor' {
|
|
interface AllExtensions {
|
|
TaskList: typeof TaskList,
|
|
}
|
|
}
|