From da9ad6b2159cbbf17804d13dff72a49ea34b40ea Mon Sep 17 00:00:00 2001 From: Tobias Waslowski Date: Thu, 7 Aug 2025 20:07:38 +0200 Subject: [PATCH] fix(commands): cursor offset --- .../components/MemoEditor/Editor/CommandSuggestions.tsx | 2 +- web/src/components/MemoEditor/Editor/commands.ts | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/web/src/components/MemoEditor/Editor/CommandSuggestions.tsx b/web/src/components/MemoEditor/Editor/CommandSuggestions.tsx index 200d7267d..be73e1111 100644 --- a/web/src/components/MemoEditor/Editor/CommandSuggestions.tsx +++ b/web/src/components/MemoEditor/Editor/CommandSuggestions.tsx @@ -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(); }; diff --git a/web/src/components/MemoEditor/Editor/commands.ts b/web/src/components/MemoEditor/Editor/commands.ts index 766bbf4ee..edc375842 100644 --- a/web/src/components/MemoEditor/Editor/commands.ts +++ b/web/src/components/MemoEditor/Editor/commands.ts @@ -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",