forked from yikoyu/vuetify-pro-tiptap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask-list.ts
42 lines (37 loc) · 1.22 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
import type { TaskItemOptions } from '@tiptap/extension-task-item'
import { TaskItem } from '@tiptap/extension-task-item'
import type { TaskListOptions as TiptapTaskListOptions } from '@tiptap/extension-task-list'
import { TaskList as TiptapTaskList } from '@tiptap/extension-task-list'
import ActionButton from './components/ActionButton.vue'
import type { ButtonView, GeneralOptions } from '@/type'
export interface TaskListOptions extends TiptapTaskListOptions, GeneralOptions {
taskItem: Partial<TaskItemOptions>
button: ButtonView
}
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.commands.toggleTaskList(),
isActive: () => editor.isActive('taskList') || false,
icon: 'taskList',
tooltip: t('editor.tasklist.tooltip')
}
})
}
},
addExtensions() {
return [TaskItem.configure(this.options.taskItem)]
}
})