@bookbox/view-html
Version:
Bookbox view for html
26 lines (25 loc) • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.render = render;
const generateHtml_1 = require("./generateHtml");
const navigation_1 = require("./navigation");
const goto_1 = require("./goto");
const theme_1 = require("./theme");
function render({ element, bookData, layoutOptions, settingsOptions }) {
var _a;
const html = (0, generateHtml_1.getBookBoxHtml)({ bookData, layoutOptions, settingsOptions });
element.innerHTML = html;
(0, theme_1.setSavedTheme)({ element: (_a = element.querySelector('.book-box')) !== null && _a !== void 0 ? _a : undefined });
const { observeNavigation, disconnectNavigation } = (0, navigation_1.getNavigation)(element);
const navigationRegistry = new FinalizationRegistry(() => {
disconnectNavigation();
});
navigationRegistry.register(element, undefined);
const initialPage = (0, navigation_1.getCurrentPage)();
window.setTimeout(() => {
if (initialPage !== null) {
(0, goto_1.gotoKey)(`page-${initialPage}`);
}
observeNavigation();
}, 100);
}