', '',''], // If keepHtml is true, remove all tags except these
keepClasses: false, //Remove Classes
badTags: ['style', 'script', 'applet', 'embed', 'noframes', 'noscript', 'html'], //Remove full tags with contents
badAttributes: [ 'start'], //Remove attributes from remaining tags
limitChars: 0, // 0|# 0 disables option
limitDisplay: 'none', // none|text|html|both
limitStop: false // true/false
}
});
$.extend($.summernote.plugins, {
'cleaner':function (context) {
var self = this,
ui = $.summernote.ui,
$note = context.layoutInfo.note,
$editor = context.layoutInfo.editor,
options = context.options,
lang = options.langInfo;
var cleanText = function (txt, nlO) {
var out = txt;
if (!options.cleaner.keepClasses) {
var sS = /(\n|\r| class=(")?Mso[a-zA-Z]+(")?)/g;
out = txt.replace(sS, ' ');
}
var nL = /(\n)+/g;
out = out.replace(nL, nlO);
if (options.cleaner.keepHtml) {
//var cS = new RegExp('', 'gi'); // EDITED TO NEXT LINE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
var cS = new RegExp('', 'gi');
out = out.replace(cS, '');
var cS = new RegExp('', 'gi');
out = out.replace(cS, '');
var cS = new RegExp('text-indent:-[^]*?;', 'gi'); out = out.replace(cS, '');
var cS = new RegExp('mso-list:l0 level1 lfo1', 'gi'); out = out.replace(cS, '');
var cS = new RegExp(' ', 'gi'); out = out.replace(cS, '');
var cS = new RegExp('
', 'gi'); out = out.replace(cS, '');
var cS = new RegExp('
', 'gi'); out = out.replace(cS, '');
var cS = new RegExp('style=[\'|"][\'|"]', 'gi'); out = out.replace(cS, '');
//var tS = new RegExp('<(/)*(meta|link|\\?xml:|st1:|o:|font)(.*?)>', 'gi'); // EDITED TO NEXT LINE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
var tS = new RegExp('<(/)*(html|meta|link|\\?xml:|st1:|o:|font)(.*?)>', 'gi');
out = out.replace(tS, '');
//console.log(out);
var bT = options.cleaner.badTags;
for (var i = 0; i < bT.length; i++) {
tS = new RegExp('<' + bT[i] + '\\b.*>.*' + bT[i] + '>', 'gi');
out = out.replace(tS, '');
}
//console.log(out);
var allowedTags = options.cleaner.keepOnlyTags;
if (typeof(allowedTags) == "undefined") allowedTags = [];
if (allowedTags.length > 0) {
allowedTags = (((allowedTags||'') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('');
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;
out = out.replace(tags, function($0, $1) {
return allowedTags.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''
});
}
var bA = options.cleaner.badAttributes;
for (var ii = 0; ii < bA.length; ii++ ) {
var aS = new RegExp(' ' + bA[ii] + '=[\'|"](.*?)[\'|"]', 'gi');
out = out.replace(aS, '');
}
}
return out;
};
if (options.cleaner.action == 'both' || options.cleaner.action == 'button') {
context.memo('button.cleaner', function () {
var button = ui.button({
contents: options.cleaner.icon,
tooltip: lang.cleaner.tooltip,
container: 'body',
click:function () {
if ($note.summernote('createRange').toString())
$note.summernote('pasteHTML', $note.summernote('createRange').toString());
else {
let tmp = cleanText($note.summernote('code'));
$note.summernote('code', tmp);
}
if(options.cleaner.notActive) { // ADDED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if ($editor.find('.note-status-output').length > 0)
$editor.find('.note-status-output').html('