fix(commands): cursor offset

This commit is contained in:
Tobias Waslowski 2025-08-07 20:07:38 +02:00
parent 953ec72338
commit da9ad6b215
No known key found for this signature in database
GPG Key ID: 30013DA2D0F8AFAD
2 changed files with 2 additions and 8 deletions

View File

@ -50,7 +50,7 @@ const CommandSuggestions = observer(({ editorRef, editorActions, commands }: Pro
editorActions.current.removeText(index, word.length);
editorActions.current.insertText(cmd.run());
if (cmd.cursorOffset) {
editorActions.current.setCursorPosition(cmd.cursorOffset);
editorActions.current.setCursorPosition(editorActions.current.getCursorPosition() + cmd.cursorOffset);
}
hide();
};

View File

@ -20,17 +20,11 @@ export const editorCommands: Command[] = [
cursorOffset: 1,
},
{
name: "table-2",
name: "table",
description: "Insert a table",
run: () => "| Header | Header |\n| ------ | ------ |\n| Cell | Cell |",
cursorOffset: 1,
},
{
name: "table-3",
description: "Insert a table",
run: () => "| Header | Header | Header |\n| ------ | ------ | ------ |\n| Cell | Cell | Cell |",
cursorOffset: 1,
},
{
name: "highlight",
description: "Insert highlighted text",