feat: add itemTypeName option

This commit is contained in:
Philipp Kühn
2021-12-11 00:13:24 +01:00
parent d64fb22e7c
commit 3d7c8e642f
6 changed files with 51 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
import { Node, mergeAttributes, wrappingInputRule } from '@tiptap/core'
export interface OrderedListOptions {
itemTypeName: string,
HTMLAttributes: Record<string, any>,
}
@@ -22,13 +23,16 @@ export const OrderedList = Node.create<OrderedListOptions>({
addOptions() {
return {
itemTypeName: 'listItem',
HTMLAttributes: {},
}
},
group: 'block list',
content: 'listItem+',
content() {
return `${this.options.itemTypeName}+`
},
addAttributes() {
return {
@@ -62,7 +66,7 @@ export const OrderedList = Node.create<OrderedListOptions>({
addCommands() {
return {
toggleOrderedList: () => ({ commands }) => {
return commands.toggleList(this.name, 'listItem')
return commands.toggleList(this.name, this.options.itemTypeName)
},
}
},