Skip to content

Commit

Permalink
add custom copies
Browse files Browse the repository at this point in the history
  • Loading branch information
0-don committed Dec 19, 2024
1 parent 7625269 commit 1e2db9d
Showing 1 changed file with 45 additions and 11 deletions.
56 changes: 45 additions & 11 deletions src/components/pages/app/clipboard/base-clipboard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { BsJournalRichtext } from "solid-icons/bs";
import { IoTrashOutline } from "solid-icons/io";
import { TbSourceCode } from "solid-icons/tb";
import { VsStarFull } from "solid-icons/vs";
import { Component } from "solid-js";
import { ClipboardStore } from "../../../../store/clipboard-store";
Expand Down Expand Up @@ -45,25 +47,57 @@ export const BaseClipboard: Component<BaseClipboardProps> = (props) => {
);
};

const handleRtfCopy = async (e: MouseEvent) => {
e.stopPropagation();
await invokeCommand(InvokeCommand.CopyClipboard, {
id: clipboard.id,
type: ClipboardType.Rtf,
});
};

const handleHtmlCopy = async (e: MouseEvent) => {
e.stopPropagation();
await invokeCommand(InvokeCommand.CopyClipboard, {
id: clipboard.id,
type: ClipboardType.Html,
});
};

return (
<div class="group relative">
{/* Actions overlay */}
<div class="absolute bottom-0 right-0 top-0 z-10 m-2 flex w-4 flex-col items-end justify-between">
<VsStarFull
onClick={(e) => {
e.stopPropagation();
handleStar(clipboard);
}}
class={`${
clipboard.star ? "text-yellow-400 dark:text-yellow-300" : "hidden text-zinc-700"
} hover:text-yellow-400 group-hover:block dark:text-white dark:hover:text-yellow-300`}
/>
<div class="absolute bottom-0 right-0 top-0 z-10 flex flex-col items-end justify-between">
<div class="flex flex-col justify-between">
<VsStarFull
onClick={(e) => {
e.stopPropagation();
handleStar(clipboard);
}}
class={`${
clipboard.star ? "text-yellow-400 dark:text-yellow-300" : "hidden text-zinc-700"
} text-lg hover:text-yellow-400 group-hover:block dark:text-white dark:hover:text-yellow-300`}
/>
{props.data.rtf && (
<BsJournalRichtext
onClick={handleRtfCopy}
title="Copy as RTF"
class="hidden text-lg text-zinc-700 hover:text-blue-600 group-hover:block dark:text-white dark:hover:text-blue-400"
/>
)}
{props.data.html && (
<TbSourceCode
onClick={handleHtmlCopy}
title="Copy as HTML"
class="hidden text-lg text-zinc-700 hover:text-green-600 group-hover:block dark:text-white dark:hover:text-green-400"
/>
)}
</div>
<IoTrashOutline
onClick={(e) => {
e.stopPropagation();
handleDelete(clipboard.id);
}}
class="hidden text-zinc-700 hover:text-red-600 group-hover:block dark:text-white dark:hover:text-red-600"
class="hidden text-lg text-zinc-700 hover:text-red-600 group-hover:block dark:text-white dark:hover:text-red-600"
/>
</div>

Expand Down

0 comments on commit 1e2db9d

Please sign in to comment.