-
Notifications
You must be signed in to change notification settings - Fork 32
/
task-list.ts
46 lines (41 loc) · 1.4 KB
/
task-list.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type { GeneralOptions } from '@/type'
import type { TaskItemOptions } from '@tiptap/extension-task-item'
import type { TaskListOptions as TiptapTaskListOptions } from '@tiptap/extension-task-list'
import { TaskItem } from '@tiptap/extension-task-item'
import { TaskList as TiptapTaskList } from '@tiptap/extension-task-list'
import ActionButton from './components/ActionButton.vue'
/**
* Represents the interface for task list options, extending TiptapTaskListOptions and GeneralOptions.
*/
export interface TaskListOptions extends TiptapTaskListOptions, GeneralOptions<TaskListOptions> {
/** options for task items */
taskItem: Partial<TaskItemOptions>
}
export const TaskList = /* @__PURE__*/ TiptapTaskList.extend<TaskListOptions>({
addOptions() {
return {
...this.parent?.(),
HTMLAttributes: {
class: 'task-list'
},
taskItem: {
HTMLAttributes: {
class: 'task-list-item'
}
},
button: ({ editor, t }) => ({
component: ActionButton,
componentProps: {
action: () => editor.chain().focus().toggleTaskList().run(),
isActive: () => editor.isActive('taskList') || false,
disabled: !editor.can().toggleTaskList(),
icon: 'taskList',
tooltip: t('editor.tasklist.tooltip')
}
})
}
},
addExtensions() {
return [TaskItem.configure(this.options.taskItem)]
}
})