mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 09:25:29 +08:00
Merge 4a01efc55c
into 1577ec0d47
This commit is contained in:
commit
b820acf2af
@ -149,7 +149,7 @@ export const TaskItem = Node.create<TaskItemOptions>({
|
||||
|
||||
const { checked } = event.target as any
|
||||
|
||||
if (editor.isEditable && typeof getPos === 'function') {
|
||||
if (typeof getPos === 'function') {
|
||||
editor
|
||||
.chain()
|
||||
.focus(undefined, { scrollIntoView: false })
|
||||
@ -161,6 +161,14 @@ export const TaskItem = Node.create<TaskItemOptions>({
|
||||
}
|
||||
const currentNode = tr.doc.nodeAt(position)
|
||||
|
||||
if (!editor.isEditable && this.options.onReadOnlyChecked) {
|
||||
// Reset state if onReadOnlyChecked returns false
|
||||
if (!currentNode || !this.options.onReadOnlyChecked(currentNode, checked)) {
|
||||
checkbox.checked = !checkbox.checked
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
tr.setNodeMarkup(position, undefined, {
|
||||
...currentNode?.attrs,
|
||||
checked,
|
||||
@ -170,12 +178,6 @@ export const TaskItem = Node.create<TaskItemOptions>({
|
||||
})
|
||||
.run()
|
||||
}
|
||||
if (!editor.isEditable && this.options.onReadOnlyChecked) {
|
||||
// Reset state if onReadOnlyChecked returns false
|
||||
if (!this.options.onReadOnlyChecked(node, checked)) {
|
||||
checkbox.checked = !checkbox.checked
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Object.entries(this.options.HTMLAttributes).forEach(([key, value]) => {
|
||||
|
Loading…
Reference in New Issue
Block a user