Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

feat: add new line if the cursor is on a character when adding a tag (#2960)

Kazuki Ha86117f61367
diff --git a/web/src/components/MemoEditor/ActionButton/TagSelector.tsx b/web/src/components/MemoEditor/ActionButton/TagSelector.tsx
index e3660be48..186c87ea1 100644
--- a/web/src/components/MemoEditor/ActionButton/TagSelector.tsx
+++ b/web/src/components/MemoEditor/ActionButton/TagSelector.tsx
@@ -32,7 +32,16 @@ const TagSelector = (props: Props) => {
});
const handleTagClick = (tag: string) => {
- editorRef.current?.insertText(`#${tag} `);
+ const current = editorRef.current;
+ if (current === null) return;
+
+ const line = current.getLine(current.getCursorLineNumber());
+ const lastCharOfLine = line.slice(-1);
+
+ if (lastCharOfLine !== " " && lastCharOfLine !== " " && line !== "") {
+ current.insertText("\n");
+ }
+ current.insertText(`#${tag} `);
};
return (