move inputrule from task_list to task_item

This commit is contained in:
Philipp Kühn
2020-10-30 16:51:25 +01:00
parent 9dabdfe288
commit a8216d0840
2 changed files with 15 additions and 10 deletions

View File

@@ -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

View File

@@ -1,8 +1,4 @@
import { Command, createNode, mergeAttributes } from '@tiptap/core'
import { wrappingInputRule } from 'prosemirror-inputrules'
// TODO: add suport for [ ] and [x]
export const inputRegex = /^\s*(\[ \])\s$/
const TaskList = createNode({
name: 'task_list',
@@ -33,12 +29,6 @@ const TaskList = createNode({
},
}
},
addInputRules() {
return [
wrappingInputRule(inputRegex, this.type),
]
},
})
export default TaskList