Skip to content

Commit

Permalink
Add markdown view toggle for all revise messages
Browse files Browse the repository at this point in the history
  • Loading branch information
codewithcheese committed Aug 1, 2024
1 parent cf5fa40 commit f143de4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/routes/(app)/chat/[id]/MessageCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import type { ChatMessage } from "$lib/chat-service.svelte";
import MessageEditor from "./MessageEditor.svelte";
import { Button } from "@/components/ui/button";
import { FilePlus2Icon, Trash2Icon } from "lucide-svelte";
import { EditIcon, EyeIcon, FilePlus2Icon, Trash2Icon } from "lucide-svelte";
import AttachmentControls from "./AttachmentControls.svelte";
import {
DropdownMenu,
Expand Down Expand Up @@ -37,6 +37,7 @@
}: Props = $props();
let format = "markdown";
let showAttachmentControls = $state(false);
let mode: "edit" | "view" = $state("edit");
function handleKeyPress(event: KeyboardEvent) {
if (event.ctrlKey && event.key === "Enter") {
Expand Down Expand Up @@ -98,7 +99,18 @@
>
<FilePlus2Icon class="h-4 w-4" />
</Button>

<Button
class="h-fit w-fit p-1 text-gray-500 hover:text-black "
variant="ghost"
size="icon"
onclick={() => (mode = mode === "edit" ? "view" : "edit")}
>
{#if mode === "view"}
<EditIcon class="h-4 w-4" />
{:else}
<EyeIcon class="h-4 w-4" />
{/if}
</Button>
<Button
class="h-fit w-fit p-1 text-gray-500 hover:text-black"
variant="ghost"
Expand All @@ -110,7 +122,7 @@
</div>
{/if}
<CardContent class={cn("p-4", editable && "pt-0")}>
{#if editable}
{#if mode === "edit" && editable}
<MessageEditor
id={message.id}
content={message.content}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(app)/chat/[id]/revise/RevisePage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
version: revision ? revision.version : 1,
initialMessages: revision.messages.map(toChatMessage),
onLoading: () => {
responseMode = "edit";
responseMode = "view";
autoScroller.onLoading();
},
onError: (e) => {
Expand Down

0 comments on commit f143de4

Please sign in to comment.