From 718da7df527b6e54dcec3f7bafd8abbfc619bae9 Mon Sep 17 00:00:00 2001 From: winetree94 Date: Fri, 22 Dec 2023 18:33:47 +0900 Subject: [PATCH] e --- packages/core/src/plugins/keymap.ts | 6 ++++++ packages/core/src/plugins/virtual-cursor.ts | 13 +++++++++++-- packages/mention/src/schemas/mention.ts | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/core/src/plugins/keymap.ts b/packages/core/src/plugins/keymap.ts index 019655fa..6a196034 100644 --- a/packages/core/src/plugins/keymap.ts +++ b/packages/core/src/plugins/keymap.ts @@ -6,6 +6,12 @@ import { clearMarks } from '../commands'; export const edimBasicKeymapPlugins = (): Plugin[] => { return [ keymap({ + /** + * Prevents focus from leaving when the Tab key is pressed. + */ + 'Shift-Tab': () => true, + Tab: () => true, + /** * Switch to the default node of the Schema when the first node is empty. */ diff --git a/packages/core/src/plugins/virtual-cursor.ts b/packages/core/src/plugins/virtual-cursor.ts index d5f2f0fa..9306f370 100644 --- a/packages/core/src/plugins/virtual-cursor.ts +++ b/packages/core/src/plugins/virtual-cursor.ts @@ -65,8 +65,16 @@ export function edimVirtualCursorPlugins(): PMPlugin[] { } } + const hasInexclusiveMark = marks.find( + (m) => m?.type.spec.inclusive === false, + ); + // Move the cursor and also change the stored marks - if (event.key === 'ArrowLeft' && $pos.textOffset === 1) { + if ( + event.key === 'ArrowLeft' && + $pos.textOffset === 1 && + !hasInexclusiveMark + ) { view.dispatch( view.state.tr .setSelection( @@ -80,7 +88,8 @@ export function edimVirtualCursorPlugins(): PMPlugin[] { if ( event.key === 'ArrowRight' && $pos.textOffset + 1 === - $pos.parent.maybeChild($pos.index())?.nodeSize + $pos.parent.maybeChild($pos.index())?.nodeSize && + !hasInexclusiveMark ) { view.dispatch( view.state.tr diff --git a/packages/mention/src/schemas/mention.ts b/packages/mention/src/schemas/mention.ts index c7048d89..753e99c7 100644 --- a/packages/mention/src/schemas/mention.ts +++ b/packages/mention/src/schemas/mention.ts @@ -24,6 +24,7 @@ export const edimMentionMarks = ( const markSpec: MarkSpec = { inclusive: false, + excludes: '_', attrs: { data_id: { default: '',