From fd5339d90abdb664111bb4ae54a68b6a3ff6c5f1 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Sat, 19 Oct 2024 18:22:33 +0530 Subject: [PATCH 1/8] Bump version to 1.3.1 Minor version bump to reflect updates. --- wxt.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wxt.config.ts b/wxt.config.ts index eac1c2b..5d06de7 100644 --- a/wxt.config.ts +++ b/wxt.config.ts @@ -50,7 +50,7 @@ export default defineConfig({ outDir: "build", manifest: { - version: "1.3.0", + version: "1.3.1", name: process.env.TARGET === "firefox" ? "Page Assist - A Web UI for Local AI Models" From 7be993c0578f2e8ee7a16c409908a859675bb3af Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Sat, 19 Oct 2024 23:54:09 +0530 Subject: [PATCH 2/8] feat: Add HTML preview to code blocks Adds an HTML preview feature to the code block component, allowing users to view the rendered output of their HTML code snippets. This improves the user experience by providing a more interactive and informative way to understand the code. --- src/components/Common/CodeBlock.tsx | 65 +++++++++++++++---- .../Option/Playground/PlaygroundChat.tsx | 2 +- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/components/Common/CodeBlock.tsx b/src/components/Common/CodeBlock.tsx index ea112f2..d48a699 100644 --- a/src/components/Common/CodeBlock.tsx +++ b/src/components/Common/CodeBlock.tsx @@ -1,6 +1,6 @@ -import { Tooltip } from "antd" -import { CheckIcon, ClipboardIcon } from "lucide-react" -import { FC, useState } from "react" +import { Tooltip, Modal } from "antd" +import { CheckIcon, ClipboardIcon, EyeIcon, Maximize2Icon } from "lucide-react" +import { FC, useState } from "react" import { useTranslation } from "react-i18next" import { Prism as SyntaxHighlighter } from "react-syntax-highlighter" import { coldarkDark } from "react-syntax-highlighter/dist/cjs/styles/prism" @@ -10,26 +10,47 @@ interface Props { value: string } -export const CodeBlock: FC =({ language, value }) => { +export const CodeBlock: FC = ({ language, value }) => { const [isBtnPressed, setIsBtnPressed] = useState(false) + const [previewVisible, setPreviewVisible] = useState(false) const { t } = useTranslation("common") + + const handleCopy = () => { + navigator.clipboard.writeText(value) + setIsBtnPressed(true) + setTimeout(() => { + setIsBtnPressed(false) + }, 4000) + } + + const handlePreview = () => { + setPreviewVisible(true) + } + + const handlePreviewClose = () => { + setPreviewVisible(false) + } + return ( <> -
+
{language}
+ {language.toLowerCase() === "html" && ( + + + + )}
+ {previewVisible && ( + +
+