Skip to content

Commit 21b9028

Browse files
committed
fix(web): move cursor when setMention before the indicator
1 parent e631d40 commit 21b9028

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/web/pmPlugins/MentionPlugin/setMention.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Fragment } from '@tiptap/pm/model';
2-
import type { EditorState } from '@tiptap/pm/state';
2+
import { TextSelection, type EditorState } from '@tiptap/pm/state';
33
import type { Editor } from '@tiptap/react';
44
import { isCaretInBlockedContext } from './isCaretInBlockedContext';
55
import { mentionPluginKey } from './mentionPluginKey';
@@ -68,6 +68,10 @@ export function setMention(
6868
.focus()
6969
.command(({ tr }) => {
7070
tr.replaceWith(from, extendedTo, fragment);
71+
72+
const targetPos = from + fragment.size + (hasSpaceAfter ? 1 : 0);
73+
tr.setSelection(TextSelection.create(tr.doc, targetPos));
74+
7175
return true;
7276
})
7377
.run();

0 commit comments

Comments
 (0)