mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: support command + k
shortcuts insert []() (#793)
* feat: support `command + k` shortcuts insert []() * fix: eslint * fix: clear code * fix: eslint * feat: insert [](url) * refactor: rename param * fix: eslint
This commit is contained in:
@ -122,6 +122,16 @@ const MemoEditor = () => {
|
||||
editorRef.current.insertText("", "`", "`");
|
||||
return;
|
||||
}
|
||||
if (event.key === "k") {
|
||||
event.preventDefault();
|
||||
const selectedContent = editorRef.current.getSelectedContent();
|
||||
editorRef.current.insertText("", "[", "](url)");
|
||||
if (selectedContent) {
|
||||
const startPos = editorRef.current.getCursorPosition() + 2;
|
||||
const endPos = startPos + 3;
|
||||
editorRef.current.setCursorPosition(startPos, endPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.key === "Enter") {
|
||||
|
Reference in New Issue
Block a user