This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type {FrontendRenderFunc} from '../plugin.ts';
|
||||
|
||||
export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => {
|
||||
try {
|
||||
const [player] = await Promise.all([
|
||||
import('asciinema-player'),
|
||||
import('asciinema-player/dist/bundle/asciinema-player.css'),
|
||||
]);
|
||||
player.create({data: opts.contentString()}, opts.container, {
|
||||
// poster (a preview frame) to display until the playback is started.
|
||||
// Set it to 1 hour (also means the end if the video is shorter) to make the preview frame show more.
|
||||
poster: 'npt:1:0:0',
|
||||
});
|
||||
// Related: https://github.com/asciinema/asciinema-player/blob/develop/src/components/Terminal.js : <div class="ap-term" ...>
|
||||
// Old PR: Fix UI regression of asciinema player https://github.com/go-gitea/gitea/pull/26159
|
||||
opts.container.querySelector<HTMLElement>('.ap-term')!.style.overflow = 'hidden';
|
||||
opts.container.querySelector<HTMLElement>('.ap-player')!.style.borderRadius = '0';
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -1,15 +1,11 @@
|
||||
import type {FrontendRenderFunc} from '../plugin.ts';
|
||||
import {initSwaggerUI} from '../swagger.ts';
|
||||
|
||||
// HINT: SWAGGER-CSS-IMPORT: this import is also necessary when swagger is used as a frontend external render
|
||||
// But it can't share the same CSS file with the standalone page: it triggers our Vite manifest parser's bug
|
||||
// Although single top-level "await import(css)" can work, it requires es2022.
|
||||
// Otherwise, single function-level "await import(css)" can't work due to Vite's dependency analysis and bundling.
|
||||
// HINT: SWAGGER-CSS-IMPORT: these styles are for the render only.
|
||||
import '../../../css/swagger-render.css';
|
||||
|
||||
export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => {
|
||||
try {
|
||||
await import('../../../css/swagger-render.css');
|
||||
await initSwaggerUI(opts.container, {specText: opts.contentString()});
|
||||
return true;
|
||||
} catch (error) {
|
||||
|
||||
@@ -4,9 +4,7 @@ export function newInplacePluginPdfViewer(): InplaceRenderPlugin {
|
||||
return {
|
||||
name: 'pdf-viewer',
|
||||
|
||||
canHandle(filename: string, _mimeType: string): boolean {
|
||||
return filename.toLowerCase().endsWith('.pdf');
|
||||
},
|
||||
canHandle: (filename: string, _mimeType: string): boolean => filename.toLowerCase().endsWith('.pdf'),
|
||||
|
||||
async render(container: HTMLElement, fileUrl: string): Promise<void> {
|
||||
const PDFObject = await import('pdfobject');
|
||||
|
||||
Reference in New Issue
Block a user