diff --git a/assets/article/article-editor.min.js b/assets/article/article-editor.min.js index 1742552..425629a 100644 --- a/assets/article/article-editor.min.js +++ b/assets/article/article-editor.min.js @@ -1 +1 @@ -if(void 0===CodeMirror)var CodeMirror=void 0;!function(){var s={settings:{},post:function(t){return new i("post",t)},get:function(t){return new i("get",t)},request:function(t,e){return new i(t,e)}},i=function(t,e){var i={method:t,url:"",before:function(){},success:function(){},error:function(){},data:!1,async:!0,headers:{}};this.p=this.extend(i,e),this.p=this.extend(this.p,s.settings),this.p.method=this.p.method.toUpperCase(),this.prepareData(),this.xhr=new XMLHttpRequest,this.xhr.open(this.p.method,this.p.url,this.p.async),this.setHeaders(),!1!==("function"!=typeof this.p.before||this.p.before(this.xhr))&&this.send()};i.prototype={extend:function(t,e){if(e)for(var i in e)t[i]=e[i];return t},prepareData:function(){if(-1===["POST","PUT"].indexOf(this.p.method)||this.isFormData()||(this.p.headers["Content-Type"]="application/x-www-form-urlencoded"),"object"!=typeof this.p.data||this.isFormData()||(this.p.data=this.toParams(this.p.data)),"GET"===this.p.method){var t=-1!==this.p.url.search(/\?/)?"&":"?";this.p.url=this.p.data?this.p.url+t+this.p.data:this.p.url}},setHeaders:function(){for(var t in this.xhr.setRequestHeader("X-Requested-With",this.p.headers["X-Requested-With"]||"XMLHttpRequest"),this.p.headers)this.xhr.setRequestHeader(t,this.p.headers[t])},isFormData:function(){return void 0!==window.FormData&&this.p.data instanceof window.FormData},isComplete:function(){return!(this.xhr.status<200||300<=this.xhr.status&&304!==this.xhr.status)},send:function(){this.p.async?(this.xhr.onload=this.loaded.bind(this),this.xhr.send(this.p.data)):(this.xhr.send(this.p.data),this.loaded.call(this))},loaded:function(){var t;this.isComplete()?(t=this.parseResponse(),"function"==typeof this.p.success&&this.p.success(t,this.xhr)):(t=this.parseResponse(),"function"==typeof this.p.error&&this.p.error(t,this.xhr,this.xhr.status))},parseResponse:function(){var t=this.xhr.response,e=this.parseJson(t);return e||t},parseJson:function(t){try{var e=JSON.parse(t);if(e&&"object"==typeof e)return e}catch(t){return!1}return!1},toParams:function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")}};function r(t,e){return this.parse(t,e)}var a=[0],n="data"+(new Date).getTime();r.ready=function(t){document.addEventListener("DOMContentLoaded",t)},r.prototype={get length(){return this.nodes.length},parse:function(t,e){var i;if(t){if(t instanceof r)return this.nodes=t.nodes,t;i=/^\s*<(\w+|!)[^>]*>/.test(t)?this.create(t):"string"!=typeof t?t.nodeType&&11===t.nodeType?t.childNodes:t.nodeType||this._isWindowNode(t)?[t]:t:this._query(t,e)}else i=[];this.nodes=this._slice(i)},create:function(t){if(/^<(\w+)\s*\/?>(?:<\/\1>|)$/.test(t))return[document.createElement(RegExp.$1)];var e=[],i=document.createElement("div");i.innerHTML=t;for(var s=0,a=i.childNodes.length;s"},selection:{multiple:!0},control:!0,source:!0,image:{states:!0,upload:!1,url:!0,select:!1,name:"file",data:!1,drop:!0,multiple:!0,clipboard:!0,types:["image/*"],tag:"figure",newtab:!1,link:!0,width:!1},classes:!1,codemirrorSrc:!1,codemirror:!1,state:{limit:100},path:{title:"## editor.title ##",sticky:!0,stickyMinHeight:200,stickyTopOffset:0},autosave:{url:!1,name:!1,data:!1,method:"post"},paste:{clean:!0,autoparse:!0,paragraphize:!0,plaintext:!1,linkTarget:!1,images:!0,links:!0,keepStyle:[],keepClass:[],keepAttrs:["td","th"],formTags:["form","input","button","select","textarea","legend","fieldset"],blockTags:["pre","div","h1","h2","h3","h4","h5","h6","table","tbody","thead","tfoot","th","tr","td","ul","ol","li","blockquote","p","hr","figure","iframe","figcaption","address","section","header","footer","aside","article","audio","source"],inlineTags:["a","svg","img","br","strong","ins","code","del","span","samp","kbd","sup","sub","mark","var","cite","small","b","u","em","i","abbr"]},clean:{comments:!1,enter:!0,enterinline:!1},tab:{key:!0,spaces:!1},topbar:{undoredo:!1,shortcuts:!0},toolbar:{hide:[],sticky:!0,stickyMinHeight:200,stickyTopOffset:0},buttons:{editor:["add","template","mobile","html"],topbar:["undo","redo","shortcut"],toolbar:!1,tags:{b:["bold"],strong:["bold"],i:["italic"],em:["italic"],del:["deleted"],u:["underline"],a:["link"]},types:!1,icons:!1,hidden:{}},card:{classname:"card",template:'

Card title

Card body

'},text:{classname:"arx-text"},noneditable:{classname:"noneditable"},embed:{responsive:"embed-responsive",script:!0,checkbox:!1},code:{template:"
",spaces:4},line:!0,layer:{template:"
"},table:{template:"
"},quote:{template:"

Quote...

Author Attribution

"},snippets:!1,templates:!1,grid:{classname:"grid",classes:"",overlay:!0,offset:{left:0,right:0},columns:12,gutter:"1.25rem",patterns:{"6|6":"column column-6|column column-6","4|4|4":"column column-4|column column-4|column column-4","3|3|3|3":"column column-3|column column-3|column column-3|column column-3","2|2|2|2|2|2":"column column-2|column column-2|column column-2|column column-2|column column-2|column column-2","3|6|3":"column column-3|column column-6|column column-3","2|8|2":"column column-2|column column-8|column column-2","5|7":"column column-5|column column-7","7|5":"column column-7|column column-5","4|8":"column column-4|column column-8","8|4":"column column-8|column column-4","3|9":"column column-3|column column-9","9|3":"column column-9|column column-3","2|10":"column column-2|column column-10","10|2":"column column-10|column column-2",12:"column column-12"}},link:{size:30,nofollow:!1,target:!1},addbar:["paragraph","image","embed","line","table","snippet","quote","code","grid","layer"],addbarAdd:[],addbarHide:[],format:["p","h1","h2","h3","ul","ol"],formatAdd:!1,outset:{none:"none",left:"outset-left",both:"outset-both",right:"outset-right"},align:{left:"align-left",center:"align-center",right:"align-right",justify:"align-justify"},valign:{none:"none",top:"valign-top",middle:"valign-middle",bottom:"valign-bottom"},shortcutsRemove:!1,shortcutsBase:{"meta+z":"## shortcuts.meta-z ##","meta+shift+z":"## shortcuts.meta-shift-z ##","meta+a":"## shortcuts.meta-a ##","meta+shift+a":"## shortcuts.meta-shift-a ##","meta+click":"## shortcuts.meta-click ##"},shortcuts:{"ctrl+shift+d, meta+shift+d":{title:"## shortcuts.meta-shift-d ##",name:"meta+shift+d",command:"block.duplicate"},"ctrl+shift+up, meta+shift+up":{title:"## shortcuts.meta-shift-up ##",name:"meta+shift+↑",command:"block.moveUp"},"ctrl+shift+down, meta+shift+down":{title:"## shortcuts.meta-shift-down ##",name:"meta+shift+↓",command:"block.moveDown"},"ctrl+shift+m, meta+shift+m":{title:"## shortcuts.meta-shift-m ##",name:"meta+shift+m",command:"inline.removeFormat"},"ctrl+b, meta+b":{title:"## shortcuts.meta-b ##",name:"meta+b",command:"inline.set",params:{tag:"b"}},"ctrl+i, meta+i":{title:"## shortcuts.meta-i ##",name:"meta+i",command:"inline.set",params:{tag:"i"}},"ctrl+u, meta+u":{title:"## shortcuts.meta-u ##",name:"meta+u",command:"inline.set",params:{tag:"u"}},"ctrl+h, meta+h":{title:"## shortcuts.meta-h ##",name:"meta+h",command:"inline.set",params:{tag:"sup"}},"ctrl+l, meta+l":{title:"## shortcuts.meta-l ##",name:"meta+l",command:"inline.set",params:{tag:"sub"}},"ctrl+alt+0, meta+alt+0":{title:"## shortcuts.meta-alt-0 ##",name:"meta+alt+0",command:"block.format",params:{tag:"p"}},"ctrl+alt+1, meta+alt+1":{title:"## shortcuts.meta-alt-1 ##",name:"meta+alt+1",command:"block.format",params:{tag:"h1"}},"ctrl+alt+2, meta+alt+2":{title:"## shortcuts.meta-alt-2 ##",name:"meta+alt+2",command:"block.format",params:{tag:"h2"}},"ctrl+alt+3, meta+alt+3":{title:"## shortcuts.meta-alt-3 ##",name:"meta+alt+3",command:"block.format",params:{tag:"h3"}},"ctrl+alt+4, meta+alt+4":{title:"## shortcuts.meta-alt-4 ##",name:"meta+alt+4",command:"block.format",params:{tag:"h4"}},"ctrl+alt+5, meta+alt+5":{title:"## shortcuts.meta-alt-5 ##",name:"meta+alt+5",command:"block.format",params:{tag:"h5"}},"ctrl+alt+6, meta+alt+6":{title:"## shortcuts.meta-alt-6 ##",name:"meta+alt+6",command:"block.format",params:{tag:"h6"}},"ctrl+shift+7, meta+shift+7":{title:"## shortcuts.meta-shift-7 ##",name:"meta+shift+7",command:"block.format",params:{tag:"ol"}},"ctrl+shift+8, meta+shift+8":{title:"## shortcuts.meta-shift-8 ##",name:"meta+shift+8",command:"block.format",params:{tag:"ul"}},"ctrl+], meta+]":{title:"## shortcuts.meta-indent ##",name:"meta+]",command:"list.indent"},"ctrl+[, meta+[":{title:"## shortcuts.meta-outdent ##",name:"meta+[",command:"list.outdent"},"ctrl+k, meta+k":{title:"## shortcuts.meta-k ##",name:"meta+k",command:"link.format"}},disableMode:!1,markerChar:"\ufeff",containers:{main:["bars","editor","source","statusbar"],bars:["pathbar","toolbar"]},tags:{denied:["font","html","head","link","title","body","meta","applet","marquee"],incode:["!DOCTYPE","!doctype","html","head","link","title","body","meta","textarea","style"],form:["form","input","button","select","textarea","legend","fieldset"],inline:["a","svg","span","strong","strike","b","u","em","i","code","del","ins","samp","kbd","sup","sub","mark","var","cite","small","abbr"],block:["pre","hr","ul","ol","li","p","h1","h2","h3","h4","h5","h6","dl","dt","dd","div","table","tbody","thead","tfoot","tr","th","td","blockquote","output","figcaption","figure","address","main","section","header","footer","aside","article","iframe","audio","source"],parser:["pre","hr","ul","ol","dl","p","h1","h2","h3","h4","h5","h6","div","table","address","blockquote","figure","main","section","header","footer","aside","article","iframe"]},bsmodal:!1,regex:{youtube:/^https?\:\/\/(?:www\.youtube(?:\-nocookie)?\.com\/|m\.youtube\.com\/|youtube\.com\/)?(?:ytscreeningroom\?vi?=|youtu\.be\/|vi?\/|user\/.+\/u\/\w{1,2}\/|embed\/|watch\?(?:.*\&)?vi?=|\&vi?=|\?(?:.*\&)?vi?=)([^#\&\?\n\/<>"']*)/gi,vimeo:/(http|https)?:\/\/(?:www.|player.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:\/[a-zA-Z0-9_-]+)?/gi,imageurl:/((https?|www)[^\s]+\.)(jpe?g|png|gif)(\?[^\s-]+)?/gi,url:/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z\u00F0-\u02AF0-9()!@:%_+.~#?&//=]*)/gi,aurl1:/(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim,aurl2:/(^|[^\/])(www\.[\S]+(\b|$))/gim},addbarExtend:{},buttonsObj:{undo:{title:"## buttons.undo ##",command:"buffer.undo"},redo:{title:"## buttons.redo ##",command:"buffer.redo"},shortcut:{title:"## buttons.shortcuts ##",observer:"shortcut.observe",command:"shortcut.popup"},template:{title:"## buttons.templates ##",command:"template.popup",observer:"template.observe"},mobile:{title:"## buttons.mobile-view ##",command:"editor.toggleView"},html:{title:"## buttons.html ##",command:"source.toggle"},paragraph:{title:"## blocks.paragraph ##",command:"block.add"},image:{title:"## blocks.image ##",command:"image.popup",observer:"image.observe"},embed:{title:"## blocks.embed ##",command:"embed.popup",observer:"embed.observe"},line:{title:"## blocks.line ##",command:"block.add",observer:"block.observe"},table:{title:"## blocks.table ##",command:"table.add",observer:"table.observe"},snippet:{title:"## blocks.snippet ##",command:"snippet.popup",observer:"snippet.observe"},quote:{title:"## blocks.quote ##",command:"block.add",observer:"block.observe"},text:{title:"## blocks.text ##",command:"block.add"},code:{title:"## blocks.code ##",command:"block.add",observer:"block.observe"},grid:{title:"## blocks.grid ##",command:"grid.popup",observer:"grid.observe"},layer:{title:"## blocks.layer ##",command:"block.add",observer:"block.observe"},card:{title:"## blocks.card ##",command:"block.add"},trash:{title:"## buttons.delete ##",command:"block.remove"}},nested:[],parser:{},parserTags:[],formatObj:{p:{title:"## blocks.paragraph ##",type:"paragraph",shortcut:"Ctrl+Alt+0"},div:{title:"## blocks.text ##",type:"text"},h1:{title:'## headings.h1 ##',type:"heading",shortcut:"Ctrl+Alt+1"},h2:{title:'## headings.h2 ##',type:"heading",shortcut:"Ctrl+Alt+2"},h3:{title:'## headings.h3 ##',type:"heading",shortcut:"Ctrl+Alt+3"},h4:{title:'## headings.h4 ##',type:"heading",shortcut:"Ctrl+Alt+4"},h5:{title:'## headings.h5 ##',type:"heading",shortcut:"Ctrl+Alt+5"},h6:{title:'## headings.h6 ##',type:"heading",shortcut:"Ctrl+Alt+6"},ol:{title:"1. ## list.ordered-list ##",type:"list",shortcut:"Ctrl+Shift+7"},ul:{title:"• ## list.unordered-list ##",type:"list",shortcut:"Ctrl+Shift+8"},dl:{title:"## blocks.dlist ##",type:"dlist"},address:{title:"## blocks.address ##",type:"address"}}},t.lang.en={accessibility:{"help-label":"Rich text editor"},editor:{title:"Article",multiple:"Multiple"},placeholders:{figcaption:"Type caption (optional)",text:"Type something...",code:"Edit to add code...",layer:"Press enter to add a new text..."},popup:{link:"Link",add:"Add",grid:"Grid",back:"Back",image:"Image",snippets:"Snippets","add-image":"Add Image"},shortcuts:{"meta-a":"Select text in the block","meta-shift-a":"Select all blocks","meta-click":"Select multiple blocks","meta-z":"Undo","meta-shift-z":"Redo","meta-shift-m":"Remove inline format","meta-b":"Bold","meta-i":"Italic","meta-u":"Underline","meta-h":"Superscript","meta-l":"Subscript","meta-k":"Link","meta-alt-0":"Normal text","meta-alt-1":"Heading 1","meta-alt-2":"Heading 2","meta-alt-3":"Heading 3","meta-alt-4":"Heading 4","meta-alt-5":"Heading 5","meta-alt-6":"Heading 6","meta-shift-7":"Ordered List","meta-shift-8":"Unordered List","meta-indent":"Indent","meta-outdent":"Outdent","meta-shift-backspace":"Delete block","meta-shift-d":"Duplicate block","meta-shift-up":"Move line up","meta-shift-down":"Move line down"},headings:{h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6"},inline:{bold:"Bold",italic:"Italic",deleted:"Deleted"},list:{"unordered-list":"Unordered List","ordered-list":"Ordered List",indent:"Indent",outdent:"Outdent"},link:{link:"Link","edit-link":"Edit link",unlink:"Unlink","link-in-new-tab":"Open link in new tab",save:"Save",insert:"Insert",cancel:"Cancel",text:"Text",url:"URL"},table:{width:"Width",nowrap:"Nowrap",save:"Save",cancel:"Cancel","table-cell":"Table Cell","add-head":"Add head","remove-head":"Remove head","add-row-below":"Add row below","add-row-above":"Add row above","remove-row":"Remove row","add-column-after":"Add column after","add-column-before":"Add column before","remove-column":"Remove column"},image:{or:"or","alt-text":"Alt Text",save:"Save",link:"Link",width:"Width",delete:"Delete",cancel:"Cancel",insert:"Insert",caption:"Caption","link-in-new-tab":"Open link in new tab","url-placeholder":"Paste url of image...","upload-new-placeholder":"Drag to upload a new image
or click to select"},code:{code:"Code",insert:"Insert",save:"Save",cancel:"Cancel"},embed:{embed:"Embed",caption:"Caption",insert:"Insert",save:"Save",cancel:"Cancel",description:"Paste any embed/html code or enter the url (vimeo or youtube video only)","responsive-video":"Responsive video"},upload:{placeholder:"Drag to upload
or click to select"},templates:{templates:"Templates"},snippets:{snippets:"Snippets"},form:{link:"Link",url:"Url",text:"Text",name:"Name","alt-text":"Alt Text",image:"Image",upload:"Upload",alignment:"Alignment",outset:"Outset",valign:"Valign"},buttons:{"mobile-view":"Mobile View",cancel:"Cancel",insert:"Insert",unlink:"Unlink",save:"Save",add:"Add","transform-to-text":"Transform to text",align:"Alignment",valign:"Valign",outset:"Outset",indent:"Indent",outdent:"Outdent",head:"Head",row:"Row",cell:"Cell",html:"HTML",templates:"Templates",shortcuts:"Keyboard Shortcuts",format:"Format",bold:"Bold",italic:"Italic",deleted:"Deleted",underline:"Underline",table:"Table",link:"Link",undo:"Undo",redo:"Redo",style:"Style",config:"Config",settings:"Settings",text:"Text",embed:"Embed",grid:"Grid",image:"Image",list:"List",delete:"Delete",duplicate:"Duplicate",sort:"Sort",edit:"Edit",inline:"Inline"},blocks:{noneditable:"Noneditable",paragraph:"Paragraph",heading:"Heading",image:"Image",figcaption:"Figcaption",embed:"Embed",line:"Line",code:"Code",quote:"Quote",quoteitem:"Paragraph",snippet:"Snippet",column:"Column",grid:"Grid",list:"List",table:"Table",layer:"Layer",row:"Row",text:"Text",cell:"Cell",dlist:"Definition List",address:"Address",form:"Form",card:"Card"}};var p=function(t,e,i){for(var s=["keycodes","prefix","dom","ajax","_repository","_subscribe"],a=0;a")).attr("data-placeholder",this.lang.get("placeholders.figcaption")),this.$block.append(e),this.app.create("block.figcaption",e)),e.html(t)}},setClassFromObj:function(t,e){this._removeObjClasses(t);var i=t[e];"none"===i&&!1===i||this.$block.addClass(i)},hasClass:function(t){t="string"==typeof t?[t]:t;for(var e=0;e/gi,"
")).replace(/<(ul|ol)/gi,"
<$1"),e=(e=(e=this.app.content.removeTags(e,["ul","ol","li"])).trim()).replace(/$/gi,""),i.remove(),e},_move:function(t,e){this.isEditable()&&this.app.selection.save(this.$block),t.getBlock()[e](this.$block,!0),this.app.block.set(this.$block,!1,!0),this.isEditable()&&this.app.selection.restore(this.$block)},_build:function(t){this.isEmptiable()&&this.isEmpty()&&this._addEmptyButton(this.$block),this.build&&this.build(t),this._buildInstancesInside(this.$block)},_buildData:function(){this.data||(this.data={}),this.data=d.extend({},!0,this.defaults,this.data)},_buildInstancesInside:function(t){t.find("[data-"+this.prefix+"-type]").each(this._buildInstanceInside.bind(this))},_buildInstanceInside:function(t){if(!t.dataget("instance")){var e=t.attr("data-"+this.prefix+"-type");this.app.create("block."+e,t)}},_buildItems:function(t,e){var i=this.$block.find(t);0!==i.length&&i.each(function(t){this.app.create("block."+e,t)}.bind(this))},_buildCaption:function(){"figure"===this.getTag()&&this.$block.find("figcaption").attr("data-placeholder",this.lang.get("placeholders.figcaption"))},_isEmpty:function(){var t=this.$block.text();return""===(t=this._cleanEmpty(t))},_getNameByTag:function(){var t=this.getTag();return this.app.utils.capitalize(t)},_render:function(){this._renderEdit(),this._renderDraggable(),this._renderEditable()},_renderDraggable:function(){void 0!==this.draggable&&!1===this.draggable&&(this.$block.on("dragstart",function(t){return t.preventDefault(),!1}),this.$block.find("img").on("dragstart",function(t){return t.preventDefault(),!1}))},_renderEditable:function(){this.isEditable()?this.$block.attr("contenteditable",!0):void 0!==this.editable&&!1===this.editable&&this.$block.attr("contenteditable",!1),this.isEditable()&&!this.opts.editor.grammarly&&this.$block.attr("data-gramm_editor",!1)},_renderEdit:function(){this.$block.dataset("instance",this),this.$block.attr("data-"+this.prefix+"-type",this.getType())},_cleanEmpty:function(t){return t=(t=-1!==(t=this.app.utils.removeInvisibleChars(t)).search(/^$/)?"":t).replace(/\n/g,"")},_removeObjClasses:function(t){var e=this._buildObjClasses(t);this.$block.removeClass(e.join(" ")),this.app.element.removeEmptyAttrs(this.$block,["class"])},_buildObjClasses:function(t){var e=[];for(var i in t)t[i]&&e.push(t[i]);return e},_addEmptyButton:function(t){if(!t.hasClass(this.prefix+"-empty-layer")){t.addClass(this.prefix+"-empty-layer");var e=this.dom("").addClass(this.prefix+"-plus-button");this.app.create("button",{name:"plus",element:e},{command:"addbar.popup"}),t.append(e)}}}),t.add("mixin","tool",{init:function(t,e,i,s){this.name=t,this.setter=i.get("setter"),this.popup=i,this.data=s,this.obj=this._observe(e),this.obj&&this._build()},getElement:function(){return this.$tool},getInput:function(){return this.$input},getValue:function(){return this.$input.val().trim()},setValue:function(t){this.$input.val(t)},setFocus:function(){this.$input.focus()},trigger:function(t){this.setValue(t),this.setter&&this.app.api(this.setter,this.popup)},_build:function(){this._buildTool(),this._buildLabel(),this._buildInputElement(),this._buildInput(),this._buildEvent(),this._has("placeholder")&&this.$input.attr("placeholder",this.lang.parse(this.obj.placeholder)),this._has("width")&&this.$input.css("width",this.obj.width),this._has("classname")&&this.$input.addClass(this.obj.classname)},_buildInputElement:function(){this.$input=this.dom("<"+this._getInputParam("tag")+">").addClass(this.prefix+this._getInputParam("classname")),this.$input.attr({name:this.name,type:this._getInputParam("type"),"data-type":this.type}),this.$input.dataset("instance",this)},_buildInput:function(){},_buildEvent:function(){if(-1===["segment"].indexOf(this.type)&&this.setter){var t="checkbox"===this.type||"select"===this.type?"change":"keydown blur";t="number"===this.type?t+" change":t,this.$input.on(t,this._catchSetter.bind(this))}},_buildTool:function(){this.$tool=this.dom("
").addClass(this.prefix+"-form-item").dataset("instance",this)},_buildLabel:function(){"checkbox"!==this.type&&this._has("label")&&(this.$label=this.dom("
")).replace(/<\/?br\s?\/?><\/li>/gi,"")},_storeTags:function(t,i){return this.app.utils.wrap(t,function(t){t.find(this.tags.join(", ")).each(function(t,e){this._replaceTag(t,e,i)}.bind(this))}.bind(this))},_restoreTags:function(t,e){for(var i=0;i]*>/.test(a)||this.isTextNode(a):"list"===e?s=this._isElement(a)&&-1!==["ul","ol"].indexOf(a.tagName.toLowerCase()):"heading"===e&&(s=this._isElement(a)&&-1!==["h1","h2","h3","h4","h5","h6"].indexOf(a.tagName.toLowerCase())),s},isEmptyOrImageInline:function(t){var e=this.dom(t).get();if(!e||3===e.nodeType)return!1;var i=e.tagName.toLowerCase(),s="false"===e.getAttribute("contenteditable"),a=this.is(e,"inline");return!!(a&&this.isEmpty(e)||a&&s||-1!==["svg","img"].indexOf(i))},isEmpty:function(t){var e=this._getNode(t);return!!e&&(3===e.nodeType?""===e.textContent.trim().replace(/\n/,""):""===e.innerHTML)},isTag:function(t,e){return this._getNode(t).tagName.toLowerCase()===e},isTextNode:function(t){var e=this._getNode(t);return e&&e.nodeType&&3===e.nodeType},isVisible:function(t){var e=this._getNode(t);return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},isScrollVisible:function(t){var e=this.app.scroll.getTarget(),i=this.dom(t),s=e.scrollTop()+e.height();return i.offset().top<=s},getFirstLevel:function(t){return this.dom(t).closest("[data-"+this.prefix+"-first-level]")},getDataBlock:function(t){return this.dom(t).closest("[data-"+this.prefix+"-type]")},getType:function(t){return this.dom(t).attr("data-"+this.prefix+"-type")},getAllInlines:function(t){for(var e=[],i=t;i;)this.is(i,"inline")&&e.push(i),i=i.parentNode;return e},getClosest:function(t,e){return this.dom(t).closest(this.getTypesSelector(e))},getParents:function(t,e){return this.dom(t).parents(this.getTypesSelector(e))},getChildren:function(t,e){return this.dom(t).find(this.getTypesSelector(e))},getTypesSelector:function(t){return"[data-"+this.prefix+"-type="+t.join("],[data-"+this.prefix+"-type=")+"]"},hasClass:function(t,e){e="string"==typeof e?[e]:e;for(var i=this.dom(t),s=e.length,a=0,n=0;n");if(n||e.append(t.innerHTML),t.attributes)for(var i=t.attributes,s=0;s");(a=this.cloneAttrs(t,a)).append(s),e.after(a);var n=e.children().last();if(this.is(n,"inline")){var o=n.html();""===(o=this.app.utils.removeInvisibleChars(o))&&n.remove()}var r=this.getType(a);return r&&this.app.create("block."+r,a,!0),""===e.html()&&e.remove(),a},cloneEmpty:function(t){var e=this.dom(t).get().tagName.toLowerCase();return this.dom("<"+e+">")},cloneAttrs:function(t,e){for(var i=this.dom(e),s=this._getNode(t).attributes,a=s.length;a--;){var n=s[a];i.attr(n.name,n.value)}return i},getAttrs:function(t){var e=this._getNode(t),i={};if(null!=e.attributes&&e.attributes.length)for(var s=0;s'),this.$button.addClass(this.prefix+"-button "+this.prefix+"-button-target"),this.type&&this.$button.addClass(this.prefix+"-button-"+this.type),this._has("classname")&&this.$button.addClass(this.obj.classname)},_buildIcon:function(){var t=this._has("icon"),e='';this.$icon=this._buildIconElement(),t&&!0!==this.obj.icon&&(e=-1!==this.obj.icon.search(/
'),this.opts.buttons.icons&&void 0!==this.opts.buttons.icons[this.name]&&(e=this.opts.buttons.icons[this.name]),this.$icon.append(e),this.$button.append(this.$icon)},_buildIconElement:function(){return this.dom("").addClass(this.prefix+"-button-icon")},_buildTooltip:function(){("toolbar"===this.type||"context"===this.type&&this.opts.tooltip.context)&&this.app.tooltip.build(this.$button,this.title)},_buildBackground:function(){this._has("background")&&this.setBackground(this.obj.background)},_buildPosition:function(t){if(this._has("position")){var e=this.obj.position;if("first"===e)t.prepend(this.$button);else if("object"==typeof e){var i=Object.prototype.hasOwnProperty.call(e,"after")?"after":"before",s=e[i],a=this._findPositionElement(s,t);a?a[i](this.$button):t.append(this.$button)}}else t.append(this.$button)},_findPositionElement:function(t,e){var i;if(Array.isArray(t))for(var s=0;s").addClass(this.classname).html(t.attr("data-tooltip"))},_cleanTitle:function(t){return!!t&&t.replace(/(<([^>]+)>)/gi,"")},_setPosition:function(t){var e=t.offset(),i=t.height();this.$tooltip.css({top:e.top+i+"px",left:e.left+"px"})},_fixBSModal:function(){this.opts.bsmodal&&this.$tooltip.css("z-index",1060)},_getButton:function(t){return this.dom(t.target).closest("."+this.prefix+"-button-target")}}),t.add("module","fragment",{build:function(t){return this.is(t)?t:this.create(t)},insert:function(t){var e=this.app.selection.get();if(e.range){if(e.collapsed){var i=e.range.startContainer;3!==i.nodeType&&"BR"===i.tagName&&i.parentNode.removeChild(i)}else e.range.deleteContents();t.frag?e.range.insertNode(t.frag):e.range.insertNode(t)}},createContainer:function(t){var e=this.dom("
");return"string"==typeof t?e.html(t):e.append(this.dom(t).clone(!0)),e.get()},create:function(t){for(var e,i,s,a="string"==typeof t?this.createContainer(t):t,n=document.createDocumentFragment(),o=[],r=0;e=a.firstChild;){r++;var l=n.appendChild(e);1===r&&(i=l),o.push(l),s=l}return{frag:n,first:i,last:s,nodes:o}},is:function(t){return"object"==typeof t&&t.frag}}),t.add("module","clipboard",{getContent:function(t){var e=this.isPlainText(t)?"text/plain":"text/html",i=t.getData(e);return"text/plain"==e?this.app.content.escapeHtml(i):i},setContent:function(t,e,i){var s=t.clipboardData;e=this.app.parser.unparse(e),e=''+e,i=i||this.app.content.getTextFromHtml(e,{nl:!0}),s.setData("text/html",e),s.setData("text/plain",i)},isPlainText:function(t){var e=t.getData("text/plain"),i=t.getData("text/html");return(!i||""===i.trim())&&null!==e}}),t.add("module","codemirror",{init:function(){this.cm=!1},create:function(t){if(this.is()){var e="object"==typeof this.opts.codemirror?this.opts.codemirror:{},i=this.opts.codemirrorSrc?this.opts.codemirrorSrc:CodeMirror;return this.cm=i.fromTextArea(this.dom(t.el).get(),e),t.height&&this.cm.setSize(null,t.height),t.focus&&this.cm.focus(),this.cm}},destroy:function(){this.cm&&(this.cm.toTextArea(),this.cm=!1)},is:function(){return this.opts.codemirror},val:function(t){return this.is()&&this.cm&&(t=this.cm.getValue()),t}}),t.add("class","upload",{defaults:{type:"image",box:!1,url:!1,cover:!0,name:"file",data:!1,multiple:!0,placeholder:!1,hidden:!0,target:!1,success:!1,error:!1,remove:!1,trigger:!1,input:!1},init:function(t,e,i){this.eventname=this.prefix+"-upload",t&&this._build(t,e,i)},send:function(t,e,i,s){this.p=this._buildParams(i,s),this._send(t,e)},complete:function(t,e){this._complete(t,e)},setImage:function(t){this.p.input||(this.$image&&this.$image.remove(),this.$remove&&this.$remove.remove(),""===t?this.$placeholder.show():(this.$placeholder.hide(),this._buildImage(t),this.p.remove&&this._buildRemove()))},_build:function(t,e,i){this.p=this._buildParams(e,i),this.$element=this.dom(t),"INPUT"===this.$element.get().tagName?this._buildByInput():this._buildByBox()},_buildImage:function(t){this.$image=this.dom(""),this.$image.attr("src",t),this.$box.append(this.$image),!1===this.p.input&&(this.$box.off("click."+this.eventname),this.$image.on("click."+this.eventname,this._click.bind(this)))},_buildRemove:function(){this.$remove=this.dom(""),this.$remove.addClass(this.prefix+"-upload-remove"),this.$remove.on("click",this._removeImage.bind(this)),this.$box.append(this.$remove)},_buildParams:function(t,e){return t=d.extend(!0,this.defaults,t),e&&(t.trigger=e),t},_buildByInput:function(){this.$input=this.$element,this.p.box?(this._buildBox(),this._buildPlaceholder()):this.p.input=!0,this._buildAccept(),this._buildMultiple(),this._buildEvents()},_buildByBox:function(){this._buildInput(),this._buildAccept(),this._buildMultiple(),this._buildBox(),this._buildPlaceholder(),this._buildEvents()},_buildBox:function(){this.$box=this.dom("
").addClass(this.prefix+"-form-upload-box"),this.$element.before(this.$box),!1===this.p.cover&&this.$box.addClass(this.prefix+"-form-upload-cover-off"),this.p.hidden&&this.$element.hide()},_buildPlaceholder:function(){this.p.placeholder&&(this.$placeholder=this.dom("").addClass(this.prefix+"-form-upload-placeholder"),this.$placeholder.html(this.p.placeholder),this.$box.append(this.$placeholder))},_buildInput:function(){this.$input=this.dom(""),this.$input.attr("type","file"),this.$input.attr("name",this._getUploadParam()),this.$input.hide(),this.$element.before(this.$input)},_buildAccept:function(){if("image"===this.p.type){var t=this.opts.image.types.join(",");this.$input.attr("accept",t)}},_buildMultiple:function(){"image"===this.p.type&&(this.p.multiple?this.$input.attr("multiple","multiple"):this.$input.removeAttr("multiple"))},_buildEvents:function(){this.$input.on("change."+this.eventname+"-"+this.uuid,this._change.bind(this)),!1===this.p.input&&(this.$box.on("click."+this.eventname,this._click.bind(this)),this.$box.on("drop."+this.eventname,this._drop.bind(this)),this.$box.on("dragover."+this.eventname,this._dragover.bind(this)),this.$box.on("dragleave."+this.eventname,this._dragleave.bind(this)))},_buildData:function(t,e,i){if("single"===this.p.multiple)i.append(t,e[0]);else if(this.p.multiple)for(var s=0;s").addClass(this.prefix+"-editor-progress"),this.$progress.attr("id",this.prefix+"-progress"),this.$progressBar=this.dom(""),this.$progress.append(this.$progressBar),this.app.$body.append(this.$progress)},hide:function(){this.app.$body.find("#"+this.prefix+"-progress").remove()}}),t.add("module","autosave",{send:function(){this.opts.autosave.url&&this._sending()},_getName:function(){return this.opts.autosave.name?this.opts.autosave.name:this.app.$element.attr("name")||"content"+this.uuid},_sending:function(){var e=this._getName(),i={};i[e]=this.app.$element.val(),i=this.app.utils.extendData(i,this.opts.autosave.data),this.ajax.request(this.opts.autosave.method,{url:this.opts.autosave.url,data:i,before:function(t){if(this.app.broadcast("autosave.before.send",{xhr:t,name:e,data:i}).isStopped())return!1}.bind(this),success:function(t){this._complete(t,e,i)}.bind(this)})},_complete:function(t,e,i){var s=t&&t.error?"autosave.error":"autosave.send";this.app.broadcast(s,{name:e,data:i,response:t})}}),t.add("module","statusbar",{init:function(){this.classname=this.prefix+"-statusbar"},start:function(){this._build()},add:function(t,e){return this.update(t,e)},update:function(t,e){var i=this.get(t);return 0===i.length&&(i=this._buildItem(t)),i.html(e)},get:function(t){var e=t?"[data-name="+t+"]":"[data-name]";return this.$statusbar.find(e)},remove:function(t){this.get(t).remove()},clear:function(){this.$statusbar.html("")},_build:function(){this.$statusbar=this.dom("
").attr("dir",this.opts.editor.direction),this.$statusbar.addClass(this.classname+" "+this.classname+"-"+this.uuid),this.app.container.get("statusbar").append(this.$statusbar)},_buildItem:function(t){var e=this.dom("").addClass(this.classname+"-item");return e.attr("data-name",t),this.$statusbar.append(e),e}}),t.add("module","shortcut",{init:function(){if(this.opts.shortcutsRemove)for(var t=this.opts.shortcutsRemove,e=0;e","/":"?","\\":"|"}},add:function(t,e){this.shortcuts[t]=e},remove:function(t){this.opts.shortcutsBase=this._remove(t,this.opts.shortcutsBase),this.opts.shortcuts=this._remove(t,this.opts.shortcuts)},popup:function(t,e){var i=/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)?"":"ctrl",s={},a=0;a=this._buildPopupItems(s,a,this.opts.shortcutsBase,i,"base"),this._buildPopupItems(s,a,this.opts.shortcuts,i),this.app.popup.create("shortcuts",{width:"360px",items:s}),this.app.popup.open({button:e})},handle:function(t){if((this.triggered=!1)===this.shortcuts)return!t.ctrlKey&&!t.metaKey||66!==t.which&&73!==t.which||t.preventDefault(),!0;if(t.ctrlKey||t.metaKey||t.shoftKey||t.altKey)for(var e in this.shortcuts)this._build(t,e,this.shortcuts[e]);return this.triggered},_buildPopupItems:function(t,e,i,s,a){for(var n in i){for(var o=this.dom("
").addClass(this.prefix+"-popup-shortcut-item"),r="base"===a?i[n]:i[n].title,l=this.dom("").addClass(this.prefix+"-popup-shortcut-title").html(this.lang.parse(r)),p=this.dom("").addClass(this.prefix+"-popup-shortcut-kbd"),h=("base"===a?n.replace("meta",s):i[n].name.replace("meta",s)).split("+"),c=0;c"+h[c]+"";p.html(h.join("+")),o.append(l),o.append(p),t[e]={html:o},e++}return e},_build:function(t,e,i){for(var s=e.split(","),a=s.length,n=0;n=s&&e.start<=l&&(a.setStart(i,e.start-s),o=!0),o&&e.end>=s&&e.end<=l&&(a.setEnd(i,e.end-s),r=!0),s=l}else for(var p=i.childNodes.length;p--;)n.push(i.childNodes[p]);this.app.selection.setRange(a)},_getEl:function(t){return t?this.dom(t).get():this.app.editor.getLayout().get()}}),t.add("module","marker",{build:function(t){var e=this.dom("").attr("id","selection-marker-"+t);return e.addClass(this.prefix+"-selection-marker"),e.html(this.opts.markerChar),e.get()},insert:function(){this.remove();var t=this.app.selection.get(),e=!t.collapsed;if(t.range){var i=this.build("start"),s=this.build("end"),a=t.range.cloneRange();e&&(a.collapse(!1),a.insertNode(s)),a.setStart(t.range.startContainer,t.range.startOffset),a.collapse(!0),a.insertNode(i),t.range.setStartAfter(i),e&&t.range.setEndBefore(s),this.app.selection.setRange(t.range)}},restore:function(){var t=this.find("start"),e=this.find("end"),i=this.app.selection.get(),s=i.range?i.range:this.app.editor.getDocNode().createRange();if(t){var a=!!e&&e.previousSibling,n=t.nextSibling;n=(!n||3!==n.nodeType||""!==n.textContent.replace(/[\n\t]/g,""))&&n,e?n&&"selection-marker-end"===n.id?this._restoreInject(s,t):a&&n?(s.selectNodeContents(a),s.collapse(!1),s.setStart(n,0)):a&&!n?(s.selectNodeContents(a),s.collapse(!1),s.setStartAfter(t)):(s.setStartAfter(t),s.setEndBefore(e)):n?(s.selectNodeContents(n),s.collapse(!0)):this._restoreInject(s,t),this.app.selection.setRange(s);var o=t&&e?2:1,r=this.app.offset.get();r={start:r.start-o,end:r.end-o},t&&t.parentNode.removeChild(t),e&&e.parentNode.removeChild(e),this.app.editor.setWinFocus(),this.app.offset.set(!1,r)}},find:function(t){var e=this.app.editor.getLayout().find("#selection-marker-"+t);return 0!==e.length&&e.get()},remove:function(){var t=this.find("start"),e=this.find("end");t&&t.parentNode.removeChild(t),e&&e.parentNode.removeChild(e)},_restoreInject:function(t,e){var i=this.app.utils.createInvisibleChar();this.dom(e).after(i),t.selectNodeContents(i),t.collapse(!1)}}),t.add("module","state",{init:function(){this.started=!1,this.storage=!1,this.state=!1,this.passed=!0,this.undoStorage=[],this.redoStorage=[]},load:function(){this.clear(),this.trigger(!0)},stop:function(){this.clear()},clear:function(){this.storage=!1,this.state=!1,this.passed=!0,this.undoStorage=[],this.redoStorage=[]},get:function(){return this.undoStorage},add:function(t){t&&(t.ctrlKey||t.metaKey||this._isUndo(t)||this._isRedo(t))||!this.app.observer.trigger||(this.state=this._createState(),!1===this.started&&(this._setState(this.state,0),this.started=!0))},trigger:function(t){if(this.passed){var e=this._createState();this.state?e=this.state:this.state||t||(e=this.storage,this.started=!0),this._addState(e),this.storage=this._createState(),this.state=!1}},listen:function(t){return this._isUndo(t)?(t.preventDefault(),this.undo(),!0):this._isRedo(t)?(t.preventDefault(),this.redo(),!0):void(this.passed=!0)},undo:function(){if(this._hasUndo()){this.passed=!1;var t=this._getUndo();this._setRedo();var e=this.app.parser.parse(t[0]);this.app.editor.getLayout().html(e.children()),this._rebuild(t,"undo");var i=this.app.block.get(),s=!(!i||!i.isEditable())&&i.getBlock();this.app.offset.set(s,t[1])}},redo:function(){if(this._hasRedo()){this.passed=!1;var t=this.redoStorage.pop();this._addState(t);var e=this.app.parser.parse(t[0]);this.app.editor.getLayout().html(e.children()),this._rebuild(t,"redo");var i=this.app.block.get(),s=!(!i||!i.isEditable())&&i.getBlock();this.app.offset.set(s,t[1])}},_rebuild:function(t,e){this.app.editor.build(),this.app.editor.getLayout().find("."+this.prefix+"-block-state").each(function(t){this.app.block.set(t)}.bind(this)),this.app.broadcast("state."+e,{html:t[0],offset:t[1]})},_isUndo:function(t){var e=t.which;return(t.ctrlKey||t.metaKey)&&90===e&&!t.shiftKey&&!t.altKey},_isRedo:function(t){var e=t.which;return(t.ctrlKey||t.metaKey)&&(90===e&&t.shiftKey||89===e&&!t.shiftKey)&&!t.altKey},_hasUndo:function(){return 0!==this.undoStorage.length},_hasRedo:function(){return 0!==this.redoStorage.length},_getUndo:function(){return 1===this.undoStorage.length?this.undoStorage[0]:this.undoStorage.pop()},_createState:function(){var t=this.app.editor.getLayout().html();t=this.app.utils.wrap(t,function(t){t.find("."+this.prefix+"-block-focus").addClass(this.prefix+"-block-state")}.bind(this));var e=this.app.block.get(),i=!(!e||!e.isEditable())&&e.getBlock();return{html:this.app.parser.unparse(t,!0),offset:this.app.offset.get(i)}},_setState:function(t,e){this.undoStorage[e]=[t.html,t.offset]},_addState:function(t){var e=this.undoStorage[this.undoStorage.length-1];void 0===e||e[0]!==t.html?(this.undoStorage.push([t.html,t.offset]),this._removeOverStorage()):e[1]=t.offset},_setRedo:function(){var t=this._createState();this.redoStorage.push([t.html,t.offset]),this.redoStorage=this.redoStorage.slice(0,this.opts.state.limit)},_removeOverStorage:function(){this.undoStorage.length>this.opts.state.limit&&(this.undoStorage=this.undoStorage.slice(0,this.undoStorage.length-this.opts.state.limit))}}),t.add("module","sync",{build:function(){this.syncedHtml=this.app.$element.val()},trigger:function(){this.opts.editor.sync&&(this.typingTimer&&clearTimeout(this.typingTimer),this.typingTimer=setTimeout(function(){var t=this._getHtml();this.is(t)&&this._sync(t)}.bind(this),300))},invoke:function(){var t=this._getHtml();this.syncedHtml=t,this._sync(t)},is:function(t){var e=!1;return this.syncedHtml!==t&&(this.syncedHtml=t,e=!0),e},_getHtml:function(){var t=this.app.editor.getLayout().html();return this.app.parser.unparse(t)},_sync:function(t){var e=this.app.broadcast("editor.before.change",{html:t});e.isStopped()||(this.app.$element.val(e.get("html")),this.app.autosave.send(),this.app.state.trigger(),this.app.broadcast("editor.change",e))}}),t.add("module","placeholder",{start:function(){this.placeholder=!1,this.$layout=this.app.editor.getLayout(),this._build()},handleClick:function(t){this.dom(t.target).hasClass(this.prefix+"-placeholder")&&(t.preventDefault(),t.stopPropagation(),this.app.editor.setFocus("start"))},trigger:function(){this.placeholder&&this.app.editor.isEmpty(!0)?this.show():this.hide()},toggle:function(){this.observerTimer&&clearTimeout(this.observerTimer),this.observerTimer=setTimeout(this.trigger.bind(this),10)},show:function(){this.$layout.addClass(this.prefix+"-placeholder")},hide:function(){this.$layout.removeClass(this.prefix+"-placeholder")},_build:function(){var t=this.opts.placeholder,e=this.app.$element.attr("placeholder");!1===t&&!e||(this.$layout.attr("placeholder",!1!==t?t:e),this.placeholder=!0,this.toggle())}}),t.add("module","list",{indent:function(){var t=this.app.selection.get(),e=this.app.selection.getBlock(),i=this.dom(e),s=i.prevElement(),a=s.get(),n=t.collapsed&&e&&a&&"LI"===a.tagName;if(this.app.selection.save(e),n){var o=(s=this.dom(a)).children("ul, ol"),r=i.closest("ul, ol");if(0!==o.length)o.append(i);else{var l=r.get().tagName.toLowerCase(),p=this.dom("<"+l+">");p.append(i),s.append(p)}}return this.app.selection.restore(),n},outdent:function(){var t=this.app.selection.get(),e=this.app.selection.getBlock(),i=this.dom(e),s=!1;if(t.collapsed&&e){var a,n,o=i.parent(),r=o.closest("li"),l=i.prevElement(),p=i.nextElement(),h=l.get(),c=p.get(),d=!1===h,u=!1!==h&&!1!==c;if(this.app.selection.save(e),0!==r.length){if(u){a=this._getAllNext(i.get()),n=this.dom("<"+o.get().tagName.toLowerCase()+">");for(var m=0;m]*><\/figure>/gi,"")).replace(/

 <\/p>/gi,"

")).replace(/

<\/p>/gi,"

")).replace(/^
  • $/gi,"
  • "),(a||s)&&(t=(t=t.replace(/

    <\/p>/gi,"")).replace(/

    \s<\/p>/gi,"")),t=this.app.utils.wrap(t,function(t){t.find(".Apple-converted-space").unwrap(),t.find("ul, ol").each(this._placeListToItem.bind(this)),t.find("li p").unwrap()}.bind(this)),this.app.broadcastHtml("editor.clean",t)},_encodePhp:function(t){return t=(t=(t=t.replace("","?>")},_isEditor:function(t){return t.match(new RegExp('meta\\stype="'+this.prefix+'-editor"',"i"))},_isHtmlMsWord:function(t){return t.match(/class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i)},_isPages:function(t){return t.match(/name="Generator"\scontent="Cocoa\sHTML\sWriter"/i)},_placeListToItem:function(t){var e=t.get(),i=e.previousSibling;if(i&&"LI"===i.tagName){var s=this.dom(i);s.find("p").unwrap(),s.append(e)}},_cleanPages:function(t){return t=(t=t.replace(/\sclass="s[0-9]"/gi,"")).replace(/\sclass="p[0-9]"/gi,"")},_cleanGDocs:function(t){return t=(t=(t=(t=(t=t.replace(/([\w\W]*?)<\/b>/gi,"$2")).replace(/([\w\W]*?)<\/b>/gi,"$3")).replace(/]*(font-style:\s?italic;\s?font-weight:\s?(bold|600|700)|font-weight:\s?(bold|600|700);\s?font-style:\s?italic)[^>]*>([\w\W]*?)<\/span>/gi,"$4")).replace(/]*font-style:\s?italic[^>]*>([\w\W]*?)<\/span>/gi,"$1")).replace(/]*font-weight:\s?(bold|600|700)[^>]*>([\w\W]*?)<\/span>/gi,"$2")},_cleanMsWord:function(t){t=(t=(t=(t=(t=(t=t.replace(//gi,"")).trim()).replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|meta|link|style|\w:\w+)(?=[\s/>]))[^>]*>/gi,"")).replace(/<(\/?)s>/gi,"<$1strike>")).replace(/ /gi," ")).replace(/([\s\u00a0]*)<\/span>/gi,function(t,e){return 0/gi,"

    ")).replace(/]*><\/p>/gi,"")).replace(/

  • ·/gi,"
  • ")).trim()).replace(/\/(p|ul|ol|h1|h2|h3|h4|h5|h6|blockquote)>\s+<(p|ul|ol|h1|h2|h3|h4|h5|h6|blockquote)/gi,"/$1>\n<$2")).split(/\n/),s=0;s$/)?" ":"\n";e+=i[s]+a}return e=e.trim()},_parseWordLists:function(t){var o=0,r=null,l=null,p=null;t.find("p").each(function(t){var e=t.attr("data-listLevel");if(null===e&&t.hasClass("MsoListParagraphCxSpMiddle")&&(e=1),null!==e){var i=t.text(),s=/^\s*\w+\./.test(i)?"
      ":"
        ";if(t.hasClass("MsoListParagraphCxSpFirst")||t.hasClass("MsoNormal")?(l=this.dom(s),t.before(l)):o"+t.html().trim()+"
      • "),null===l&&(t.before(s),l=t.prev()),l.append(r),t.remove(),o=e}else l=null,o=0}.bind(this))}}),t.add("module","tidy",{init:function(){},parse:function(t){t=this.app.content.encodeAttrSings(t);var e=["li"],i=["li"];this.lineBefore=new RegExp("^<(/?"+e.join("|/?")+"|"+i.join("|")+")[ >]"),this.lineAfter=new RegExp("^<(/?"+e.join("|/?")+"|/"+i.join("|/")+")[ >]"),this.newLevel=new RegExp("^]");var s=0,a=t.length,n=0,o=null,r=null,l="",p="",h="";for(this.cleanlevel=0;s"!==t.charAt(n);)n++;var c;if(s=n,"!--"===(l=t.substr(o,n-o)).substr(1,3)){if(!l.match(/--$/)){for(;"--\x3e"!==t.substr(n,3);)n++;n+=2,l=t.substr(o,n-o),s=n}"\n"!==p.charAt(p.length-1)&&(p+="\n"),p+=this.getTabs(),p+=l+">\n"}else"!"===l[1]?p=this.placeTag(l+">",p):"?"===l[1]?p+=l+">\n":c===l.match(/^<(script|style|pre)/i)?(c[1]=c[1].toLowerCase(),l=this.cleanTag(l),p=this.placeTag(l,p),(r=String(t.substr(s+1)).toLowerCase().indexOf("[\s\n]*/gi,"")).replace(/<(p|h1|h2|h3|h4|h5|h6|li|td|th)(.*?)>[\s\n]*<\/\1>/gi,"<$1$2>")).replace(/[\s\n]*<\/li>/gi,"")).replace(/\n<\/script>/gi,"<\/script>"),t=this.app.content.decodeAttrSings(t),this.cleanlevel=0,t},cleanTag:function(t){var e,i="",s="";for((t=(t=(t=t.replace(/\n/g," ")).replace(/\s{2,}/g," ")).replace(/^\s+|\s+$/g," ")).match(/\/$/)&&(s="/",t=t.replace(/\/+$/,""));e=/\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/.exec(t);)e[2]?i+=e[1].toLowerCase()+"="+e[2]:e[1]&&(i+=e[1].toLowerCase()),i+=" ",t=t.substr(e[0].length);return i.replace(/\s*$/,"")+s+">"},placeTag:function(t,e){var i=t.match(this.newLevel);return(t.match(this.lineBefore)||i)&&(e=e.replace(/\s*$/,""),e+="\n"),i&&"/"===t.charAt(1)&&this.cleanlevel--,"\n"===e.charAt(e.length-1)&&(e+=this.getTabs()),i&&"/"!==t.charAt(1)&&this.cleanlevel++,e+=t,(t.match(this.lineAfter)||t.match(this.newLevel))&&(e=e.replace(/ *$/,""),e+="\n"),e}}),t.add("module","source",{start:function(){this.eventname=this.prefix+"-source-events",this._build()},toggle:function(){this.is()?this.close():this.open()},is:function(){return"none"!==this.app.container.get("source").css("display")},open:function(){this.app.broadcast("source.before.open");var t=this.app.editor.getContent();t=this.app.tidy.parse(t);var e=this.app.container.get("editor").height();this.$source.height(e),this.$source.val(t),this.$source.on("focus."+this.eventname,this._handleFocus.bind(this)),this.$source.on("input."+this.eventname,this._handleChanges.bind(this)),this.$source.on("keydown."+this.eventname,this.app.input.handleTextareaTab.bind(this)),this.app.editor.unselectAll(),this.app.container.get("editor").hide(),this.app.container.get("source").show();var i=this.app.codemirror.create({el:this.$source,height:e,focus:!0});i&&(i.on("change",this._handleChanges.bind(this)),i.on("focus",this._handleFocus.bind(this))),this.app.editor.disableUI(),this.app.toolbar.setToggled("html"),this.app.broadcast("source.open")},close:function(){this.app.broadcast("source.before.close");var t=this.getContent();this.app.codemirror.destroy(),this.$source.off("."+this.eventname),this.app.container.get("source").hide(),this.app.container.get("editor").show(),this.app.editor.setContent({html:t,caret:"start"}),this.app.editor.enableUI(),this.app.toolbar.unsetToggled("html"),this.app.broadcast("source.close")},update:function(t){var e=this.app.editor.isTextarea()?"val":"html";this.app.$element[e](t)},getContent:function(){var t=this.$source.val();return t=this.app.codemirror.val(t)},_build:function(){this.opts.source&&(this.$source=this.dom("