From bf8b19dc19f711bdcef728593e881bc287363c6e Mon Sep 17 00:00:00 2001 From: lisiur Date: Sun, 9 Jul 2023 19:15:27 +0800 Subject: [PATCH] feat: support copying code block and highlighting user input's code support copying code block and highlighting user input's code fix #52 --- package.json | 1 + web/src/components/chat/History.tsx | 16 +++++------ web/src/style.css | 10 +++++++ web/src/themes/dark/vars.ts | 3 ++ web/src/themes/light/vars.ts | 3 ++ web/src/themes/types.ts | 3 ++ web/src/utils/mdRender.ts | 44 +++++++++++++++++++++++++++++ 7 files changed, 71 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 889dc07..f77f360 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "install": "cd web && pnpm install", "dev": "cd gui && RUST_LOG=chat_wizard_service=debug cargo tauri dev --no-watch", + "build": "pnpm run build:gui", "build:web": "cd web && pnpm build", "build:gui": "cd gui && cargo tauri build", "build:server": "pnpm run build:web && cd server && cargo build", diff --git a/web/src/components/chat/History.tsx b/web/src/components/chat/History.tsx index 798696e..e82dd4d 100644 --- a/web/src/components/chat/History.tsx +++ b/web/src/components/chat/History.tsx @@ -31,7 +31,7 @@ import { UserMessage, } from "../../models/message"; import { interceptLink } from "../../utils/interceptLink"; -import mdRender from "../../utils/mdRender"; +import { renderMarkdown } from "../../utils/mdRender"; import { writeToClipboard } from "../../utils/api"; import { Clipboard20Regular as CopyIcon, @@ -201,7 +201,7 @@ export default defineComponent({ if (codeBlockAssignNum % 2 === 1) { content += "\n```"; } - const html = mdRender(content); + const html = renderMarkdown(content); return (
{msg.done ? ( @@ -230,14 +229,13 @@ export default defineComponent({ } function renderUserMessage(msg: UserMessage) { + const html = renderMarkdown(msg.content); return (
-

{msg.content}

-
+ class="markdown-root user-msg inline-block px-3 ml-2 rounded-t-xl rounded-r-xl z-1" + v-html={html} + >