mirror of
https://github.com/go-gitea/gitea.git
synced 2026-06-23 19:50:08 +00:00
- Bump `eslint`, `typescript-eslint` and `eslint-plugin-unicorn` (to v68), and configure the rules added in unicorn v66/v67/v68. - Remove `eslint-plugin-github` and its workarounds (rules, type stub, pnpm peer override, in-code `eslint-disable` comments); the rules worth keeping are covered by `unicorn` equivalents. - Apply the resulting fixes and autofixes across the JS codebase. _Prepared with Claude (Opus 4.8)._ --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
20 lines
803 B
TypeScript
20 lines
803 B
TypeScript
import type {InplaceRenderPlugin} from '../plugin.ts';
|
|
|
|
export function newInplacePluginPdfViewer(): InplaceRenderPlugin {
|
|
return {
|
|
name: 'pdf-viewer',
|
|
|
|
canHandle: (filename: string, _mimeType: string): boolean => filename.toLowerCase().endsWith('.pdf'),
|
|
|
|
async render(container: HTMLElement, fileUrl: string): Promise<void> {
|
|
const PDFObject = await import('pdfobject');
|
|
// TODO: the PDFObject library does not support dynamic height adjustment,
|
|
// TODO: it seems that this render must be an inplace render, because the URL must be accessible from the current context
|
|
container.style.height = `${window.innerHeight - 100}px`;
|
|
if (!PDFObject.default.embed(fileUrl, container)) {
|
|
throw new Error('Unable to render the PDF file');
|
|
}
|
|
},
|
|
};
|
|
}
|