Skip to content

Commit

Permalink
feat: add a button to copy markdown extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Oct 21, 2024
1 parent bdf8472 commit 5ad3000
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/utils/copy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { toast } from "svelte-sonner"

export async function copy(text: string) {
try {
await navigator.clipboard.writeText(text)
toast.success("Copied to clipboard")
} catch (err) {
toast.error(String(err))
}
}
4 changes: 4 additions & 0 deletions src/routes/(static)/read/Right.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import ToggleGroup from "./ToggleGroup.svelte"
import Highlight from "$lib/Highlight.svelte"
import Markdown from "$lib/Markdown.svelte"
import { copy } from "$lib/utils/copy"
import { toMarkdown } from "$lib/utils/html2md"
import { responseToTextStream } from "$lib/utils/iter"
import { read } from "$lib/utils/reader"
Expand Down Expand Up @@ -55,6 +56,9 @@
<div class="absolute bottom-5 z-1 flex flex-row gap-1.5 md:left-5 <md:(w-full justify-center)">
<ToggleGroup values={["llm", "readability"]} bind:choice={$engine} />
<ToggleGroup values={["rendered", "raw"]} bind:choice={$type} />
<button on:click={() => copy(displayMarkdown)} class="rounded-md bg-neutral-8 p-2 shadow-(md neutral-9/15) transition hover:bg-neutral-7">
<div class="i-ri-file-copy-line" />
</button>
</div>

</section>

0 comments on commit 5ad3000

Please sign in to comment.