forked from yikoyu/vuetify-pro-tiptap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
indent.ts
34 lines (29 loc) · 920 Bytes
/
indent.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
import { Extension } from '@tiptap/core'
import ActionButton from './components/ActionButton.vue'
import type { ButtonView, GeneralOptions } from '@/type'
export interface IndentOptions extends GeneralOptions {
button: ButtonView
}
export const Indent = /* @__PURE__*/ Extension.create<IndentOptions>({
name: 'indent',
addOptions() {
return {
divider: false,
spacer: false,
button: ({ editor, t }) => {
const items: ['indent', 'outdent'] = ['indent', 'outdent']
return items.map(item => ({
component: ActionButton,
componentProps: {
action: () => {
if (item === 'indent') editor.commands.sinkListItem('listItem')
if (item === 'outdent') editor.commands.liftListItem('listItem')
},
icon: item,
tooltip: t(`editor.${item}.tooltip`)
}
}))
}
}
}
})