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

pull/2980/head
Kazuki H 1 year ago committed by GitHub
parent fc1a2cf2fc
commit a86117f613
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 (

Loading…
Cancel
Save