1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-19 21:29:41 +02:00
codex.docs/src/frontend/js/modules/page.js

60 lines
1.4 KiB
JavaScript
Raw Normal View History

/**
* @class Page
* @classdesc Class for page module
*/
export default class Page {
/**
* Creates base properties
*/
constructor() {
this.codeStyler = null;
this.tableOfContent = null;
}
/**
* Called by ModuleDispatcher to initialize module from DOM
*/
init() {
this.codeStyler = this.createCodeStyling();
this.tableOfContent = this.createTableOfContent();
}
/**
* Init code highlighting
*/
async createCodeStyling() {
const { default: CodeStyler } = await import(/* webpackChunkName: "code-styling" */ './../classes/codeStyler');
try {
// eslint-disable-next-line no-new
new CodeStyler({
selector: '.block-code__content',
});
} catch (error) {
console.error(error); // @todo send to Hawk
}
}
/**
* Init table of content
*
* @returns {Promise<TableOfContent>}
*/
async createTableOfContent() {
const { default: TableOfContent } = await import(/* webpackChunkName: "table-of-content" */ '../classes/table-of-content');
try {
// eslint-disable-next-line no-new
new TableOfContent({
tagSelector:
'h2.block-header--anchor,' +
'h3.block-header--anchor,' +
'h4.block-header--anchor',
appendTo: document.getElementById('layout-sidebar-right'),
});
} catch (error) {
console.error(error); // @todo send to Hawk
}
}
}