platform/packages/text/src/nodes/todo.ts
Alexander Onnikov d784867e0a
UBERF-8274 Allow to create nested todos in editor (#6727)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
2024-09-25 23:53:43 +07:00

36 lines
749 B
TypeScript

import { TaskItem } from '@tiptap/extension-task-item'
import { TaskList } from '@tiptap/extension-task-list'
import { getDataAttribute } from './utils'
export const TodoItemNode = TaskItem.extend({
name: 'todoItem',
addOptions () {
return {
nested: true,
HTMLAttributes: {},
taskListTypeName: 'todoList'
}
},
addAttributes () {
return {
...this.parent?.(),
todoid: getDataAttribute('todoid', { default: null, keepOnSplit: false }),
userid: getDataAttribute('userid', { default: null, keepOnSplit: false })
}
}
})
export const TodoListNode = TaskList.extend({
name: 'todoList',
addOptions () {
return {
itemTypeName: 'todoItem',
HTMLAttributes: {}
}
}
})