mirror of
https://github.com/usememos/memos.git
synced 2024-12-21 02:01:55 +03:00
fix: memo formater
This commit is contained in:
parent
076c42d9c4
commit
374721fa48
@ -146,6 +146,11 @@ export function formatMemoContent(content: string) {
|
||||
content = content.replace(IMAGE_URL_REG, "");
|
||||
}
|
||||
|
||||
content = content
|
||||
.replace(TAG_REG, "<span class='tag-span'>#$1</span>")
|
||||
.replace(LINK_REG, "<a class='link' target='_blank' rel='noreferrer' href='$1'>$1</a>")
|
||||
.replace(MEMO_LINK_REG, "<span class='memo-link-text' data-value='$2'>$1</span>");
|
||||
|
||||
// 中英文之间加空格
|
||||
if (shouldSplitMemoWord) {
|
||||
content = content
|
||||
@ -153,11 +158,6 @@ export function formatMemoContent(content: string) {
|
||||
.replace(/([A-Za-z0-9?.,;[\]]+)([\u4e00-\u9fa5])/g, "$1 $2");
|
||||
}
|
||||
|
||||
content = content
|
||||
.replace(TAG_REG, "<span class='tag-span'>#$1</span>")
|
||||
.replace(LINK_REG, "<a class='link' target='_blank' rel='noreferrer' href='$1'>$1</a>")
|
||||
.replace(MEMO_LINK_REG, "<span class='memo-link-text' data-value='$2'>$1</span>");
|
||||
|
||||
const tempDivContainer = document.createElement("div");
|
||||
tempDivContainer.innerHTML = content;
|
||||
for (let i = 0; i < tempDivContainer.children.length; i++) {
|
||||
|
@ -116,6 +116,8 @@ const MemoEditor: React.FC<Props> = () => {
|
||||
return () => {
|
||||
editorRef.current?.element.removeEventListener("paste", handlePasteEvent);
|
||||
editorRef.current?.element.removeEventListener("drop", handleDropEvent);
|
||||
editorRef.current?.element.removeEventListener("click", handleClickEvent);
|
||||
editorRef.current?.element.removeEventListener("keydown", handleKeyDownEvent);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user