Clean HTML Pasted into Froala
7
/**
* Froala - Clean HTML Plugin.
*/
+function ($) {
$.FroalaEditor.PLUGINS.cleanHtml = function (editor) {
function _init() {
editor.events.on('paste.beforeCleanup', function (clipboardHtml) {
return _convertHtmlToPlainText(clipboardHtml);
});
}
function _convertHtmlToPlainText(clipboardHtml) {
return '<p>' + clipboardHtml.replace(/<br>/gi, "\n").replace(/<(?:.|\s)*?>/g, '') + '</p>';
}
return {
_init: _init
};
};
}(jQuery);
Then include via:
/**
* Extend Rich Editor.
*/
\Backend\FormWidgets\RichEditor::extend(function ($widget) {
$widget->addJs('/plugins/author/name/assets/js/froala.clean-html.js', 'Author.Name');
});
There are no comments yet
Be the first one to comment