feat: add copy button to memo (#267)

* feat: copy-content

* Update web/src/less/memo-detail.less

Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
f97
2022-10-05 15:39:04 +07:00
committed by GitHub
parent ca2557eb7e
commit 2ea612e2fe
7 changed files with 106 additions and 53 deletions

View File

@ -1,3 +1,4 @@
import copy from "copy-to-clipboard";
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import { memo, useEffect, useRef, useState } from "react";
@ -61,6 +62,11 @@ const Memo: React.FC<Props> = (props: Props) => {
navigate(`/m/${memo.id}`);
};
const handleCopyContent = () => {
copy(memo.content);
toastHelper.success(t("message.succeed-copy-content"));
};
const handleTogglePinMemoBtnClick = async () => {
try {
if (memo.pinned) {
@ -205,6 +211,9 @@ const Memo: React.FC<Props> = (props: Props) => {
<span className="btn" onClick={handleMarkMemoClick}>
{t("common.mark")}
</span>
<span className="btn" onClick={handleCopyContent}>
{t("memo.copy")}
</span>
<span className="btn" onClick={handleViewMemoDetailPage}>
{t("memo.view-detail")}
</span>