This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ncsimplehtmleditor.min.js
8 lines (8 loc) · 64.3 KB
/
ncsimplehtmleditor.min.js
1
2
3
4
5
6
7
8
/*!
* {:noCode: Simple HTML Editor :} v1.0.0-b
* https://thenocoder.github.io/ncSimpleHtmlEditor/
* Copyright (c) 2022
* Licensed under MIT
* https://github.com/TheNocoder/ncSimpleHtmlEditor/blob/master/LICENSE
*/
if(window.ncsedtRestorable=function(){var _this=this;this.restorableNodesTag=document.querySelectorAll("ncsedt-restorable"),this.restorableNodesAttr=document.querySelectorAll('[data-ncsedt-restorable="true"]'),this.restorableHtml=[],this.restorableAttr=[],this.restorableUndoHtml=[],this.restorableUndoAttr=[],this.restorableHtmlCount=0,this.restorableAttrCount=0,this.restorableNodesTag.forEach((function(node){_this.restorableHtml[_this.restorableHtmlCount++]=node.innerHTML})),this.restorableNodesAttr.forEach((function(node){_this.restorableAttr[_this.restorableAttrCount++]=node.cloneNode().attributes}))},ncsedtRestorable.prototype.restore=function(){var _this=this,count=0;count=0,this.restorableNodesTag.forEach((function(node){_this.restorableUndoHtml[count++]=node.innerHTML})),count=0,this.restorableNodesAttr.forEach((function(node){_this.restorableUndoAttr[count++]=node.cloneNode().attributes}));for(let i=0;i<this.restorableNodesTag.length;i++)this.restorableNodesTag[i].innerHTML=this.restorableHtml[i];for(let i=0;i<this.restorableNodesAttr.length;i++)Array.prototype.slice.call(this.restorableNodesAttr[i].attributes).forEach((function(cur){_this.restorableNodesAttr[i].removeAttribute(cur.name)}));for(let i=0;i<this.restorableNodesAttr.length;i++)Array.prototype.slice.call(this.restorableAttr[i]).forEach((function(cur){_this.restorableNodesAttr[i].setAttribute(cur.name,cur.value)}))},ncsedtRestorable.prototype.undoRestore=function(){var _this=this;for(let i=0;i<this.restorableNodesTag.length;i++)this.restorableNodesTag[i].innerHTML=this.restorableUndoHtml[i];for(let i=0;i<this.restorableNodesAttr.length;i++)Array.prototype.slice.call(this.restorableUndoAttr[i]).forEach((function(cur){_this.restorableNodesAttr[i].setAttribute(cur.name,cur.value)}))},!("ncsedtRestorableObj"in window))var ncsedtRestorableObj=new ncsedtRestorable;window.ncSimpleHtmlEditor=function(options={}){var _this=this;this.restorable=window.ncsedtRestorableObj||new ncsedtRestorable;const defaults={editable:"body",linearHistory:!0,groupingHistory:200,toolbarCols:null,saveTimeout:500,maxImageUpload:12e5,toolbar:["edit","undo","redo","up","down","cut","copy","paste","code","link","image","head","save"],buttons:{edit:{name:"edit",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAABP0lEQVRo3u3YMU4CQRTG8T+7nkM3HkUTK26BHa2Vt9BGGlAEgl5Dz2E2XoFGGqLNTljJDDNLwXtD3pdMQTIkv+/tsNkFLBaLxQIV8AmsgAeglAZ1yTnwBfy21jtwJg07FJ9NiX34LEoMI3i3Fij+TdwnlniUhrpUwNUBJVbScIevgR/gpmOJDy14B+pSogYuJPGhu80a6O/svdvZ8w1casSnlBDHV/w/NqHlO07D5vtiCU1+AgyADfErIZYK/+THQNHsucV/Ja6l8fsm7/A94MmzR/zMnyT++ZTwo1zxRfM5G/yS7eNvAbwY3vBpePfqlx3+rYUvc8dPDW/4OL79X41aPPgfiedsb5UlMPPsqRF+GXGJTf4VpZMPFWhPfo7iyYcKOLz6yYcKhJZKfGoBtfiUAqrxsQLq8RaLxXKc/AH+RGvPIDl6DwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wOS0xNlQxNDo1ODoyMyswMDowMGRD6r4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDktMTZUMTQ6NTg6MjMrMDA6MDAVHlICAAAAAElFTkSuQmCC",icon2:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAACI0lEQVRo3u3YsWoUURTG8Z9ICIiNsDEiioioKGEbK0uxUWwkjU9kbRUbn8BitQkE0byBTUSx0FgkisaAaCGITSx2Bzezd3buzM7OzJL9YNhqzvy/c+45995lrrnmmmsuOljHL6xhoWmgIlrCFg6GnnUsNg1WFn5mTCzhTQZ8aRMdbKJbg4E7+Jtj4AA9kT3R8b+c+zWZWI00sRYT7FXqpWmY6AZixpj4GRN8BXtTNNEdxAvFzDPxMvYjV/El9fIP3KgIflzMe/gTgN/GcpGPXcHnCk2k4YuY2B/wFNZl7FZgIgs+xsRv3CyZNHAJO8r3RB78uJiruDsJfKIL+muwaCWy4Hu4b3StV9FnY018ishaDHyyIT0QV4nKdB4fIz/4Igf+OJ7WbQDO4J380p90eFMchj+GJwH479OGT7SMtxEmFvE8AP+4SfhEoUqEyr/g8CHskQaWTZZOGz0Kj5skD7Ug82ndFpfRE0YvLY1lPtG4TSpUiVN4rSWZj9lhQxmu87JUGH5DP7OtWiax8MmovIav4hu7VfAGvxtaNCqLwj+T3RONVaIK+MZMTAL/Hrc03BMx8L0M+OQOG0pCbT1RJvMfcDYVp7HplIbLy/w2zmXEaqQSacAEPpT5HVzMiVd7JfKmSvLs6v8BEKNaTcTAfxtAFVFtJvLg93C9ZOxaTOSdNlcmjN/qs9ORMhEasZtNQxXVcCW29C8/M6eufuZnEv7o6h+WFd8aD3ft0gAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wOS0xNlQxNDo1ODozMSswMDowMD92+wkAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDktMTZUMTQ6NTg6MzErMDA6MDBOK0O1AAAAAElFTkSuQmCC",title:"Edit",disabled:function(){return _this.disabledEdit()},action:function(){_this.editToggle()}},code:{name:"code",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAACIElEQVRo3u2ZsUscQRjFf8ZCMFVSmFIskiqkUxEkXbAJFmJO0MQmraSxDYLYJVVII5axCakEm5C/IBwh2ClBxPaKWNhEjMlZXA7mHrPZmZ3ZGYR9cMXevO99783s7c7tQoMGDRrkxHCiPgvAHjADjAO/gE7u8D54A3SNz9tYwrcSBZiS43aivlEwDJwzuALjuU354JGYj3ruh55Cyw6cSTluV9CoBS3gtwNvh8EVeC3jV8CLXOa7DtwDCfBExrupQ5jmywKMCvcvcMcSIFkINV8W4LFwjywcc7zWEMv/GpgNy34D68LftXB0Qq6o4Ydtm3mXRp+kZs3CWQQuqXElqpoHOJW6yQJebSFCzI9J3QUw8h9+9BAh5gHmpfarQ020EKHmAbak/p1jXXCIGOYBvojGc4/ayiFimR8CzkTnvqeGUwjXzdyQZ/MHDN5xz4BjT42ivqXbl6JVWPFovCr1nz2NLxZ4cD4NnwUKvJfaTQ/zob2jCLWl7mlq8yGCI/RuWmbNvRzmqwpPC/fEoUfLs0e0ELbr8ivhfcxtvo+lgkaKXeGsl+jatuhLsc33Ybu8KX7I+GyJZsjlOkoIE3fp/W00Z/O2Y4Ak5m0hTMwxOKPfHbSSmzdDXMp3GxJg20Eni/k+WnK8LwFeVtDIio4EeJjbkA8mxPw5Cd4/xHy8ro/QvwF/bnKAJO8AYi5xh95N7Ce9Dd0H4DBFiAYNGjTIh2vrWlwSpGLTnQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wOS0xNlQxNDo1OTo1MiswMDowMCczgy0AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDktMTZUMTQ6NTk6NTIrMDA6MDBWbjuRAAAAAElFTkSuQmCC",title:"Code",disabled:function(){return _this.disabledCode()},action:function(){_this.editCode()}},undo:{name:"undo",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAABhklEQVRo3u3WMWsUURDA8Z9i5CQaG5toIURMIRLUJo3Gyi5fxVYbwWATIYVo48ewsLJUsFFMYZVCiyTNhQhBwXDEnGfxVjiWvTWn7xED84dpdpeZ+e/Mg0cQBEEQBEEQ/E88PuwG/pXBUZI4MeL5ffSwNEauCdzELdzAZUzjNH7gC7axibd4g1Xs55YaDMVBBK7iedXgYMzYwZNKtohAm8QVvMTPv2i8Hv0q12wJgfqZmJBWbC9D4/XYq2p1cgv8nsRFaW9zN16PDzh/kGaPjRAYxXdMtrzfxWu8wntsoVvlPCcd6nncxh2cacm1iUV8zDWBtuji3h8aqjOFu/jUkvcr5koK9LGMU+MWGaIjrWdvRI11aXLZBb5Jq5CLa9LaNNV6h5MlJrCUUQAuSDvfVOtBCYES145pbDTU2cWlEgIlJnFd85l4UUqgxCQeNdToY6aUQO5JdPC5ocbK8EfHM/+1hxklenhae9aVrhut5LgK5JI4izU8w4L8PzwIgiAIgiAIgiPML+zxM5YSM3skAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIyLTA5LTE2VDE1OjAxOjUyKzAwOjAwmCW2HgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMi0wOS0xNlQxNTowMTo1MiswMDowMOl4DqIAAAAASUVORK5CYII=",title:"Undo",disabled:function(){return _this.disabledUno()},action:function(){_this.undo()}},redo:{name:"redo",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAABiklEQVRo3u3WT0tUURjH8U+hhoSuijQqd4oECS1aBJK73ktvoCCs2am7auHLCIJatSraRFjbsDYFUVAgRqFWji7uLPQ4c+femWO6eL5wFvfP8/D9nXMv5xAEQRAEQRAEQTUaRy3Qr/xOenMgQ+MBXMUNXMdFnMUZDOIXvuID3uIlXuFfTfn7uWdkEg+x1pqZOuM7lnG5ovze2r6ZwjM0exBPRxNPMF1Rvq8Ag7iNzQzi6fiLRZzqIt9zgPNYOQTxdKxgokT+QIATFeRn8BQXSt75ied4gdf4hh+t/mM4h2u4qfjZh0t6/cbpkudVnPfJr5fMxipuYaRGz1HcaYXsZZUqM47PHZpsYB5DdRomDGMJ24cRYAhvOjT4hCt9iKfMKT7BrAHudih+11qZnDRqyFcKMKHYPdPCL8p/5P8hXynAY+2/+ZljIN81wCXFGSUtundM5LsGWGhT8NH+HfIo5Q8EOJlc/1GcHPfyAFsZ5bOfKtuFmsUjvFdsPLnkcxw3giAIgiAIgiAIwC7w7i5ZynjYFQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wOS0xNlQxNTowMjowNCswMDowMFgiNkMAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDktMTZUMTU6MDI6MDQrMDA6MDApf47/AAAAAElFTkSuQmCC",title:"Redo",disabled:function(){return _this.disabledRedo()},action:function(){_this.redo()}},up:{name:"up",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAAAsUlEQVRo3u3VTQqCUBhG4dMP0aBZbaLVNWzaRlqJm2gpzmoSNXGQYJJe7bsXzgOCA9H3CCJIkqRei+gBKS7AFVhGDxk7/tUcxUV8ji8uomt8MRF947OP+GV8thFDxmcXMWZ8NhEp4yeJWCWMPwFn4PHl2NL+C9fAveO6I7AHqr+88gFq2m/6MMdDsviIDCiZAdEMiGZANAOiGRDNgGjFB6xnvPcN2DXnG+AZHStJkqb2BvfBZVUwT6fHAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIyLTA5LTI3VDExOjAxOjU1KzAwOjAwYMkoEwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMi0wOS0yN1QxMTowMTo1NSswMDowMBGUkK8AAAAASUVORK5CYII=",title:"Select up",disabled:function(){return _this.disabledUp()},action:function(){_this.up()}},down:{name:"down",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAAArUlEQVRo3u2XvQrCMBgAT9FJEAqu4vO4+BgOvrSv4NjJOgm10Gp/vwTv4JuSkLtsAREREelkBxTAKlqkLw+gqs1hjkvW0ZUGRAsYEC1gQLSAAdECBkQLGBAtYEC0wN8HbEacPQLbjvXm45yAfcveCrgvHX8GSj5/XUPmCdyWlp8qIlR+bEQS8kMjkpLvG5Gk/K8RSct/i8hCvi0iK/lmRJbyby7ANVpCRERE5uIFO9pmz/tN+9wAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjItMDktMjdUMTE6MDE6MzcrMDA6MDAxOTC9AAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIyLTA5LTI3VDExOjAxOjM3KzAwOjAwQGSIAQAAAABJRU5ErkJggg==",title:"Selenct down",disabled:function(){return _this.disabledDown()},action:function(){_this.down()}},copy:{name:"copy",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAAA7klEQVRo3u2ZSw6CMBRFj4apcQMyZu0aEscO3JGagAvAATqQQOTTvlfiPQmTQuk9bdKXtCDSJAdKoAaayE+U8HeD4NEESsPwiwU2PW01sIsxMxMyLOrcjPgmGbbeASTgHcBLwKJO1MAZKKaG+7XNWdeJx3vMYALWdaIBTkNh52yj1nXiM+Y+lIBVnRg1zt/uQskgAW8k4I0EvJGANxLwRgLeSMAbCXizeoGspy3ps9Auq18BCXgjAW8k4E02o8+T78PdKFelHaqhF3NW4GoQuMsl5M8K2ksHq7uBG3AIPSM57aVDFTF4BRxjhBcheQHmPezLx9HoXgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wOS0yN1QwNDozOTozNCswMDowMArEXrAAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDktMjdUMDQ6Mzk6MzQrMDA6MDB7meYMAAAAAElFTkSuQmCC",title:"Copy",disabled:function(){return _this.disabledCopy()},action:function(){_this.copy()}},cut:{name:"cut",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAAB9klEQVRo3u2YTU7CQBiGHzHqCgzXELmAceERSIhncUndGRFTAtHD+BNdeAAFI3HJDQSXGFxMScgU2pnOtDOLvskkJP2m87ztVzp9oVSpUmlqAn1gDPxGYwyEwLFruCQdAHfAH7DcMhbAENh3DbsJ/jkBXB5Plk0ECWsp6V4DfjUGBcArGWgSb5sp0Aaq0WgBE+Lt1MgZPlA5SShN+gLqG+rqkbH12lvX8ACf0sRWQu25VDtyDQ8wkyZXE2prUu3MNbyugUOp9sc1POi1UFuq/XAND/GHeML2h/hbqr12DQ9ie7CQTjhFPLC1aLQ3wC+Bnmv4lYYpi2QFKAQexLbg0bKJwuDXTQyIt1NWE4FGrVU1EG/YETBH/FW+A11Ez5uayBVeRRcpJq4S6jumi+9aMPAG7ABnW46fRsdfpPpX4NLWVbQh3TvhpQIJ+gRxB3Lr90rOhiqIdlmpk4cJWwpQ/4v1rp104L0zkQW+UBNyLjRDvNRuUHuRpRkM8gJXyYVUwQo3oZsLebeZy5ILebOdzpoLefNBE0on1MmFuopr5GrCJBfy4qPeJBfyIlYxyYW8CLZMciEvosVQmqyTC3kR7mbNhRbAkYEBqyay5EJ9Q3hVE0rSzYUegD1LBtJMKEslF1ogrrxNeOuSc6F59LuHec+XKlXKUP835G8IanS10wAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wOS0yN1QwNDo0MDowNCswMDowMFFlZxoAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDktMjdUMDQ6NDA6MDQrMDA6MDAgON+mAAAAAElFTkSuQmCC",title:"Cut",disabled:function(){return _this.disabledCut()},action:function(){_this.cut()}},paste:{name:"paste",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAABG0lEQVRo3u2ZzWrCUBBGj9WtUNc1a99KfT1F6KYoXbgVq6+iQiK4TRcmoGKS3h/7WToHZhHIzP0OCVlkID4dYAxsgVNRG2AEtB9wXlR6wBeQV9QaeFWHrKLdEL6sFfCiDnuP8Q/ClzX8rVAJMAMyh3BlfQBvQB+Ye/RnwDswCAm/9zi4rP7NLN85h6LfmVnAoTEFcmDqI+Dz2lzWvJBIgEXgrLQqZKtGIG+4NycuTfPvZn3Kz5kLJqDGBNR0AnpbAb3R+PNPwATUmIAaE1BjAmpMQI0JqDEBNSagxgTUmIAaE1BjAmrq/swdge7Fdex9gAuVC466J7AUBr7l06dpwHnBFrIailE7rvdtTiScF2ypIHgKTELCG8Z/4BuHD+VLGLARSgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wOS0yN1QwNDozOTo1MCswMDowMDjkcyQAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDktMjdUMDQ6Mzk6NTArMDA6MDBJucuYAAAAAElFTkSuQmCC",title:"Paste",disabled:function(){return _this.disabledPaste()},action:function(){_this.paste()}},link:{name:"link",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAADHElEQVRo3u2ZzUsUYRzHP7uBSh0qLTtUKKuBQdGpOkSkFBQEnZLqYJEQBL0IEkT0B1QQhYc6mG1u18B7eRGtSxHUUahs7WZrmEX4Eurh2YHxO2+77szOCvuFYXlmvvP7fZ6Z53n2eZ6Bqqqqal0rEVPeOuAo0AQ0ADngO/AWmI/7ofgpBWSAv8Cyy/EHSAPNcYO6qRdY8ADXYx64HjewpSTwrEBwPfqCgm8oA3wa6Ha59g0YAoaBL0A9sFk8hzH940PEnJ7wgzifag7oxDmAJIEuYEb8c5jOXhHwk0BrwL37XSrxvFLgUwXG6JJ7Z4GacsFnSoS34mQlRsd6gbf0QuK4DQQkQ6zAAHBRzv0A2jEjTrGaknJDlBW4DVwOER5gu5R/hcTq0D7gP4U1mx3AAYIfXAKYoEx9YEgSTQEtLr5TwL+85zX+o8oFnKNQbRTw9cCiJDvt4R0WX7+HrxWYFm86CniA85Loo4/3Kc4R6ph4GjDTap3YNUdVgbuS7J6PdwswLv5R8WzKA9s9N8OCTQJtcu6xJOsJiHEIWLL5l4Cd4hkluJmtgioUPg2ck/O/pbw1IM57YMxWTgAnxPM5/5sBroZRAQv+EqbT2pWVcnsB8UakrDPN6Tx8N+YNlSz7YkST78LZJA4GxOthdbN7JNfbCHGG0CvJ5oCN4hkTzzimw3rpgfjvhAWrSuFcw04C28TXgXN4fOIT95N4z0ZVAZ1Z5vBejOia942H74z4FvB/W2tWHc6tj04ffw1merCMmS6cdPG0AD8l5qso4MEMbfZEXwneBEtiJmqNLtdSmOZnj7kI7I2qAlck2UAJsdzgl4FbYYB6DVf6h5QrAX4E2C3n08DDKCugi4fGoEBFwL/EvOFIdZzVrztLcX8uXs0mU2ScNasWs9FqT95VIvxgueAtpQVgBrPp5Kc9lQIPZhGhc/MZzM6DwiQwy0BdScUGb+mGC5DVJwaB+5j9mwkPX6zwlvo84IKO/kqAt3QNMxMt9ONEaMvAMNWE2SWe9QCP5fPQWj7y1QBH8qCNmH2gLPCOCv9AV1VVVVWgVgAPDHRgefYM4AAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wOS0xNlQxNDo1OTozMiswMDowMOFciqoAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDktMTZUMTQ6NTk6MzIrMDA6MDCQATIWAAAAAElFTkSuQmCC",title:"Link",disabled:function(){return _this.disabledLink()},action:function(){_this.editLink()}},image:{name:"image",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAABzUlEQVRo3u2ZyUrDUBSGvzosxLEqqAj6AKJvIK58AKdncOXeCUdc+BKiILoQhYLgwpUg4hOIIu4UdyotKDi0LpJLQ8hNk7S9p4X7wYHCPWn+L0N7cwMWWRqr/P0bwARwJS2aNHzBrTXpMHHZdIN/u1UAVqRDJQk/BUx7JFalw8UNr5ihDs6ELrxiFvhxe5alw/rZKhE+SGJJOnTc8Io5j8RiuTtPlRgfBNaBcaBPs32X+/kXyEXcbwfF/6B3TU8OyODc+NkkcsPAM8Xfcql69BykWJzUQHhVe7qQYZdQFmhPYl4FPoB03I38R8EkvVH332A4WMWxAtJYAWmsgDRWQBorII0VkKbSAmmgW1pKkWQ6fQZcUv6SZeTpdCUFFjy9OyV6Sz2LGxcYA748vXmcJZQg+oFroKdWBNqA+4D+HDDi620Bbt3xc/T3oFGBQ/QP4w9Ap9uXAo5847oVOmMC8yHhVWXc8NsBY3/ApJTAKPAZQUBdLnnN2CswYFqgFbiLGD5K3QDNJgX2Kxhe1a5JgWpj14XqhroXaAoZy+Ks4ytM3wdedO8QQs/AhWBgP6dJNhoCXpB/N/BEcTqSSOIYZ33edPA34ABn9mqpWf4B0/l4sgdYXjsAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjItMDktMTZUMTU6MDE6MTUrMDA6MDDZyIZqAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIyLTA5LTE2VDE1OjAxOjE1KzAwOjAwqJU+1gAAAABJRU5ErkJggg==",title:"Image",disabled:function(){return _this.disabledImage()},action:function(){_this.editImage()}},head:{name:"head",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAADI0lEQVRo3u2ZT09TQRTFf4KtCRBNwJIodK0LdwgWd+BnMBDdgaisCYluXAqu1QBxSeKfGFeKSz6AAZMaNzRxYQWbKC6gKGWhdTGvyePOtH3TzrQYe5JZzOvMmXPfu3PvnSm00ML/jWOOeNqBIWAEGADOA2eAruD3PeArsAGsA6vAO+BPs19AEpgHNoGiZfsCzAH9zRCeAJaAgxqEy3YALACnGyX+GvDDgXDZtoFxn8JjwJMKAnaAp8ANYDD4SrGgJYJnU8AzYLcCz2Iwxyk6gLdlFtwAJoIxNnyTQKYM54olX9U3bxL/C5gBjtfJPQvsG/jf4OhLmNwmA1xw9YaAFCrMynUW6iW+biB9j/Jp1+gH0ob1xmolTKBHm4wn8WEjcmLN70BPLWRL6D7v0m3KIQUUxNqPbUmS6ElqpgHiS7gn1i5gmbHn0UNlPdHGFl3orjQXdXI7em0z0UDxJUwLDVmgLcrEYTFxB4dJxQKdQF5oGZKDTBaNiP4KagM3Gj+DtcMYjWLAgOivNkF8ubWlNqMB50Q/Lfpx4AEqc26hNnzc0xi5ttRmhExesk6XEaoYPPMxphc9qVWFjP/yrZhqlpynMSfQ88EhRApLAkXDs9+exlSFyYA90T8p+suGOcuexpwS/XwUoz5SOfbGUb66ReUN6mJMSmj5EMWAV2LSVJRJnnBLaHkpB5hcaE30R2kerlTRZoT8bLscnVJiMMrENtSlU3jiZBMMmBIaPmMRNefE5AwerjoqIA58Ehru2xD0oye02QYacAc9gfXZkiwIkn3U/vCNy+hHyoe1EHWjag+Z6pMexZ9FP0xtU8e96Th6vZLGz41yEpWo5HpX6yVeNJDmcOtOw+hn4CLwyAV5DHUykuQF1O1BZx3cceAuus8Xgdc4vEjoKGNE6WtMWxrSCdxED5Vh8c6TZww9MoVbHniOql8uoQ4j8aD1Bs9uAy/QM6x0G69XOGPo0clF+4aDDRsVPajrPpPv2rYCKs53N0p8GH2osiNbg/AsqjywzrBhuPqbtQ24iCq9B1C3B30c/pt1E1VTraGuS9Y5An+zttDCv46/K53XmFVUFdIAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjItMDktMjRUMDc6MTM6NTQrMDA6MDAX56YDAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIyLTA5LTI0VDA3OjEzOjU0KzAwOjAwZroevwAAAABJRU5ErkJggg==",title:"Edit head",disabled:function(){return _this.disabledHead()},action:function(){_this.editHead()}},save:{name:"save",icon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAABXElEQVRo3u2ZMU7DQBAAJwjhVHyA0KGInoJPAfkCJR+hAsQDEC1JqkDDL0BKTE0oHCQU2T77srtnix3pKq9vd3zrs04Gx3GcLnMKPAIrYK08rqWLPwY+DQpXk7g3Ll5cwqJtVCW2J9XijPJWvemLgJpElYBUm6hLWAuIS6QQqJPojQDAedP4QUCgLFbqhR4Erq+bxO8JFZMMF0jNfsQ9od41pfcr4AKp0RAYAhNgDnxtxgy4AjJLuZhP+Qh4o/rr+7qJ0cq/0wTDQPF/JZqshLnApEHxv+OyiwLzFgLTLgrkLQRyqfypttFvqYkkBd6VYs0EbpVio2n7DmQUW2So/xfAgUJ+kQlGAYkFcKSYX2SCjGKfn1LsNjnwAlzQ7Mm3yh9zJrbif5yJ605kK+Cw5olYsqy6ULcCzwkL3uYp5qYx9j84ysYHcBJrPgYeKJbQuvAlcLdL8Y7jOPr8ALb40CVRgUo/AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIyLTA5LTE2VDE0OjU4OjU2KzAwOjAwPL7MAAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMi0wOS0xNlQxNDo1ODo1NiswMDowME3jdLwAAAAASUVORK5CYII=",icon2:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAABvklEQVRo3u2Zu0oDQRSGv0jUWKigTZAIYiH2Bn0FOx/AQiSVVV4hpYiVta3YeEGsLSwEo40+gRcQO4MXtIzF7uKyzGSzs3NmDcwPU+25/N/mZGaXBS8vL6//rEXgFPgAusKrZdv8LPDmwLgYxJFj89YhXIyNKESyqJSWUI/q9qAAiEHoAGyNiTiEawDrEEUA9IIYGACAlX7jSykAqlhbf+hSyvVuP/FDlswUJg9QtMoGOWmz61QD/wt4gKIlAVABmkAb+ArXNbAFjGSo85rXiMlRXgPu0Z++hxn6jwIN4DlD/1wAlRTzB8C4gY9p4NwFQLOH+V3ybb9GuVkB2ujvfCFnR1aAT0XOIzBh2L/qGuBbkbNu2LtO8E5gmm8EcJuIf8Jsm64DnbDGD7DsCmAzEW/yGhg3H60rVwBl4CYWv6qJm8lg/gGYcwUAMMXfblRTXG+FJuvS5k0BIJj7DWBYYT6qFYcQMZ8HQKedRL0OwaOCiHkJgBKwr6ib3LnmbZgHeE9plrbWFDXLwJkm3tqdj3SSE2BPU3cMuJQ2D7BAvg8cLwSPxCpNAneS5uMQx5iPU6NH7SpwIWney8vLS16/eT7oBHxeUFYAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjItMDktMTdUMTY6Mjk6NTQrMDA6MDCj7IdOAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIyLTA5LTE3VDE2OjI5OjU0KzAwOjAw0rE/8gAAAABJRU5ErkJggg==",title:"Save",disabled:function(){return _this.disabledSave()},action:function(){_this.save()}}},draggerIcon:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAABgAAAAYADwa0LPAAAA+klEQVRo3u3ZUQ7CIBAE0NGDGOL9r+SHJ6k/bWJIkV3KDrvCJHx3XgwsrcDKiuukfYXMA8ALwBvAc3SZ1vLbvkIh8vKhEKXyIRC18q4R0vIuEdryrhCt5bshboa4jfGsuyGAkukAidDJ7BnHhpUm37DSmJxO36eNNaD7EZsflQxAN8TZOc8CXEaUhhQT0Iz4NWHZADXi6vXAaokQXssXEeEn8Vm8/grd9oE0wzZxDcEGdJ8FTIDJNGYBzO5DDIDpjdQaYPqynwgAzTPWS/3wTA/QTOy/+zrnonwrwlV5LcJleSnCdfkaIkT5EiJU+RwRsvyRhMB/dK9MkQ9aiYmYo9JGZAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMi0wOS0xNlQxMjoyOTo1MSswMDowMJ8FU+4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjItMDktMTZUMTI6Mjk6NTErMDA6MDDuWOtSAAAAAElFTkSuQmCC"};this.options=this.deepMerge(defaults,options),this.options.groupingHistory=this.options.groupingHistory/1e4,this.editEnable=null,this.clipboard=null,this.editable=document.querySelector(this.options.editable),this.editableInBody(),this.wrapEditable(),this.implement=document.querySelector("#ncsedt-implement"),this.implementToLastBody(),this.focused=this.editable,this.focusedPrev=this.focused,this.observer=this.setObserver(),this.historyUndo=[],this.historyRedo=[],this.historyForce=[],this.setEventEditorChanges()},ncSimpleHtmlEditor.prototype.deepMerge=function(target,source){for(key of Object.keys(source))target.hasOwnProperty(key)&&"object"==typeof source[key]?this.deepMerge(target[key],source[key]):target[key]=source[key];return target},ncSimpleHtmlEditor.prototype.isEditEnable=function(target,source){return this.editEnable},ncSimpleHtmlEditor.prototype.getFocused=function(target,source){return this.focused},ncSimpleHtmlEditor.prototype.getFocusedPrev=function(target,source){return this.focusedPrev},ncSimpleHtmlEditor.prototype.getEditable=function(target,source){return this.editable},ncSimpleHtmlEditor.prototype.getClipboard=function(target,source){return this.clipboard},ncSimpleHtmlEditor.prototype.editableInBody=function(){this.editable.contains(document.body)&&this.editable!=document.body&&(console.log('The highest node that can be edited is body, set options.editable = "body"'),this.options.editable="body",this.editable=document.querySelector(this.options.editable))},ncSimpleHtmlEditor.prototype.wrapEditable=function(){const wrapContent=(target,wrapper=document.createElement("ncsedt-editable"))=>([...target.childNodes].forEach(child=>wrapper.appendChild(child)),target.appendChild(wrapper),wrapper);this.editable=wrapContent(this.editable),this.editable.id="ncsedt-editable",this.editable.setAttribute("contentEditable","true")},ncSimpleHtmlEditor.prototype.implementToLastBody=function(){var implement=document.createDocumentFragment();implement.appendChild(this.implement),document.body.appendChild(implement),this.implement.insertAdjacentHTML("beforeend",'<div id="ncsedt-container"></div>'),this.implement.insertAdjacentHTML("beforebegin","\x3c!-- ncsedt-implement:begin --\x3e"),this.implement.insertAdjacentHTML("afterend","\x3c!-- ncsedt-implement:end --\x3e"),this.container=document.getElementById("ncsedt-container"),this.container.insertAdjacentHTML("beforebegin","\x3c!-- ncsedt-container:begin --\x3e"),this.container.insertAdjacentHTML("afterend","\x3c!-- ncsedt-container:end --\x3e")},ncSimpleHtmlEditor.prototype.start=function(){this.editOff(),this.tollbar=this.renderTollbar(),this.dialogCode=this.renderDialogCode(),this.dialogImage=this.renderDialogImage(),this.dialogLink=this.renderDialogLink(),this.dialogHead=this.renderDialogHead(),this.movable("#ncsedt-toolbar","#ncsedt-toolbar-dragger"),this.movable("#ncsedt-dialog-code","#ncsedt-dialog-code .dragger"),this.movable("#ncsedt-dialog-image","#ncsedt-dialog-image .dragger"),this.movable("#ncsedt-dialog-link","#ncsedt-dialog-link .dragger"),this.movable("#ncsedt-dialog-head","#ncsedt-dialog-head .dragger"),this.setEvents(),this.setEventsToolbar(),this.setEventsDialogCode(),this.setEventsDialogImage(),this.setEventsDialogLink(),this.setEventsDialogHead(),document.dispatchEvent(new Event("editorstart"))},ncSimpleHtmlEditor.prototype.editOn=function(){var btnsEdit=document.querySelectorAll(".ncsedt-toolbar-btn-edit img");for(element of(this.editable.setAttribute("contentEditable","true"),btnsEdit))element.src=this.options.buttons.edit.icon2;this.editEnable=!0,this.setFocus(this.focused),this.observe(),document.dispatchEvent(new Event("editorchanges"))},ncSimpleHtmlEditor.prototype.editOff=function(){this.observer.disconnect();var editable=document.querySelectorAll("*[contentEditable]"),btnsEdit=document.querySelectorAll(".ncsedt-toolbar-btn-edit img");for(element of editable)element.setAttribute("contentEditable","false");for(element of btnsEdit)element.src=this.options.buttons.edit.icon;for(focused of document.querySelectorAll(".focused"))focused.classList.remove("focused");this.editEnable=!1,document.dispatchEvent(new Event("editorchanges"))},ncSimpleHtmlEditor.prototype.setFocus=function(element){if(this.editEnable&&element&&element.isContentEditable){for(oldfocused of document.querySelectorAll(".focused"))oldfocused.classList.remove("focused");this.focusedPrev=this.focused,this.focused=element,this.focused.focus(),this.focused.classList.add("focused"),document.dispatchEvent(new Event("focusedchange"))}},ncSimpleHtmlEditor.prototype.save=function(){var _this=this,templatesource=this.getDocumentHTML(),download=document.createElement("a"),btnsSave=document.querySelectorAll(".ncsedt-toolbar-btn-save img");for(button of(this.saving=!0,this.editOff(),btnsSave))button.src=this.options.buttons.save.icon2,button.parentNode.disabled=!0;download.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(templatesource)),download.setAttribute("download","index.html"),this.container.appendChild(download),download.click(),setTimeout((function(){for(button of(_this.saving=!1,btnsSave))button.src=_this.options.buttons.save.icon,button.parentNode.disabled=!1}),this.options.saveTimeout),this.container.removeChild(download),this.editOn()},ncSimpleHtmlEditor.prototype.getDocumentHTML=function(selector=null){var html="";return window.scrollTo({top:0,left:0,behavior:"instant"}),this.restorable.restore(),this.removable(),html=selector?document.querySelector(selector).innerHTML:(new XMLSerializer).serializeToString(document),this.undoRemovable(),this.restorable.undoRestore(),this.ncsedtRemover(html)},ncSimpleHtmlEditor.prototype.ncsedtRemover=function(html){return html=(html=(html=(html=(html=html.replace(/<ncsedt-removable>\s*<\/ncsedt-removable>/gis,"")).replace(/<!--\s*ncsedt-implement:before\s*-->.*<\/ncsedt-editable>/gis,"</ncsedt-editable>")).replace(/<!--\s*ncsedt-implement:begin\s*-->.*<!--\s*ncsedt-implement:end\s*-->/gis,"")).replace(/<!--\s*ncsedt-container:begin\s*-->.*<!--\s*ncsedt-container:end\s*-->/gis,"")).replace(/<\/?ncsedt-editable[^>]*>/gis,"")},ncSimpleHtmlEditor.prototype.removable=function(){var _this=this,count=0;this.removableHtml=[],document.querySelectorAll("ncsedt-removable").forEach((function(node){_this.removableHtml[count++]=node.innerHTML,node.innerHTML=""}))},ncSimpleHtmlEditor.prototype.undoRemovable=function(){var _this=this,count=0;document.querySelectorAll("ncsedt-removable").forEach((function(node){node.innerHTML=_this.removableHtml[count++]}))},ncSimpleHtmlEditor.prototype.editToggle=function(){this.editEnable?this.editOff():this.editOn()},ncSimpleHtmlEditor.prototype.undo=function(){this.undoredo(!0)},ncSimpleHtmlEditor.prototype.redo=function(){this.undoredo(!1)},ncSimpleHtmlEditor.prototype.up=function(){this.focused.parentElement&&(this.setFocus(this.focused.parentElement),this.focused.scrollIntoView({block:"center"}))},ncSimpleHtmlEditor.prototype.down=function(){this.focused.firstElementChild&&(this.setFocus(this.focused.firstElementChild),this.focused.scrollIntoView({block:"center"}))},ncSimpleHtmlEditor.prototype.copy=function(){this.focused!=this.editable&&(this.clipboard=this.focused.outerHTML,document.dispatchEvent(new Event("editorchanges")))},ncSimpleHtmlEditor.prototype.cut=function(){this.focused!=this.editable&&(this.clipboard=this.focused.outerHTML,this.focused.parentElement.removeChild(this.focused),this.setFocus(this.focused.parentElement))},ncSimpleHtmlEditor.prototype.paste=function(){this.clipboard&&this.focused!=this.editable&&this.focused.insertAdjacentHTML("afterend",this.clipboard)},ncSimpleHtmlEditor.prototype.disabledEdit=function(){return!1},ncSimpleHtmlEditor.prototype.disabledSave=function(){return!(this.editEnable&&!this.saving)},ncSimpleHtmlEditor.prototype.disabledUno=function(){return!this.editEnable||!this.historyUndo.length},ncSimpleHtmlEditor.prototype.disabledRedo=function(){return!this.editEnable||!this.historyRedo.length},ncSimpleHtmlEditor.prototype.disabledUp=function(){return!(this.editEnable&&this.focused.parentElement&&this.focused.parentElement.isContentEditable)},ncSimpleHtmlEditor.prototype.disabledDown=function(){return!this.editEnable||!this.focused.firstElementChild},ncSimpleHtmlEditor.prototype.disabledCut=function(){return!this.editEnable||this.focused==this.editable},ncSimpleHtmlEditor.prototype.disabledCopy=function(){return!this.editEnable||this.focused==this.editable},ncSimpleHtmlEditor.prototype.disabledPaste=function(){return!this.editEnable||!this.clipboard||this.focused==this.editable},ncSimpleHtmlEditor.prototype.disabledLink=function(){return!this.editEnable},ncSimpleHtmlEditor.prototype.disabledImage=function(){return!this.editEnable},ncSimpleHtmlEditor.prototype.disabledHead=function(){return!this.editEnable},ncSimpleHtmlEditor.prototype.disabledCode=function(){return!this.editEnable},ncSimpleHtmlEditor.prototype.setObserver=function(){return new MutationObserver((function(mutations){_this.editEnable&&!_this.ignoreMutations&&(mutations.forEach((function(mutation){switch(mutation.time=Date.now()/1e4,mutation.type){case"characterData":mutation.newValue=mutation.target.nodeValue,_this.historyUndo.push(mutation),_this.resetLinearHistory(),document.dispatchEvent(new Event("contentchanges"));break;case"attributes":var attrName=mutation.attributeName,attrValue=mutation.target.getAttribute(mutation.attributeName);(_this.focused.contains(mutation.target)||document.head.contains(mutation.target))&&_this.historyForceCheck(attrName,attrValue)&&(mutation.newValue=attrValue,_this.historyUndo.push(mutation),_this.historyForceRemove(attrName,attrValue),_this.resetLinearHistory(),document.dispatchEvent(new Event("contentchanges")));break;case"childList":_this.historyUndo.push(mutation),_this.resetLinearHistory(),document.dispatchEvent(new Event("contentchanges"))}})),document.dispatchEvent(new Event("editorchanges")))}))},ncSimpleHtmlEditor.prototype.observe=function(){this.observer.observe(this.editable,{attributes:!0,characterData:!0,childList:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),this.options.toolbar.includes("head")&&this.observer.observe(document.head,{attributes:!0,characterData:!0,childList:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0})},ncSimpleHtmlEditor.prototype.resetLinearHistory=function(){this.historyRedo.length&&this.options.linearHistory&&(this.historyRedo=[])},ncSimpleHtmlEditor.prototype.historyForcePush=function(attr,val){var force=attr+":"+val.toString();this.historyForce.push(force)},ncSimpleHtmlEditor.prototype.historyForceCheck=function(attr,val){var value,force=attr+":"+(val||"").toString();return this.historyForce.includes(force)},ncSimpleHtmlEditor.prototype.historyForceRemove=function(attr,val){var force=attr+":"+val.toString();this.historyForce.includes(force)&&this.historyForce.splice(this.historyForce.indexOf(force),1)},ncSimpleHtmlEditor.prototype.undoredo=function(undo){this.observer.disconnect();for(var previousTime=null,groupingByTime=!0;;){if(undo){if(!this.historyUndo.length)break;var mutation=this.historyUndo.pop();if(this.historyRedo.push(mutation),previousTime&&mutation.time+_this.options.groupingHistory<previousTime){this.historyUndo.push(mutation),this.historyRedo.pop();break}}else{if(!this.historyRedo.length)break;var mutation=this.historyRedo.pop();if(this.historyUndo.push(mutation),previousTime&&mutation.time-_this.options.groupingHistory>previousTime){this.historyRedo.push(mutation),this.historyUndo.pop();break}}switch(mutation.type){case"characterData":var parentView;(mutation.target.parentElement.parentElement.parentElement||mutation.target.parentElement.parentElement||mutation.target.parentElement).scrollIntoView({block:"center"}),this.setFocus(mutation.target.parentElement),mutation.target.textContent=undo?mutation.oldValue:mutation.newValue;break;case"attributes":mutation.target.scrollIntoView({block:"center"}),this.setFocus(mutation.target);var value=undo?mutation.oldValue:mutation.newValue;null===value?mutation.target.removeAttribute(mutation.attributeName):mutation.target.setAttribute(mutation.attributeName,value);break;case"childList":mutation.target.scrollIntoView({block:"center"}),this.setFocus(mutation.target);var addNodes=undo?mutation.removedNodes:mutation.addedNodes,removeNodes=undo?mutation.addedNodes:mutation.removedNodes;Array.from(addNodes).forEach(mutation.nextSibling?node=>{mutation.nextSibling.parentNode.insertBefore(node,mutation.nextSibling)}:node=>{mutation.target.appendChild(node)}),Array.from(removeNodes).forEach((function(node){node.parentNode.removeChild(node)}))}previousTime=mutation.time}this.observe(),document.dispatchEvent(new Event("editorchanges")),document.dispatchEvent(new Event("contentchanges"))},ncSimpleHtmlEditor.prototype.setEventEditorChanges=function(){var _this=this;document.addEventListener("editorchanges",(function(){_this.setDisabledBtns()}))},ncSimpleHtmlEditor.prototype.setEvents=function(){var _this=this;this.editable.addEventListener("click",(function(evt){_this.focused!=evt.target&&_this.setFocus(evt.target)}),!0),this.editable.addEventListener("input",(function(evt){"insertParagraph"==evt.inputType&&setTimeout((function(){_this.setFocus(document.getSelection().anchorNode)}),50)}),!0),this.editable.addEventListener("dblclick",(function(){"A"==_this.focused.tagName||"A"==_this.focused.parentElement.tagName?_this.command(_this.options.buttons.link):"IMG"==_this.focused.tagName||"IMG"==_this.focused.parentElement.tagName?_this.command(_this.options.buttons.image):_this.command(_this.options.buttons.code)}),!0),document.addEventListener("contentchanges",(function(){window.onbeforeunload=function(evt){return evt.returnValue="",""}}))},ncSimpleHtmlEditor.prototype.setEventsToolbar=function(){for(var name of(_this=this,this.options.toolbar)){var button=this.options.buttons[name],toolbarBtns=document.querySelectorAll(".ncsedt-toolbar-btn-"+button.name);for(btn of toolbarBtns)btn.addEventListener("click",handleCommand(button))}function handleCommand(button){return function(e){_this.command(button)}}},ncSimpleHtmlEditor.prototype.command=function(command){command.action()},ncSimpleHtmlEditor.prototype.setDisabledBtns=function(){for(var name of this.options.toolbar){var option=this.options.buttons[name],buttons=document.querySelectorAll(".ncsedt-toolbar-btn-"+option.name);for(button of buttons)button.disabled=option.disabled()}},ncSimpleHtmlEditor.prototype.movable=function(movableSelector,draggerSelector){new ncSimpleMoveable(movableSelector,draggerSelector)},ncSimpleHtmlEditor.prototype.renderTollbar=function(){var toolbar=document.createElement("toolbar");for(var name of(toolbar.id="ncsedt-toolbar",toolbar.classList.add("ncsedt-toolbar"),toolbar.innerHTML='<button class="ncsedt-toolbar-dragger ncsedt-toolbar-btn" id="ncsedt-toolbar-dragger"> <img class="ncsedt-toolbar-icon-dragger ncsedt-toolbar-icon" src="'+this.options.draggerIcon+'" title="Move"></button>',this.options.toolbar)){var option=this.options.buttons[name],button=document.createElement("button");button.classList.add("ncsedt-toolbar-btn"),button.classList.add("ncsedt-toolbar-btn-"+option.name),button.disabled=option.disabled(),button.innerHTML='<img class="ncsedt-toolbar-icon" src="'+option.icon+'" title="'+option.title+'">',toolbar.append(button)}if(this.container.append(toolbar),this.options.toolbarCols){var style=window.getComputedStyle(toolbar),padding=parseInt(style.getPropertyValue("padding")),border=parseInt(style.getPropertyValue("border"));toolbar.style.width=42*this.options.toolbarCols+2*padding+2*border+"px"}return toolbar},ncSimpleHtmlEditor.prototype.renderDialogCode=function(){var _this=this,dialogCode='<dialog id="ncsedt-dialog-code" class="ncsedt-dialog"> <div class="ncsedt-btns"> <div class="ncsedt-btns-left"> <button type="button" class="sbutton dragger"><img class="" src="'+this.options.draggerIcon+'" title="Move"> <span>Edit source code</span></button> </div> <div class="ncsedt-btns-right"> <button type="button" class="sbutton cancel"> <b>⨯</b> </button> </div> </div> <div class="body"> <textarea class="code sbutton" placeholder=" ( empty ) "></textarea> </div> <div class="ncsedt-btns"> <div class="ncsedt-btns-left"> <button type="button" class="sbutton parent">⇑</button> <button type="button" class="sbutton child">⇓</button> <button type="button" class="sbutton link"><img class="" src="'+this.options.buttons.link.icon+'" title="Edit link"></button> <button type="button" class="sbutton image"><img class="" src="'+this.options.buttons.image.icon+'" title="Edit image"></button> </div> <div class="ncsedt-btns-right"> <button type="button" class="sbutton confirm">✓ Ok</button> </div> </div></dialog>';return this.container.insertAdjacentHTML("beforeend",dialogCode),document.getElementById("ncsedt-dialog-code")},ncSimpleHtmlEditor.prototype.setEventsDialogCode=function(){var _this=this;document.querySelector("#ncsedt-dialog-code .cancel").addEventListener("click",(function(){_this.dialogCode.close()})),document.querySelector("#ncsedt-dialog-code .parent").addEventListener("click",(function(){_this.editCodeParent()})),document.querySelector("#ncsedt-dialog-code .child").addEventListener("click",(function(){_this.editCodeChild()})),document.querySelector("#ncsedt-dialog-code .confirm").addEventListener("click",(function(){_this.editCodeConfirm()})),document.querySelector("#ncsedt-dialog-code .link").addEventListener("click",(function(){_this.dialogCode.open&&_this.dialogCode.close(),_this.command(_this.options.buttons.link)})),document.querySelector("#ncsedt-dialog-code .image").addEventListener("click",(function(){_this.dialogCode.open&&_this.dialogCode.close(),_this.setFocus(_this.focused.querySelector("img")),_this.command(_this.options.buttons.image)}))},ncSimpleHtmlEditor.prototype.editCode=function(){this.editEnable&&(this.focused.querySelector("img")||this.focused.parentElement.querySelector("img")?this.dialogCode.querySelector("#ncsedt-dialog-code .image").style.visibility="visible":this.dialogCode.querySelector("#ncsedt-dialog-code .image").style.visibility="hidden",window.getSelection().toString()||this.focused.querySelector("a")||this.focused.parentElement.querySelector("a")?this.dialogCode.querySelector("#ncsedt-dialog-code .link").style.visibility="visible":this.dialogCode.querySelector("#ncsedt-dialog-code .link").style.visibility="hidden",this.dialogCode.querySelector("textarea.code").value=this.focused.innerHTML,this.dialogCode.open||this.dialogCode.showModal())},ncSimpleHtmlEditor.prototype.editCodeConfirm=function(){this.editEnable&&(this.dialogCode.open&&this.dialogCode.close(),this.focused.isContentEditable&&this.focused.innerHTML!=this.dialogCode.querySelector("textarea.code").value&&(this.focused.innerHTML=this.dialogCode.querySelector("textarea.code").value))},ncSimpleHtmlEditor.prototype.editCodeParent=function(){this.editEnable&&this.focused.parentElement&&this.focused.parentElement.isContentEditable&&(this.setFocus(this.focused.parentElement),this.editCode())},ncSimpleHtmlEditor.prototype.editCodePrev=function(){this.editEnable&&this.focusedPrev&&this.focusedPrev.isContentEditable&&(this.setFocus(this.focusedPrev),this.editCode())},ncSimpleHtmlEditor.prototype.editCodeChild=function(){this.editEnable&&this.focused.firstElementChild&&this.focused.firstElementChild.isContentEditable&&(this.setFocus(this.focused.firstElementChild),this.editCode())},ncSimpleHtmlEditor.prototype.renderDialogImage=function(){var _this=this,dialogImage='<dialog id="ncsedt-dialog-image" class="ncsedt-dialog"> <div class="ncsedt-btns"> <div class="ncsedt-btns-left"> <button type="button" class="sbutton dragger"><img class="" src="'+this.options.draggerIcon+'" title="Move"> <span id="ncsedt-dialog-image-title">Edit image</span></button> </div> <div class="ncsedt-btns-right"> <button type="button" class="sbutton cancel"> <b>⨯</b> </button> </div> </div> <div class="body"> <div class="preview"> <img class="image" src="'+this.options.buttons.image.icon+'"> <button id="ncsedt-dialog-image-upload" type="button" class="upload sbutton">⤒ Upload</button> <input id="ncsedt-dialog-image-file" class="file" accept="image/*" type="file" /> </div> <label for="ncsedt-dialog-image-src">Image URL:</label> <input id="ncsedt-dialog-image-src" class="src sbutton" type="text"> <div class="separator"></div> <label for="ncsedt-dialog-image-alt">Alt. text:</label> <input id="ncsedt-dialog-image-alt" class="alt sbutton" type="text"> <div class="separator"></div> <input size="3" id="ncsedt-dialog-image-width" class="width sbutton" type="text" placeholder="auto"> <button type="button" class="sbutton style-width" value="100%">⟷</button> <button type="button" class="sbutton style-width" value="50%">50%</button> <button type="button" class="sbutton style-width" value="25%">25%</button> <button type="button" class="sbutton style-width" value="">↺</button> <div class="separator"></div> <input size="3" id="ncsedt-dialog-image-height" class="height sbutton style-height" type="text" placeholder="auto"> <button type="button" class="sbutton style-height" value="100%">↕</button> <button type="button" class="sbutton style-height" value="">↺</button> <div class="separator"></div> <input size="3" id="ncsedt-dialog-image-float" class="float sbutton style-float" type="text" placeholder="no"> <button type="button" class="sbutton style-float" value="left">↫</button> <button type="button" class="sbutton style-float" value="right">↬</button> <button type="button" class="sbutton style-float" value="">↺</button> <div class="separator"></div> <input size="3" id="ncsedt-dialog-image-padding" class="padding sbutton style-padding" type="text" placeholder="no"> <button type="button" class="sbutton style-padding" value="10px">⊡</button> <button type="button" class="sbutton style-padding" value="">↺</button> <div class="image-remove"> <div class="separator"></div> <label for="ncsedt-dialog-image-remove">Remove image:</label> <input id="ncsedt-dialog-image-remove" class="remove" type="checkbox"> </div> </div> <div class="ncsedt-btns"> <div class="ncsedt-btns-left"> <button type="button" class="sbutton parent">⇑</button> <button type="button" class="sbutton child">⇓</button> <button type="button" class="sbutton code"><img class="" src="'+this.options.buttons.code.icon+'" title="Edit code"></button> <button type="button" class="sbutton link"><img class="" src="'+this.options.buttons.link.icon+'" title="Edit link"></button> </div> <div class="ncsedt-btns-right"> <button type="button" class="sbutton confirm">✓ Ok</button> </div> </div></dialog>';return this.container.insertAdjacentHTML("beforeend",dialogImage),document.getElementById("ncsedt-dialog-image")},ncSimpleHtmlEditor.prototype.setEventsDialogImage=function(){var _this=this;document.querySelector("#ncsedt-dialog-image .cancel").addEventListener("click",(function(){_this.dialogImage.close()})),document.querySelector("#ncsedt-dialog-image .confirm").addEventListener("click",(function(){_this.editImageConfirm()})),document.querySelector("#ncsedt-dialog-image .parent").addEventListener("click",(function(){_this.editImageParent()})),document.querySelector("#ncsedt-dialog-image .child").addEventListener("click",(function(){_this.editImageChild()})),document.querySelector("#ncsedt-dialog-image .code").addEventListener("click",(function(){_this.dialogImage.open&&_this.dialogImage.close(),_this.command(_this.options.buttons.code)})),document.querySelector("#ncsedt-dialog-image .link").addEventListener("click",(function(){_this.dialogImage.open&&_this.dialogImage.close(),_this.command(_this.options.buttons.link)})),document.querySelector("#ncsedt-dialog-image .upload").addEventListener("click",(function(){document.querySelector("#ncsedt-dialog-image-file").dispatchEvent(new MouseEvent("click"))})),document.querySelector("#ncsedt-dialog-image-file").addEventListener("change",(function(e){if(this.files[0].size>_this.options.maxImageUpload){var inMb=(_this.options.maxImageUpload/1024/1024).toFixed(1);return alert("File is too big! "+inMb+"Mb. max. (Use .webp format)"),this.value="",!1}var reader=new window.FileReader;reader.readAsDataURL(this.files[0]),reader.onloadend=function(){_this.dialogImage.querySelector("#ncsedt-dialog-image .image").src=reader.result,_this.dialogImage.querySelector("#ncsedt-dialog-image .src").value="data:image/..."}})),document.querySelectorAll("#ncsedt-dialog-image button.style-width").forEach((function(element){element.addEventListener("click",(function(evt){_this.dialogImage.querySelector("#ncsedt-dialog-image-width").value=evt.target.value}))})),document.querySelectorAll("#ncsedt-dialog-image button.style-height").forEach((function(element){element.addEventListener("click",(function(evt){_this.dialogImage.querySelector("#ncsedt-dialog-image-height").value=evt.target.value}))})),document.querySelectorAll("#ncsedt-dialog-image button.style-float").forEach((function(element){element.addEventListener("click",(function(evt){_this.dialogImage.querySelector("#ncsedt-dialog-image-float").value=evt.target.value,evt.target.value?_this.dialogImage.querySelector("#ncsedt-dialog-image-padding").value="10px":_this.dialogImage.querySelector("#ncsedt-dialog-image-padding").value=""}))})),document.querySelectorAll("#ncsedt-dialog-image button.style-padding").forEach((function(element){element.addEventListener("click",(function(evt){_this.dialogImage.querySelector("#ncsedt-dialog-image-padding").value=evt.target.value}))}))},ncSimpleHtmlEditor.prototype.editImage=function(){if(this.editEnable){if("IMG"==this.focused.parentElement.tagName&&this.editImageParent(),this.focused.firstElementChild&&this.focused.lastElementChild&&"IMG"==this.focused.firstElementChild.tagName&&"IMG"==this.focused.lastElementChild.tagName&&this.editImageChild(),this.currentSelection=window.getSelection(),this.currentRange=this.currentSelection.getRangeAt(0),this.dialogImage.querySelector("#ncsedt-dialog-image-remove").checked=!1,"IMG"==this.focused.tagName){var style=window.getComputedStyle(this.focused);this.dialogImage.querySelector("#ncsedt-dialog-image-title").innerHTML="Image (Edit)",this.dialogImage.querySelector(".preview img").src=this.focused.src,this.focused.getAttribute("src").startsWith("data:image/")?this.dialogImage.querySelector("#ncsedt-dialog-image-src").value="data:image/...":this.dialogImage.querySelector("#ncsedt-dialog-image-src").value=this.focused.getAttribute("src"),this.dialogImage.querySelector("#ncsedt-dialog-image-alt").value=this.focused.getAttribute("alt"),this.dialogImage.querySelector("#ncsedt-dialog-image-width").value=this.focused.style.width,this.dialogImage.querySelector("#ncsedt-dialog-image-height").value=this.focused.style.height,this.dialogImage.querySelector("#ncsedt-dialog-image-float").value=this.focused.style.float,this.dialogImage.querySelector("#ncsedt-dialog-image-padding").value=this.focused.style.padding,this.dialogImage.querySelector("#ncsedt-dialog-image .image-remove").style.visibility="visible"}else this.dialogImage.querySelector("#ncsedt-dialog-image-title").innerHTML="Image (CREATE)",this.dialogImage.querySelector(".preview img").src=this.options.buttons.image.icon,this.dialogImage.querySelector("#ncsedt-dialog-image-src").value="",this.dialogImage.querySelector("#ncsedt-dialog-image-alt").value="",this.dialogImage.querySelector("#ncsedt-dialog-image-width").value="",this.dialogImage.querySelector("#ncsedt-dialog-image-height").value="",this.dialogImage.querySelector("#ncsedt-dialog-image-float").value="",this.dialogImage.querySelector("#ncsedt-dialog-image-padding").value="",this.dialogImage.querySelector("#ncsedt-dialog-image .image-remove").style.visibility="hidden";this.dialogImage.open||this.dialogImage.showModal()}},ncSimpleHtmlEditor.prototype.editImageConfirm=function(){this.dialogImage.open&&this.dialogImage.close(),this.editEnable&&this.focused.isContentEditable&&("IMG"==this.focused.tagName?this.dialogImage.querySelector("#ncsedt-dialog-image-remove").checked?this.focused.outerHTML=this.focused.innerHTML:this.editImageConfirmExisting():this.editImageConfirmNew())},ncSimpleHtmlEditor.prototype.editImageConfirmExisting=function(){var newsrc=this.dialogImage.querySelector("#ncsedt-dialog-image-src").value,newalt=this.dialogImage.querySelector("#ncsedt-dialog-image-alt").value,newwidth=this.dialogImage.querySelector("#ncsedt-dialog-image-width").value,newheight=this.dialogImage.querySelector("#ncsedt-dialog-image-height").value,newfloat=this.dialogImage.querySelector("#ncsedt-dialog-image-float").value,newpadding=this.dialogImage.querySelector("#ncsedt-dialog-image-padding").value,oldsrc=this.focused.getAttribute("src"),oldalt=this.focused.getAttribute("alt"),oldwidth=this.focused.style.width,oldheight=this.focused.style.height,oldfloat=this.focused.style.float,oldpadding=this.focused.style.padding;newwidth&&!isNaN(newwidth)&&(newwidth+="%"),newheight&&!isNaN(newheight)&&(newheight+="%"),newpadding&&!isNaN(newpadding)&&(newpadding+="px"),oldsrc!=newsrc&&("data:image/..."==newsrc&&(newsrc=this.dialogImage.querySelector("#ncsedt-dialog-image .image").src),this.historyForcePush("src",newsrc),this.focused.setAttribute("src",newsrc)),oldalt!=newalt&&(this.historyForcePush("alt",newalt),this.focused.setAttribute("alt",newalt)),oldwidth!=newwidth&&(this.focused.style.width=newwidth,this.historyForcePush("style",this.focused.style.cssText)),oldheight!=newheight&&(this.focused.style.height=newheight,this.historyForcePush("style",this.focused.style.cssText)),oldfloat!=newfloat&&(this.focused.style.float=newfloat,this.historyForcePush("style",this.focused.style.cssText)),oldpadding!=newpadding&&(this.focused.style.padding=newpadding,this.historyForcePush("style",this.focused.style.cssText))},ncSimpleHtmlEditor.prototype.editImageConfirmNew=function(){var newsrc=this.dialogImage.querySelector("#ncsedt-dialog-image-src").value,newalt=this.dialogImage.querySelector("#ncsedt-dialog-image-alt").value,newwidth=this.dialogImage.querySelector("#ncsedt-dialog-image-width").value,newheight=this.dialogImage.querySelector("#ncsedt-dialog-image-height").value,newfloat=this.dialogImage.querySelector("#ncsedt-dialog-image-float").value,newpadding=this.dialogImage.querySelector("#ncsedt-dialog-image-padding").value;if(isNaN(newwidth)||(newwidth+="%"),isNaN(newheight)||(newheight+="%"),newsrc){"data:image/..."==newsrc&&(newsrc=this.dialogImage.querySelector("#ncsedt-dialog-image .image").src);var newimg=document.createElement("img");newimg.setAttribute("src",newsrc),newimg.setAttribute("alt",newalt),newimg.style.width=newwidth,newimg.style.height=newheight,newimg.style.float=newfloat,newimg.style.padding=newpadding,this.currentRange.surroundContents(newimg)}},ncSimpleHtmlEditor.prototype.editImageParent=function(){this.editEnable&&(this.focused.parentElement&&"IMG"==this.focused.parentElement.tagName&&this.focused.parentElement.isContentEditable?(this.setFocus(this.focused.parentElement),this.editImage()):this.focused.parentElement.parentElement&&this.focused.parentElement.parentElement.querySelector("img")&&this.focused.parentElement.parentElement.isContentEditable?(this.setFocus(this.focused.parentElement.parentElement.querySelector("img")),this.editImage()):this.focused.previousElementSibling&&"IMG"==this.focused.previousElementSibling.tagName&&this.focused.previousElementSibling.isContentEditable&&(this.setFocus(this.focused.previousElementSibling),this.editImage()))},ncSimpleHtmlEditor.prototype.editImagePrev=function(){this.editEnable&&this.focusedPrev&&this.focusedPrev.isContentEditable&&(this.setFocus(this.focusedPrev),this.editImage())},ncSimpleHtmlEditor.prototype.editImageChild=function(){this.editEnable&&(this.focused.querySelector("img")?(this.setFocus(this.focused.querySelector("img")),this.editImage()):this.focused.nextElementSibling&&"IMG"==this.focused.nextElementSibling.tagName&&this.focused.nextElementSibling.isContentEditable&&(this.setFocus(this.focused.nextElementSibling),this.editImage()))},ncSimpleHtmlEditor.prototype.renderDialogLink=function(){var dialogLink='<dialog id="ncsedt-dialog-link" class="ncsedt-dialog"> <div class="ncsedt-btns"> <div class="ncsedt-btns-left"> <button type="button" class="sbutton dragger"><img class="" src="'+this.options.draggerIcon+'" title="Move"> <span id="ncsedt-dialog-link-title">Edit link</span></button> </div> <div class="ncsedt-btns-right"> <button type="button" class="sbutton cancel"> <b>⨯</b> </button> </div> </div> <div class="body"> <label for="ncsedt-dialog-link-anchor">Anchor:</label> <textarea id="ncsedt-dialog-link-anchor" rows="2" class="anchor sbutton" placeholder=" ( empty ) "></textarea> <label for="ncsedt-dialog-link-href">URL:</label> <input id="ncsedt-dialog-link-href" class="href sbutton" type="text"> <label for="ncsedt-dialog-link-target">Open in new:</label> <input id="ncsedt-dialog-link-target" class="target" type="checkbox"> <div class="link-remove" style="float: right"> <label for="ncsedt-dialog-link-remove">Remove link:</label> <input id="ncsedt-dialog-link-remove" class="remove" type="checkbox"> </div> </div> <div class="ncsedt-btns"> <div class="ncsedt-btns-left"> <button type="button" class="sbutton parent">⇑</button> <button type="button" class="sbutton child">⇓</button> <button type="button" class="sbutton code"><img class="" src="'+this.options.buttons.code.icon+'" title="Edit code"></button> <button type="button" class="sbutton image"><img class="" src="'+this.options.buttons.image.icon+'" title="Edit image"></button> </div> <div class="ncsedt-btns-right"> <button type="button" class="sbutton confirm">✓ Ok</button> </div> </div></dialog>';return this.container.insertAdjacentHTML("beforeend",dialogLink),document.getElementById("ncsedt-dialog-link")},ncSimpleHtmlEditor.prototype.setEventsDialogLink=function(){var _this=this;document.querySelector("#ncsedt-dialog-link .cancel").addEventListener("click",(function(){_this.dialogLink.close()})),document.querySelector("#ncsedt-dialog-link .parent").addEventListener("click",(function(){_this.editLinkParent()})),document.querySelector("#ncsedt-dialog-link .child").addEventListener("click",(function(){_this.editLinkChild()})),document.querySelector("#ncsedt-dialog-link .confirm").addEventListener("click",(function(){_this.editLinkConfirm()})),document.querySelector("#ncsedt-dialog-link .code").addEventListener("click",(function(){_this.dialogLink.open&&_this.dialogLink.close(),_this.command(_this.options.buttons.code)})),document.querySelector("#ncsedt-dialog-link .image").addEventListener("click",(function(){_this.dialogLink.open&&_this.dialogLink.close(),_this.command(_this.options.buttons.image)}))},ncSimpleHtmlEditor.prototype.editLink=function(){if(this.editEnable){if(this.currentSelection=window.getSelection(),this.currentRange=this.currentSelection.getRangeAt(0),"A"==this.focused.parentElement.tagName&&this.editLinkParent(),this.focused.firstElementChild&&this.focused.lastElementChild&&("A"!=this.focused.firstElementChild.tagName||"A"!=this.focused.lastElementChild.tagName||this.currentSelection.toString()||this.editLinkChild()),"IMG"==this.focused.tagName||this.focused.firstElementChild&&"IMG"==this.focused.firstElementChild.tagName?this.dialogLink.querySelector("#ncsedt-dialog-link .image").style.visibility="visible":this.dialogLink.querySelector("#ncsedt-dialog-link .image").style.visibility="hidden","A"==this.focused.tagName)this.dialogLink.querySelector("#ncsedt-dialog-link-title").innerHTML="Link (Edit)",this.dialogLink.querySelector("#ncsedt-dialog-link-anchor").value=this.focused.innerHTML,this.dialogLink.querySelector("#ncsedt-dialog-link-href").value=this.focused.getAttribute("href"),this.dialogLink.querySelector("#ncsedt-dialog-link-remove").checked=!1,this.dialogLink.querySelector("#ncsedt-dialog-link .link-remove").style.visibility="visible","_blank"==this.focused.getAttribute("target")?this.dialogLink.querySelector("#ncsedt-dialog-link-target").checked=!0:this.dialogLink.querySelector("#ncsedt-dialog-link-target").checked=!1;else{if(this.currentSelection.anchorNode.nodeType==Node.TEXT_NODE&&this.currentSelection.toString())var anchor=this.currentSelection;else var anchor=this.focused.innerHTML||this.focused.outerHTML;this.dialogLink.querySelector("#ncsedt-dialog-link-title").innerHTML="Link (CREATE)",this.dialogLink.querySelector(".anchor").value=anchor,this.dialogLink.querySelector(".href").value="",this.dialogLink.querySelector("#ncsedt-dialog-link-target").checked=!1,this.dialogLink.querySelector("#ncsedt-dialog-link-remove").checked=!1,this.dialogLink.querySelector("#ncsedt-dialog-link .link-remove").style.visibility="hidden"}this.dialogLink.open||this.dialogLink.showModal()}},ncSimpleHtmlEditor.prototype.editLinkConfirm=function(){this.dialogLink.open&&this.dialogLink.close(),this.editEnable&&this.focused.isContentEditable&&("A"==this.focused.tagName?this.dialogLink.querySelector("#ncsedt-dialog-link-remove").checked?this.focused.outerHTML=this.focused.innerHTML:this.editLinkConfirmExisting():this.editLinkConfirmNew())},ncSimpleHtmlEditor.prototype.editLinkConfirmExisting=function(){var newtarget=this.dialogLink.querySelector("#ncsedt-dialog-link-target").checked?"_blank":"",newanchor=this.dialogLink.querySelector("#ncsedt-dialog-link-anchor").value,newurl=this.dialogLink.querySelector("#ncsedt-dialog-link-href").value,oldtarget=this.focused.getAttribute("target"),oldanchor=this.focused.innerHTML,oldurl=this.focused.getAttribute("href");oldtarget==newtarget&&oldanchor==newanchor&&oldurl==newurl||(this.historyForcePush("href",newurl),this.historyForcePush("target",newtarget),this.focused.innerHTML=newanchor,this.focused.setAttribute("href",newurl),this.focused.setAttribute("target",newtarget))},ncSimpleHtmlEditor.prototype.editLinkConfirmNew=function(){var newtarget=this.dialogLink.querySelector("#ncsedt-dialog-link-target").checked?"_blank":"",newanchor=this.dialogLink.querySelector("#ncsedt-dialog-link-anchor").value,newurl=this.dialogLink.querySelector("#ncsedt-dialog-link-href").value;if(newanchor.length||newurl.length){var newlink=document.createElement("a");newlink.setAttribute("href",newurl),newlink.setAttribute("target",newtarget),this.focused.contains(this.currentRange.commonAncestorContainer)?(this.currentRange.surroundContents(newlink),newlink.innerHTML=newanchor):(newlink.innerHTML=newanchor,this.focused.outerHTML=newlink.outerHTML)}},ncSimpleHtmlEditor.prototype.editLinkParent=function(){this.editEnable&&this.focused.parentElement&&this.focused.parentElement.isContentEditable&&(this.setFocus(this.focused.parentElement),this.editLink())},ncSimpleHtmlEditor.prototype.editLinkPrev=function(){this.editEnable&&this.focusedPrev&&this.focusedPrev.isContentEditable&&(this.setFocus(this.focusedPrev),this.editLink())},ncSimpleHtmlEditor.prototype.editLinkChild=function(){this.editEnable&&this.focused.firstElementChild&&this.focused.firstElementChild.isContentEditable&&(this.setFocus(this.focused.firstElementChild),this.editLink())},ncSimpleHtmlEditor.prototype.renderDialogHead=function(){var dialogHead='<dialog id="ncsedt-dialog-head" class="ncsedt-dialog"> <div class="ncsedt-btns"> <div class="ncsedt-btns-left"> <button type="button" class="sbutton dragger"><img class="" src="'+this.options.draggerIcon+'" title="Move"> <span id="ncsedt-dialog-title">Edit head</span></button> </div> <div class="ncsedt-btns-right"> <button type="button" class="sbutton cancel"> <b>⨯</b> </button> </div> </div> <div class="body"> <label for="ncsedt-dialog-head-title">Title:</label> <input id="ncsedt-dialog-head-title" class="title sbutton" type="text"> <div class="separator"></div> <label for="ncsedt-dialog-head-description">Description:</label> <textarea id="ncsedt-dialog-head-description" rows="3" class="description sbutton" placeholder=" ( empty ) "></textarea> <div class="separator"></div> <div class="edit-all" style="display: none"> <label for="ncsedt-dialog-head-all">Edit source code:</label> <textarea id="ncsedt-dialog-head-all" rows="3" class="all sbutton" placeholder=" ( empty ) "></textarea> </div> </div> <div class="ncsedt-btns"> <div class="ncsedt-btns-left"> <button type="button" class="sbutton show-all"><img class="" src="'+this.options.buttons.code.icon+'" title="Edit code"> Edit all</button> </div> <div class="ncsedt-btns-right"> <button type="button" class="sbutton confirm">✓ Ok</button> </div> </div></dialog>';return this.container.insertAdjacentHTML("beforeend",dialogHead),document.getElementById("ncsedt-dialog-head")},ncSimpleHtmlEditor.prototype.setEventsDialogHead=function(){var _this=this;document.querySelector("#ncsedt-dialog-head .cancel").addEventListener("click",(function(){_this.dialogHead.close()})),document.querySelector("#ncsedt-dialog-head .show-all").addEventListener("click",(function(){"none"==_this.dialogHead.querySelector("#ncsedt-dialog-head .edit-all").style.display?_this.dialogHead.querySelector("#ncsedt-dialog-head .edit-all").style.display="inline-block":_this.dialogHead.querySelector("#ncsedt-dialog-head .edit-all").style.display="none"})),document.querySelector("#ncsedt-dialog-head .confirm").addEventListener("click",(function(){_this.editHeadConfirm()}))},ncSimpleHtmlEditor.prototype.editHead=function(){if(this.editEnable){if(document.head.querySelector('meta[name="description"]'))var description=document.head.querySelector('meta[name="description"]').getAttribute("content");else var description="";this.dialogHead.querySelector("#ncsedt-dialog-head-title").value=document.title||"pedo",this.dialogHead.querySelector("#ncsedt-dialog-head-description").value=description,this.dialogHead.querySelector("#ncsedt-dialog-head-all").value=document.head.innerHTML,this.dialogHead.open||this.dialogHead.showModal()}},ncSimpleHtmlEditor.prototype.editHeadConfirm=function(){if(this.dialogHead.open&&this.dialogHead.close(),this.editEnable){if(document.head.querySelector('meta[name="description"]'))var description=document.head.querySelector('meta[name="description"]').getAttribute("content");else var description="";var newtitle=this.dialogHead.querySelector("#ncsedt-dialog-head-title").value,newdescription=this.dialogHead.querySelector("#ncsedt-dialog-head-description").value,newhead=this.dialogHead.querySelector("#ncsedt-dialog-head-all").value,oldtitle=document.title,oldescription=description,oldhead;if(newhead!=document.head.innerHTML&&(document.head.innerHTML=newhead),newtitle!=oldtitle&&(document.title=newtitle),newdescription!=oldescription){if(!document.head.querySelector('meta[name="description"]')){var meta=document.createElement("meta");meta.setAttribute("name","description"),document.head.appendChild(meta)}this.historyForcePush("content",newdescription),document.head.querySelector('meta[name="description"]').setAttribute("content",newdescription)}}},window.ncSimpleMoveable=function(movableSelector,draggerSelector){var supports;this.movable=document.querySelector(movableSelector),this.dragger=document.querySelector(draggerSelector),"ontouchstart"in document.createElement("div")?this.movableOnTouch():this.movableOnDrag()},ncSimpleMoveable.prototype.movableOnDrag=function(){var _this=this,pos1=0,pos2=0,pos3=0,pos4=0;function dragMouseDown(e){(e=e||window.event).preventDefault();var style=window.getComputedStyle(_this.movable),marginTop=parseInt(style.getPropertyValue("margin-top")),marginLeft=parseInt(style.getPropertyValue("margin-left"));_this.movable.style.margin="0px",_this.movable.style.top=_this.movable.offsetTop+marginTop+"px",_this.movable.style.left=_this.movable.offsetLeft+marginLeft+"px",pos3=e.clientX,pos4=e.clientY,document.onmouseup=closeDragElement,document.onmousemove=elementDrag}function elementDrag(e){(e=e||window.event).preventDefault(),pos1=pos3-e.clientX,pos2=pos4-e.clientY,pos3=e.clientX,pos4=e.clientY,_this.movable.style.top=_this.movable.offsetTop-pos2+"px",_this.movable.style.left=_this.movable.offsetLeft-pos1+"px"}function closeDragElement(){document.onmouseup=null,document.onmousemove=null;var xDraggerOffset=_this.dragger.offsetLeft,xOffset=_this.movable.offsetLeft+xDraggerOffset,yDraggerOffset=_this.dragger.offsetTop,yOffset=_this.movable.offsetTop+yDraggerOffset,xMax=window.innerWidth-_this.dragger.offsetWidth,yMax=window.innerHeight-_this.dragger.offsetHeight,xMIn=0,yMin=0;yOffset>yMax&&(_this.movable.style.top=yMax-yDraggerOffset+"px"),yOffset<0&&(_this.movable.style.top=0-yDraggerOffset+"px"),xOffset>xMax&&(_this.movable.style.left=xMax-xDraggerOffset+"px"),xOffset<0&&(_this.movable.style.left=0-xDraggerOffset+"px")}this.movable.style.position="fixed",this.dragger.onmousedown=dragMouseDown},ncSimpleMoveable.prototype.movableOnTouch=function(){var _this=this;this.movable.style.position="fixed",this.dragger.addEventListener("touchmove",(function(e){e.preventDefault();var xOffset=_this.dragger.offsetLeft+Math.round(_this.dragger.offsetWidth/2),yOffset=_this.dragger.offsetTop+Math.round(_this.dragger.offsetHeight/2);_this.movable.style.margin="0px";var touchLocation=e.targetTouches[0];_this.movable.style.left=touchLocation.pageX-xOffset+"px",_this.movable.style.top=touchLocation.pageY-window.pageYOffset-yOffset+"px"})),this.movable.addEventListener("touchend",(function(e){var xDraggerOffset=_this.dragger.offsetLeft,xOffset=_this.movable.offsetLeft+xDraggerOffset,yDraggerOffset=_this.dragger.offsetTop,yOffset=_this.movable.offsetTop+yDraggerOffset,xMax=window.innerWidth-_this.dragger.offsetWidth,yMax=window.innerHeight-_this.dragger.offsetHeight,xMIn=0,yMin=0;yOffset>yMax&&(_this.movable.style.top=yMax-yDraggerOffset+"px"),yOffset<0&&(_this.movable.style.top=0-yDraggerOffset+"px"),xOffset>xMax&&(_this.movable.style.left=xMax-xDraggerOffset+"px"),xOffset<0&&(_this.movable.style.left=0-xDraggerOffset+"px")}))},document.currentScript.dataset.ncsheditorauto&&window.addEventListener("DOMContentLoaded",(function(){"ncSHEditor"in window||(ncSHEditor=new ncSimpleHtmlEditor,ncSHEditor.start())}));