mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
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:
@ -9,7 +9,6 @@ import { checkShouldShowMemoWithFilters } from "@/helpers/filter";
|
|||||||
import Memo from "./Memo";
|
import Memo from "./Memo";
|
||||||
import "@/less/memo-list.less";
|
import "@/less/memo-list.less";
|
||||||
import { PLAIN_LINK_REG } from "@/labs/marked/parser";
|
import { PLAIN_LINK_REG } from "@/labs/marked/parser";
|
||||||
import copy from "copy-to-clipboard";
|
|
||||||
|
|
||||||
const MemoList = () => {
|
const MemoList = () => {
|
||||||
const { t } = useTranslation();
|
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 (
|
return (
|
||||||
<div className="memo-list-container">
|
<div className="memo-list-container">
|
||||||
{sortedMemos.map((memo) => (
|
{sortedMemos.map((memo) => (
|
||||||
|
Reference in New Issue
Block a user