//['insert', ['link', 'picture', 'video']], // iframe tag will be sanitized TODO if iframe[class=note-video-clip] can be added into safe list, insert video can be enabled
['insert',['link','picture']],
['view',['fullscreen','help']],
];
constcleanPastedHTML=function(input){
constbadTags=[
'style',
'script',
'applet',
'embed',
'noframes',
'noscript',
'meta',
'link',
'button',
'form',
].join('|');
constbadPatterns=newRegExp(
`(?:${[
`<(${badTags})s*[^>][\\s\\S]*?<\\/\\1>`,
`<(${badTags})[^>]*?\\/>`,
].join('|')})`,
'gi',
);
letoutput=input;
// remove bad Tags
output=output.replace(badPatterns,'');
// remove attributes ' style="..."'
constbadAttributes=newRegExp(
`(?:${[
'on\\S+=([\'"]?).*?\\1',
'href=([\'"]?)javascript:.*?\\2',
'style=([\'"]?).*?\\3',
'target=\\S+',
].join('|')})`,
'gi',
);
output=output.replace(badAttributes,'');
output=output.replace(/(<a )/gi,'$1target=_ ');// always to new target
$('.minicards').toggle(!isActive);// mini card is still showing when editor is in fullscreen mode, we hide here manually
});
}
},
onPaste(){
// clear up unwanted tag info when user pasted in text
constthisNote=$(this);
constupdatePastedText=function(someNote){
constoriginal=someNote.summernote('code');
constcleaned=cleanPastedHTML(original);//this is where to call whatever clean function you want. I have mine in a different file, called CleanPastedHTML.
someNote.summernote('code','');//clear original
someNote.summernote('pasteHTML',cleaned);//this sets the displayed content editor to the cleaned pasted code.
};
setTimeout(function(){
//this kinda sucks, but if you don't do a setTimeout,
//the function is called before the text is really pasted.