How to destroy WProofreader and clean all its resources in full page view of source mode in CKEditor
window.WEBSPELLCHECKER_CONFIG = {
...
onLoad: function(instance) {
var container = instance.getContainerNode(), // Link to the editable container
isCkeditor4 = container.classList.contains('cke_editable'); // Uncommon check for CKEditor 4
if (isCkeditor4) {
container.savedWscInstance = instance; // Save link on the WProofreader instance to the editable DOM element
}
},
...
};// Subscribe to the CKEditor 4 'instanceReady' event
CKEDITOR.on('instanceReady', function(event) {
var editor = event.editor;
// Subscribe to the CKEditor 4 'beforeSetMode' event
editor.on('beforeSetMode', function(e) {
// If a user switches from the WYSIWYG mode to the source mode of CKEditor 4
if (e.data === 'source') {
var container = editor.editable().$,
parent = container.parentNode,
links = parent.getElementsByTagName('link'),
styleName = 'wsc.css',
link;
if (!container.savedWscInstance) {
return;
}
// Destroy the WProofreader instance and remove the link to it
container.savedWscInstance.destroy();
container.savedWscInstance = null;
// Go through all links and remove link to the wsc.css style file
for (var i = 0; i < links.length; i++) {
link = links[i];
if (link.href.indexOf(styleName) !== -1 && link.parentNode) {
link.parentNode.removeChild(link);
}
}
}
});
});PreviousHow to customize the look and feel of WProofreader?NextHow to disable the 'Proofread in dialog' mode
Last updated
Was this helpful?