From c3365336dfec7d2ffdbc8508e239c1032018a6f0 Mon Sep 17 00:00:00 2001 From: samyoo-zhang <47513335+samyoo-zhang@users.noreply.github.com> Date: Wed, 29 May 2024 17:41:38 +0800 Subject: [PATCH 1/3] Update code.ts At the end of the paragraph, press the right key and jump out of the inlineCode wrapper --- packages/extension-code/src/code.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/extension-code/src/code.ts b/packages/extension-code/src/code.ts index 068804b512e..7413d1881de 100644 --- a/packages/extension-code/src/code.ts +++ b/packages/extension-code/src/code.ts @@ -89,6 +89,18 @@ export const Code = Mark.create({ addKeyboardShortcuts() { return { 'Mod-e': () => this.editor.commands.toggleCode(), + 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 + const isInlineCode = $cursor?.nodeBefore?.marks?.some((mark: Mark) => mark.type?.name === 'code'); + if ($cursor && isInlineCode && !$cursor.nodeAfter) { + this.editor.commands.unsetCode(); + this.editor.commands.insertContent(' '); + return false; + } + return false; + }, } }, From 0e82b50fde7376a53117d3298d974bc76a95ed74 Mon Sep 17 00:00:00 2001 From: samyoo-zhang <47513335+samyoo-zhang@users.noreply.github.com> Date: Wed, 29 May 2024 17:52:57 +0800 Subject: [PATCH 2/3] Update code.ts At the end of the paragraph, press the right key and jump out of the inlineCode wrapper --- packages/extension-code/src/code.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/extension-code/src/code.ts b/packages/extension-code/src/code.ts index 7413d1881de..43a1ff0d8a7 100644 --- a/packages/extension-code/src/code.ts +++ b/packages/extension-code/src/code.ts @@ -95,8 +95,7 @@ export const Code = Mark.create({ // At the end of the paragraph, press the right key and 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.commands.unsetCode(); - this.editor.commands.insertContent(' '); + this.editor.chain().unsetCode().insertContent(' ').run(); return false; } return false; From 63f5f07d32c4adc55b8a3870fa1eeafc2627d758 Mon Sep 17 00:00:00 2001 From: samyoo-zhang <47513335+samyoo-zhang@users.noreply.github.com> Date: Wed, 29 May 2024 18:25:30 +0800 Subject: [PATCH 3/3] Update code.ts At the end of the paragraph, press the right key and then jump out of the inlineCode wrapper --- packages/extension-code/src/code.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/extension-code/src/code.ts b/packages/extension-code/src/code.ts index 43a1ff0d8a7..408c22c532c 100644 --- a/packages/extension-code/src/code.ts +++ b/packages/extension-code/src/code.ts @@ -92,11 +92,10 @@ export const Code = Mark.create({ 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; },