Update code.ts

At the end of the paragraph, press the right key and then jump out of the inlineCode wrapper
This commit is contained in:
samyoo-zhang 2024-05-29 18:25:30 +08:00 committed by GitHub
parent 0e82b50fde
commit 63f5f07d32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -92,11 +92,10 @@ export const Code = Mark.create<CodeOptions>({
ArrowRight: event => {
const state: EditorState = event?.editor?.state;
const { $cursor }: any = state.selection || {};
// At the end of the paragraph, press the right key and jump out of the inlineCode wrapper
// At the end of the paragraph, press the right key and then jump out of the inlineCode wrapper
const isInlineCode = $cursor?.nodeBefore?.marks?.some((mark: Mark) => mark.type?.name === 'code');
if ($cursor && isInlineCode && !$cursor.nodeAfter) {
this.editor.chain().unsetCode().insertContent(' ').run();
return false;
}
return false;
},