2020-10-22 18:34:49 +08:00
|
|
|
import { createNode } from '@tiptap/core'
|
2020-09-11 04:29:15 +08:00
|
|
|
|
2020-10-23 04:40:40 +08:00
|
|
|
const ListItem = createNode({
|
2020-10-22 18:34:49 +08:00
|
|
|
name: 'list_item',
|
|
|
|
|
2020-11-02 22:18:03 +08:00
|
|
|
content: '(paragraph|list?)+',
|
2020-10-22 18:34:49 +08:00
|
|
|
|
|
|
|
defining: true,
|
|
|
|
|
|
|
|
parseHTML() {
|
|
|
|
return [
|
2020-10-30 20:19:06 +08:00
|
|
|
{
|
|
|
|
tag: 'li',
|
|
|
|
},
|
2020-10-22 18:34:49 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
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'),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
2020-10-23 04:40:40 +08:00
|
|
|
|
|
|
|
export default ListItem
|
|
|
|
|
|
|
|
declare module '@tiptap/core/src/Editor' {
|
|
|
|
interface AllExtensions {
|
|
|
|
ListItem: typeof ListItem,
|
|
|
|
}
|
|
|
|
}
|