mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
19 lines
691 B
JavaScript
19 lines
691 B
JavaScript
import { AutoloadPage } from 'vj/misc/Page';
|
|
import load from 'vj/components/wastyle/index';
|
|
import Notification from 'vj/components/notification/index';
|
|
|
|
const highlighterPage = new AutoloadPage('highlighterPage', async () => {
|
|
const [{ default: prismjs }, [success, format]] = await Promise.all([
|
|
import('./prismjs'),
|
|
UserContext.formatCode ? load() : [true, null],
|
|
]);
|
|
if (!success) Notification.error(`Astyle load fail: ${format}`);
|
|
function runHighlight($container) {
|
|
prismjs.highlightBlocks($container, success ? format : null);
|
|
}
|
|
runHighlight($('body'));
|
|
$(document).on('vjContentNew', (e) => runHighlight($(e.target)));
|
|
});
|
|
|
|
export default highlighterPage;
|