UNPKG

@bookbox/view-html

Version:

Bookbox view for html

23 lines (22 loc) 948 B
import { getBookBoxHtml } from './generateHtml'; import { getCurrentPage, getNavigation } from './navigation'; import { gotoKey } from './goto'; import { setSavedTheme } from './theme'; export function render({ element, bookData, layoutOptions, settingsOptions }) { var _a; const html = getBookBoxHtml({ bookData, layoutOptions, settingsOptions }); element.innerHTML = html; setSavedTheme({ element: (_a = element.querySelector('.book-box')) !== null && _a !== void 0 ? _a : undefined }); const { observeNavigation, disconnectNavigation } = getNavigation(element); const navigationRegistry = new FinalizationRegistry(() => { disconnectNavigation(); }); navigationRegistry.register(element, undefined); const initialPage = getCurrentPage(); window.setTimeout(() => { if (initialPage !== null) { gotoKey(`page-${initialPage}`); } observeNavigation(); }, 100); }