feat: add copy content functionality to MemoActionMenu
This commit is contained in:
parent
686d31b357
commit
7079790d4f
3 changed files with 36 additions and 6 deletions
|
|
@ -6,6 +6,8 @@ import {
|
||||||
BookmarkPlusIcon,
|
BookmarkPlusIcon,
|
||||||
CopyIcon,
|
CopyIcon,
|
||||||
Edit3Icon,
|
Edit3Icon,
|
||||||
|
FileTextIcon,
|
||||||
|
LinkIcon,
|
||||||
MoreVerticalIcon,
|
MoreVerticalIcon,
|
||||||
TrashIcon,
|
TrashIcon,
|
||||||
SquareCheckIcon,
|
SquareCheckIcon,
|
||||||
|
|
@ -24,7 +26,15 @@ import { NodeType } from "@/types/proto/api/v1/markdown_service";
|
||||||
import { Memo } from "@/types/proto/api/v1/memo_service";
|
import { Memo } from "@/types/proto/api/v1/memo_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import { Button } from "./ui/button";
|
import { Button } from "./ui/button";
|
||||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "./ui/dropdown-menu";
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuSub,
|
||||||
|
DropdownMenuSubContent,
|
||||||
|
DropdownMenuSubTrigger,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from "./ui/dropdown-menu";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
memo: Memo;
|
memo: Memo;
|
||||||
|
|
@ -127,6 +137,11 @@ const MemoActionMenu = observer((props: Props) => {
|
||||||
toast.success(t("message.succeed-copy-link"));
|
toast.success(t("message.succeed-copy-link"));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCopyContent = () => {
|
||||||
|
copy(memo.content);
|
||||||
|
toast.success(t("message.succeed-copy-content"));
|
||||||
|
};
|
||||||
|
|
||||||
const handleDeleteMemoClick = () => {
|
const handleDeleteMemoClick = () => {
|
||||||
setDeleteDialogOpen(true);
|
setDeleteDialogOpen(true);
|
||||||
};
|
};
|
||||||
|
|
@ -196,10 +211,22 @@ const MemoActionMenu = observer((props: Props) => {
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{!isArchived && (
|
{!isArchived && (
|
||||||
<DropdownMenuItem onClick={handleCopyLink}>
|
<DropdownMenuSub>
|
||||||
|
<DropdownMenuSubTrigger>
|
||||||
<CopyIcon className="w-4 h-auto" />
|
<CopyIcon className="w-4 h-auto" />
|
||||||
|
{t("common.copy")}
|
||||||
|
</DropdownMenuSubTrigger>
|
||||||
|
<DropdownMenuSubContent>
|
||||||
|
<DropdownMenuItem onClick={handleCopyLink}>
|
||||||
|
<LinkIcon className="w-4 h-auto" />
|
||||||
{t("memo.copy-link")}
|
{t("memo.copy-link")}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem onClick={handleCopyContent}>
|
||||||
|
<FileTextIcon className="w-4 h-auto" />
|
||||||
|
{t("memo.copy-content")}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuSubContent>
|
||||||
|
</DropdownMenuSub>
|
||||||
)}
|
)}
|
||||||
{!readonly && (
|
{!readonly && (
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ function DropdownMenuSubTrigger({
|
||||||
data-slot="dropdown-menu-sub-trigger"
|
data-slot="dropdown-menu-sub-trigger"
|
||||||
data-inset={inset}
|
data-inset={inset}
|
||||||
className={cn(
|
className={cn(
|
||||||
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8",
|
"focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
"close": "Close",
|
"close": "Close",
|
||||||
"collapse": "Collapse",
|
"collapse": "Collapse",
|
||||||
"confirm": "Confirm",
|
"confirm": "Confirm",
|
||||||
|
"copy": "Copy",
|
||||||
"create": "Create",
|
"create": "Create",
|
||||||
"created-at": "Created At",
|
"created-at": "Created At",
|
||||||
"database": "Database",
|
"database": "Database",
|
||||||
|
|
@ -141,6 +142,7 @@
|
||||||
"self": "Comments",
|
"self": "Comments",
|
||||||
"write-a-comment": "Write a comment"
|
"write-a-comment": "Write a comment"
|
||||||
},
|
},
|
||||||
|
"copy-content": "Copy Content",
|
||||||
"copy-link": "Copy Link",
|
"copy-link": "Copy Link",
|
||||||
"count-memos-in-date": "{{count}} {{memos}} in {{date}}",
|
"count-memos-in-date": "{{count}} {{memos}} in {{date}}",
|
||||||
"delete-confirm": "Are you sure you want to delete this memo?",
|
"delete-confirm": "Are you sure you want to delete this memo?",
|
||||||
|
|
@ -188,6 +190,7 @@
|
||||||
"password-not-match": "Passwords do not match.",
|
"password-not-match": "Passwords do not match.",
|
||||||
"remove-completed-task-list-items-successfully": "The removal was successful",
|
"remove-completed-task-list-items-successfully": "The removal was successful",
|
||||||
"restored-successfully": "Restored successfully",
|
"restored-successfully": "Restored successfully",
|
||||||
|
"succeed-copy-content": "Content copied successfully.",
|
||||||
"succeed-copy-link": "Link copied successfully.",
|
"succeed-copy-link": "Link copied successfully.",
|
||||||
"update-succeed": "Update succeeded",
|
"update-succeed": "Update succeeded",
|
||||||
"user-not-found": "User not found"
|
"user-not-found": "User not found"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue