mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
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:
@ -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>
|
||||
|
Reference in New Issue
Block a user