/*!
RichText: WYSIWYG editor developed as jQuery plugin
@name RichText
@version 1.1.0
@author https://github.com/webfashionist - Bob Schockweiler - richtext@webfashion.eu
@license GNU AFFERO GENERAL PUBLIC LICENSE Version 3
@preserve
Copyright (C) 2020 Bob Schockweiler ( richtext@webfashion.eu )
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
(function($){$.fn.richText=function(options){var settings=$.extend({bold:true,italic:true,underline:true,leftAlign:true,centerAlign:true,rightAlign:true,justify:true,ol:true,ul:true,heading:true,fonts:true,fontList:["Arial","Arial Black","Comic Sans MS","Courier New","Geneva","Georgia","Helvetica","Impact","Lucida Console","Tahoma","Times New Roman","Verdana"],fontColor:true,backgroundColor:true,fontSize:true,fontSizes:undefined,imageUpload:true,fileUpload:true,videoEmbed:true,urls:true,table:true,removeStyles:true,code:true,colors:[],fileHTML:"",imageHTML:"",translations:{title:"Title",white:"White",black:"Black",brown:"Brown",beige:"Beige",darkBlue:"Dark Blue",blue:"Blue",lightBlue:"Light Blue",darkRed:"Dark Red",red:"Red",darkGreen:"Dark Green",green:"Green",purple:"Purple",darkTurquois:"Dark Turquois",turquois:"Turquois",darkOrange:"Dark Orange",orange:"Orange",yellow:"Yellow",imageURL:"Image URL",altText:"Alternative text",fileURL:"File URL",linkText:"Link text",url:"URL",size:"Size",responsive:"Responsive",text:"Text",openIn:"Open in",sameTab:"Same tab",newTab:"New tab",align:"Align",left:"Left",justify:"Justify",center:"Center",right:"Right",rows:"Rows",columns:"Columns",add:"Add",pleaseEnterURL:"Please enter an URL",videoURLnotSupported:"Video URL not supported",pleaseSelectImage:"Please select an image",pleaseSelectFile:"Please select a file",bold:"Bold",italic:"Italic",underline:"Underline",alignLeft:"Align left",alignCenter:"Align centered",alignRight:"Align right",addOrderedList:"Ordered list",addUnorderedList:"Unordered list",addHeading:"Heading/title",addFont:"Font",addFontColor:"Font color",addBackgroundColor:"Background color",addFontSize:"Font size",addImage:"Add image",addVideo:"Add video",addFile:"Add file",addURL:"Add URL",addTable:"Add table",removeStyles:"Remove styles",code:"Show HTML code",undo:"Undo",redo:"Redo",save:"Save",close:"Close",help:"Help",words:"word(s)"},youtubeCookies:false,preview:false,placeholder:"",useSingleQuotes:false,height:0,heightPercentage:0,adaptiveHeight:false,id:"",class:"",useParagraph:false,maxlength:0,maxlengthIncludeHTML:false,wordCount:false,callback:undefined,useTabForNext:false,save:false,saveCallback:undefined,saveOnBlur:0,undoRedo:true,disableScripts:false,DOMPurify:false},options);var $inputElement=$(this);$inputElement.addClass("richText-initial");var $editor,$toolbarList=$("
"),$toolbarElement=$(" "),$btnBold=$(" ",{class:"richText-btn","data-command":"bold",title:settings.translations.bold,name:"bold","aria-label":settings.translations.bold,"aria-role":"button",html:' '}),$btnItalic=$(" ",{class:"richText-btn","data-command":"italic",title:settings.translations.italic,name:"italic","aria-label":settings.translations.italic,"aria-role":"button",html:' '}),$btnUnderline=$(" ",{class:"richText-btn","data-command":"underline",title:settings.translations.underline,name:"underline","aria-label":settings.translations.underline,"aria-role":"button",html:' '}),$btnJustify=$(" ",{class:"richText-btn","data-command":"justifyFull",title:settings.translations.justify,name:"justify","aria-label":settings.translations.justify,"aria-role":"button",html:' '}),$btnLeftAlign=$(" ",{class:"richText-btn","data-command":"justifyLeft",title:settings.translations.alignLeft,name:"alignLeft","aria-label":settings.translations.alignLeft,"aria-role":"button",html:' '}),$btnCenterAlign=$(" ",{class:"richText-btn","data-command":"justifyCenter",title:settings.translations.alignCenter,name:"alignCenter","aria-label":settings.translations.alignCenter,"aria-role":"button",html:' '}),$btnRightAlign=$(" ",{class:"richText-btn","data-command":"justifyRight",title:settings.translations.alignRight,name:"alignRight","aria-label":settings.translations.alignRight,"aria-role":"button",html:' '}),$btnOL=$(" ",{class:"richText-btn","data-command":"insertOrderedList",title:settings.translations.addOrderedList,name:"addOrderedList","aria-label":settings.translations.addOrderedList,"aria-role":"button",html:' '}),$btnUL=$(" ",{class:"richText-btn","data-command":"insertUnorderedList",title:settings.translations.addUnorderedList,name:"addUnorderedList","aria-label":settings.translations.addUnorderedList,"aria-role":"button",html:' '}),$btnHeading=$(" ",{class:"richText-btn",title:settings.translations.addHeading,name:"addHeading","aria-label":settings.translations.addHeading,"aria-role":"button",html:''}),$btnFont=$(" ",{class:"richText-btn",title:settings.translations.addFont,name:"addFont","aria-label":settings.translations.addFont,"aria-role":"button",html:' '}),$btnFontColor=$(" ",{class:"richText-btn",title:settings.translations.addFontColor,name:"addFontColor","aria-label":settings.translations.addFontColor,"aria-role":"button",html:' '}),$btnBackgroundColor=$(" ",{class:"richText-btn",title:settings.translations.addBackgroundColor,name:"addBackgroundColor","aria-label":settings.translations.addBackgroundColor,"aria-role":"button",html:' '}),$btnFontSize=$(" ",{class:"richText-btn",title:settings.translations.addFontSize,name:"addFontSize","aria-label":settings.translations.addFontSize,"aria-role":"button",html:' '}),$btnImageUpload=$(" ",{class:"richText-btn",title:settings.translations.addImage,name:"addImage","aria-label":settings.translations.addImage,"aria-role":"button",html:' '}),$btnVideoEmbed=$(" ",{class:"richText-btn",title:settings.translations.addVideo,name:"addVideo","aria-label":settings.translations.addVideo,"aria-role":"button",html:' '}),$btnFileUpload=$(" ",{class:"richText-btn",title:settings.translations.addFile,name:"addFile","aria-label":settings.translations.addFile,"aria-role":"button",html:' '}),$btnURLs=$(" ",{class:"richText-btn",title:settings.translations.addURL,name:"addURL","aria-label":settings.translations.addURL,"aria-role":"button",html:' '}),$btnTable=$(" ",{class:"richText-btn",title:settings.translations.addTable,name:"addTable","aria-label":settings.translations.addTable,"aria-role":"button",html:' '}),$btnRemoveStyles=$(" ",{class:"richText-btn","data-command":"removeFormat",title:settings.translations.removeStyles,name:"removeStyles","aria-label":settings.translations.removeStyles,"aria-role":"button",html:' '}),$btnCode=$(" ",{class:"richText-btn","data-command":"toggleCode",title:settings.translations.code,name:"code","aria-label":settings.translations.code,"aria-role":"button",html:' '}),$btnSave=$(" ",{class:"save-btn","data-command":"toggleSave",title:settings.translations.save,name:"save","aria-label":settings.translations.save,"aria-role":"button",html:' '});var $dropdownOuter=$("
",{class:"richText-dropdown-outer"});var $dropdownClose=$(" ",{class:"richText-dropdown-close",html:' '});$dropdownOuter.prepend($dropdownClose.clone());var $dropdownList=$("",{class:"richText-dropdown"}),$dropdownBox=$("
",{class:"richText-dropdown"}),$form=$("
",{class:"richText-form"}),$formItem=$("
",{class:"richText-form-item"}),$formLabel=$(" "),$formInput=$(" ",{type:"text"}),$formInputFile=$(" ",{type:"file"}),$formInputSelect=$(" "),$formButton=$(" ",{text:settings.translations.add,class:"btn",type:"button"});var savedSelection;var editorID="richText-"+Math.random().toString(36).substring(7);var ignoreSave=false,$resizeImage=null;var history=[];history[editorID]=[];var historyPosition=[];historyPosition[editorID]=0;var $titles=$dropdownList.clone();$titles.append($(" ",{html:''+settings.translations.title+" #1 "}));$titles.append($(" ",{html:''+settings.translations.title+" #2 "}));$titles.append($(" ",{html:''+settings.translations.title+" #3 "}));$titles.append($(" ",{html:''+settings.translations.title+" #4 "}));$btnHeading.append($dropdownOuter.clone().append($titles));var fonts=settings.fontList;var $fonts=$dropdownList.clone();for(var i=0;i ",{html:''+fonts[i]+" "}))}$btnFont.append($dropdownOuter.clone().append($fonts));var $fontSizes=$dropdownList.clone();if(settings.fontSizes&&Array.isArray(settings.fontSizes)){for(let i=0;i100){console.warn("Invalid font size: "+settings.fontSizes[i]);continue}$fontSizes.append($(" ",{html:''+settings.translations.text+" "+settings.fontSizes[i]+"px "}))}}else{for(let fontSize=24;fontSize>=12;fontSize-=2){$fontSizes.append($(" ",{html:''+settings.translations.text+" "+fontSize+"px "}))}}$btnFontSize.append($dropdownOuter.clone().append($fontSizes));var $fontColors=$dropdownList.clone();$fontColors.html(loadColors("forecolor"));$btnFontColor.append($dropdownOuter.clone().append($fontColors));var $backgroundColors=$dropdownList.clone();$backgroundColors.html(loadColors("hiliteColor"));$btnBackgroundColor.append($dropdownOuter.clone().append($backgroundColors));var $linksDropdown=$dropdownBox.clone();var $linksForm=$form.clone().attr("id","richText-URL").attr("data-editor",editorID);$linksForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.url).attr("for","url")).append($formInput.clone().attr("id","url")));$linksForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.text).attr("for","urlText")).append($formInput.clone().attr("id","urlText")));$linksForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.openIn).attr("for","openIn")).append($formInputSelect.clone().attr("id","openIn").append($(" ",{value:"_self",text:settings.translations.sameTab})).append($(" ",{value:"_blank",text:settings.translations.newTab}))));$linksForm.append($formItem.clone().append($formButton.clone()));$linksDropdown.append($linksForm);$btnURLs.append($dropdownOuter.clone().append($linksDropdown));var $videoDropdown=$dropdownBox.clone();var $videoForm=$form.clone().attr("id","richText-Video").attr("data-editor",editorID);$videoForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.url).attr("for","videoURL")).append($formInput.clone().attr("id","videoURL")));$videoForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.size).attr("for","size")).append($formInputSelect.clone().attr("id","size").append($(" ",{value:"responsive",text:settings.translations.responsive})).append($(" ",{value:"640x360",text:"640x360"})).append($(" ",{value:"560x315",text:"560x315"})).append($(" ",{value:"480x270",text:"480x270"})).append($(" ",{value:"320x180",text:"320x180"}))));$videoForm.append($formItem.clone().append($formButton.clone()));$videoDropdown.append($videoForm);$btnVideoEmbed.append($dropdownOuter.clone().append($videoDropdown));var $imageDropdown=$dropdownBox.clone();var $imageForm=$form.clone().attr("id","richText-Image").attr("data-editor",editorID);if(settings.imageHTML&&($(settings.imageHTML).find("#imageURL").length>0||$(settings.imageHTML).attr("id")==="imageURL")){$imageForm.html(settings.imageHTML)}else{$imageForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.imageURL).attr("for","imageURL")).append($formInput.clone().attr("id","imageURL")));$imageForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.altText).attr("for","altText")).append($formInput.clone().attr("id","altText")));$imageForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.align).attr("for","align")).append($formInputSelect.clone().attr("id","align").append($(" ",{value:"left",text:settings.translations.left})).append($(" ",{value:"center",text:settings.translations.center})).append($(" ",{value:"right",text:settings.translations.right}))))}$imageForm.append($formItem.clone().append($formButton.clone()));$imageDropdown.append($imageForm);$btnImageUpload.append($dropdownOuter.clone().append($imageDropdown));var $fileDropdown=$dropdownBox.clone();var $fileForm=$form.clone().attr("id","richText-File").attr("data-editor",editorID);if(settings.fileHTML&&($(settings.fileHTML).find("#fileURL").length>0||$(settings.fileHTML).attr("id")==="fileURL")){$fileForm.html(settings.fileHTML)}else{$fileForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.fileURL).attr("for","fileURL")).append($formInput.clone().attr("id","fileURL")));$fileForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.linkText).attr("for","fileText")).append($formInput.clone().attr("id","fileText")))}$fileForm.append($formItem.clone().append($formButton.clone()));$fileDropdown.append($fileForm);$btnFileUpload.append($dropdownOuter.clone().append($fileDropdown));var $tableDropdown=$dropdownBox.clone();var $tableForm=$form.clone().attr("id","richText-Table").attr("data-editor",editorID);$tableForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.rows).attr("for","tableRows")).append($formInput.clone().attr("id","tableRows").attr("type","number")));$tableForm.append($formItem.clone().append($formLabel.clone().text(settings.translations.columns).attr("for","tableColumns")).append($formInput.clone().attr("id","tableColumns").attr("type","number")));$tableForm.append($formItem.clone().append($formButton.clone()));$tableDropdown.append($tableForm);$btnTable.append($dropdownOuter.clone().append($tableDropdown));function init(){var value,attributes,attributes_html="";if(settings.useParagraph!==false){document.execCommand("DefaultParagraphSeparator",false,"p")}if($inputElement.prop("tagName")==="TEXTAREA"){}else if($inputElement.val()){value=$inputElement.val();attributes=$inputElement.prop("attributes");$.each(attributes,function(){if(this.name){attributes_html+=" "+this.name+'="'+this.value+'"'}});$inputElement.replaceWith($(""));$inputElement=$('[data-richtext="init"]');$inputElement.removeAttr("data-richtext")}else if($inputElement.html()){value=$inputElement.html();attributes=$inputElement.prop("attributes");$.each(attributes,function(){if(this.name){attributes_html+=" "+this.name+'="'+this.value+'"'}});$inputElement.replaceWith($(""));$inputElement=$('[data-richtext="init"]');$inputElement.removeAttr("data-richtext")}else{attributes=$inputElement.prop("attributes");$.each(attributes,function(){if(this.name){attributes_html+=" "+this.name+'="'+this.value+'"'}});$inputElement.replaceWith($("'));$inputElement=$('[data-richtext="init"]');$inputElement.removeAttr("data-richtext")}$editor=$("
",{class:"richText"});var $toolbar=$("
",{class:"richText-toolbar"});var $editorView=$("
",{class:"richText-editor",id:editorID,contenteditable:!settings.preview});$editorView.on("clear",()=>{var $editor=$("#"+editorID);$editor.siblings(".richText-initial").val("
");$editor.html($editor.siblings(".richText-initial").val())});$editorView.on("setContent",(event,content)=>{var $editor=$("#"+editorID);$editor.siblings(".richText-initial").val(content);$editor.html($editor.siblings(".richText-initial").val())});$editorView.on("getContent",(event,callback)=>{if(typeof callback!=="function"){return}callback($editorView.siblings(".richText-initial").val())});$editorView.on("save",(event,callback)=>{$editorView.trigger("change");if(typeof settings.saveCallback==="function"){settings.saveCallback($editor,"save",getEditorContent(editorID))}});$editorView.on("pasteAtCaret",(event,content)=>{var $editor=$("#"+editorID);if(!content||!content.length){return}restoreSelection($editor.attr("id"));pasteHTMLAtCaret(content);if(settings.disableScripts){removeScripts($editor.attr("id"))}if(settings.DOMPurify){sanitizeContent($editor.attr("id"))}updateTextarea()});$editorView.on("destroy",(event,options)=>{const destroy=()=>{let $main=$editorView.parents(".richText");$main.find(".richText-toolbar").remove();$main.find(".richText-editor").remove();const $textarea=$main.find(".richText-initial");$textarea.unwrap(".richText").data("editor","richText").removeClass("richText-initial").show();if(options&&typeof options.callback==="function"){options.callback($textarea)}};if(options&&options.delay){setTimeout(()=>{destroy()},options.delay);return}destroy()});var tabindex=$inputElement.prop("tabindex");if(tabindex>=0&&settings.useTabForNext===true){$editorView.attr("tabindex",tabindex)}if(!settings.preview){$toolbar.append($toolbarList)}if(settings.placeholder){if(!$editorView.text().length){$editorView.attr("placeholder",settings.placeholder);$editorView.on("focus",function(){$editorView.removeAttr("placeholder")});$editorView.on("focusout blur",function(){if(this.hasAttribute("placeholder")){return}if($(this).text().length){return}$(this).attr("placeholder",settings.placeholder)})}}settings.$editor=$editor;settings.blurTriggered=false;settings.$editor.on("click",()=>{settings.blurTriggered=false});if(settings.bold===true){$toolbarList.append($toolbarElement.clone().append($btnBold))}if(settings.italic===true){$toolbarList.append($toolbarElement.clone().append($btnItalic))}if(settings.underline===true){$toolbarList.append($toolbarElement.clone().append($btnUnderline))}if(settings.leftAlign===true){$toolbarList.append($toolbarElement.clone().append($btnLeftAlign))}if(settings.centerAlign===true){$toolbarList.append($toolbarElement.clone().append($btnCenterAlign))}if(settings.rightAlign===true){$toolbarList.append($toolbarElement.clone().append($btnRightAlign))}if(settings.justify===true){$toolbarList.append($toolbarElement.clone().append($btnJustify))}if(settings.ol===true){$toolbarList.append($toolbarElement.clone().append($btnOL))}if(settings.ul===true){$toolbarList.append($toolbarElement.clone().append($btnUL))}if(settings.fonts===true&&settings.fontList.length>0){$toolbarList.append($toolbarElement.clone().append($btnFont))}if(settings.fontSize===true){$toolbarList.append($toolbarElement.clone().append($btnFontSize))}if(settings.heading===true){$toolbarList.append($toolbarElement.clone().append($btnHeading))}if(settings.fontColor===true){$toolbarList.append($toolbarElement.clone().append($btnFontColor))}if(settings.backgroundColor===true){$toolbarList.append($toolbarElement.clone().append($btnBackgroundColor))}if(settings.imageUpload===true){$toolbarList.append($toolbarElement.clone().append($btnImageUpload))}if(settings.fileUpload===true){$toolbarList.append($toolbarElement.clone().append($btnFileUpload))}if(settings.videoEmbed===true){$toolbarList.append($toolbarElement.clone().append($btnVideoEmbed))}if(settings.urls===true){$toolbarList.append($toolbarElement.clone().append($btnURLs))}if(settings.table===true){$toolbarList.append($toolbarElement.clone().append($btnTable))}if(settings.removeStyles===true){$toolbarList.append($toolbarElement.clone().append($btnRemoveStyles))}if(settings.code===true){$toolbarList.append($toolbarElement.clone().append($btnCode))}if(settings.save===true){$toolbarList.append($toolbarElement.clone().append($btnSave))}$editorView.html($inputElement.val());$editorView.data("content-val",$inputElement.val());$editor.append($toolbar);$editor.append($editorView);$editor.append($inputElement.clone().hide());$inputElement.replaceWith($editor);$bottomToolbar=$("
",{class:"richText-toolbar"});if(!settings.preview&&settings.undoRedo){$bottomToolbar.append($(" ",{class:"richText-undo is-disabled",html:' ',title:settings.translations.undo,name:"undo","aria-label":settings.translations.undo,"aria-role":"button"}));$bottomToolbar.append($(" ",{class:"richText-redo is-disabled",html:' ',title:settings.translations.redo,name:"redo","aria-label":settings.translations.redo,"aria-role":"button"}))}$bottomToolbar.append($(" ",{class:"richText-help","aria-label":settings.translations.help,"aria-role":"button",title:settings.translations.help,name:"help",html:' '}));$editor.append($bottomToolbar);var maxlength=settings.maxlength;if(!maxlength&&$inputElement.attr("maxlength")){maxlength=$inputElement.attr("maxlength")}if(maxlength>0){$editor.data("maxlength",maxlength);$editor.children(".richText-toolbar").children(".richText-help").before($(" ",{class:"richText-length",text:"0/"+maxlength}));updateMaxLength($editor.find(".richText-editor").attr("id"))}if(settings.wordCount){$editor.children(".richText-toolbar").children(".richText-help").before($(" ",{class:"richText-wordcount",text:"0 "+settings.translations.words}));updateWordCount($editor.find(".richText-editor").attr("id"))}if(settings.height&&settings.height>0){$editor.children(".richText-editor, .richText-initial").css({"min-height":settings.height+"px",height:settings.adaptiveHeight?"auto":settings.height+"px"})}else if(settings.heightPercentage&&settings.heightPercentage>0){var parentHeight=$editor.parent().innerHeight();var height=settings.heightPercentage/100*parentHeight;height-=$toolbar.outerHeight()*2;height-=parseInt($editor.css("margin-top"));height-=parseInt($editor.css("margin-bottom"));height-=parseInt($editor.find(".richText-editor").css("padding-top"));height-=parseInt($editor.find(".richText-editor").css("padding-bottom"));$editor.children(".richText-editor, .richText-initial").css({"min-height":height+"px",height:settings.adaptiveHeight?"auto":height+"px"})}else if(settings.adaptiveHeight){$editor.children(".richText-editor, .richText-initial").css({height:"auto"})}if(settings.class){$editor.addClass(settings.class)}if(settings.id){$editor.attr("id",settings.id)}fixFirstLine();history[editorID].push($editor.find("textarea").val());if(settings.callback&&typeof settings.callback==="function"){settings.callback($editor)}}init();settings.$editor.find(".richText-help").on("click",function(){var $editor=$(this).parents(".richText");if($editor){var $outer=$("
",{class:"richText-help-popup",style:"position:absolute;top:0;right:0;bottom:0;left:0;background-color: rgba(0,0,0,0.3);"});var $inner=$("
",{style:"position:relative;margin:60px auto;padding:20px;background-color:#FAFAFA;width:70%;font-family:Calibri,Verdana,Helvetica,sans-serif;font-size:small;"});var $content=$("
",{html:' '});$content.append('RichText ');$content.append(' Powered by webfashionist/RichText (Github) License: AGPL-3.0 ');$outer.append($inner.append($content));$editor.append($outer);$outer.on("click","#closeHelp",function(){$(this).parents(".richText-help-popup").remove()})}});settings.$editor.find(".richText-undo, .richText-redo").on("click",function(){var $this=$(this);if($this.hasClass("richText-undo")&&!$this.hasClass("is-disabled")){undo(settings.$editor)}else if($this.hasClass("richText-redo")&&!$this.hasClass("is-disabled")){redo(settings.$editor)}});settings.$editor.find(".richText-editor").on("input change blur keydown keyup",function(e){if((e.keyCode===9||e.keyCode==="9")&&e.type==="keydown"){if(settings.useTabForNext===true){focusNextElement();return false}e.preventDefault();tabifyEditableTable(window,e);return false}fixFirstLine();if(settings.disableScripts){removeScripts($(this).attr("id"))}if(settings.DOMPurify){sanitizeContent($(this).attr("id"))}updateTextarea(e);doSave($(this).attr("id"));updateMaxLength($(this).attr("id"));updateWordCount($(this).attr("id"))});function sanitizeContent(editorID){if(!window.DOMPurify||typeof window.DOMPurify.sanitize!=="function"){console.error("RichText: DOMPurify is not loaded. Please include it in your project.");return}const $editor=$("#"+editorID);const html=$editor.html();const clean=window.DOMPurify.sanitize(html,{USE_PROFILES:{html:true}});$editor.html(clean);const $editorInitial=$editor.parent().find(".richText-initial");$editorInitial.val(window.DOMPurify.sanitize($editorInitial.val(),{USE_PROFILES:{html:true}}))}function removeScripts(editorID){const regex=/