Skip to content

Commit

Permalink
e
Browse files Browse the repository at this point in the history
  • Loading branch information
winetree94 committed Dec 22, 2023
1 parent fef56c0 commit 718da7d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/core/src/plugins/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
13 changes: 11 additions & 2 deletions packages/core/src/plugins/virtual-cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/mention/src/schemas/mention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const edimMentionMarks = (

const markSpec: MarkSpec = {
inclusive: false,
excludes: '_',
attrs: {
data_id: {
default: '',
Expand Down

0 comments on commit 718da7d

Please sign in to comment.