Unverified Commit a86117f6 authored by Kazuki H's avatar Kazuki H Committed by GitHub

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

parent fc1a2cf2
...@@ -32,7 +32,16 @@ const TagSelector = (props: Props) => { ...@@ -32,7 +32,16 @@ const TagSelector = (props: Props) => {
}); });
const handleTagClick = (tag: string) => { 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 ( return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment