Create a local module with lifecycle hooks and event handlers
The current runtime still follows the same core contract: a module instance gets a context,
can implement initialize and destroy, and can react to editor events through an
events map.
Lifecycle module demo paragraph.
Module output
Ready.
Example configuration - Lifecycle and Events
class LifecycleMonitor {
constructor(context) {
this.context = context;
this.events = {
'summernote.change summernote.focus summernote.blur': () => {
this.updatePanel();
},
};
}
initialize() {
this.panel = document.createElement('div');
this.context.layoutInfo.editor[0].append(this.panel);
this.updatePanel();
}
destroy() {
this.panel.remove();
}
getSummary() {
return '...';
}
}
summernote.create('#module-lifecycle-editor', {
height: 220,
modules: {
lifecycleMonitor: LifecycleMonitor,
},
});