move inputrule from task_list to task_item
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import { createNode, mergeAttributes } from '@tiptap/core'
|
||||
import { wrappingInputRule } from 'prosemirror-inputrules'
|
||||
|
||||
export const inputRegex = /^\s*(\[([ |x])\])\s$/
|
||||
|
||||
export interface TaskItemOptions {
|
||||
nested: boolean,
|
||||
@@ -94,6 +97,18 @@ const TaskItem = createNode({
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addInputRules() {
|
||||
return [
|
||||
wrappingInputRule(
|
||||
inputRegex,
|
||||
this.type,
|
||||
match => ({
|
||||
checked: match[match.length - 1] === 'x',
|
||||
}),
|
||||
),
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
export default TaskItem
|
||||
|
||||
Reference in New Issue
Block a user