tiptap/packages/extension-list-item/src/index.ts
2020-11-13 11:42:04 +01:00

38 lines
674 B
TypeScript

import { createNode } from '@tiptap/core'
const ListItem = createNode({
name: 'listItem',
content: '(paragraph|list?)+',
defining: true,
parseHTML() {
return [
{
tag: 'li',
},
]
},
renderHTML({ attributes }) {
return ['li', attributes, 0]
},
addKeyboardShortcuts() {
return {
Enter: () => this.editor.commands.splitListItem('listItem'),
Tab: () => this.editor.commands.sinkListItem('listItem'),
'Shift-Tab': () => this.editor.commands.liftListItem('listItem'),
}
},
})
export default ListItem
declare module '@tiptap/core' {
interface AllExtensions {
ListItem: typeof ListItem,
}
}