Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: unexpected empty lines when copying-pasting (#1654)

CorrectRoadHe1c809d6f1af
diff --git a/web/src/components/MemoList.tsx b/web/src/components/MemoList.tsx
index af6bfb578..2262925de 100644
--- a/web/src/components/MemoList.tsx
+++ b/web/src/components/MemoList.tsx
@@ -8,6 +8,7 @@ import { DEFAULT_MEMO_LIMIT } from "@/helpers/consts";
import { checkShouldShowMemoWithFilters } from "@/helpers/filter";
import Memo from "./Memo";
import "@/less/memo-list.less";
+import copy from "copy-to-clipboard";
const MemoList = () => {
const { t } = useTranslation();
@@ -148,6 +149,21 @@ const MemoList = () => {
}
};
+ useEffect(() => {
+ window.addEventListener("copy", handleCopy);
+ return () => {
+ window.removeEventListener("copy", handleCopy);
+ };
+ }, []);
+
+ const handleCopy = (event: ClipboardEvent) => {
+ event.preventDefault();
+ const rawStr = document.getSelection()?.toString();
+ if (rawStr !== undefined) {
+ copy(rawStr.split("\n\n").join("\n"));
+ }
+ };
+
return (
<div className="memo-list-container">
{sortedMemos.map((memo) => (