diff --git a/app_doc/util_upload_img.py b/app_doc/util_upload_img.py index a405442..9372d81 100644 --- a/app_doc/util_upload_img.py +++ b/app_doc/util_upload_img.py @@ -23,11 +23,11 @@ def upload_ice_img(request): # formData.append('upload_type', "files"); ################## try: - up_type = request.POST.get('upload_type') - up_num = request.POST.get('upload_num') + up_type = request.POST.get('upload_type','') + up_num = request.POST.get('upload_num','') + iceEditor_img = str(request.POST.get('iceEditor-img','')) except: - up_num = -1 - + pass if up_type == "files": # 多文件上传功能,需要修改js文件 res_dic = {'length':int(up_num)} @@ -35,11 +35,13 @@ def upload_ice_img(request): file_obj = request.FILES.get('file_' + str(i)) result = ice_save_file(file_obj,request.user) res_dic[i] = result + elif iceEditor_img.lower().startswith('http'): + res_dic = ice_url_img_upload(iceEditor_img,request.user) else: # 粘贴上传和单文件上传 file_obj = request.FILES.get('file[]') result = ice_save_file(file_obj,request.user) - res_dic = {0:result,"length":1} #一个文件,直接把文件数量固定了 + res_dic = {0:result,"length":1,'other_msg':iceEditor_img} #一个文件,直接把文件数量固定了 return HttpResponse(json.dumps(res_dic), content_type="application/json") def ice_save_file(file_obj,user): @@ -88,7 +90,35 @@ def ice_save_file(file_obj,user): return {"error":0, "name": str(file_obj),'url':file_url} return {"error": "文件存储异常"} +# ice_url图片上传 +def ice_url_img_upload(url,user): + relative_path = upload_generation_dir() + name_time = time.strftime("%Y-%m-%d_%H%M%S_") + name_join = "" + name_rand = name_join.join(random.sample('zyxwvutsrqponmlkjihgfedcba',10) ) + file_name = name_time + name_rand + '.png' # 日期时间_随机字符串命名 + path_file = os.path.join(relative_path, file_name) + path_file = settings.MEDIA_ROOT + path_file + # print('文件路径:', path_file) + file_url = settings.MEDIA_URL + relative_path + file_name + # print("文件URL:", file_url) + header = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36" + } + r = requests.get(url, headers=header, stream=True) + + if r.status_code == 200: + with open(path_file, 'wb') as f: + f.write(r.content) # 保存文件 + Image.objects.create( + user=user, + file_path=file_url, + file_name=file_name, + remark='iceurl粘贴上传', + ) + resp_data = {"error":0, "name": file_name,'url':file_url} + return resp_data diff --git a/static/iceEditor/src/iceEditor.js b/static/iceEditor/src/iceEditor.js index f4f9eba..897fac3 100644 --- a/static/iceEditor/src/iceEditor.js +++ b/static/iceEditor/src/iceEditor.js @@ -6,7 +6,7 @@ * MIT License By www.iceui.net + 作者:ice + 官方:www.iceui.net - + 时间:2020-11-20 + + 时间:2020-12-17 +------------------------------------------------------------------------------------+ + 版权声明:该版权完全归iceUI官方所有,可转载使用和学习,但请务必保留版权信息 +------------------------------------------------------------------------------------+ @@ -27,6 +27,8 @@ 'subscript','createLink','unlink','line','hr','face','table','files','music','video','insertImage', 'removeFormat','paste','line','code' ]; + // 不需要的工具栏菜单 + this.notMenu=[]; // 文字背景颜色 this.backColor = [ '#ffffff','#000000','#eeece1','#1f497d','#4f81bd','#c0504d','#9bbb59','#8064a2','#4bacc6','#f79646', @@ -855,7 +857,7 @@ ice.editor.prototype.menuHTML=function(){ } }); //添加视频 - this.createMenu({title:'添加视频',name:'video',icon:'video',id:this.videoId,popup:{width:320,height:170,title:'添加视频',content:'
URL:
确定
'}, + this.createMenu({title:'添加视频',name:'video',icon:'video',id:this.videoId,popup:{width:320,height:170,title:'添加视频',content:'
URL:
确定
'}, success:function(e,z){ z.video = z.id(z.videoId); var type; @@ -866,40 +868,24 @@ ice.editor.prototype.menuHTML=function(){ var btn = z.video.getElementsByClassName('iceEditor-btn')[0]; btn.onclick=function(){ if(!url.value.length) return alert('视频地址不能为空'); - var obj = z.video.getElementsByTagName('input'); - //获取单选按钮的值 - for(var i=0;i1){ - id = id[0].split('video/'); - if(id.length>1 && id[1].length){ - v.src='https://player.bilibili.com/player.html?bvid='+id[1]; - }else{ - return alert('b站'+error); - } - }else{ - return alert('b站'+error); + var v = z.c('iframe'); + v.width=width.value.length?width.value:510; + v.height=height.value.length?height.value:498; + v.setAttribute('frameborder',0); + v.setAttribute('allowfullscreen',true); + var error = '抱歉,无法处理该链接!'; + var domain = /^http(s)?:\/\/(.*?)\//.exec(url.value) // 正则出域名 + if (domain.length == 3) { + if (domain[2] == 'www.bilibili.com' || domain[2] == 'bilibili.com' ) { // bilibili + //源地址:https://www.bilibili.com/video/BV1UZ4y1g7De?spm_id_from=333.851.b_7265706f7274466972737431.11 + //处理地址:https://player.bilibili.com/player.html?bvid=BV1UZ4y1g7De + id = /video\/(.*?)\?/g.exec(url.value) + if (!id) { + id = /video\/(.*)/g.exec(url.value) } - }else if(type === 3){ //优酷 - //源地址:https://v.youku.com/v_show/id_XMjM0ODA3NjIw.html + v.src='https://player.bilibili.com/player.html?bvid='+id[1]; + } else if (domain[2] == 'v.youku.com') { // youku + //源地址:https://v.youku.com/v_show/id_XNTAwOTI4MzUxNg==.html //处理地址:https://player.youku.com/embed/XMjM0ODA3NjIw var id = url.value.split('.html'); if(id.length>1){ @@ -909,10 +895,21 @@ ice.editor.prototype.menuHTML=function(){ }else{ return alert('优酷:'+error); } - }else{ + } else { return alert('优酷:'+error); } + } else if (domain[2] == 'www.ixigua.com') { //西瓜视频 + id = /[0-9]{6,}/g.exec(url.value) + v.src='https://www.ixigua.com/iframe/'+id[0]; + } else { + v = z.c('video'); + v.src=url.value; + v.width=width.value.length?width.value:510; + v.height=height.value.length?height.value:498; + v.controls='controls'; } + } else { + return alert('URL地址不合法!'); } z.setHTML(v,true); close.style.display='none'; @@ -943,9 +940,11 @@ ice.editor.prototype.menuFormat=function() { ul.appendChild(line); continue; } - ul.appendChild(this.menuList[this.menu[i]]); - if(this.menuList[this.menu[i]].success){ - this.menuList[this.menu[i]].success(this.menuList[this.menu[i]],_z); + if (this.notMenu.indexOf(this.menu[i]) == -1) { + ul.appendChild(this.menuList[this.menu[i]]); + if(this.menuList[this.menu[i]].success){ + this.menuList[this.menu[i]].success(this.menuList[this.menu[i]],_z); + } } } if(this.maxWindow){ diff --git a/static/iceEditor/src/iceEditor.min.js b/static/iceEditor/src/iceEditor.min.js index b2a2500..3c6ef0b 100644 --- a/static/iceEditor/src/iceEditor.min.js +++ b/static/iceEditor/src/iceEditor.min.js @@ -6,7 +6,7 @@ * MIT License By www.iceui.net + 作者:ice + 官方:www.iceui.net - + 时间:2020-11-20 + + 时间:2020-12-20 +------------------------------------------------------------------------------------+ + 版权声明:该版权完全归iceUI官方所有,可转载使用和学习,但请务必保留版权信息 +------------------------------------------------------------------------------------+ @@ -15,6 +15,6 @@ + css……等文件,因为整个编辑器只是一个Js,支持上传图片、附件!支持添加音乐、视频! +------------------------------------------------------------------------------------+ */ -"use strict";var ice=ice||{};ice.editor=function(e){this.menu=["backColor","fontSize","foreColor","bold","italic","underline","strikeThrough","line","justifyLeft","justifyCenter","justifyRight","indent","outdent","line","insertOrderedList","insertUnorderedList","line","superscript","subscript","createLink","unlink","line","hr","face","table","files","music","video","insertImage","removeFormat","paste","line","code"],this.backColor=["#ffffff","#000000","#eeece1","#1f497d","#4f81bd","#c0504d","#9bbb59","#8064a2","#4bacc6","#f79646","#f2f2f2","#979797","#ddd9c3","#c6d9f0","#dbe5f1","#f2dcdb","#ebf1dd","#e5e0ec","#dbeef3","#fdeada","#d8d8d8","#595959","#c4bd97","#8db3e2","#b8cce4","#e5b9b7","#d7e3bc","#ccc1d9","#b7dde8","#fbd5b5","#bfbfbf","#3f3f3f","#938953","#548dd4","#95b3d7","#d99694","#c3d69b","#b2a2c7","#92cddc","#fac08f","#a5a5a5","#262626","#494429","#17365d","#366092","#953734","#76923c","#5f497a","#31859b","#e36c09","#7f7f7f","#0c0c0c","#1d1b10","#0f243e","#244061","#632423","#4f6128","#3f3151","#205867","#974806","#c00000","#ff0000","#ffc000","#ffff00","#92d050","#00b050","#00b0f0","#0070c0","#002060","#7030a0"],this.foreColor=this.backColor,this.width="100%",this.height="400px",this.code=0,this.maxWindow=1,this.disabled=0,this.css="",this.uploadUrl=0,this.pasteText=1,this.screenshot=1,this.screenshotUpload=1,this.imgAutoUpload=1,this.imgDomain=0,this.ajax.uploadTimeout=15e3,this.ajax.xhr=function(){},this.ajax.timeout=function(){},this.ajax.progress=function(){},this.ajax.success=function(){},this.ajax.error=function(){},this.ajax.complete=function(){},this.filesUpload={},this.filesUpload.success=function(){},this.filesUpload.error=function(){},this.filesUpload.complete=function(){},this.imgUpload={},this.imgUpload.success=function(){},this.imgUpload.error=function(){},this.imgUpload.complete=function(){},this.face=[{title:"文字",type:"text",list:[{title:"开心",content:"(^_^)"},{title:"受不了",content:"(>_<)"},{title:"鄙视",content:"(¬、¬)"},{title:"难过",content:"(*>﹏<*)"},{title:"可爱",content:"(。◕‿◕。)"},{title:"无奈",content:"╮(╯_╰)╭"},{title:"惊喜",content:"╰(*°▽°*)╯"},{title:"听音乐",content:"♪(^∇^*)"},{title:"害羞",content:"(✿◡‿◡)"},{title:"睡啦",content:"(∪。∪)..zzZ"},{title:"臭美",content:"(o≖◡≖)"},{title:"流汗",content:"(ーー゛)"}]}],this.filterTag=["meta","script","object","form","iframe"],this.filterStyle=["background-image"],this.blockTag=["address","caption","dd","div","dl","dt","fieldset","h1","h2","h3","h4","h5","h6","legend","fieldset","li","noframes","noscript","ol","ul","p","pre","table","tbody","tfoot","th","thead","tr","video"],this.getTime="1"+String((new Date).getTime()).substr(4,8),this.iframeId="_iframe"+this.getTime,this.toolId="_tool"+this.getTime,this.linkId="_link"+this.getTime,this.linkInputId="_LinkInput"+this.getTime,this.musicId="_music"+this.getTime,this.musicInputId="_musicInput"+this.getTime,this.videoId="_video"+this.getTime,this.imageId="_image"+this.getTime,this.imgUploadId="_imgUpload"+this.getTime,this.filesId="_files"+this.getTime,this.filesUploadId="_filesUpload"+this.getTime,this.tableId="_table"+this.getTime,this.dragId="_drag"+this.getTime,this.menuList={};var t=this;if(this.editor=this.id(e),!this.editor)return alert("请提供一个有效的id");if(this.textarea=0,"TEXTAREA"!==this.editor.nodeName&&"DIV"!==this.editor.nodeName)return console.log("iceEditor:暂不支持该标签「"+this.editor.nodeName+"」,推荐使用div或textarea");if("TEXTAREA"==this.editor.nodeName){this.editor.style.display="none",this.divId="_div"+this.getTime;var i=this.c("div");i.className="iceEditor",i.id=this.divId,this.insertAfter(i,this.editor),this.textarea=this.editor,this.editor=this.id(this.divId),this.value=this.textarea.value}else this.editor.className="iceEditor",this.value=this.editor.innerHTML,this.editor.innerHTML="";this.cssConfig=this.c("style"),this.cssConfig.type="text/css",this.editor.appendChild(this.cssConfig),this.tool=this.c("div"),this.tool.id=this.toolId,this.tool.className="iceEditor-tool iceEditor-noselect",this.editor.appendChild(this.tool),this.iframe=this.c("iframe"),this.iframe.id=this.iframeId,this.iframe.className="iceEditor-noselect",this.iframe.frameBorder=0,this.editor.appendChild(this.iframe),this.dragBg=this.c("div"),this.dragBg.className="iceEditor-dragBg",this.editor.appendChild(this.dragBg),this.drag=this.c("div"),this.drag.id=this.dragId,this.drag.className="iceEditor-drag iceEditor-noselect",this.drag.innerHTML='',this.editor.appendChild(this.drag),this.drag.onmousedown=function(){t.dragBg.style.display="block";var e=event.clientY,i=t.iframe.clientHeight;window.onmousemove=function(){var o=event.clientY-e;i>=100?(t.iframe.height=i+o+"px",t.height=i+o+"px"):(t.iframe.height="100px",t.height=i+o+"px")},window.onmouseup=function(){window.onmousemove=null,window.onmouseup=null,t.dragBg.style.display="none"}},this.disableds=this.c("div"),this.disableds.className="iceEditor-disabled",this.editor.appendChild(this.disableds),this.w=this.iframe.contentWindow,this.d=this.iframe.contentDocument,this.d.open();var o=this.value.trim();o.length&&"

