mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 11:49:02 +08:00
feat: escape code blocks on arrow down, fix #1204
This commit is contained in:
parent
44ccba2b42
commit
ffafff9e36
@ -146,6 +146,37 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
|
||||
.exitCode()
|
||||
.run()
|
||||
},
|
||||
|
||||
// escape node on arrow down
|
||||
ArrowDown: ({ editor }) => {
|
||||
const { state } = editor
|
||||
const { selection, doc } = state
|
||||
const { $from, empty } = selection
|
||||
|
||||
if (!empty || $from.parent.type !== this.type) {
|
||||
return false
|
||||
}
|
||||
|
||||
const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2
|
||||
|
||||
if (!isAtEnd) {
|
||||
return false
|
||||
}
|
||||
|
||||
const after = $from.after()
|
||||
|
||||
if (after === undefined) {
|
||||
return false
|
||||
}
|
||||
|
||||
const nodeAfter = doc.nodeAt(after)
|
||||
|
||||
if (nodeAfter) {
|
||||
return false
|
||||
}
|
||||
|
||||
return editor.commands.exitCode()
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user