1import {htmlEscape} from 'escape-goat';
2
3export async function initPdfViewer() {
4 const els = document.querySelectorAll('.pdf-content');
5 if (!els.length) return;
6
7 const pdfobject = await import(/* webpackChunkName: "pdfobject" */'pdfobject');
8
9 for (const el of els) {
10 const src = el.getAttribute('data-src');
11 const fallbackText = el.getAttribute('data-fallback-button-text');
12 pdfobject.embed(src, el, {
13 fallbackLink: htmlEscape`
14 <a role="button" class="ui basic button pdf-fallback-button" href="[url]">${fallbackText}</a>
15 `,
16 });
17 el.classList.remove('is-loading');
18 }
19}