1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-05 01:57:20 +00:00

Add support for 3D/CAD file formats preview (#34794)

Fix #34775 

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Kerwin Bryant
2025-06-30 16:12:25 +08:00
committed by GitHub
parent f74a13610d
commit 176962c03e
29 changed files with 627 additions and 409 deletions

View File

@ -0,0 +1,20 @@
import type {FileRenderPlugin} from '../plugin.ts';
export function newRenderPluginPdfViewer(): FileRenderPlugin {
return {
name: 'pdf-viewer',
canHandle(filename: string, _mimeType: string): boolean {
return filename.toLowerCase().endsWith('.pdf');
},
async render(container: HTMLElement, fileUrl: string): Promise<void> {
const PDFObject = await import(/* webpackChunkName: "pdfobject" */'pdfobject');
// TODO: the PDFObject library does not support dynamic height adjustment,
container.style.height = `${window.innerHeight - 100}px`;
if (!PDFObject.default.embed(fileUrl, container)) {
throw new Error('Unable to render the PDF file');
}
},
};
}