diff --git a/web/src/components/MemoEditor/ActionButton/TagSelector.tsx b/web/src/components/MemoEditor/ActionButton/TagSelector.tsx index e3660be4..186c87ea 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 (