"==o.substr(0,3)||(o="

"+this.value+"

"),this.d.write(''+o+""),this.d.close(),this.d.body.designMode="on",this.d.body.contentEditable=!0,this.d.body.addEventListener("click",function(){t.parentTagName=t.range.anchorNode.parentNode.tagName;for(var e=0;e/g,"\n");t.textarea.innerHTML=t.unhtml(i.innerHTML)},1e3),this.init(),this.create(),this.paste()},ice.editor.prototype={id:function(e){return document.getElementById(e)},c:function(e){return document.createElement(e)},init:function(){this.files=null,this.insertImage=null,this.element=this.d.body,this.range=this.d.createRange?this.w.getSelection():this.d.selection.createRange()},insertAfter:function(e,t){var i=t.parentNode;i.lastChild==t?i.appendChild(e,t):i.insertBefore(e,t.nextSibling)},setHTML:function(e,t){this.element.focus();var i=this.range.getRangeAt(0);t||e.appendChild(i.extractContents()),i.deleteContents(),i.insertNode(this.w.document.createDocumentFragment().appendChild(e)),i.collapse(!1)},setText:function(e,t){this.element.focus();var i=this.range.getRangeAt(0);i.deleteContents();var o=document.createElement("div");t?o.innerHTML=e:o.appendChild(document.createTextNode(e));for(var n,a,l=document.createDocumentFragment();n=o.firstChild;)a=l.appendChild(n);i.insertNode(l),a&&(i=i.cloneRange(),i.setStartAfter(a),i.collapse(!0),this.range.removeAllRanges(),this.range.addRange(i)),i.collapse(!0)},getSelectHTML:function(){var e=this.c("p");return e.appendChild(this.range.getRangeAt(0).cloneContents()),e.innerHTML},getSelectText:function(){return"false"==this.range.toString()||""==this.range.toString()?"":this.range.toString()},unhtml:function(e){var t="";return 0==e.length?"":(t=e.replace(/&/g,"&"),t=t.replace(//g,">"),t=t.replace(/\'/g,"'"),t=t.replace(/\"/g,"""))},html:function(e){var t="";return 0==e.length?"":(t=e.replace(/</g,"<"),t=t.replace(/>/g,">"),t=t.replace(/'/g,"'"),t=t.replace(/"/g,'"'),t=t.replace(/&/g,"&"))},toText:function(e){var t=this.c("div");null!=t.textContent?t.textContent=e:t.innerText=e;var i=t.innerHTML;return t=null,i},toHTML:function(e){var t=this.c("div");t.innerHTML=e;var i=t.innerText||t.textContent;return t=null,i},inNodeParent:function(e,t){return!!e&&(!!e.parentNode&&("string"==typeof t?(t=t.toUpperCase(),e.tagName==t||(e.parentNode.tagName==t||this.inNodeParent(e.parentNode,t))):e.parentNode==t||this.inNodeParent(e.parentNode,t)))},inArray:function(e,t){if("string"==typeof e||"number"==typeof e){for(var i in t)if(e===t[i])return!0;return!1}},getRange:function(){return this.range.getRangeAt(0)},popup:function(e){return e=e||{},'
'+(e.title||"")+'
'+(e.content||"")+"
"},getCoords:function(e){var t=e.getBoundingClientRect(),i=e.ownerDocument,o=i.body,n=i.documentElement,a=n.clientTop||o.clientTop||0,l=n.clientLeft||o.clientLeft||0;return{top:t.top-a,left:t.left-l}},pd:function(t){window.event?window.event.cancelBubble=!0:e.stopPropagation()},isIE:function(){return!!window.ActiveXObject||"ActiveXObject"in window},ajax:function(e){function t(e){var t=0;t=e.lengthComputable?Math.round(e.loaded/e.total*100):0,i.ajax.progress(t,e,o)}var i=this;if(e=e||{},e.url){e.timeout=e.timeout||i.ajax.uploadTimeout,e.data=e.data||{};var o=new XMLHttpRequest;o.addEventListener("progress",t,!1),o.open("POST",e.url,!0),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),e.data instanceof FormData==0&&o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),i.ajax.xhr(o),o.send(e.data instanceof FormData?e.data:function(e){var t=[];for(var i in e)t.push(i+"="+encodeURIComponent(e[i]));return t.join("&")}(e.data)),e.loading&&e.loading(),e.timer=setTimeout(function(){o.onreadystatechange=null,i.ajax.timeout(o),e.error&&e.error("网络超时。")},e.timeout),o.onreadystatechange=function(){if(4===o.readyState&&200===o.status)if(clearTimeout(e.timer),o.status>=200&&o.status<300||304==o.status){var t="";o.responseText.length>0&&(t=JSON.parse(o.responseText)),i.ajax.success(t,o),i.ajax.complete(t,o),e.success&&e.success(t)}else i.ajax.error(o),i.ajax.complete(o),e.error&&e.error(o);else i.ajax.error(o),i.ajax.complete(o)}}},createMenu:function(e){var t=this,i=this.c("li");if(e.id&&(i.id=e.id),e.css&&(i.className=e.css),e.style&&(this.css+=e.style),e.menu||e.icon){var o=this.c("div");e.title&&(o.title=e.title),o.className="iceEditor-exec",e.menu?o.innerHTML=e.menu:e.icon&&(o.innerHTML=''),e.data&&o.setAttribute("data",e.data),i.appendChild(o)}if(e.dropdown){var o=this.c("div");o.className="iceEditor-menuDropdown",o.innerHTML=e.dropdown,i.appendChild(o),i.openMenu=1,i.onmouseover=function(){i.openMenu&&(o.className="iceEditor-menuDropdown iceEditor-menuActive")},i.onmouseout=function(){o.className="iceEditor-menuDropdown"};for(var n=o.getElementsByClassName("iceEditor-exec"),a=0;a
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 文字大小
  • '});for(var e='
      ',t=0;t';e+='
    • 文字背景颜色
    ',this.createMenu({title:"文字背景颜色",name:"backColor",icon:"backColor",dropdown:e});for(var e='
      ',t=0;t';e+='
    • 文字颜色
    ',this.createMenu({title:"文字颜色",name:"foreColor",icon:"foreColor",dropdown:e}),this.createMenu({title:"加粗",name:"bold",data:"bold",icon:"bold"}),this.createMenu({title:"倾斜",name:"italic",data:"italic",icon:"italic"}),this.createMenu({title:"下划线",name:"underline",data:"underline",icon:"underline"}),this.createMenu({title:"删除线",name:"strikeThrough",data:"strikeThrough",icon:"strike"}),this.createMenu({title:"左对齐",name:"justifyLeft",data:"justifyLeft",icon:"alignleft"}),this.createMenu({title:"居中对齐",name:"justifyCenter",data:"justifyCenter",icon:"aligncenter"}),this.createMenu({title:"右对齐",name:"justifyRight",data:"justifyRight",icon:"alignright"}),this.createMenu({title:"缩进",name:"indent",data:"indent",icon:"indent"}),this.createMenu({title:"取消缩进",name:"outdent",data:"outdent",icon:"outdent"}),this.createMenu({title:"有序列表",name:"insertOrderedList",data:"insertOrderedList",icon:"orderedlist"}),this.createMenu({title:"无序列表",name:"insertUnorderedList",data:"insertUnorderedList",icon:"unorderedlist"}),this.createMenu({title:"下标",name:"subscript",data:"subscript",icon:"subscript"}),this.createMenu({title:"上标",name:"superscript",data:"superscript",icon:"superscript"}),this.createMenu({title:"取消连接",name:"unlink",data:"unlink",icon:"unlink"}),this.createMenu({title:"添加水平线",name:"hr",data:"insertHorizontalRule",icon:"min"}),this.createMenu({title:"清除格式",name:"removeFormat",data:"removeFormat",icon:"remove"}),this.createMenu({title:"富文本粘贴",name:"paste",icon:"word",success:function(e,t){t.pasteText||(e.className="iceEditor-active-s"),e.onclick=function(){t.pasteText=!t.pasteText,e.className=t.pasteText?"":"iceEditor-active-s"}}}),this.createMenu({title:"全选",name:"selectAll",data:"selectAll",icon:"empty"}),this.createMenu({title:"查看源码",name:"code",icon:"code",data:"code"});for(var e='
    ',t=0;t"+this.face[t].title+"";e+='
    ';for(var t=0;t';for(var i=0;i':e+=''+this.face[t].list[i].content+"";e+="
    "}e+="
    ",this.createMenu({title:"插入表情",name:"face",icon:"face",dropdown:e,success:function(e,t){for(var i=e.getElementsByClassName("iceEditor-faceTitle")[0],o=i.getElementsByTagName("span"),n=e.getElementsByClassName("iceEditor-faceMain")[0],a=e.getElementsByClassName("iceEditor-faceList"),l=n.getElementsByTagName("span"),r=0;r
  • 表格:1×1
  • ',success:function(e,t){t.table=t.id(t.tableId);var i=t.table.getElementsByClassName("iceEditor-tableBox")[0],o=t.table.getElementsByClassName("iceEditor-tableBgOn")[0],n=t.table.getElementsByClassName("iceEditor-tableNum")[0];i.onmouseover=function(e){var i=t.getCoords(this),a=1,l=1;this.onmousemove=function(e){var t=e||event,r=t.clientX-i.left-5,s=t.clientY-i.top-5;r<=180&&s<=180&&(a=Math.ceil(r/18),l=Math.ceil(s/18),o.style.width=18*a+"px",o.style.height=18*l+"px",n.innerHTML="表格:"+a+"×"+l)},this.onmousedown=function(){var e=t.c("table");e.width="100%",e.border=1,e.style.border="1px solid #bdbdbd",e.style.borderSpacing=0,e.style.borderCollapse="collapse",e.className="table table-border";for(var i=0;i"}t.setHTML(e,!0)},this.onmouseout=function(){this.onmousemove=null,this.onmouseout=null}}}}),this.createMenu({title:"添加链接",name:"createLink",icon:"link",id:this.linkId,popup:{width:320,height:110,title:"添加链接",content:''},success:function(e,t){t.link=t.id(t.linkId),t.linkInput=t.id(t.linkInputId),t.link.getElementsByClassName("iceEditor-btn")[0].onclick=function(){var e=t.getSelectHTML().replace(/]+>/gi,"").replace(/<\s*\/a\s*>/gi,""),i=t.c("a");t.link.getElementsByTagName("input")[1].checked&&(i.target="_blank"),i.href=t.linkInput.value,i.innerHTML=e,t.setHTML(i,!0),t.link.getElementsByClassName("iceEditor-popup")[0].style.display="none",t.pd()}}}),this.createMenu({title:"添加音乐",name:"music",icon:"music",id:this.musicId,popup:{width:320,height:80,title:"添加音乐",content:'
    确定
    '},success:function(e,t){t.music=t.id(t.musicId),t.musicInput=t.id(t.musicInputId),t.music.getElementsByClassName("iceEditor-btn")[0].onclick=function(){var e=t.c("audio");e.src=t.musicInput.value,e.controls="controls",t.setHTML(e,!0),t.music.getElementsByClassName("iceEditor-popup")[0].style.display="none",t.pd()}}}),this.createMenu({title:"附件上传",name:"files",icon:"files",id:this.filesId,popup:{width:320,height:200,title:"附件上传",content:'
    '},success:function(e,t){t.files=t.id(t.filesId);var i=t.files.getElementsByClassName("iceEditor-popup")[0];t.id(t.filesUploadId).onchange=function(){if(!t.uploadUrl)return alert("请配置uploadUrl项");for(var e=new FormData,o=0;o
    确定
    '},success:function(e,t){t.insertImage=t.id(t.imageId);var i=t.insertImage.getElementsByClassName("iceEditor-popup")[0],o=t.insertImage.getElementsByClassName("iceEditor-insertImageUrl")[0],n=t.insertImage.getElementsByClassName("iceEditor-inputWidth")[0],a=t.insertImage.getElementsByClassName("iceEditor-inputHeight")[0];t.insertImage.getElementsByClassName("iceEditor-btn")[0].onclick=function(){var e=t.c("img");e.src=o.value,n.value.trim()&&(e.width=n.value.trim()),a.value.trim()&&(e.height=a.value.trim()),t.setHTML(e),i.style.display="none",t.pd()},t.id(t.imgUploadId).onchange=function(){if(!t.uploadUrl)return alert("请配置uploadUrl项");for(var e=new FormData,o=0;o
    URL:
    确定
    '},success:function(e,t){t.video=t.id(t.videoId);var i,o=t.video.getElementsByClassName("iceEditor-popup")[0],n=t.video.getElementsByClassName("iceEditor-videoUrl")[0],a=t.video.getElementsByClassName("iceEditor-inputWidth")[0],l=t.video.getElementsByClassName("iceEditor-inputHeight")[0];t.video.getElementsByClassName("iceEditor-btn")[0].onclick=function(){if(!n.value.length)return alert("视频地址不能为空");for(var e=t.video.getElementsByTagName("input"),r=0;r1))return alert("b站"+c);if(d=d[0].split("video/"),!(d.length>1&&d[1].length))return alert("b站"+c);s.src="https://player.bilibili.com/player.html?bvid="+d[1]}else if(3===i){var d=n.value.split(".html");if(!(d.length>1))return alert("优酷:"+c);if(d=d[0].split("id_"),!(d.length>1&&d[1].length))return alert("优酷:"+c);s.src="https://player.youku.com/embed/"+d[1]}}t.setHTML(s,!0),o.style.display="none",t.pd()}}}),this.createMenu({title:"最大化",name:"max",icon:"max",data:"max",css:"iceEditor-maxWindow"}),this.createMenu({title:"最小化",name:"min",icon:"min",data:"min",css:"iceEditor-minWindow"}),this.createMenu({name:"disabled",css:"iceEditor-disabledMask"})},ice.editor.prototype.menuFormat=function(){var e=this;this.menuHTML();var t=this.c("ul");t.className="iceEditor-menu",this.tool.innerHTML="",this.tool.appendChild(t);for(var i=0;i/g,"\n");var r=t.getHTML();r=r.replace(/<\/p>

    /gim,"

    \n

    ").replace(/>

    \n\n<"),t.d.body.innerHTML=t.unhtml(r)}else{t.tool.className="iceEditor-tool iceEditor-noselect",n.style.display="none",this.className="iceEditor-exec",t.d.body.className="";var r=t.getHTML();t.d.body.innerHTML=t.html(r);for(var a=t.d.body.getElementsByTagName("pre"),l=0;l")}break;case"max":var s=window.innerHeight;"number"!=typeof s&&("CSS1Compat"==document.compatMode?s=document.documentElement.clientHeight:webWidth=document.body.clientWidth),t.editor.style.position="fixed",t.editor.style.zIndex=t.getTime,t.editor.style.width="100%",t.editor.style.height="100%",t.editor.style.top=0,t.editor.style.left=0,t.iframe.height=s-35-20+"px",this.parentNode.style.display="none",t.tool.getElementsByClassName("iceEditor-minWindow")[0].style.display="block";break;case"min":t.editor.removeAttribute("style"),t.iframe.height=t.height,this.parentNode.style.display="none",t.tool.getElementsByClassName("iceEditor-maxWindow")[0].style.display="block";break;default:var c=this.attr.split("|");t.w.document._useStyleWithCSS||(t.w.document.execCommand("styleWithCSS",null,!0),t.w.document._useStyleWithCSS=!0),c.length>1?t.w.document.execCommand(c[0],!1,c[1]):t.w.document.execCommand(c[0],!1,null)}return!1})},ice.editor.prototype.pasteWord=function(e){function t(e){if(!/(pt|cm)/.test(e))return e;var t;return e.replace(/([\d.]+)(\w+)/,function(e,i,o){i=i,t=o}),(e="cm"==t?25*parseFloat(e):Math.round(96*parseFloat(e)/72))+(e?"px":"")}function i(e){return e.replace(/[\d.]+\w+/g,function(e){return t(e)})}return function(e){return/(class="?Mso|style="[^"]*\bmso\-|w:WordDocument|<(v|o):|lang=)/gi.test(e)}(e)?function(e){return e.replace(//gi,"").replace(//gi,"").replace(//gi,"").replace(/.*?<\/head>/gi,"").replace(/<\/body>/gi,"").replace(/<\/html>/gi,"").replace(/[\t\s]+/gi," ").replace(/.*?<\/xml>/gi,"").replace(/.*?<\/o:p>/gi,"").replace(/]*>\s*<\/span>/gi,"").replace(/<(span|font|p|b|i|u|s)[^>]*>\s*<\/\1>/gi,"").replace(/v:\w+=(["']?)[^'"]+\1/g,"").replace(/]*class="?MsoHeading"?[^>]*>(.*?)<\/p>/gi,"

    $1

    ").replace(/\s+(class|lang|align)\s*=\s*(['"]?)([\w-]+)\2/gi,function(e,t,i,o){return"class"==t&&"MsoListParagraph"==o?e:""}).replace(/<(font|span)[^>]*>(\s*)<\/\1>/gi,function(e,t,i){return i.replace(/[\t\r\n ]+/g," ")}).replace(/(<[a-z][^>]*)\sstyle=(["'])([^\2]*?)\2/gi,function(e,o,n,a){for(var l,r=[],s=a.replace(/^\s+|\s+$/,"").replace(/'/g,"'").replace(/"/gi,"'").replace(/[\d.]+(cm|pt)/g,function(e){return t(e)}).split(/;\s*/g),c=0;l=s[c];c++){var d,p,h=l.split(":");if(2==h.length){if(d=h[0].toLowerCase().trim(),p=h[1].toLowerCase().trim(),/^(background)\w*/.test(d)&&0==p.replace(/(initial|\s)/g,"").length||/^(margin)\w*/.test(d)&&/^0\w+$/.test(p))continue;switch(d){case"mso-vertical-align-alt"://g,"").replace(//g,"").replace(//g,"").replace(/.*?<\/head>/g,"").replace(/<\/body>/g,"").replace(/<\/html>/g,"").replace(/\s+(id|class|lang|align|data|data-\w*)\s*=\s*(['"]?).*?\2/gi,"");for(var t=0;t]*>.*?","gim"),"");var i=this;return e=e.replace(/\s+style\s*=\s*(['"]?)(.*?)\1/g,function(e,t,o){if(o){o=o.replace(/('|")/gi,"'");var n=o.split(";");if(n.length){for(var a=[],l=0;l1&&/rgb\s*\(/gi.test(c[1])?(c[1]=c[1].replace(/rgb\s*\(.*?\)/gi,function(e){return e=e.split(/\D+/),"#"+((1<<24)+(parseInt(e[1])<<16)+(parseInt(e[2])<<8)+parseInt(e[3])).toString(16).slice(1)}),a.push(s+":"+c[1])):a.push(r)}}}return' style="'+a.join(";")+'"'}}return""}),e.replace(/]*)>/g,"").replace(/<\/div>/g,"

    ")}, -ice.editor.prototype.formatHTML=function(e){e=e.replace(/[\t\s]+/g," ").replace(/<(span|font|p|b|i|u|s)[^>]*>(<(?!img)[^>]*>)*<\/\1>/gi,"").replace(/<(.+)\s+>/g,"<$1>").replace(/(){1,}/gi,"
    ");for(var t=0;t","gim"),"\r\n");return e.replace(/\r\n{1,}/gim,"\r\n").trim()},ice.editor.prototype.paste=function(){function e(t){if(!t)return!1;var i=t.nextSibling;return i&&1!=i.nodeType&&(i=e(i)),i}try{this.w.document.execCommand("AutoUrlDetect",!1,!1)}catch(e){}var t=this,i=(this.w,function(e){if(!t.screenshotUpload){var i=t.c("p"),o=t.c("img");return o.src=e,i.appendChild(o),void t.setHTML(i,!0)}var n=function(e){var t;t=e.split(",")[0].indexOf("base64")>=0?atob(e.split(",")[1]):unescape(e.split(",")[1]);for(var i=e.split(",")[0].split(":")[1].split(";")[0],o=new Uint8Array(t.length),n=0;n").replace(/ /g," ").replace(/'/g,"'").replace(/"/g,"'")),t.screenshot&&!t.inNodeParent(t.range.getRangeAt(0).endContainer,"pre")){if(n){var s=n.items&&-1!==n.items[0].type.indexOf("image")?n.items[0].getAsFile():0;if(s){var c=new FileReader;c.onload=function(e){var t=e.target.result;i(t)},c.readAsDataURL(s)}}o()}if(l.length){if(t.code)return void t.setText(a);var d=l.replace(/[\r|\n]+/g,"\n").split("\n");if(t.inNodeParent(t.range.getRangeAt(0).endContainer,"pre")){for(var d=a.replace(/[\r|\n]+/g,"\n").split("\n"),p=0;p"),!0)}if(t.pasteText&&1==d.length)return void t.setText(l);if(t.pasteText||!r)for(var p=0;p"+d[p].trim()+"

    ",!0);else l=t.pasteWord(l),l=t.formatHTML(l),l=t.pasteHTML(l),l=t.formatHTML(l),t.setText(l,!0);if(l=t.getHTML(),t.d.body.innerHTML=l,l=t.getHTML(),l=l.replace(/

    <\/p>/gi,"").replace(/<\/p>
    /gi,"").replace(/<(span|font|p|b|i|u|s)[^>]*>(<(?!img)[^>]*>)*<\/\1>/gi,""),t.d.body.innerHTML=l,t.imgAutoUpload){var l=t.getHTML();l.replace(//gi,function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e){if("/"!=i.substr(0,1)||"//"==i.substr(0,2)){t.imgDomain=t.imgDomain&&Array.isArray(t.imgDomain)?t.imgDomain:[document.domain],!t.imgDomain.includes(document.domain)&&t.imgDomain.push(document.domain);for(var o=0;o
    ":"
    ",o=t.range.getRangeAt(0);o.insertNode(o.createContextualFragment(a));var l=t.range.anchorNode.nextSibling.nextSibling;o.setStart(l,0),o.setEnd(l,0),o.collapse()}else"PRE"!=t.parentTagName&&"PRE"!=t.range.anchorNode.tagName||t.setText("
    ",!0);return void i.preventDefault()}if(i.ctrlKey||i.metaKey)switch(i.keyCode){case 13:i.preventDefault();break;case 66:case 98:case 73:case 105:case 85:case 117:i.preventDefault()}})},ice.editor.prototype.create=function(){this.cssConfig.styleSheet?this.cssConfig.styleSheet.cssText=this.css:this.cssConfig.innerHTML=this.css,this.menuFormat(),this.menuAction(),this.disableds.style.display=this.disabled?"block":"none"},ice.editor.prototype.getHTML=function(){return this.content.innerHTML},ice.editor.prototype.getText=function(){return this.content.innerText},ice.editor.prototype.getValue=function(){return this.content.innerHTML},ice.editor.prototype.setValue=function(e){this.content.innerHTML=e},ice.editor.prototype.addValue=function(e){this.content.innerHTML+=e},ice.editor.prototype.inputDisabled=function(){this.d.body.designMode="off",this.d.body.contentEditable=!1},ice.editor.prototype.inputEnable=function(){this.d.body.designMode="on",this.d.body.contentEditable=!0},ice.editor.prototype.inputCallback=function(e){var t=this;t.d.body.oninput=function(){e&&e.call(t,t.getHTML(),t.getText())}},ice.editor.css='.iceEditor{color:#353535!important;font-family:"Microsoft YaHei";font-size:14px!important;background:#fff;position:relative;border:solid 1px #ccc}.iceEditor *{margin:0;padding:0;box-sizing:border-box}.iceEditor a{color:#606060;text-decoration:none;-webkit-tap-highlight-color:transparent}.iceEditor a:hover{color:#000}.iceEditor-line{height:20px;width:1px;background:#cecece;margin:8px 8px 0 8px;}.iceEditor-row{margin-bottom:10px;}.iceEditor-group{text-align:left;margin-bottom:10px;}.iceEditor-group label {min-width:50px!important;display:inline-block!important;text-align:right!important;font-weight:normal!important;}.iceEditor input{height:27px!important;line-height:27px!important;padding:3px!important;border:1px solid #B7B7B7!important;font-family:inherit;font-size:inherit;vertical-align:middle;outline:none;display:inline-block!important;}.iceEditor-exec{cursor:pointer}.iceEditor-icon{width:22px;height:16px;fill:currentColor;overflow:hidden;vertical-align:middle;font-size:16px}.iceEditor-noselect{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.iceEditor-menuDropdown{min-width:35px;min-height:35px;transition:all .4s ease;margin-top:60px;opacity:0;visibility:hidden;position:absolute;background:#fff;z-index:999;box-shadow:0 2px 9px 0 rgba(0,0,0,.2);border-bottom:2px solid #676767;border-top:1px solid #676767}.iceEditor-menuDropdown::before{content:"";display:block;width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-bottom:8px solid #676767;position:absolute;top:-8px;left:9px}.iceEditor-menuTitle{width:100%!important;text-align:center;height:30px;line-height:30px;border-top:1px solid #efefef}.iceEditor-tool{width:100%;background:#eee;border-bottom:solid 1px #ccc;position:relative}.iceEditor-tool:after,.iceEditor-tool:before{display:table;content:" "}.iceEditor-tool:after{clear:both}.iceEditor-menu{width:100%;padding:0 10px;display:inline-block;float:left}.iceEditor-menu a{list-style:none;float:left;min-width:35px;height:35px;padding:0 5px;text-align:center;line-height:35px;cursor:pointer}.iceEditor-menu a:hover{background:#cdcdcd}.iceEditor-menu>li>div.iceEditor-exec{list-style:none;float:left;min-width:35px;height:35px;padding:0 5px;text-align:center;line-height:35px;cursor:pointer}.iceEditor-menu>li>div.iceEditor-exec:hover{background:#cdcdcd}.iceEditor-menu svg{fill:currentColor;overflow:hidden;vertical-align:middle;font-size:16px}.iceEditor-menu .iceEditor-active{background:#e0e0e0;position:relative;z-index:999}.iceEditor-menu .iceEditor-actives,.iceEditor-menu .iceEditor-active-s{background:#d8d8d8;}.iceEditor-menu .iceEditor-disabledMask{background:rgba(238,238,238,0.7);width:100%;height:100%;position:absolute;left:0;top:0;display:none}.iceEditor-menu li{display:inline-block;float:left;line-height:initial;}.iceEditor-menu li .iceEditor-menuDropdown.iceEditor-menuActive{margin-top:44px;opacity:1;visibility:visible}.iceEditor-menu li.iceEditor-minWindow{display:none}.iceEditor-menu li.iceEditor-maxWindow,.iceEditor-menu li.iceEditor-minWindow{float:right}.iceEditor-menu li.iceEditor-maxWindow>div,.iceEditor-menu li.iceEditor-minWindow>div{position:relative;z-index:9}.iceEditor-menu li.iceEditor-maxWindow .iceEditor-icon,.iceEditor-menu li.iceEditor-minWindow .iceEditor-icon{color:#606060}.iceEditor-codeLanguages select{padding:5px 5px;width:120px;outline:none;font-size:15px;margin-top:10px;}.iceEditor input.iceEditor-uploadInput{display:none!important}.iceEditor-uploadBtn{float:none;width:auto;font-size:15px;background:#00b7ee;height:40px;line-height:40px;padding:0 30px;color:#fff;display:inline-block;margin:0 auto 15px auto;cursor:pointer;box-shadow:0 1px 1px rgba(0,0,0,.1)}.iceEditor-uploadBtn:hover{background:#009ccb}.iceEditor-uploadIcon{width:45px;height:45px;color:#bababa;margin:20px 20px 10px}.iceEditor-backColor{width:230px;padding:5px}.iceEditor-backColor span{width:20px;height:20px;padding:0;margin:1px;display:inline-block}.iceEditor-fontSize{width:280px}.iceEditor-fontSize li{width:40px;text-align:center}.iceEditor-fontSize span{width:40px;display:inline-block;padding:10px 0}.iceEditor-fontSize span:hover{background:#eee;color:#4CAF50}.iceEditor-createLink label{display:inline-block;}.iceEditor .iceEditor-link{width:175px!important;}.iceEditor-popup .iceEditor-insertImage{text-align:center}.iceEditor-popup .iceEditor-insertImageUrl{width:220px!important;height:27px;outline:0;margin-right:15px}.iceEditor-popup .iceEditor-inputWidth{width:50px!important;height:27px;outline:0;margin-right:15px}.iceEditor-popup .iceEditor-inputHeight{width:50px!important;height:27px;outline:0}.iceEditor-popup .iceEditor-btn{width:auto;display:inline-block;float:none;color:#fff!important;height:27px;line-height:25px;padding:0 10px;background:#939393;vertical-align:middle;margin-left:5px;border:1px solid #7b7b7b}.iceEditor-popup .iceEditor-btn:hover{background:#7b7b7b!important;color:#fff}.iceEditor-tableBox{position:relative;width:190px;height:214px;padding:5px;overflow:hidden}.iceEditor-tableBgOn{position:absolute!important;top:5px;left:5px;z-index:4;width:18px;height:18px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASAgMAAAAroGbEAAAACVBMVEUAAIjd6vvD2f9LKLW+AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfYAR0BKwNDEVT0AAAAG0lEQVQI12NgAAOtVatWMTCohoaGUY+EmIkEAEruEzK2J7tvAAAAAElFTkSuQmCC) repeat}.iceEditor-tableBgOff{width:180px;height:180px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASAgMAAAAroGbEAAAACVBMVEUAAIj4+Pjp6ekKlAqjAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfYAR0BKhmnaJzPAAAAG0lEQVQI12NgAAOtVatWMTCohoaGUY+EmIkEAEruEzK2J7tvAAAAAElFTkSuQmCC) repeat}.iceEditor-tableNum{height:30px;line-height:30px;text-align:center;color:#757575}.iceEditor-video{text-align:left}.iceEditor-video label{margin-right:20px;display:inline-block}.iceEditor-video input{margin-right:5px}.iceEditor-video div{height:27px;margin-bottom:10px}.iceEditor-popup .iceEditor-videoUrl{width:255px!important;height:27px;outline:0;margin-right:0}.iceEditor-content{width:100%;height:100%;padding:20px;position:relative}.iceEditor-content:focus{outline:0}.iceEditor-dragBg{position:absolute;width:100%;height:100%;top:0;left:0;z-index:1;display:none;}.iceEditor-drag{color:#757575;background:#eee;text-align:center;height:12px;line-height:0;cursor:n-resize}.iceEditor-disabled{position:absolute;width:100%;height:100%;top:0;left:0;background:rgba(191,191,191,.79);z-index:99999;display:none}.iceEditor-popup{display:none}.iceEditor-popupMain{width:400px;height:200px;position:fixed;margin:auto;top:0;bottom:0;left:0;right:0;background:#fff;box-shadow:0 1px 1px rgba(0,0,0,.12);z-index:9999;animation-name:iceEditorPopup;animation-duration:.5s}.iceEditor-popupBox{width:100%;height:100%;position:fixed;top:0;left:0;background:rgba(0,0,0,.33);opacity:.5;filter:alpha(opacity=50);z-index:1}.iceEditor-popupTitle{width:100%;height:30px;line-height:30px;background:#2f2f2f;padding:0 10px;color:#fff}.iceEditor-popupTitle span{display:inline-block;vertical-align:middle}.iceEditor-popupTitle::before{content:"";display:inline-block;width:10px;height:10px;border-radius:10px;background:#c7f98c;vertical-align:middle;margin-right:8px}.iceEditor-popupClose{float:right;padding:0 10px;color:#fff;font-size:18px;cursor:pointer}.iceEditor-popupClose:hover{color:#8fe5ff}.iceEditor-popupContent{width:100%;padding:10px;color:#000;overflow:auto;float:left}.iceEditor-popupBtn{width:100%;border:0;color:#fff;background:#03A9F4;border-top:1px solid #efefef;padding:0 20px;margin:0;height:35px;text-align:center;line-height:35px;cursor:pointer;margin-top:20px;outline:0}.iceEditor-popupBtn:hover{color:#151515;background:#efefef}@keyframes iceEditorPopup{0%{top:-100px;opacity:0}to{top:0;opacity:1}}', -ice.editor.svg='',function(){var e,t,i=document.createElement("style"),o=document.body;i.type="text/css",i.styleSheet?i.styleSheet.cssText=ice.editor.css:i.innerHTML=ice.editor.css,document.getElementsByTagName("head")[0].appendChild(i),e=document.createElement("div"),e.innerHTML=ice.editor.css+ice.editor.svg,ice.editor.svg=null,(t=e.getElementsByTagName("svg")[0])&&(t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.width=0,t.style.height=0,t.style.overflow="hidden",o.firstChild?o.firstChild.parentNode.insertBefore(t,o.firstChild):o.appendChild(t))}(); \ No newline at end of file +"use strict";var ice=ice||{};ice.editor=function(e){this.menu=["backColor","fontSize","foreColor","bold","italic","underline","strikeThrough","line","justifyLeft","justifyCenter","justifyRight","indent","outdent","line","insertOrderedList","insertUnorderedList","line","superscript","subscript","createLink","unlink","line","hr","face","table","files","music","video","insertImage","removeFormat","paste","line","code"],this.notMenu=[],this.backColor=["#ffffff","#000000","#eeece1","#1f497d","#4f81bd","#c0504d","#9bbb59","#8064a2","#4bacc6","#f79646","#f2f2f2","#979797","#ddd9c3","#c6d9f0","#dbe5f1","#f2dcdb","#ebf1dd","#e5e0ec","#dbeef3","#fdeada","#d8d8d8","#595959","#c4bd97","#8db3e2","#b8cce4","#e5b9b7","#d7e3bc","#ccc1d9","#b7dde8","#fbd5b5","#bfbfbf","#3f3f3f","#938953","#548dd4","#95b3d7","#d99694","#c3d69b","#b2a2c7","#92cddc","#fac08f","#a5a5a5","#262626","#494429","#17365d","#366092","#953734","#76923c","#5f497a","#31859b","#e36c09","#7f7f7f","#0c0c0c","#1d1b10","#0f243e","#244061","#632423","#4f6128","#3f3151","#205867","#974806","#c00000","#ff0000","#ffc000","#ffff00","#92d050","#00b050","#00b0f0","#0070c0","#002060","#7030a0"],this.foreColor=this.backColor,this.width="100%",this.height="400px",this.code=0,this.maxWindow=1,this.disabled=0,this.css="",this.uploadUrl=0,this.pasteText=1,this.screenshot=1,this.screenshotUpload=1,this.imgAutoUpload=1,this.imgDomain=0,this.ajax.uploadTimeout=15e3,this.ajax.xhr=function(){},this.ajax.timeout=function(){},this.ajax.progress=function(){},this.ajax.success=function(){},this.ajax.error=function(){},this.ajax.complete=function(){},this.filesUpload={},this.filesUpload.success=function(){},this.filesUpload.error=function(){},this.filesUpload.complete=function(){},this.imgUpload={},this.imgUpload.success=function(){},this.imgUpload.error=function(){},this.imgUpload.complete=function(){},this.face=[{title:"文字",type:"text",list:[{title:"开心",content:"(^_^)"},{title:"受不了",content:"(>_<)"},{title:"鄙视",content:"(¬、¬)"},{title:"难过",content:"(*>﹏<*)"},{title:"可爱",content:"(。◕‿◕。)"},{title:"无奈",content:"╮(╯_╰)╭"},{title:"惊喜",content:"╰(*°▽°*)╯"},{title:"听音乐",content:"♪(^∇^*)"},{title:"害羞",content:"(✿◡‿◡)"},{title:"睡啦",content:"(∪。∪)..zzZ"},{title:"臭美",content:"(o≖◡≖)"},{title:"流汗",content:"(ーー゛)"}]}],this.filterTag=["meta","script","object","form","iframe"],this.filterStyle=["background-image"],this.blockTag=["address","caption","dd","div","dl","dt","fieldset","h1","h2","h3","h4","h5","h6","legend","fieldset","li","noframes","noscript","ol","ul","p","pre","table","tbody","tfoot","th","thead","tr","video"],this.getTime="1"+String((new Date).getTime()).substr(4,8),this.iframeId="_iframe"+this.getTime,this.toolId="_tool"+this.getTime,this.linkId="_link"+this.getTime,this.linkInputId="_LinkInput"+this.getTime,this.musicId="_music"+this.getTime,this.musicInputId="_musicInput"+this.getTime,this.videoId="_video"+this.getTime,this.imageId="_image"+this.getTime,this.imgUploadId="_imgUpload"+this.getTime,this.filesId="_files"+this.getTime,this.filesUploadId="_filesUpload"+this.getTime,this.tableId="_table"+this.getTime,this.dragId="_drag"+this.getTime,this.menuList={};var t=this;if(this.editor=this.id(e),!this.editor)return alert("请提供一个有效的id");if(this.textarea=0,"TEXTAREA"!==this.editor.nodeName&&"DIV"!==this.editor.nodeName)return console.log("iceEditor:暂不支持该标签「"+this.editor.nodeName+"」,推荐使用div或textarea");if("TEXTAREA"==this.editor.nodeName){this.editor.style.display="none",this.divId="_div"+this.getTime;var i=this.c("div");i.className="iceEditor",i.id=this.divId,this.insertAfter(i,this.editor),this.textarea=this.editor,this.editor=this.id(this.divId),this.value=this.textarea.value}else this.editor.className="iceEditor",this.value=this.editor.innerHTML,this.editor.innerHTML="";this.cssConfig=this.c("style"),this.cssConfig.type="text/css",this.editor.appendChild(this.cssConfig),this.tool=this.c("div"),this.tool.id=this.toolId,this.tool.className="iceEditor-tool iceEditor-noselect",this.editor.appendChild(this.tool),this.iframe=this.c("iframe"),this.iframe.id=this.iframeId,this.iframe.className="iceEditor-noselect",this.iframe.frameBorder=0,this.editor.appendChild(this.iframe),this.dragBg=this.c("div"),this.dragBg.className="iceEditor-dragBg",this.editor.appendChild(this.dragBg),this.drag=this.c("div"),this.drag.id=this.dragId,this.drag.className="iceEditor-drag iceEditor-noselect",this.drag.innerHTML='',this.editor.appendChild(this.drag),this.drag.onmousedown=function(){t.dragBg.style.display="block";var e=event.clientY,i=t.iframe.clientHeight;window.onmousemove=function(){var o=event.clientY-e;i>=100?(t.iframe.height=i+o+"px",t.height=i+o+"px"):(t.iframe.height="100px",t.height=i+o+"px")},window.onmouseup=function(){window.onmousemove=null,window.onmouseup=null,t.dragBg.style.display="none"}},this.disableds=this.c("div"),this.disableds.className="iceEditor-disabled",this.editor.appendChild(this.disableds),this.w=this.iframe.contentWindow,this.d=this.iframe.contentDocument,this.d.open();var o=this.value.trim();o.length&&"

    "==o.substr(0,3)||(o="

    "+this.value+"

    "),this.d.write(''+o+""),this.d.close(),this.d.body.designMode="on",this.d.body.contentEditable=!0,this.d.body.addEventListener("click",function(){t.parentTagName=t.range.anchorNode.parentNode.tagName;for(var e=0;e/g,"\n");t.textarea.innerHTML=t.unhtml(i.innerHTML)},1e3),this.init(),this.create(),this.paste()},ice.editor.prototype={id:function(e){return document.getElementById(e)},c:function(e){return document.createElement(e)},init:function(){this.files=null,this.insertImage=null,this.element=this.d.body,this.range=this.d.createRange?this.w.getSelection():this.d.selection.createRange()},insertAfter:function(e,t){var i=t.parentNode;i.lastChild==t?i.appendChild(e,t):i.insertBefore(e,t.nextSibling)},setHTML:function(e,t){this.element.focus();var i=this.range.getRangeAt(0);t||e.appendChild(i.extractContents()),i.deleteContents(),i.insertNode(this.w.document.createDocumentFragment().appendChild(e)),i.collapse(!1)},setText:function(e,t){this.element.focus();var i=this.range.getRangeAt(0);i.deleteContents();var o=document.createElement("div");t?o.innerHTML=e:o.appendChild(document.createTextNode(e));for(var n,a,l=document.createDocumentFragment();n=o.firstChild;)a=l.appendChild(n);i.insertNode(l),a&&(i=i.cloneRange(),i.setStartAfter(a),i.collapse(!0),this.range.removeAllRanges(),this.range.addRange(i)),i.collapse(!0)},getSelectHTML:function(){var e=this.c("p");return e.appendChild(this.range.getRangeAt(0).cloneContents()),e.innerHTML},getSelectText:function(){return"false"==this.range.toString()||""==this.range.toString()?"":this.range.toString()},unhtml:function(e){var t="";return 0==e.length?"":(t=e.replace(/&/g,"&"),t=t.replace(//g,">"),t=t.replace(/\'/g,"'"),t=t.replace(/\"/g,"""))},html:function(e){var t="";return 0==e.length?"":(t=e.replace(/</g,"<"),t=t.replace(/>/g,">"),t=t.replace(/'/g,"'"),t=t.replace(/"/g,'"'),t=t.replace(/&/g,"&"))},toText:function(e){var t=this.c("div");null!=t.textContent?t.textContent=e:t.innerText=e;var i=t.innerHTML;return t=null,i},toHTML:function(e){var t=this.c("div");t.innerHTML=e;var i=t.innerText||t.textContent;return t=null,i},inNodeParent:function(e,t){return!!e&&(!!e.parentNode&&("string"==typeof t?(t=t.toUpperCase(),e.tagName==t||(e.parentNode.tagName==t||this.inNodeParent(e.parentNode,t))):e.parentNode==t||this.inNodeParent(e.parentNode,t)))},inArray:function(e,t){if("string"==typeof e||"number"==typeof e){for(var i in t)if(e===t[i])return!0;return!1}},getRange:function(){return this.range.getRangeAt(0)},popup:function(e){return e=e||{},'
    '+(e.title||"")+'
    '+(e.content||"")+"
    "},getCoords:function(e){var t=e.getBoundingClientRect(),i=e.ownerDocument,o=i.body,n=i.documentElement,a=n.clientTop||o.clientTop||0,l=n.clientLeft||o.clientLeft||0;return{top:t.top-a,left:t.left-l}},pd:function(t){window.event?window.event.cancelBubble=!0:e.stopPropagation()},isIE:function(){return!!window.ActiveXObject||"ActiveXObject"in window},ajax:function(e){function t(e){var t=0;t=e.lengthComputable?Math.round(e.loaded/e.total*100):0,i.ajax.progress(t,e,o)}var i=this;if(e=e||{},e.url){e.timeout=e.timeout||i.ajax.uploadTimeout,e.data=e.data||{};var o=new XMLHttpRequest;o.addEventListener("progress",t,!1),o.open("POST",e.url,!0),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),e.data instanceof FormData==0&&o.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),i.ajax.xhr(o),o.send(e.data instanceof FormData?e.data:function(e){var t=[];for(var i in e)t.push(i+"="+encodeURIComponent(e[i]));return t.join("&")}(e.data)),e.loading&&e.loading(),e.timer=setTimeout(function(){o.onreadystatechange=null,i.ajax.timeout(o),e.error&&e.error("网络超时。")},e.timeout),o.onreadystatechange=function(){if(4===o.readyState&&200===o.status)if(clearTimeout(e.timer),o.status>=200&&o.status<300||304==o.status){var t="";o.responseText.length>0&&(t=JSON.parse(o.responseText)),i.ajax.success(t,o),i.ajax.complete(t,o),e.success&&e.success(t)}else i.ajax.error(o),i.ajax.complete(o),e.error&&e.error(o);else i.ajax.error(o),i.ajax.complete(o)}}},createMenu:function(e){var t=this,i=this.c("li");if(e.id&&(i.id=e.id),e.css&&(i.className=e.css),e.style&&(this.css+=e.style),e.menu||e.icon){var o=this.c("div");e.title&&(o.title=e.title),o.className="iceEditor-exec",e.menu?o.innerHTML=e.menu:e.icon&&(o.innerHTML=''),e.data&&o.setAttribute("data",e.data),i.appendChild(o)}if(e.dropdown){var o=this.c("div");o.className="iceEditor-menuDropdown",o.innerHTML=e.dropdown,i.appendChild(o),i.openMenu=1,i.onmouseover=function(){i.openMenu&&(o.className="iceEditor-menuDropdown iceEditor-menuActive")},i.onmouseout=function(){o.className="iceEditor-menuDropdown"};for(var n=o.getElementsByClassName("iceEditor-exec"),a=0;a
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 文字大小
  • '});for(var e='
      ',t=0;t';e+='
    • 文字背景颜色
    ',this.createMenu({title:"文字背景颜色",name:"backColor",icon:"backColor",dropdown:e});for(var e='
      ',t=0;t';e+='
    • 文字颜色
    ',this.createMenu({title:"文字颜色",name:"foreColor",icon:"foreColor",dropdown:e}),this.createMenu({title:"加粗",name:"bold",data:"bold",icon:"bold"}),this.createMenu({title:"倾斜",name:"italic",data:"italic",icon:"italic"}),this.createMenu({title:"下划线",name:"underline",data:"underline",icon:"underline"}),this.createMenu({title:"删除线",name:"strikeThrough",data:"strikeThrough",icon:"strike"}),this.createMenu({title:"左对齐",name:"justifyLeft",data:"justifyLeft",icon:"alignleft"}),this.createMenu({title:"居中对齐",name:"justifyCenter",data:"justifyCenter",icon:"aligncenter"}),this.createMenu({title:"右对齐",name:"justifyRight",data:"justifyRight",icon:"alignright"}),this.createMenu({title:"缩进",name:"indent",data:"indent",icon:"indent"}),this.createMenu({title:"取消缩进",name:"outdent",data:"outdent",icon:"outdent"}),this.createMenu({title:"有序列表",name:"insertOrderedList",data:"insertOrderedList",icon:"orderedlist"}),this.createMenu({title:"无序列表",name:"insertUnorderedList",data:"insertUnorderedList",icon:"unorderedlist"}),this.createMenu({title:"下标",name:"subscript",data:"subscript",icon:"subscript"}),this.createMenu({title:"上标",name:"superscript",data:"superscript",icon:"superscript"}),this.createMenu({title:"取消连接",name:"unlink",data:"unlink",icon:"unlink"}),this.createMenu({title:"添加水平线",name:"hr",data:"insertHorizontalRule",icon:"min"}),this.createMenu({title:"清除格式",name:"removeFormat",data:"removeFormat",icon:"remove"}),this.createMenu({title:"富文本粘贴",name:"paste",icon:"word",success:function(e,t){t.pasteText||(e.className="iceEditor-active-s"),e.onclick=function(){t.pasteText=!t.pasteText,e.className=t.pasteText?"":"iceEditor-active-s"}}}),this.createMenu({title:"全选",name:"selectAll",data:"selectAll",icon:"empty"}),this.createMenu({title:"查看源码",name:"code",icon:"code",data:"code"});for(var e='
    ',t=0;t"+this.face[t].title+"";e+='
    ';for(var t=0;t';for(var i=0;i':e+=''+this.face[t].list[i].content+"";e+="
    "}e+="
    ",this.createMenu({title:"插入表情",name:"face",icon:"face",dropdown:e,success:function(e,t){for(var i=e.getElementsByClassName("iceEditor-faceTitle")[0],o=i.getElementsByTagName("span"),n=e.getElementsByClassName("iceEditor-faceMain")[0],a=e.getElementsByClassName("iceEditor-faceList"),l=n.getElementsByTagName("span"),r=0;r
  • 表格:1×1
  • ',success:function(e,t){t.table=t.id(t.tableId);var i=t.table.getElementsByClassName("iceEditor-tableBox")[0],o=t.table.getElementsByClassName("iceEditor-tableBgOn")[0],n=t.table.getElementsByClassName("iceEditor-tableNum")[0];i.onmouseover=function(e){var i=t.getCoords(this),a=1,l=1;this.onmousemove=function(e){var t=e||event,r=t.clientX-i.left-5,s=t.clientY-i.top-5;r<=180&&s<=180&&(a=Math.ceil(r/18),l=Math.ceil(s/18),o.style.width=18*a+"px",o.style.height=18*l+"px",n.innerHTML="表格:"+a+"×"+l)},this.onmousedown=function(){var e=t.c("table");e.width="100%",e.border=1,e.style.border="1px solid #bdbdbd",e.style.borderSpacing=0,e.style.borderCollapse="collapse",e.className="table table-border";for(var i=0;i"}t.setHTML(e,!0)},this.onmouseout=function(){this.onmousemove=null,this.onmouseout=null}}}}),this.createMenu({title:"添加链接",name:"createLink",icon:"link",id:this.linkId,popup:{width:320,height:110,title:"添加链接",content:''},success:function(e,t){t.link=t.id(t.linkId),t.linkInput=t.id(t.linkInputId),t.link.getElementsByClassName("iceEditor-btn")[0].onclick=function(){var e=t.getSelectHTML().replace(/]+>/gi,"").replace(/<\s*\/a\s*>/gi,""),i=t.c("a");t.link.getElementsByTagName("input")[1].checked&&(i.target="_blank"),i.href=t.linkInput.value,i.innerHTML=e,t.setHTML(i,!0),t.link.getElementsByClassName("iceEditor-popup")[0].style.display="none",t.pd()}}}),this.createMenu({title:"添加音乐",name:"music",icon:"music",id:this.musicId,popup:{width:320,height:80,title:"添加音乐",content:'
    确定
    '},success:function(e,t){t.music=t.id(t.musicId),t.musicInput=t.id(t.musicInputId),t.music.getElementsByClassName("iceEditor-btn")[0].onclick=function(){var e=t.c("audio");e.src=t.musicInput.value,e.controls="controls",t.setHTML(e,!0),t.music.getElementsByClassName("iceEditor-popup")[0].style.display="none",t.pd()}}}),this.createMenu({title:"附件上传",name:"files",icon:"files",id:this.filesId,popup:{width:320,height:200,title:"附件上传",content:'
    '},success:function(e,t){t.files=t.id(t.filesId);var i=t.files.getElementsByClassName("iceEditor-popup")[0];t.id(t.filesUploadId).onchange=function(){if(!t.uploadUrl)return alert("请配置uploadUrl项");for(var e=new FormData,o=0;o
    确定
    '},success:function(e,t){t.insertImage=t.id(t.imageId);var i=t.insertImage.getElementsByClassName("iceEditor-popup")[0],o=t.insertImage.getElementsByClassName("iceEditor-insertImageUrl")[0],n=t.insertImage.getElementsByClassName("iceEditor-inputWidth")[0],a=t.insertImage.getElementsByClassName("iceEditor-inputHeight")[0];t.insertImage.getElementsByClassName("iceEditor-btn")[0].onclick=function(){var e=t.c("img");e.src=o.value,n.value.trim()&&(e.width=n.value.trim()),a.value.trim()&&(e.height=a.value.trim()),t.setHTML(e),i.style.display="none",t.pd()},t.id(t.imgUploadId).onchange=function(){if(!t.uploadUrl)return alert("请配置uploadUrl项");for(var e=new FormData,o=0;o
    URL:
    确定
    '},success:function(e,t){t.video=t.id(t.videoId);var i=t.video.getElementsByClassName("iceEditor-popup")[0],o=t.video.getElementsByClassName("iceEditor-videoUrl")[0],n=t.video.getElementsByClassName("iceEditor-inputWidth")[0],a=t.video.getElementsByClassName("iceEditor-inputHeight")[0];t.video.getElementsByClassName("iceEditor-btn")[0].onclick=function(){if(!o.value.length)return alert("视频地址不能为空");var e=t.c("iframe");e.width=n.value.length?n.value:510,e.height=a.value.length?a.value:498,e.setAttribute("frameborder",0),e.setAttribute("allowfullscreen",!0);var l=/^http(s)?:\/\/(.*?)\//.exec(o.value);if(3!=l.length)return alert("URL地址不合法!");if("www.bilibili.com"==l[2]||"bilibili.com"==l[2])r=/video\/(.*?)\?/g.exec(o.value),r||(r=/video\/(.*)/g.exec(o.value)),e.src="https://player.bilibili.com/player.html?bvid="+r[1];else if("v.youku.com"==l[2]){var r=o.value.split(".html");if(!(r.length>1))return alert("优酷:抱歉,无法处理该链接!");if(r=r[0].split("id_"),!(r.length>1&&r[1].length))return alert("优酷:抱歉,无法处理该链接!");e.src="https://player.youku.com/embed/"+r[1]}else"www.ixigua.com"==l[2]?(r=/[0-9]{6,}/g.exec(o.value),e.src="https://www.ixigua.com/iframe/"+r[0]):(e=t.c("video"),e.src=o.value,e.width=n.value.length?n.value:510,e.height=a.value.length?a.value:498,e.controls="controls");t.setHTML(e,!0),i.style.display="none",t.pd()}}}),this.createMenu({title:"最大化",name:"max",icon:"max",data:"max",css:"iceEditor-maxWindow"}),this.createMenu({title:"最小化",name:"min",icon:"min",data:"min",css:"iceEditor-minWindow"}),this.createMenu({name:"disabled",css:"iceEditor-disabledMask"})},ice.editor.prototype.menuFormat=function(){var e=this;this.menuHTML();var t=this.c("ul");t.className="iceEditor-menu",this.tool.innerHTML="",this.tool.appendChild(t);for(var i=0;i/g,"\n");var r=t.getHTML();r=r.replace(/<\/p>

    /gim,"

    \n

    ").replace(/>

    \n\n<"),t.d.body.innerHTML=t.unhtml(r)}else{t.tool.className="iceEditor-tool iceEditor-noselect",n.style.display="none",this.className="iceEditor-exec",t.d.body.className="";var r=t.getHTML();t.d.body.innerHTML=t.html(r);for(var a=t.d.body.getElementsByTagName("pre"),l=0;l")}break;case"max":var s=window.innerHeight;"number"!=typeof s&&("CSS1Compat"==document.compatMode?s=document.documentElement.clientHeight:webWidth=document.body.clientWidth),t.editor.style.position="fixed",t.editor.style.zIndex=t.getTime,t.editor.style.width="100%",t.editor.style.height="100%",t.editor.style.top=0,t.editor.style.left=0,t.iframe.height=s-35-20+"px",this.parentNode.style.display="none",t.tool.getElementsByClassName("iceEditor-minWindow")[0].style.display="block";break;case"min":t.editor.removeAttribute("style"),t.iframe.height=t.height,this.parentNode.style.display="none",t.tool.getElementsByClassName("iceEditor-maxWindow")[0].style.display="block";break;default:var c=this.attr.split("|");t.w.document._useStyleWithCSS||(t.w.document.execCommand("styleWithCSS",null,!0),t.w.document._useStyleWithCSS=!0),c.length>1?t.w.document.execCommand(c[0],!1,c[1]):t.w.document.execCommand(c[0],!1,null)}return!1})},ice.editor.prototype.pasteWord=function(e){function t(e){if(!/(pt|cm)/.test(e))return e;var t;return e.replace(/([\d.]+)(\w+)/,function(e,i,o){i=i,t=o}),(e="cm"==t?25*parseFloat(e):Math.round(96*parseFloat(e)/72))+(e?"px":"")}function i(e){return e.replace(/[\d.]+\w+/g,function(e){return t(e)})}return function(e){return/(class="?Mso|style="[^"]*\bmso\-|w:WordDocument|<(v|o):|lang=)/gi.test(e)}(e)?function(e){return e.replace(//gi,"").replace(//gi,"").replace(//gi,"").replace(/.*?<\/head>/gi,"").replace(/<\/body>/gi,"").replace(/<\/html>/gi,"").replace(/[\t\s]+/gi," ").replace(/.*?<\/xml>/gi,"").replace(/.*?<\/o:p>/gi,"").replace(/]*>\s*<\/span>/gi,"").replace(/<(span|font|p|b|i|u|s)[^>]*>\s*<\/\1>/gi,"").replace(/v:\w+=(["']?)[^'"]+\1/g,"").replace(/]*class="?MsoHeading"?[^>]*>(.*?)<\/p>/gi,"

    $1

    ").replace(/\s+(class|lang|align)\s*=\s*(['"]?)([\w-]+)\2/gi,function(e,t,i,o){return"class"==t&&"MsoListParagraph"==o?e:""}).replace(/<(font|span)[^>]*>(\s*)<\/\1>/gi,function(e,t,i){return i.replace(/[\t\r\n ]+/g," ")}).replace(/(<[a-z][^>]*)\sstyle=(["'])([^\2]*?)\2/gi,function(e,o,n,a){for(var l,r=[],s=a.replace(/^\s+|\s+$/,"").replace(/'/g,"'").replace(/"/gi,"'").replace(/[\d.]+(cm|pt)/g,function(e){return t(e)}).split(/;\s*/g),c=0;l=s[c];c++){var d,p,h=l.split(":");if(2==h.length){if(d=h[0].toLowerCase().trim(),p=h[1].toLowerCase().trim(),/^(background)\w*/.test(d)&&0==p.replace(/(initial|\s)/g,"").length||/^(margin)\w*/.test(d)&&/^0\w+$/.test(p))continue;switch(d){case"mso-vertical-align-alt":/
    /g,"").replace(//g,"").replace(//g,"").replace(/.*?<\/head>/g,"").replace(/<\/body>/g,"").replace(/<\/html>/g,"").replace(/\s+(id|class|lang|align|data|data-\w*)\s*=\s*(['"]?).*?\2/gi,"");for(var t=0;t]*>.*?","gim"),"");var i=this;return e=e.replace(/\s+style\s*=\s*(['"]?)(.*?)\1/g,function(e,t,o){if(o){o=o.replace(/('|")/gi,"'");var n=o.split(";");if(n.length){for(var a=[],l=0;l1&&/rgb\s*\(/gi.test(c[1])?(c[1]=c[1].replace(/rgb\s*\(.*?\)/gi,function(e){return e=e.split(/\D+/),"#"+((1<<24)+(parseInt(e[1])<<16)+(parseInt(e[2])<<8)+parseInt(e[3])).toString(16).slice(1)}),a.push(s+":"+c[1])):a.push(r)}}}return' style="'+a.join(";")+'"'}}return""}),e.replace(/]*)>/g,"").replace(/<\/div>/g,"

    ")},ice.editor.prototype.formatHTML=function(e){ + e=e.replace(/[\t\s]+/g," ").replace(/<(span|font|p|b|i|u|s)[^>]*>(<(?!img)[^>]*>)*<\/\1>/gi,"").replace(/<(.+)\s+>/g,"<$1>").replace(/(){1,}/gi,"
    ");for(var t=0;t","gim"),"\r\n");return e.replace(/\r\n{1,}/gim,"\r\n").trim()},ice.editor.prototype.paste=function(){function e(t){if(!t)return!1;var i=t.nextSibling;return i&&1!=i.nodeType&&(i=e(i)),i}try{this.w.document.execCommand("AutoUrlDetect",!1,!1)}catch(e){}var t=this,i=(this.w,function(e){if(!t.screenshotUpload){var i=t.c("p"),o=t.c("img");return o.src=e,i.appendChild(o),void t.setHTML(i,!0)}var n=function(e){var t;t=e.split(",")[0].indexOf("base64")>=0?atob(e.split(",")[1]):unescape(e.split(",")[1]);for(var i=e.split(",")[0].split(":")[1].split(";")[0],o=new Uint8Array(t.length),n=0;n").replace(/ /g," ").replace(/'/g,"'").replace(/"/g,"'")),t.screenshot&&!t.inNodeParent(t.range.getRangeAt(0).endContainer,"pre")){if(n){var s=n.items&&-1!==n.items[0].type.indexOf("image")?n.items[0].getAsFile():0;if(s){var c=new FileReader;c.onload=function(e){var t=e.target.result;i(t)},c.readAsDataURL(s)}}o()}if(l.length){if(t.code)return void t.setText(a);var d=l.replace(/[\r|\n]+/g,"\n").split("\n");if(t.inNodeParent(t.range.getRangeAt(0).endContainer,"pre")){for(var d=a.replace(/[\r|\n]+/g,"\n").split("\n"),p=0;p"),!0)}if(t.pasteText&&1==d.length)return void t.setText(l);if(t.pasteText||!r)for(var p=0;p"+d[p].trim()+"

    ",!0);else l=t.pasteWord(l),l=t.formatHTML(l),l=t.pasteHTML(l),l=t.formatHTML(l),t.setText(l,!0);if(l=t.getHTML(),t.d.body.innerHTML=l,l=t.getHTML(),l=l.replace(/

    <\/p>/gi,"").replace(/<\/p>
    /gi,"").replace(/<(span|font|p|b|i|u|s)[^>]*>(<(?!img)[^>]*>)*<\/\1>/gi,""),t.d.body.innerHTML=l,t.imgAutoUpload){var l=t.getHTML();l.replace(//gi,function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";!function(e){if("/"!=i.substr(0,1)||"//"==i.substr(0,2)){t.imgDomain=t.imgDomain&&Array.isArray(t.imgDomain)?t.imgDomain:[document.domain],!t.imgDomain.includes(document.domain)&&t.imgDomain.push(document.domain);for(var o=0;o
    ":"
    ",o=t.range.getRangeAt(0);o.insertNode(o.createContextualFragment(a));var l=t.range.anchorNode.nextSibling.nextSibling;o.setStart(l,0),o.setEnd(l,0),o.collapse()}else"PRE"!=t.parentTagName&&"PRE"!=t.range.anchorNode.tagName||t.setText("
    ",!0);return void i.preventDefault()}if(i.ctrlKey||i.metaKey)switch(i.keyCode){case 13:i.preventDefault();break;case 66:case 98:case 73:case 105:case 85:case 117:i.preventDefault()}})},ice.editor.prototype.create=function(){this.cssConfig.styleSheet?this.cssConfig.styleSheet.cssText=this.css:this.cssConfig.innerHTML=this.css,this.menuFormat(),this.menuAction(),this.disableds.style.display=this.disabled?"block":"none"},ice.editor.prototype.getHTML=function(){return this.content.innerHTML},ice.editor.prototype.getText=function(){return this.content.innerText},ice.editor.prototype.getValue=function(){return this.content.innerHTML},ice.editor.prototype.setValue=function(e){this.content.innerHTML=e},ice.editor.prototype.addValue=function(e){this.content.innerHTML+=e},ice.editor.prototype.inputDisabled=function(){this.d.body.designMode="off",this.d.body.contentEditable=!1},ice.editor.prototype.inputEnable=function(){this.d.body.designMode="on",this.d.body.contentEditable=!0},ice.editor.prototype.inputCallback=function(e){var t=this;t.d.body.oninput=function(){e&&e.call(t,t.getHTML(),t.getText())}},ice.editor.css='.iceEditor{color:#353535!important;font-family:"Microsoft YaHei";font-size:14px!important;background:#fff;position:relative;border:solid 1px #ccc}.iceEditor *{margin:0;padding:0;box-sizing:border-box}.iceEditor a{color:#606060;text-decoration:none;-webkit-tap-highlight-color:transparent}.iceEditor a:hover{color:#000}.iceEditor-line{height:20px;width:1px;background:#cecece;margin:8px 8px 0 8px;}.iceEditor-row{margin-bottom:10px;}.iceEditor-group{text-align:left;margin-bottom:10px;}.iceEditor-group label {min-width:50px!important;display:inline-block!important;text-align:right!important;font-weight:normal!important;}.iceEditor input{height:27px!important;line-height:27px!important;padding:3px!important;border:1px solid #B7B7B7!important;font-family:inherit;font-size:inherit;vertical-align:middle;outline:none;display:inline-block!important;}.iceEditor-exec{cursor:pointer}.iceEditor-icon{width:22px;height:16px;fill:currentColor;overflow:hidden;vertical-align:middle;font-size:16px}.iceEditor-noselect{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.iceEditor-menuDropdown{min-width:35px;min-height:35px;transition:all .4s ease;margin-top:60px;opacity:0;visibility:hidden;position:absolute;background:#fff;z-index:999;box-shadow:0 2px 9px 0 rgba(0,0,0,.2);border-bottom:2px solid #676767;border-top:1px solid #676767}.iceEditor-menuDropdown::before{content:"";display:block;width:0;height:0;border-left:8px solid transparent;border-right:8px solid transparent;border-bottom:8px solid #676767;position:absolute;top:-8px;left:9px}.iceEditor-menuTitle{width:100%!important;text-align:center;height:30px;line-height:30px;border-top:1px solid #efefef}.iceEditor-tool{width:100%;background:#eee;border-bottom:solid 1px #ccc;position:relative}.iceEditor-tool:after,.iceEditor-tool:before{display:table;content:" "}.iceEditor-tool:after{clear:both}.iceEditor-menu{width:100%;padding:0 10px;display:inline-block;float:left}.iceEditor-menu a{list-style:none;float:left;min-width:35px;height:35px;padding:0 5px;text-align:center;line-height:35px;cursor:pointer}.iceEditor-menu a:hover{background:#cdcdcd}.iceEditor-menu>li>div.iceEditor-exec{list-style:none;float:left;min-width:35px;height:35px;padding:0 5px;text-align:center;line-height:35px;cursor:pointer}.iceEditor-menu>li>div.iceEditor-exec:hover{background:#cdcdcd}.iceEditor-menu svg{fill:currentColor;overflow:hidden;vertical-align:middle;font-size:16px}.iceEditor-menu .iceEditor-active{background:#e0e0e0;position:relative;z-index:999}.iceEditor-menu .iceEditor-actives,.iceEditor-menu .iceEditor-active-s{background:#d8d8d8;}.iceEditor-menu .iceEditor-disabledMask{background:rgba(238,238,238,0.7);width:100%;height:100%;position:absolute;left:0;top:0;display:none}.iceEditor-menu li{display:inline-block;float:left;line-height:initial;}.iceEditor-menu li .iceEditor-menuDropdown.iceEditor-menuActive{margin-top:44px;opacity:1;visibility:visible}.iceEditor-menu li.iceEditor-minWindow{display:none}.iceEditor-menu li.iceEditor-maxWindow,.iceEditor-menu li.iceEditor-minWindow{float:right}.iceEditor-menu li.iceEditor-maxWindow>div,.iceEditor-menu li.iceEditor-minWindow>div{position:relative;z-index:9}.iceEditor-menu li.iceEditor-maxWindow .iceEditor-icon,.iceEditor-menu li.iceEditor-minWindow .iceEditor-icon{color:#606060}.iceEditor-codeLanguages select{padding:5px 5px;width:120px;outline:none;font-size:15px;margin-top:10px;}.iceEditor input.iceEditor-uploadInput{display:none!important}.iceEditor-uploadBtn{float:none;width:auto;font-size:15px;background:#00b7ee;height:40px;line-height:40px;padding:0 30px;color:#fff;display:inline-block;margin:0 auto 15px auto;cursor:pointer;box-shadow:0 1px 1px rgba(0,0,0,.1)}.iceEditor-uploadBtn:hover{background:#009ccb}.iceEditor-uploadIcon{width:45px;height:45px;color:#bababa;margin:20px 20px 10px}.iceEditor-backColor{width:230px;padding:5px}.iceEditor-backColor span{width:20px;height:20px;padding:0;margin:1px;display:inline-block}.iceEditor-fontSize{width:280px}.iceEditor-fontSize li{width:40px;text-align:center}.iceEditor-fontSize span{width:40px;display:inline-block;padding:10px 0}.iceEditor-fontSize span:hover{background:#eee;color:#4CAF50}.iceEditor-createLink label{display:inline-block;}.iceEditor .iceEditor-link{width:175px!important;}.iceEditor-popup .iceEditor-insertImage{text-align:center}.iceEditor-popup .iceEditor-insertImageUrl{width:220px!important;height:27px;outline:0;margin-right:15px}.iceEditor-popup .iceEditor-inputWidth{width:50px!important;height:27px;outline:0;margin-right:15px}.iceEditor-popup .iceEditor-inputHeight{width:50px!important;height:27px;outline:0}.iceEditor-popup .iceEditor-btn{width:auto;display:inline-block;float:none;color:#fff!important;height:27px;line-height:25px;padding:0 10px;background:#939393;vertical-align:middle;margin-left:5px;border:1px solid #7b7b7b}.iceEditor-popup .iceEditor-btn:hover{background:#7b7b7b!important;color:#fff}.iceEditor-tableBox{position:relative;width:190px;height:214px;padding:5px;overflow:hidden}.iceEditor-tableBgOn{position:absolute!important;top:5px;left:5px;z-index:4;width:18px;height:18px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASAgMAAAAroGbEAAAACVBMVEUAAIjd6vvD2f9LKLW+AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfYAR0BKwNDEVT0AAAAG0lEQVQI12NgAAOtVatWMTCohoaGUY+EmIkEAEruEzK2J7tvAAAAAElFTkSuQmCC) repeat}.iceEditor-tableBgOff{width:180px;height:180px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASAgMAAAAroGbEAAAACVBMVEUAAIj4+Pjp6ekKlAqjAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfYAR0BKhmnaJzPAAAAG0lEQVQI12NgAAOtVatWMTCohoaGUY+EmIkEAEruEzK2J7tvAAAAAElFTkSuQmCC) repeat}.iceEditor-tableNum{height:30px;line-height:30px;text-align:center;color:#757575}.iceEditor-video{text-align:left}.iceEditor-video label{margin-right:20px;display:inline-block}.iceEditor-video input{margin-right:5px}.iceEditor-video div{height:27px;margin-bottom:10px}.iceEditor-popup .iceEditor-videoUrl{width:255px!important;height:27px;outline:0;margin-right:0}.iceEditor-content{width:100%;height:100%;padding:20px;position:relative}.iceEditor-content:focus{outline:0}.iceEditor-dragBg{position:absolute;width:100%;height:100%;top:0;left:0;z-index:1;display:none;}.iceEditor-drag{color:#757575;background:#eee;text-align:center;height:12px;line-height:0;cursor:n-resize}.iceEditor-disabled{position:absolute;width:100%;height:100%;top:0;left:0;background:rgba(191,191,191,.79);z-index:99999;display:none}.iceEditor-popup{display:none}.iceEditor-popupMain{width:400px;height:200px;position:fixed;margin:auto;top:0;bottom:0;left:0;right:0;background:#fff;box-shadow:0 1px 1px rgba(0,0,0,.12);z-index:9999;animation-name:iceEditorPopup;animation-duration:.5s}.iceEditor-popupBox{width:100%;height:100%;position:fixed;top:0;left:0;background:rgba(0,0,0,.33);opacity:.5;filter:alpha(opacity=50);z-index:1}.iceEditor-popupTitle{width:100%;height:30px;line-height:30px;background:#2f2f2f;padding:0 10px;color:#fff}.iceEditor-popupTitle span{display:inline-block;vertical-align:middle}.iceEditor-popupTitle::before{content:"";display:inline-block;width:10px;height:10px;border-radius:10px;background:#c7f98c;vertical-align:middle;margin-right:8px}.iceEditor-popupClose{float:right;padding:0 10px;color:#fff;font-size:18px;cursor:pointer}.iceEditor-popupClose:hover{color:#8fe5ff}.iceEditor-popupContent{width:100%;padding:10px;color:#000;overflow:auto;float:left}.iceEditor-popupBtn{width:100%;border:0;color:#fff;background:#03A9F4;border-top:1px solid #efefef;padding:0 20px;margin:0;height:35px;text-align:center;line-height:35px;cursor:pointer;margin-top:20px;outline:0}.iceEditor-popupBtn:hover{color:#151515;background:#efefef}@keyframes iceEditorPopup{0%{top:-100px;opacity:0}to{top:0;opacity:1}}', + ice.editor.svg='',function(){var e,t,i=document.createElement("style"),o=document.body;i.type="text/css",i.styleSheet?i.styleSheet.cssText=ice.editor.css:i.innerHTML=ice.editor.css,document.getElementsByTagName("head")[0].appendChild(i),e=document.createElement("div"),e.innerHTML=ice.editor.css+ice.editor.svg,ice.editor.svg=null,(t=e.getElementsByTagName("svg")[0])&&(t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.width=0,t.style.height=0,t.style.overflow="hidden",o.firstChild?o.firstChild.parentNode.insertBefore(t,o.firstChild):o.appendChild(t))}(); \ No newline at end of file diff --git a/template/app_doc/editor/tpl_editor_ice.html b/template/app_doc/editor/tpl_editor_ice.html index f1c6fa1..c8334f4 100644 --- a/template/app_doc/editor/tpl_editor_ice.html +++ b/template/app_doc/editor/tpl_editor_ice.html @@ -94,6 +94,7 @@ //'files', //ice内置多文件上传,需要配合修改js才能用 ] editor.uploadUrl="{% url 'upload_ice_img' %}"; //粘贴上传请求路径 + editor.imgAutoUpload=true; editor.create(); autoCacheDoc(); \ No newline at end of file