From df9cca5a52ac14f996711e422b8b6ca64dc34de8 Mon Sep 17 00:00:00 2001 From: Thuc Pham <51660321+thucpn@users.noreply.github.com> Date: Wed, 24 Jul 2024 16:03:58 +0700 Subject: [PATCH] feat: upgrade pdf viewer (#179) --------- Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de> --- .changeset/young-cameras-boil.md | 5 +++++ .../app/components/ui/chat/widgets/PdfDialog.tsx | 14 +++++++++++++- templates/types/streaming/nextjs/package.json | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .changeset/young-cameras-boil.md diff --git a/.changeset/young-cameras-boil.md b/.changeset/young-cameras-boil.md new file mode 100644 index 00000000..52ee9418 --- /dev/null +++ b/.changeset/young-cameras-boil.md @@ -0,0 +1,5 @@ +--- +"create-llama": patch +--- + +Upgrade pdf viewer diff --git a/templates/types/streaming/nextjs/app/components/ui/chat/widgets/PdfDialog.tsx b/templates/types/streaming/nextjs/app/components/ui/chat/widgets/PdfDialog.tsx index 42c2ad47..8dafffc4 100644 --- a/templates/types/streaming/nextjs/app/components/ui/chat/widgets/PdfDialog.tsx +++ b/templates/types/streaming/nextjs/app/components/ui/chat/widgets/PdfDialog.tsx @@ -1,4 +1,4 @@ -import { PDFViewer, PdfFocusProvider } from "@llamaindex/pdf-viewer"; +import dynamic from "next/dynamic"; import { Button } from "../../button"; import { Drawer, @@ -16,6 +16,18 @@ export interface PdfDialogProps { trigger: React.ReactNode; } +// Dynamic imports for client-side rendering only +const PDFViewer = dynamic( + () => import("@llamaindex/pdf-viewer").then((module) => module.PDFViewer), + { ssr: false }, +); + +const PdfFocusProvider = dynamic( + () => + import("@llamaindex/pdf-viewer").then((module) => module.PdfFocusProvider), + { ssr: false }, +); + export default function PdfDialog(props: PdfDialogProps) { return ( <Drawer direction="left"> diff --git a/templates/types/streaming/nextjs/package.json b/templates/types/streaming/nextjs/package.json index 7cb91d79..59e8dafa 100644 --- a/templates/types/streaming/nextjs/package.json +++ b/templates/types/streaming/nextjs/package.json @@ -12,7 +12,7 @@ "dependencies": { "@apidevtools/swagger-parser": "^10.1.0", "@e2b/code-interpreter": "^0.0.5", - "@llamaindex/pdf-viewer": "^1.1.1", + "@llamaindex/pdf-viewer": "^1.1.3", "@radix-ui/react-collapsible": "^1.0.3", "@radix-ui/react-hover-card": "^1.0.7", "@radix-ui/react-slot": "^1.0.2", -- GitLab