fix: copy-to-clipboard not works well in Safari (#1779)

* Fix copy-to-clipboard not works well in Safari

* Fix typescript type check failure

* Remove global copy inject in home page

---------

Co-authored-by: Athurg Feng <athurg@gooth.org>
This commit is contained in:
Athurg Gooth 2023-06-01 08:53:40 +08:00 committed by GitHub
parent dd8c10743d
commit 55cf19aa2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,6 @@ import { checkShouldShowMemoWithFilters } from "@/helpers/filter";
import Memo from "./Memo";
import "@/less/memo-list.less";
import { PLAIN_LINK_REG } from "@/labs/marked/parser";
import copy from "copy-to-clipboard";
const MemoList = () => {
const { t } = useTranslation();
@ -151,21 +150,6 @@ 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) => (