2023-05-29 14:10:00 +02:00
|
|
|
import {htmlEscape} from 'escape-goat';
|
2025-03-04 03:49:15 +08:00
|
|
|
import {registerGlobalInitFunc} from '../modules/observer.ts';
|
2023-05-29 14:10:00 +02:00
|
|
|
|
|
|
|
export async function initPdfViewer() {
|
2025-03-04 03:49:15 +08:00
|
|
|
registerGlobalInitFunc('initPdfViewer', async (el: HTMLInputElement) => {
|
|
|
|
const pdfobject = await import(/* webpackChunkName: "pdfobject" */'pdfobject');
|
2023-05-29 14:10:00 +02:00
|
|
|
|
|
|
|
const src = el.getAttribute('data-src');
|
|
|
|
const fallbackText = el.getAttribute('data-fallback-button-text');
|
|
|
|
pdfobject.embed(src, el, {
|
|
|
|
fallbackLink: htmlEscape`
|
|
|
|
<a role="button" class="ui basic button pdf-fallback-button" href="[url]">${fallbackText}</a>
|
|
|
|
`,
|
|
|
|
});
|
|
|
|
el.classList.remove('is-loading');
|
2025-03-04 03:49:15 +08:00
|
|
|
});
|
2023-05-29 14:10:00 +02:00
|
|
|
}
|