Jinjo
September 27, 2024, 9:13pm
#1
Hi All,
We have a site that uses the mlricheditor, which is an extended version (I think) of the standard richeditor.
With the standard richeditor, we can do this:
jQuery.FroalaEditor.PLUGINS.cleanHtml = function (editor) { // code }
The code is based on this: Clean HTML Pasted into Froala · October CMS Tricks
The issue is that when we use the mlricheditor it does not work. I’m guessing rainlab named it something different? Tried jQuery.MLRichEditor, no dice.
Any ideas?
Thanks!
apinard
September 29, 2024, 5:58pm
#2
Hi @Jinjo ,
Check out the file located at formwidgets/mlricheditor/assets/js/mlricheditor.js
.
Try this?
(function($) {
// Define the cleanHtml plugin
$.FroalaEditor.PLUGINS.cleanHtml = function(editor) {
return {
clean: function() {
var html = editor.html.get();
// Add your cleaning logic here
// For example, stripping out unwanted tags
editor.html.set(html);
}
};
};
// MLRichEditor implementation
var MLRichEditor = function(element, options) {
// Initialization logic...
this.$richeditor = $('[data-control=richeditor]:first', this.$el);
// Ensure FroalaEditor is initialized
if (this.$richeditor.data('oc.richEditor')) {
this.$richeditor.richEditor('events.on', 'contentChanged', function() {
// Call cleanHtml when content changes
this.cleanHtml.clean();
}.bind($.FroalaEditor.PLUGINS.cleanHtml));
}
};
})(window.jQuery);
1 Like