mirror of
https://github.com/usememos/memos.git
synced 2025-10-13 07:49:00 +08:00
feat: add new line if the cursor is on a character when adding a tag (#2960)
This commit is contained in:
parent
fc1a2cf2fc
commit
a86117f613
1 changed files with 10 additions and 1 deletions
|
@ -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 (
|
||||||
|
|
Loading…
Add table
Reference in a new issue