mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-21 15:28:09 +08:00
38 lines
662 B
TypeScript
38 lines
662 B
TypeScript
import { createNode } from '@tiptap/core'
|
|
|
|
const ListItem = createNode({
|
|
name: 'list_item',
|
|
|
|
content: '(paragraph|list?)+',
|
|
|
|
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'),
|
|
}
|
|
},
|
|
})
|
|
|
|
export default ListItem
|
|
|
|
declare module '@tiptap/core/src/Editor' {
|
|
interface AllExtensions {
|
|
ListItem: typeof ListItem,
|
|
}
|
|
}
|