2018-07-12 00:40:01 -05:00
|
|
|
|
!function(e,t){"use strict";function n(e,t,n){this.root=this.currentNode=e,this.nodeType=t,this.filter=n}function i(e,t){for(var n=e.length;n--;)if(!t(e[n]))return!1;return!0}function o(e){return e.nodeType===w&&!!he[e.nodeName]}function r(e){switch(e.nodeType){case F:return fe;case w:case H:if(ae&&me.has(e))return me.get(e);break;default:return ue}var t;return t=i(e.childNodes,a)?ce.test(e.nodeName)?fe:pe:ge,ae&&me.set(e,t),t}function a(e){return r(e)===fe}function s(e){return r(e)===pe}function d(e){return r(e)===ge}function l(e,t){var i=new n(t,W,s);return i.currentNode=e,i}function c(e,t){return e=l(e,t).previousNode(),e!==t?e:null}function h(e,t){return e=l(e,t).nextNode(),e!==t?e:null}function u(e){return!e.textContent&&!e.querySelector("IMG")}function f(e,t){return!o(e)&&e.nodeType===t.nodeType&&e.nodeName===t.nodeName&&"A"!==e.nodeName&&e.className===t.className&&(!e.style&&!t.style||e.style.cssText===t.style.cssText)}function p(e,t,n){if(e.nodeName!==t)return!1;for(var i in n)if(e.getAttribute(i)!==n[i])return!1;return!0}function g(e,t,n,i){for(;e&&e!==t;){if(p(e,n,i))return e;e=e.parentNode}return null}function m(e,t){for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function v(e,t,n){var i,o,r,a,s,d="";return e&&e!==t&&(d=v(e.parentNode,t,n),e.nodeType===w&&(d+=(d?">":"")+e.nodeName,(i=e.id)&&(d+="#"+i),(o=e.className.trim())&&(r=o.split(/\s\s*/),r.sort(),d+=".",d+=r.join(".")),(a=e.dir)&&(d+="[dir="+a+"]"),r&&(s=n.classNames,de.call(r,s.highlight)>-1&&(d+="[backgroundColor="+e.style.backgroundColor.replace(/ /g,"")+"]"),de.call(r,s.colour)>-1&&(d+="[color="+e.style.color.replace(/ /g,"")+"]"),de.call(r,s.fontFamily)>-1&&(d+="[fontFamily="+e.style.fontFamily.replace(/ /g,"")+"]"),de.call(r,s.fontSize)>-1&&(d+="[fontSize="+e.style.fontSize+"]")))),d}function _(e){var t=e.nodeType;return t===w||t===H?e.childNodes.length:e.length||0}function N(e){var t=e.parentNode;return t&&t.removeChild(e),e}function C(e,t){var n=e.parentNode;n&&n.replaceChild(t,e)}function S(e){for(var t=e.ownerDocument.createDocumentFragment(),n=e.childNodes,i=n?n.length:0;i--;)t.appendChild(e.firstChild);return t}function y(e,n,i,o){var r,a,s,d=e.createElement(n);if(i instanceof Array&&(o=i,i=null),i)for(r in i)i[r]!==t&&d.setAttribute(r,i[r]);if(o)for(a=0,s=o.length;a<s;a+=1)d.appendChild(o[a]);return d}function T(e,t){var n,i,r=t.__squire__,s=e.ownerDocument,d=e;if(e===t&&((i=e.firstChild)&&"BR"!==i.nodeName||(n=r.createDefaultBlock(),i?e.replaceChild(n,i):e.appendChild(n),e=n,n=null)),e.nodeType===F)return d;if(a(e)){for(i=e.firstChild;ie&&i&&i.nodeType===F&&!i.data;)e.removeChild(i),i=e.firstChild;i||(ie?(n=s.createTextNode(z),r._didAddZWS()):n=s.createTextNode(""))}else if(ne){for(;e.nodeType!==F&&!o(e);){if(!(i=e.firstChild)){n=s.createTextNode("");break}e=i}e.nodeType===F?/^ +$/.test(e.data)&&(e.data=""):o(e)&&e.parentNode.insertBefore(s.createTextNode(""),e)}else if(!e.querySelector("BR"))for(n=y(s,"BR");(i=e.lastElementChild)&&!a(i);)e=i;if(n)try{e.appendChild(n)}catch(t){r.didError({name:"Squire: fixCursor – "+t,message:"Parent: "+e.nodeName+"/"+e.innerHTML+" appendChild: "+n.nodeName})}return d}function E(e,t){var n,i,o,r,s=e.childNodes,l=e.ownerDocument,c=null,h=t.__squire__._config;for(n=0,i=s.length;n<i;n+=1)o=s[n],r="BR"===o.nodeName,!r&&a(o)?(c||(c=y(l,h.blockTag,h.blockAttributes)),c.appendChild(o),n-=1,i-=1):(r||c)&&(c||(c=y(l,h.blockTag,h.blockAttributes)),T(c,t),r?e.replaceChild(c,o):(e.insertBefore(c,o),n+=1,i+=1),c=null),d(o)&&E(o,t);return c&&e.appendChild(T(c,t)),e}function b(e,t,n,i){var o,r,a,s=e.nodeType;if(s===F&&e!==n)return b(e.parentNode,e.splitText(t),n,i);if(s===w){if("number"==typeof t&&(t=t<e.childNodes.length?e.childNodes[t]:null),e===n)return t;for(o=e.parentNode,r=e.cloneNode(!1);t;)a=t.nextSibling,r.appendChild(t),t=a;return"OL"===e.nodeName&&g(e,i,"BLOCKQUOTE")&&(r.start=(+e.start||1)+e.childNodes.length-1),T(e,i),T(r,i),(a=e.nextSibling)?o.insertBefore(r,a):o.appendChild(r),b(o,r,n,i)}return t}function k(e,t){for(var n,i,o,r=e.childNodes,s=r.length,d=[];s--;)if(n=r[s],i=s&&r[s-1],s&&a(n)&&f(n,i)&
|
|
|
|
|
r&&r.nodeType===F||(r=o.childNodes[e.startOffset-1]),r&&r.nodeType===F&&(e.setStart(r,0),e.collapse(!0))))}return e||null},nt._keyUpDetectChange=function(e){var t=e.keyCode;e.ctrlKey||e.metaKey||e.altKey||!(t<16||t>20)||!(t<33||t>45)||this._docWasChanged()},nt._docWasChanged=function(){if(ae&&(me=new WeakMap),!this._ignoreAllChanges){if(re&&this._ignoreChange)return void(this._ignoreChange=!1);this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),this.fireEvent("input")}},nt._recordUndoState=function(e,t){if(!this._isInUndoState||t){var n,i=this._undoIndex,o=this._undoStack,r=this._config.undo,a=r.documentSizeThreshold,s=r.undoLimit;t||(i+=1),i<this._undoStackLength&&(o.length=this._undoStackLength=i),e&&this._saveRangeToBookmark(e),n=this._getHTML(),a>-1&&2*n.length>a&&s>-1&&i>s&&(o.splice(0,i-s),i=s,this._undoStackLength=s),o[i]=n,this._undoIndex=i,this._undoStackLength+=1,this._isInUndoState=!0}},nt.saveUndoState=function(e){return e===t&&(e=this.getSelection()),this._recordUndoState(e,this._isInUndoState),this._getRangeAndRemoveBookmark(e),this},nt.undo=function(){if(0!==this._undoIndex||!this._isInUndoState){this._recordUndoState(this.getSelection(),!1),this._undoIndex-=1,this._setHTML(this._undoStack[this._undoIndex]);var e=this._getRangeAndRemoveBookmark();e&&this.setSelection(e),this._isInUndoState=!0,this.fireEvent("undoStateChange",{canUndo:0!==this._undoIndex,canRedo:!0}),this.fireEvent("input")}return this},nt.redo=function(){var e=this._undoIndex,t=this._undoStackLength;if(e+1<t&&this._isInUndoState){this._undoIndex+=1,this._setHTML(this._undoStack[this._undoIndex]);var n=this._getRangeAndRemoveBookmark();n&&this.setSelection(n),this.fireEvent("undoStateChange",{canUndo:!0,canRedo:e+2<t}),this.fireEvent("input")}return this},nt.hasFormat=function(e,t,i){if(e=e.toUpperCase(),t||(t={}),!i&&!(i=this.getSelection()))return!1;!i.collapsed&&i.startContainer.nodeType===F&&i.startOffset===i.startContainer.length&&i.startContainer.nextSibling&&i.setStartBefore(i.startContainer.nextSibling),!i.collapsed&&i.endContainer.nodeType===F&&0===i.endOffset&&i.endContainer.previousSibling&&i.setEndAfter(i.endContainer.previousSibling);var o,r,a=this._root,s=i.commonAncestorContainer;if(g(s,a,e,t))return!0;if(s.nodeType===F)return!1;o=new n(s,4,function(e){return Te(i,e,!0)},!1);for(var d=!1;r=o.nextNode();){if(!g(r,a,e,t))return!1;d=!0}return d},nt.getFontInfo=function(e){var n,i,o,r={color:t,backgroundColor:t,family:t,size:t},a=0;if(!e&&!(e=this.getSelection()))return r;if(n=e.commonAncestorContainer,e.collapsed||n.nodeType===F)for(n.nodeType===F&&(n=n.parentNode);a<4&&n;)(i=n.style)&&(!r.color&&(o=i.color)&&(r.color=o,a+=1),!r.backgroundColor&&(o=i.backgroundColor)&&(r.backgroundColor=o,a+=1),!r.family&&(o=i.fontFamily)&&(r.family=o,a+=1),!r.size&&(o=i.fontSize)&&(r.size=o,a+=1)),n=n.parentNode;return r},nt._addFormat=function(e,t,i){var o,r,s,d,l,c,h,u,f=this._root;if(i.collapsed){for(o=T(this.createElement(e,t),f),Ne(i,o),i.setStart(o.firstChild,o.firstChild.length),i.collapse(!0),u=o;a(u);)u=u.parentNode;at(u,o)}else{if(r=new n(i.commonAncestorContainer,4|W,function(e){return(e.nodeType===F||"BR"===e.nodeName||"IMG"===e.nodeName)&&Te(i,e,!0)},!1),s=i.startContainer,l=i.startOffset,d=i.endContainer,c=i.endOffset,r.currentNode=s,r.filter(s)||(s=r.nextNode(),l=0),!s)return i;do{h=r.currentNode,!g(h,f,e,t)&&(h===d&&h.length>c&&h.splitText(c),h===s&&l&&(h=h.splitText(l),d===s&&(d=h,c-=l),s=h,l=0),o=this.createElement(e,t),C(h,o),o.appendChild(h))}while(r.nextNode());d.nodeType!==F&&(h.nodeType===F?(d=h,c=h.length):(d=h.parentNode,c=1)),i=this.createRange(s,l,d,c)}return i},nt._removeFormat=function(e,t,n,i){this._saveRangeToBookmark(n);var o,r=this._doc;n.collapsed&&(ie?(o=r.createTextNode(z),this._didAddZWS()):o=r.createTextNode(""),Ne(n,o));for(var s=n.commonAncestorContainer;a(s);)s=s.parentNode;var d=n.startContainer,l=n.startOffset,c=n.endContainer,h=n.endOffset,u=[],f=function(e,t){if(!Te(n,e,!1)){var i,o,r=e.nodeType===F;if(!Te(n,e,!0))return void("INPUT"===e.nodeName||
|