fix(code-block): on arrow down move to next node (#4721)

This commit is contained in:
hollykurt 2024-07-22 16:17:03 +03:00 committed by GitHub
parent 618bca91e8
commit 4e5b2d89cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/extension-code-block": patch
---
code-block: on arrow down move into the next node

View File

@ -1,5 +1,10 @@
import { mergeAttributes, Node, textblockTypeInputRule } from '@tiptap/core'
import { Plugin, PluginKey, TextSelection } from '@tiptap/pm/state'
import {
Plugin,
PluginKey,
Selection,
TextSelection,
} from '@tiptap/pm/state'
export interface CodeBlockOptions {
/**
@ -222,7 +227,10 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
const nodeAfter = doc.nodeAt(after)
if (nodeAfter) {
return false
return editor.commands.command(({ tr }) => {
tr.setSelection(Selection.near(doc.resolve(after)))
return true
})
}
return editor.commands.exitCode()