feat: add support for lazy loading

This commit is contained in:
Elian Doran 2025-01-07 17:26:40 +02:00
parent eee0b3bd07
commit f37de61dfb
No known key found for this signature in database

View File

@ -31,6 +31,7 @@ export default class MermaidEditing extends Plugin {
init() {
this._registerCommands();
this._defineConverters();
this._config = this.editor.config.get("mermaid");
}
/**
@ -284,7 +285,11 @@ export default class MermaidEditing extends Plugin {
*
* @param {HTMLElement} domElement
*/
_renderMermaid( domElement ) {
async _renderMermaid( domElement ) {
if (!window.mermaid && typeof this._config?.lazyLoad === "function") {
await this._config.lazyLoad();
}
mermaid.init( undefined, domElement );
}
}