mirror of https://github.com/usememos/memos.git
fix(commands): cursor offset
This commit is contained in:
parent
953ec72338
commit
da9ad6b215
|
|
@ -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();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue