diff --git a/app/src/components/plugins/file.tsx b/app/src/components/plugins/file.tsx
index 721f271..4b82c69 100644
--- a/app/src/components/plugins/file.tsx
+++ b/app/src/components/plugins/file.tsx
@@ -1,5 +1,5 @@
import { Download, Eye, File } from "lucide-react";
-import { saveAsFile, saveBlobAsFile } from "@/utils/dom.ts";
+import { saveAsFile, saveBlobAsFile, saveImageAsFile } from "@/utils/dom.ts";
import { useMemo } from "react";
import { Button } from "@/components/ui/button.tsx";
import FileViewer from "@/components/FileViewer.tsx";
@@ -15,11 +15,16 @@ import FileViewer from "@/components/FileViewer.tsx";
export function parseFile(data: string, acceptDownload?: boolean) {
const filename = data.split("\n")[0].replace("[[", "").replace("]]", "");
const content = data.replace(`[[${filename}]]\n`, "");
+
const image = useMemo(() => {
// get image url from content (like: https://i.imgur.com/xxxxx.png)
- const match = content
- .toLowerCase()
- .match(/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/);
+ const match = content.match(/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/);
+ return match ? match[0] : "";
+ }, [filename, content]);
+
+ const b64image = useMemo(() => {
+ // get base64 image from content (like: data:image/png;base64,xxxxx)
+ const match = content.match(/(data:image\/.*;base64,.*=)/);
return match ? match[0] : "";
}, [filename, content]);
@@ -38,12 +43,16 @@ export function parseFile(data: string, acceptDownload?: boolean) {