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

28 lines
509 B
TypeScript
Raw Normal View History

2020-10-22 18:34:49 +08:00
import { createNode } from '@tiptap/core'
2020-09-11 04:29:15 +08:00
2020-10-22 18:34:49 +08:00
export default createNode({
name: 'list_item',
content: 'paragraph block*',
defining: true,
parseHTML() {
return [
{ tag: 'li' },
]
},
renderHTML({ attributes }) {
return ['li', attributes, 0]
},
addKeyboardShortcuts() {
return {
Enter: () => this.editor.splitListItem('list_item'),
Tab: () => this.editor.sinkListItem('list_item'),
'Shift-Tab': () => this.editor.liftListItem('list_item'),
}
},
})