mirror of
https://github.com/usememos/memos.git
synced 2025-04-25 14:48:48 +02:00
fix: unexpected empty lines when copying-pasting (#1654)
This commit is contained in:
parent
218009a5ec
commit
e1c809d6f1
@ -8,6 +8,7 @@ import { DEFAULT_MEMO_LIMIT } from "@/helpers/consts";
|
|||||||
import { checkShouldShowMemoWithFilters } from "@/helpers/filter";
|
import { checkShouldShowMemoWithFilters } from "@/helpers/filter";
|
||||||
import Memo from "./Memo";
|
import Memo from "./Memo";
|
||||||
import "@/less/memo-list.less";
|
import "@/less/memo-list.less";
|
||||||
|
import copy from "copy-to-clipboard";
|
||||||
|
|
||||||
const MemoList = () => {
|
const MemoList = () => {
|
||||||
const { t } = useTranslation();
|
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 (
|
return (
|
||||||
<div className="memo-list-container">
|
<div className="memo-list-container">
|
||||||
{sortedMemos.map((memo) => (
|
{sortedMemos.map((memo) => (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user