tiptap/packages/extension-list-item/index.ts

18 lines
431 B
TypeScript
Raw Normal View History

2020-09-11 04:29:15 +08:00
import { Node } from '@tiptap/core'
export default new Node()
.name('list_item')
.schema(() => ({
content: 'paragraph block*',
defining: true,
draggable: false,
2020-09-23 02:39:24 +08:00
parseDOM: [{ tag: 'li' }],
2020-09-11 04:29:15 +08:00
toDOM: () => ['li', 0],
}))
.keys(({ editor, name }) => ({
2020-09-23 02:23:54 +08:00
Enter: () => editor.splitListItem(name),
2020-09-23 02:39:24 +08:00
Tab: () => editor.sinkListItem(name),
'Shift-Tab': () => editor.liftListItem(name),
2020-09-11 04:29:15 +08:00
}))
.create()