From 3afa14bf400e04374dd78fc090f573ec3e603e38 Mon Sep 17 00:00:00 2001 From: Neil Jenkins Date: Mon, 14 Mar 2016 15:22:40 +1100 Subject: [PATCH] Release v1.5.1 --- build/squire-raw.js | 4 ++++ build/squire.js | 4 ++-- package.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build/squire-raw.js b/build/squire-raw.js index f3a9a85..7ad4e87 100644 --- a/build/squire-raw.js +++ b/build/squire-raw.js @@ -1993,6 +1993,8 @@ var onCut = function ( event ) { moveRangeBoundariesUpTree( range, body ); node.appendChild( deleteContentsOfRange( range, body ) ); clipboardData.setData( 'text/html', node.innerHTML ); + clipboardData.setData( 'text/plain', + node.innerText || node.textContent ); event.preventDefault(); } else { setTimeout( function () { @@ -2017,6 +2019,8 @@ var onCopy = function ( event ) { if ( !isEdge && clipboardData ) { node.appendChild( range.cloneContents() ); clipboardData.setData( 'text/html', node.innerHTML ); + clipboardData.setData( 'text/plain', + node.innerText || node.textContent ); event.preventDefault(); } }; diff --git a/build/squire.js b/build/squire.js index b501c83..9fb55e0 100644 --- a/build/squire.js +++ b/build/squire.js @@ -1,2 +1,2 @@ -!function(e,t){"use strict";function n(e,t,n){this.root=this.currentNode=e,this.nodeType=t,this.filter=n}function r(e,t){for(var n=e.length;n--;)if(!t(e[n]))return!1;return!0}function i(e,t,n){if(e.nodeName!==t)return!1;for(var r in n)if(e.getAttribute(r)!==n[r])return!1;return!0}function o(e,t){return!a(e)&&e.nodeType===t.nodeType&&e.nodeName===t.nodeName&&e.className===t.className&&(!e.style&&!t.style||e.style.cssText===t.style.cssText)}function a(e){return e.nodeType===A&&!!ot[e.nodeName]}function s(e){return it.test(e.nodeName)}function d(e){var t=e.nodeType;return(t===A||t===R)&&!s(e)&&r(e.childNodes,s)}function l(e){var t=e.nodeType;return!(t!==A&&t!==R||s(e)||d(e))}function c(e){var t=e.ownerDocument,r=new n(t.body,I,d,!1);return r.currentNode=e,r}function f(e){return c(e).previousNode()}function h(e){return c(e).nextNode()}function u(e,t,n){do if(i(e,t,n))return e;while(e=e.parentNode);return null}function p(e){var t,n,r,i,o,a=e.parentNode;return a&&e.nodeType===A?(t=p(a),t+=(t?">":"")+e.nodeName,(n=e.id)&&(t+="#"+n),(r=e.className.trim())&&(i=r.split(/\s\s*/),i.sort(),t+=".",t+=i.join(".")),(o=e.dir)&&(t+="[dir="+o+"]")):t=a?p(a):"",t}function g(e){var t=e.nodeType;return t===A?e.childNodes.length:e.length||0}function m(e){var t=e.parentNode;return t&&t.removeChild(e),e}function v(e,t){var n=e.parentNode;n&&n.replaceChild(t,e)}function C(e){for(var t=e.ownerDocument.createDocumentFragment(),n=e.childNodes,r=n?n.length:0;r--;)t.appendChild(e.firstChild);return t}function N(e,n,r,i){var o,a,s,d,l=e.createElement(n);if(r instanceof Array&&(i=r,r=null),r)for(o in r)a=r[o],a!==t&&l.setAttribute(o,r[o]);if(i)for(s=0,d=i.length;d>s;s+=1)l.appendChild(i[s]);return l}function S(e){var t,n,r=e.ownerDocument,i=e;if("BODY"===e.nodeName&&((n=e.firstChild)&&"BR"!==n.nodeName||(t=B(r).createDefaultBlock(),n?e.replaceChild(t,n):e.appendChild(t),e=t,t=null)),s(e)){for(n=e.firstChild;X&&n&&n.nodeType===D&&!n.data;)e.removeChild(n),n=e.firstChild;n||(X?(t=r.createTextNode(H),B(r)._didAddZWS()):t=r.createTextNode(""))}else if($){for(;e.nodeType!==D&&!a(e);){if(n=e.firstChild,!n){t=r.createTextNode("");break}e=n}e.nodeType===D?/^ +$/.test(e.data)&&(e.data=""):a(e)&&e.parentNode.insertBefore(r.createTextNode(""),e)}else if(!e.querySelector("BR"))for(t=N(r,"BR");(n=e.lastElementChild)&&!s(n);)e=n;return t&&e.appendChild(t),i}function y(e){var t,n,r,i,o=e.childNodes,a=e.ownerDocument,d=null,c=B(a)._config;for(t=0,n=o.length;n>t;t+=1)r=o[t],i="BR"===r.nodeName,!i&&s(r)?(d||(d=N(a,c.blockTag,c.blockAttributes)),d.appendChild(r),t-=1,n-=1):(i||d)&&(d||(d=N(a,c.blockTag,c.blockAttributes)),S(d),i?e.replaceChild(d,r):(e.insertBefore(d,r),t+=1,n+=1),d=null),l(r)&&y(r);return d&&e.appendChild(S(d)),e}function _(e,t,n){var r,i,o,a=e.nodeType;if(a===D&&e!==n)return _(e.parentNode,e.splitText(t),n);if(a===A){if("number"==typeof t&&(t=td?t.startOffset-=1:t.startOffset===d&&(t.startContainer=r,t.startOffset=g(r))),t.endContainer===e&&(t.endOffset>d?t.endOffset-=1:t.endOffset===d&&(t.endContainer=r,t.endOffset=g(r))),m(n),n.nodeType===D?r.appendData(n.data):l.push(C(n));else if(n.nodeType===A){for(i=l.length;i--;)n.appendChild(l.pop());T(n,t)}}function b(e,t,n){for(var r,i,o,a=t;1===a.parentNode.childNodes.length;)a=a.parentNode;m(a),i=e.childNodes.length,r=e.lastChild,r&&"BR"===r.nodeName&&(e.removeChild(r),i-=1),o={startContainer:e,startOffset:i,endContainer:e,endOffset:i},e.appendChild(C(t)),T(e,o),n.setStart(o.startContainer,o.startOffset),n.collapse(!0),G&&(r=e.lastChild)&&"BR"===r.nodeName&&e.removeChild(r)}function E(e){var t,n,r=e.previousSibling,i=e.firstChild,a=e.ownerDocument,s="LI"===e.nodeName;if(!s||i&&/^[OU]L$/.test(i.nodeName))if(r&&o(r,e)){if(!l(r)){if(!s)return;n=N(a,"DIV"),n.appendChild(C(r)),r.appendChild(n)}m(e),t=!l(e),r.appendChild(C(e)),t&&y(r),i&&E(i)}else s&&(r=N(a,"DIV"),e.insertBefore(r,i),S(r))}function B(e){for(var t,n=zt.length;n--;)if(t=zt[n],t._doc===e)return t;return null}function k(e,t){var n,r;e||(e={});for(n in t)r=t[n],e[n]=r&&r.constructor===Object?k(e[n],r):r;return e}function O(e,t){var n,r=e.defaultView,i=e.body;this._win=r,this._doc=e,this._body=i,this._events={},this._lastSelection=null,J&&this.addEventListener("beforedeactivate",this.getSelection),this._hasZWS=!1,this._lastAnchorNode=null,this._lastFocusNode=null,this._path="",this.addEventListener("keyup",this._updatePathOnEvent),this.addEventListener("mouseup",this._updatePathOnEvent),r.addEventListener("focus",this,!1),r.addEventListener("blur",this,!1),this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0,this._isInUndoState=!1,this._ignoreChange=!1,et?(n=new MutationObserver(this._docWasChanged.bind(this)),n.observe(i,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),this._mutation=n):this.addEventListener("keyup",this._keyUpDetectChange),this._awaitingPaste=!1,this.addEventListener(V?"beforecut":"cut",Mt),this.addEventListener("copy",Ht),this.addEventListener(V?"beforepaste":"paste",Wt),this.addEventListener(G?"keypress":"keydown",_t),this._keyHandlers=Object.create(Bt),this.setConfig(t),V&&(r.Text.prototype.splitText=function(e){var t=this.ownerDocument.createTextNode(this.data.slice(e)),n=this.nextSibling,r=this.parentNode,i=this.length-e;return n?r.insertBefore(t,n):r.appendChild(t),i&&this.deleteData(e,i),t}),i.setAttribute("contenteditable","true");try{e.execCommand("enableObjectResizing",!1,"false"),e.execCommand("enableInlineTableEditing",!1,"false")}catch(o){}zt.push(this),this.setHTML("")}function x(e,t,n){var r,i;for(r=t.firstChild;r;r=i){if(i=r.nextSibling,s(r)){if(r.nodeType===D||"BR"===r.nodeName||"IMG"===r.nodeName){n.appendChild(r);continue}}else if(d(r)){n.appendChild(e.createDefaultBlock([x(e,r,e._doc.createDocumentFragment())]));continue}x(e,r,n)}return n}var L=2,A=1,D=3,R=11,I=1,U=4,P=0,w=1,F=2,M=3,H="​",W=e.defaultView,z=navigator.userAgent,K=/iP(?:ad|hone|od)/.test(z),Z=/Mac OS X/.test(z),q=/Gecko\//.test(z),V=/Trident\/[456]\./.test(z),G=!!W.opera,j=/Edge\//.test(z),Q=!j&&/WebKit\//.test(z),Y=Z?"meta-":"ctrl-",$=V||G,X=V||Q,J=V,et="undefined"!=typeof MutationObserver,tt=/[^ \t\r\n]/,nt=Array.prototype.indexOf;Object.create||(Object.create=function(e){var t=function(){};return t.prototype=e,new t});var rt={1:1,2:2,3:4,8:128,9:256,11:1024};n.prototype.nextNode=function(){for(var e,t=this.currentNode,n=this.root,r=this.nodeType,i=this.filter;;){for(e=t.firstChild;!e&&t&&t!==n;)e=t.nextSibling,e||(t=t.parentNode);if(!e)return null;if(rt[e.nodeType]&r&&i(e))return this.currentNode=e,e;t=e}},n.prototype.previousNode=function(){for(var e,t=this.currentNode,n=this.root,r=this.nodeType,i=this.filter;;){if(t===n)return null;if(e=t.previousSibling)for(;t=e.lastChild;)e=t;else e=t.parentNode;if(!e)return null;if(rt[e.nodeType]&r&&i(e))return this.currentNode=e,e;t=e}},n.prototype.previousPONode=function(){for(var e,t=this.currentNode,n=this.root,r=this.nodeType,i=this.filter;;){for(e=t.lastChild;!e&&t&&t!==n;)e=t.previousSibling,e||(t=t.parentNode);if(!e)return null;if(rt[e.nodeType]&r&&i(e))return this.currentNode=e,e;t=e}};var it=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|U|VAR|WBR)$/,ot={BR:1,IMG:1,INPUT:1},at=function(e,t){for(var n=e.childNodes;t&&e.nodeType===A;)e=n[t-1],n=e.childNodes,t=n.length;return e},st=function(e,t){if(e.nodeType===A){var n=e.childNodes;if(t-1,o=e.compareBoundaryPoints(w,r)<1;return!i&&!o}var a=e.compareBoundaryPoints(P,r)<1,s=e.compareBoundaryPoints(F,r)>-1;return a&&s},ut=function(e){for(var t,n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset;n.nodeType!==D&&(t=n.childNodes[r],t&&!a(t));)n=t,r=0;if(o)for(;i.nodeType!==D&&(t=i.childNodes[o-1],t&&!a(t));)i=t,o=g(i);else for(;i.nodeType!==D&&(t=i.firstChild,t&&!a(t));)i=t;e.collapsed?(e.setStart(i,o),e.setEnd(n,r)):(e.setStart(n,r),e.setEnd(i,o))},pt=function(e,t){var n,r=e.startContainer,i=e.startOffset,o=e.endContainer,a=e.endOffset;for(t||(t=e.commonAncestorContainer);r!==t&&!i;)n=r.parentNode,i=nt.call(n.childNodes,r),r=n;for(;o!==t&&a===g(o);)n=o.parentNode,a=nt.call(n.childNodes,o)+1,o=n;e.setStart(r,i),e.setEnd(o,a)},gt=function(e){var t,n=e.startContainer;return s(n)?t=f(n):d(n)?t=n:(t=at(n,e.startOffset),t=h(t)),t&&ht(e,t,!0)?t:null},mt=function(e){var t,n,r=e.endContainer;if(s(r))t=f(r);else if(d(r))t=r;else{if(t=st(r,e.endOffset),!t)for(t=r.ownerDocument.body;n=t.lastChild;)t=n;t=f(t)}return t&&ht(e,t,!0)?t:null},vt=new n(null,U|I,function(e){return e.nodeType===D?tt.test(e.data):"IMG"===e.nodeName}),Ct=function(e){var t=e.startContainer,n=e.startOffset;if(vt.root=null,t.nodeType===D){if(n)return!1;vt.currentNode=t}else vt.currentNode=st(t,n);return vt.root=gt(e),!vt.previousNode()},Nt=function(e){var t,n=e.endContainer,r=e.endOffset;if(vt.root=null,n.nodeType===D){if(t=n.data.length,t&&t>r)return!1;vt.currentNode=n}else vt.currentNode=at(n,r);return vt.root=mt(e),!vt.nextNode()},St=function(e){var t,n=gt(e),r=mt(e);n&&r&&(t=n.parentNode,e.setStart(t,nt.call(t.childNodes,n)),t=r.parentNode,e.setEnd(t,nt.call(t.childNodes,r)+1))},yt={8:"backspace",9:"tab",13:"enter",32:"space",33:"pageup",34:"pagedown",37:"left",39:"right",46:"delete",219:"[",221:"]"},_t=function(e){var t=e.keyCode,n=yt[t],r="",i=this.getSelection();e.defaultPrevented||(n||(n=String.fromCharCode(t).toLowerCase(),/^[A-Za-z0-9]$/.test(n)||(n="")),G&&46===e.which&&(n="."),t>111&&124>t&&(n="f"+(t-111)),"backspace"!==n&&"delete"!==n&&(e.altKey&&(r+="alt-"),e.ctrlKey&&(r+="ctrl-"),e.metaKey&&(r+="meta-")),e.shiftKey&&(r+="shift-"),n=r+n,this._keyHandlers[n]?this._keyHandlers[n](this,e,i):1!==n.length||i.collapsed||(this.saveUndoState(i),ct(i),this._ensureBottomLine(),this.setSelection(i),this._updatePath(i,!0)))},Tt=function(e){return function(t,n){n.preventDefault(),t[e]()}},bt=function(e,t){return t=t||null,function(n,r){r.preventDefault();var i=n.getSelection();n.hasFormat(e,null,i)?n.changeFormat(null,{tag:e},i):n.changeFormat({tag:e},t,i)}},Et=function(e,t){try{t||(t=e.getSelection());var n,r=t.startContainer;for(r.nodeType===D&&(r=r.parentNode),n=r;s(n)&&(!n.textContent||n.textContent===H);)r=n,n=r.parentNode;r!==n&&(t.setStart(n,nt.call(n.childNodes,r)),t.collapse(!0),n.removeChild(r),d(n)||(n=f(n)),S(n),ut(t)),"BODY"===r.nodeName&&(r=r.firstChild)&&"BR"===r.nodeName&&m(r),e._ensureBottomLine(),e.setSelection(t),e._updatePath(t,!0)}catch(i){e.didError(i)}},Bt={enter:function(e,t,n){var r,i,o;if(t.preventDefault(),e._recordUndoState(n),dn(n.startContainer),e._removeZWS(),e._getRangeAndRemoveBookmark(n),n.collapsed||ct(n),r=gt(n),!r||/^T[HD]$/.test(r.nodeName))return dt(n,e.createElement("BR")),n.collapse(!1),e.setSelection(n),void e._updatePath(n,!0);if((i=u(r,"LI"))&&(r=i),!r.textContent){if(u(r,"UL")||u(r,"OL"))return e.modifyBlocks(an,n);if(u(r,"BLOCKQUOTE"))return e.modifyBlocks(Jt,n)}for(o=Yt(e,r,n.startContainer,n.startOffset),Vt(r),Ut(r),S(r);o.nodeType===A;){var a,s=o.firstChild;if("A"===o.nodeName&&(!o.textContent||o.textContent===H)){s=e._doc.createTextNode(""),v(o,s),o=s;break}for(;s&&s.nodeType===D&&!s.data&&(a=s.nextSibling,a&&"BR"!==a.nodeName);)m(s),s=a;if(!s||"BR"===s.nodeName||s.nodeType===D&&!G)break;o=s}n=e._createRange(o,0),e.setSelection(n),e._updatePath(n,!0)},backspace:function(e,t,n){if(e._removeZWS(),e.saveUndoState(n),n.collapsed)if(Ct(n)){t.preventDefault();var r,i=gt(n);if(!i)return;if(y(i.parentNode),r=f(i)){if(!r.isContentEditable)return void m(r);for(b(r,i,n),i=r.parentNode;i&&!i.nextSibling;)i=i.parentNode;i&&(i=i.nextSibling)&&E(i),e.setSelection(n)}else if(i){if(u(i,"UL")||u(i,"OL"))return e.modifyBlocks(an,n);if(u(i,"BLOCKQUOTE"))return e.modifyBlocks(Xt,n);e.setSelection(n),e._updatePath(n,!0)}}else e.setSelection(n),setTimeout(function(){Et(e)},0);else t.preventDefault(),ct(n),Et(e,n)},"delete":function(e,t,n){var r,i,o,a,s,d;if(e._removeZWS(),e.saveUndoState(n),n.collapsed)if(Nt(n)){if(t.preventDefault(),r=gt(n),!r)return;if(y(r.parentNode),i=h(r)){if(!i.isContentEditable)return void m(i);for(b(r,i,n),i=r.parentNode;i&&!i.nextSibling;)i=i.parentNode;i&&(i=i.nextSibling)&&E(i),e.setSelection(n),e._updatePath(n,!0)}}else{if(o=n.cloneRange(),pt(n,e._body),a=n.endContainer,s=n.endOffset,a.nodeType===A&&(d=a.childNodes[s],d&&"IMG"===d.nodeName))return t.preventDefault(),m(d),ut(n),void Et(e,n);e.setSelection(o),setTimeout(function(){Et(e)},0)}else t.preventDefault(),ct(n),Et(e,n)},tab:function(e,t,n){var r,i;if(e._removeZWS(),n.collapsed&&Ct(n))for(r=gt(n);i=r.parentNode;){if("UL"===i.nodeName||"OL"===i.nodeName){r.previousSibling&&(t.preventDefault(),e.modifyBlocks(on,n));break}r=i}},"shift-tab":function(e,t,n){if(e._removeZWS(),n.collapsed&&Ct(n)){var r=n.startContainer;(u(r,"UL")||u(r,"OL"))&&(t.preventDefault(),e.modifyBlocks(an,n))}},space:function(e,t,n){var r,i;e._recordUndoState(n),dn(n.startContainer),e._getRangeAndRemoveBookmark(n),r=n.endContainer,i=r.parentNode,n.collapsed&&"A"===i.nodeName&&!r.nextSibling&&n.endOffset===g(r)&&n.setStartAfter(i),e.setSelection(n)},left:function(e){e._removeZWS()},right:function(e){e._removeZWS()}};Z&&q&&(Bt["meta-left"]=function(e,t){t.preventDefault();var n=qt(e);n&&n.modify&&n.modify("move","backward","lineboundary")},Bt["meta-right"]=function(e,t){t.preventDefault();var n=qt(e);n&&n.modify&&n.modify("move","forward","lineboundary")}),Z||(Bt.pageup=function(e){e.moveCursorToStart()},Bt.pagedown=function(e){e.moveCursorToEnd()}),Bt[Y+"b"]=bt("B"),Bt[Y+"i"]=bt("I"),Bt[Y+"u"]=bt("U"),Bt[Y+"shift-7"]=bt("S"),Bt[Y+"shift-5"]=bt("SUB",{tag:"SUP"}),Bt[Y+"shift-6"]=bt("SUP",{tag:"SUB"}),Bt[Y+"shift-8"]=Tt("makeUnorderedList"),Bt[Y+"shift-9"]=Tt("makeOrderedList"),Bt[Y+"["]=Tt("decreaseQuoteLevel"),Bt[Y+"]"]=Tt("increaseQuoteLevel"),Bt[Y+"y"]=Tt("redo"),Bt[Y+"z"]=Tt("undo"),Bt[Y+"shift-z"]=Tt("redo");var kt={1:10,2:13,3:16,4:18,5:24,6:32,7:48},Ot={backgroundColor:{regexp:tt,replace:function(e,t){return N(e,"SPAN",{"class":"highlight",style:"background-color:"+t})}},color:{regexp:tt,replace:function(e,t){return N(e,"SPAN",{"class":"colour",style:"color:"+t})}},fontWeight:{regexp:/^bold/i,replace:function(e){return N(e,"B")}},fontStyle:{regexp:/^italic/i,replace:function(e){return N(e,"I")}},fontFamily:{regexp:tt,replace:function(e,t){return N(e,"SPAN",{"class":"font",style:"font-family:"+t})}},fontSize:{regexp:tt,replace:function(e,t){return N(e,"SPAN",{"class":"size",style:"font-size:"+t})}}},xt=function(e){return function(t,n){var r=N(t.ownerDocument,e);return n.replaceChild(r,t),r.appendChild(C(t)),r}},Lt={SPAN:function(e,t){var n,r,i,o,a,s,d=e.style,l=e.ownerDocument;for(n in Ot)r=Ot[n],i=d[n],i&&r.regexp.test(i)&&(s=r.replace(l,i),o&&o.appendChild(s),o=s,a||(a=s));return a&&(o.appendChild(C(e)),t.replaceChild(a,e)),o||e},STRONG:xt("B"),EM:xt("I"),STRIKE:xt("S"),FONT:function(e,t){var n,r,i,o,a,s=e.face,d=e.size,l=e.color,c=e.ownerDocument;return s&&(n=N(c,"SPAN",{"class":"font",style:"font-family:"+s}),a=n,o=n),d&&(r=N(c,"SPAN",{"class":"size",style:"font-size:"+kt[d]+"px"}),a||(a=r),o&&o.appendChild(r),o=r),l&&/^#?([\dA-F]{3}){1,2}$/i.test(l)&&("#"!==l.charAt(0)&&(l="#"+l),i=N(c,"SPAN",{"class":"colour",style:"color:"+l}),a||(a=i),o&&o.appendChild(i),o=i),a||(a=o=N(c,"SPAN")),t.replaceChild(a,e),o.appendChild(C(e)),o},TT:function(e,t){var n=N(e.ownerDocument,"SPAN",{"class":"font",style:'font-family:menlo,consolas,"courier new",monospace'});return t.replaceChild(n,e),n.appendChild(C(e)),n}},At=/^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|UL)$/,Dt=/^(?:HEAD|META|STYLE)/,Rt=new n(null,U|I,function(){return!0}),It=function cn(e){var t,n,r,i,o,a,d,l,c,f,h,u,p=e.childNodes;for(t=e;s(t);)t=t.parentNode;for(Rt.root=t,n=0,r=p.length;r>n;n+=1)if(i=p[n],o=i.nodeName,a=i.nodeType,d=Lt[o],a===A){if(l=i.childNodes.length,d)i=d(i,e);else{if(Dt.test(o)){e.removeChild(i),n-=1,r-=1;continue}if(!At.test(o)&&!s(i)){n-=1,r+=l-1,e.replaceChild(C(i),i);continue}}l&&cn(i)}else{if(a===D){if(h=i.data,c=!tt.test(h.charAt(0)),f=!tt.test(h.charAt(h.length-1)),!c&&!f)continue;if(c){for(Rt.currentNode=i;(u=Rt.previousPONode())&&(o=u.nodeName,!("IMG"===o||"#text"===o&&/\S/.test(u.data)));)if(!s(u)){u=null;break}u||(h=h.replace(/^\s+/g,""))}if(f){for(Rt.currentNode=i;(u=Rt.nextNode())&&!("IMG"===o||"#text"===o&&/\S/.test(u.data));)if(!s(u)){u=null;break}u||(h=h.replace(/^\s+/g,""))}if(h){i.data=h;continue}}e.removeChild(i),n-=1,r-=1}return e},Ut=function fn(e){for(var t,n=e.childNodes,r=n.length;r--;)t=n[r],t.nodeType!==A||a(t)?t.nodeType!==D||t.data||e.removeChild(t):(fn(t),s(t)&&!t.firstChild&&e.removeChild(t))},Pt=function(e){return e.nodeType===A?"BR"===e.nodeName:tt.test(e.data)},wt=function(e){for(var t,r=e.parentNode;s(r);)r=r.parentNode;return t=new n(r,I|U,Pt),t.currentNode=e,!!t.nextNode()},Ft=function(e){var t,n,r,i=e.querySelectorAll("BR"),o=[],a=i.length;for(t=0;a>t;t+=1)o[t]=wt(i[t]);for(;a--;)n=i[a],r=n.parentNode,r&&(o[a]?s(r)||y(r):m(n))},Mt=function(e){var t=e.clipboardData,n=this.getSelection(),r=this.createElement("div"),i=this._body,o=this;this.saveUndoState(n),!j&&t?(pt(n,i),r.appendChild(ct(n,i)),t.setData("text/html",r.innerHTML),e.preventDefault()):setTimeout(function(){try{o._ensureBottomLine()}catch(e){o.didError(e)}},0),this.setSelection(n)},Ht=function(e){var t=e.clipboardData,n=this.getSelection(),r=this.createElement("div");!j&&t&&(r.appendChild(n.cloneContents()),t.setData("text/html",r.innerHTML),e.preventDefault())},Wt=function(e){var t,n,r,i,o,a=e.clipboardData,s=a&&a.items,d=!1,l=!1,c=null,f=this;if(!j&&s){for(e.preventDefault(),t=s.length;t--;){if(n=s[t],r=n.type,"text/html"===r)return void n.getAsString(function(e){f.insertHTML(e,!0)});"text/plain"===r&&(c=n),/^image\/.*/.test(r)&&(l=!0)}return void(l?(this.fireEvent("dragover",{dataTransfer:a,preventDefault:function(){d=!0}}),d&&this.fireEvent("drop",{dataTransfer:a})):c&&n.getAsString(function(e){f.insertPlainText(e,!0)}))}if(i=a&&a.types,!j&&i&&(nt.call(i,"text/html")>-1||!q&&nt.call(i,"text/plain")>-1&&nt.call(i,"text/rtf")<0))return e.preventDefault(),void((o=a.getData("text/html"))?this.insertHTML(o,!0):(o=a.getData("text/plain"))&&this.insertPlainText(o,!0));this._awaitingPaste=!0;var h=this._body,u=this.getSelection(),p=u.startContainer,g=u.startOffset,v=u.endContainer,C=u.endOffset,N=gt(u),S=this.createElement("DIV",{style:"position: absolute; overflow: hidden; top:"+(h.scrollTop+(N?N.getBoundingClientRect().top:0))+"px; right: 150%; width: 1px; height: 1px;"});h.appendChild(S),u.selectNodeContents(S),this.setSelection(u),setTimeout(function(){try{f._awaitingPaste=!1;for(var e,t,n="",r=S;S=r;)r=S.nextSibling,m(S),e=S.firstChild,e&&e===S.lastChild&&"DIV"===e.nodeName&&(S=e),n+=S.innerHTML;t=f._createRange(p,g,v,C),f.setSelection(t),n&&f.insertHTML(n,!0)}catch(i){f.didError(i)}},0)},zt=[],Kt=O.prototype;Kt.setConfig=function(e){return e=k({blockTag:"DIV",blockAttributes:null,tagAttributes:{blockquote:null,ul:null,ol:null,li:null}},e),e.blockTag=e.blockTag.toUpperCase(),this._config=e,this},Kt.createElement=function(e,t,n){return N(this._doc,e,t,n)},Kt.createDefaultBlock=function(e){var t=this._config;return S(this.createElement(t.blockTag,t.blockAttributes,e))},Kt.didError=function(e){console.log(e)},Kt.getDocument=function(){return this._doc};var Zt={focus:1,blur:1,pathChange:1,select:1,input:1,undoStateChange:1};Kt.fireEvent=function(e,t){var n,r,i=this._events[e];if(i)for(t||(t={}),t.type!==e&&(t.type=e),i=i.slice(),n=i.length;n--;){r=i[n];try{r.handleEvent?r.handleEvent(t):r.call(this,t)}catch(o){o.details="Squire: fireEvent error. Event type: "+e,this.didError(o)}}return this},Kt.destroy=function(){var e,t=this._win,n=this._doc,r=this._events;t.removeEventListener("focus",this,!1),t.removeEventListener("blur",this,!1);for(e in r)Zt[e]||n.removeEventListener(e,this,!0);this._mutation&&this._mutation.disconnect();for(var i=zt.length;i--;)zt[i]===this&&zt.splice(i,1)},Kt.handleEvent=function(e){this.fireEvent(e.type,e)},Kt.addEventListener=function(e,t){var n=this._events[e];return t?(n||(n=this._events[e]=[],Zt[e]||this._doc.addEventListener(e,this,!0)),n.push(t),this):(this.didError({name:"Squire: addEventListener with null or undefined fn",message:"Event type: "+e}),this)},Kt.removeEventListener=function(e,t){var n,r=this._events[e];if(r){for(n=r.length;n--;)r[n]===t&&r.splice(n,1);r.length||(delete this._events[e],Zt[e]||this._doc.removeEventListener(e,this,!1))}return this},Kt._createRange=function(e,t,n,r){if(e instanceof this._win.Range)return e.cloneRange();var i=this._doc.createRange();return i.setStart(e,t),n?i.setEnd(n,r):i.setEnd(e,t),i},Kt.scrollRangeIntoView=function(e){var t,n,r=e.getBoundingClientRect();if(r&&!r.top&&(t=this._doc.createElement("SPAN"),e=e.cloneRange(),dt(e,t),r=t.getBoundingClientRect(),n=t.parentNode,n.removeChild(t),n.normalize()),r){var i=this._win,o=i.innerHeight,a=r.top;a>o&&i.scrollBy(0,a-o+20),this.fireEvent("scrollPointIntoView",{x:r.left,y:a})}},Kt._moveCursorTo=function(e){var t=this._body,n=this._createRange(t,e?0:t.childNodes.length);return ut(n),this.setSelection(n),this},Kt.moveCursorToStart=function(){return this._moveCursorTo(!0)},Kt.moveCursorToEnd=function(){return this._moveCursorTo(!1)};var qt=function(e){return e._win.getSelection()||null};Kt.setSelection=function(e){if(e){K&&this._win.focus();var t=qt(this);t&&(t.removeAllRanges(),t.addRange(e),this.scrollRangeIntoView(e))}return this},Kt.getSelection=function(){var e,t,n,r=qt(this);return r&&r.rangeCount?(e=r.getRangeAt(0).cloneRange(),t=e.startContainer,n=e.endContainer,t&&a(t)&&e.setStartBefore(t),n&&a(n)&&e.setEndBefore(n),this._lastSelection=e):e=this._lastSelection,e||(e=this._createRange(this._body.firstChild,0)),e},Kt.getSelectedText=function(){var e,t=this.getSelection(),r=new n(t.commonAncestorContainer,U|I,function(e){return ht(t,e,!0)}),i=t.startContainer,o=t.endContainer,a=r.currentNode=i,d="",l=!1;for(r.filter(a)||(a=r.nextNode());a;)a.nodeType===D?(e=a.data,e&&/\S/.test(e)&&(a===o&&(e=e.slice(0,t.endOffset)),a===i&&(e=e.slice(t.startOffset)),d+=e,l=!0)):("BR"===a.nodeName||l&&!s(a))&&(d+="\n",l=!1),a=r.nextNode();return d},Kt.getPath=function(){return this._path};var Vt=function(e){for(var t,r,i,o=new n(e,U,function(){return!0},!1);r=o.nextNode();)for(;(i=r.data.indexOf(H))>-1;){if(1===r.length){do t=r.parentNode,t.removeChild(r),r=t,o.currentNode=t;while(s(r)&&!g(r));break}r.deleteData(i,1)}};Kt._didAddZWS=function(){this._hasZWS=!0},Kt._removeZWS=function(){this._hasZWS&&(Vt(this._body),this._hasZWS=!1)},Kt._updatePath=function(e,t){var n,r=e.startContainer,i=e.endContainer;(t||r!==this._lastAnchorNode||i!==this._lastFocusNode)&&(this._lastAnchorNode=r,this._lastFocusNode=i,n=r&&i?r===i?p(i):"(selection)":"",this._path!==n&&(this._path=n,this.fireEvent("pathChange",{path:n}))),e.collapsed||this.fireEvent("select")},Kt._updatePathOnEvent=function(){this._updatePath(this.getSelection())},Kt.focus=function(){return G||this._body.focus(),this._win.focus(),this},Kt.blur=function(){return q&&this._body.blur(),top.focus(),this};var Gt="squire-selection-start",jt="squire-selection-end";Kt._saveRangeToBookmark=function(e){var t,n=this.createElement("INPUT",{id:Gt,type:"hidden"}),r=this.createElement("INPUT",{id:jt,type:"hidden"});dt(e,n),e.collapse(!1),dt(e,r),n.compareDocumentPosition(r)&L&&(n.id=jt,r.id=Gt,t=n,n=r,r=t),e.setStartAfter(n),e.setEndBefore(r)},Kt._getRangeAndRemoveBookmark=function(e){var t=this._doc,n=t.getElementById(Gt),r=t.getElementById(jt);if(n&&r){var i,o=n.parentNode,a=r.parentNode,s={startContainer:o,endContainer:a,startOffset:nt.call(o.childNodes,n),endOffset:nt.call(a.childNodes,r)};o===a&&(s.endOffset-=1),m(n),m(r),T(o,s),o!==a&&T(a,s),e||(e=t.createRange()),e.setStart(s.startContainer,s.startOffset),e.setEnd(s.endContainer,s.endOffset),i=e.collapsed,ut(e),i&&e.collapse(!0)}return e||null},Kt._keyUpDetectChange=function(e){var t=e.keyCode;e.ctrlKey||e.metaKey||e.altKey||!(16>t||t>20)||!(33>t||t>45)||this._docWasChanged()},Kt._docWasChanged=function(){return et&&this._ignoreChange?void(this._ignoreChange=!1):(this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),void this.fireEvent("input"))},Kt._recordUndoState=function(e){if(!this._isInUndoState){var t=this._undoIndex+=1,n=this._undoStack;te+1&&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:t>e+2}),this.fireEvent("input")}return this},Kt.hasFormat=function(e,t,r){if(e=e.toUpperCase(),t||(t={}),!r&&!(r=this.getSelection()))return!1;!r.collapsed&&r.startContainer.nodeType===D&&r.startOffset===r.startContainer.length&&r.startContainer.nextSibling&&r.setStartBefore(r.startContainer.nextSibling),!r.collapsed&&r.endContainer.nodeType===D&&0===r.endOffset&&r.endContainer.previousSibling&&r.setEndAfter(r.endContainer.previousSibling);var i,o,a=r.commonAncestorContainer;if(u(a,e,t))return!0;if(a.nodeType===D)return!1;i=new n(a,U,function(e){return ht(r,e,!0)},!1);for(var s=!1;o=i.nextNode();){if(!u(o,e,t))return!1;s=!0}return s},Kt.getFontInfo=function(e){var n,r,i,o={color:t,backgroundColor:t,family:t,size:t},a=0;if(!e&&!(e=this.getSelection()))return o;if(n=e.commonAncestorContainer,e.collapsed||n.nodeType===D)for(n.nodeType===D&&(n=n.parentNode);4>a&&n&&(r=n.style);)!o.color&&(i=r.color)&&(o.color=i,a+=1),!o.backgroundColor&&(i=r.backgroundColor)&&(o.backgroundColor=i,a+=1),!o.family&&(i=r.fontFamily)&&(o.family=i,a+=1),!o.size&&(i=r.fontSize)&&(o.size=i,a+=1),n=n.parentNode;return o},Kt._addFormat=function(e,t,r){var i,o,a,s,d,l,c,f;if(r.collapsed)i=S(this.createElement(e,t)),dt(r,i),r.setStart(i.firstChild,i.firstChild.length),r.collapse(!0);else{if(o=new n(r.commonAncestorContainer,U|I,function(e){return(e.nodeType===D||"BR"===e.nodeName||"IMG"===e.nodeName)&&ht(r,e,!0)},!1),a=r.startContainer,d=r.startOffset,s=r.endContainer,l=r.endOffset,o.currentNode=a,o.filter(a)||(a=o.nextNode(),d=0),!a)return r;do c=o.currentNode,f=!u(c,e,t),f&&(c===s&&c.length>l&&c.splitText(l),c===a&&d&&(c=c.splitText(d),s===a&&(s=c,l-=d),a=c,d=0),i=this.createElement(e,t),v(c,i),i.appendChild(c));while(o.nextNode());s.nodeType!==D&&(c.nodeType===D?(s=c,l=c.length):(s=c.parentNode,l=1)),r=this._createRange(a,d,s,l)}return r},Kt._removeFormat=function(e,t,n,r){this._saveRangeToBookmark(n);var o,a=this._doc;n.collapsed&&(X?(o=a.createTextNode(H),this._didAddZWS()):o=a.createTextNode(""),dt(n,o));for(var d=n.commonAncestorContainer;s(d);)d=d.parentNode;var l=n.startContainer,c=n.startOffset,f=n.endContainer,h=n.endOffset,u=[],p=function(e,t){if(!ht(n,e,!1)){var r,i,o=e.nodeType===D;if(!ht(n,e,!0))return void("INPUT"===e.nodeName||o&&!e.data||u.push([t,e]));if(o)e===f&&h!==e.length&&u.push([t,e.splitText(h)]),e===l&&c&&(e.splitText(c),u.push([t,e]));else for(r=e.firstChild;r;r=i)i=r.nextSibling,p(r,t)}},g=Array.prototype.filter.call(d.getElementsByTagName(e),function(r){return ht(n,r,!0)&&i(r,e,t)});r||g.forEach(function(e){p(e,e)}),u.forEach(function(e){var t=e[0].cloneNode(!1),n=e[1];v(n,t),t.appendChild(n)}),g.forEach(function(e){v(e,C(e))}),this._getRangeAndRemoveBookmark(n),o&&n.collapse(!1);var m={startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset};return T(d,m),n.setStart(m.startContainer,m.startOffset),n.setEnd(m.endContainer,m.endOffset),n},Kt.changeFormat=function(e,t,n,r){return n||(n=this.getSelection())?(this.saveUndoState(n),t&&(n=this._removeFormat(t.tag.toUpperCase(),t.attributes||{},n,r)),e&&(n=this._addFormat(e.tag.toUpperCase(),e.attributes||{},n)),this.setSelection(n),this._updatePath(n,!0),et||this._docWasChanged(),this):void 0};var Qt={DT:"DD",DD:"DT",LI:"LI"},Yt=function(e,t,n,r){var o=Qt[t.nodeName],a=null,s=_(n,r,t.parentNode),d=e._config;return o||(o=d.blockTag,a=d.blockAttributes),i(s,o,a)||(t=N(s.ownerDocument,o,a),s.dir&&(t.dir=s.dir),v(s,t),t.appendChild(C(s)),s=t),s -};Kt.forEachBlock=function(e,t,n){if(!n&&!(n=this.getSelection()))return this;t&&this.saveUndoState(n);var r=gt(n),i=mt(n);if(r&&i)do if(e(r)||r===i)break;while(r=h(r));return t&&(this.setSelection(n),this._updatePath(n,!0),et||this._docWasChanged()),this},Kt.modifyBlocks=function(e,t){if(!t&&!(t=this.getSelection()))return this;this._isInUndoState?this._saveRangeToBookmark(t):this._recordUndoState(t),St(t);var n,r=this._body;return pt(t,r),n=lt(t,r),dt(t,e.call(this,n)),t.endOffsett;t+=1){for(i=d[t],o=C(i),a=o.childNodes,r=a.length;r--;)s=a[r],v(s,C(s));y(o),v(i,o)}return e},on=function(e){var t,n,r,i,o,a,s=e.querySelectorAll("LI"),d=this._config.tagAttributes,c=d.li;for(t=0,n=s.length;n>t;t+=1)r=s[t],l(r.firstChild)||(i=r.parentNode.nodeName,o=r.previousSibling,o&&(o=o.lastChild)&&o.nodeName===i||(a=d[i.toLowerCase()],v(r,this.createElement("LI",c,[o=this.createElement(i,a)]))),o.appendChild(r));return e},an=function(e){var t=e.querySelectorAll("LI");return Array.prototype.filter.call(t,function(e){return!l(e.firstChild)}).forEach(function(t){var n,r=t.parentNode,i=r.parentNode,o=t.firstChild,a=o;for(t.previousSibling&&(r=_(r,t,i));a&&(n=a.nextSibling,!l(a));)i.insertBefore(a,r),a=n;for("LI"===i.nodeName&&o.previousSibling&&_(i,o,i.parentNode);t!==e&&!t.childNodes.length;)r=t.parentNode,r.removeChild(t),t=r},this),y(e),e};Kt._ensureBottomLine=function(){var e=this._body,t=e.lastElementChild;t&&t.nodeName===this._config.blockTag&&d(t)||e.appendChild(this.createDefaultBlock())},Kt.setKeyHandler=function(e,t){return this._keyHandlers[e]=t,this},Kt._getHTML=function(){return this._body.innerHTML},Kt._setHTML=function(e){var t=this._body;t.innerHTML=e;do S(t);while(t=h(t));this._ignoreChange=!0},Kt.getHTML=function(e){var t,n,r,i,o,a=[];if(e&&(o=this.getSelection())&&this._saveRangeToBookmark(o),$)for(t=this._body;t=h(t);)t.textContent||t.querySelector("BR")||(n=this.createElement("BR"),t.appendChild(n),a.push(n));if(r=this._getHTML().replace(/\u200B/g,""),$)for(i=a.length;i--;)m(a[i]);return o&&this._getRangeAndRemoveBookmark(o),r},Kt.setHTML=function(e){var t,n=this._doc.createDocumentFragment(),r=this.createElement("DIV");r.innerHTML=e,n.appendChild(C(r)),It(n),Ft(n),y(n);for(var i=n;i=h(i);)S(i);this._ignoreChange=!0;for(var o=this._body;t=o.lastChild;)o.removeChild(t);o.appendChild(n),S(o),this._undoIndex=-1,this._undoStack.length=0,this._undoStackLength=0,this._isInUndoState=!1;var a=this._getRangeAndRemoveBookmark()||this._createRange(o.firstChild,0);return this.saveUndoState(a),J?this._lastSelection=a:this.setSelection(a),this._updatePath(a,!0),this},Kt.insertElement=function(e,t){if(t||(t=this.getSelection()),t.collapse(!0),s(e))dt(t,e),t.setStartAfter(e);else{for(var n,r,i=this._body,o=gt(t)||i;o!==i&&!o.nextSibling;)o=o.parentNode;o!==i&&(n=o.parentNode,r=_(n,o.nextSibling,i)),r?i.insertBefore(e,r):(i.appendChild(e),r=this.createDefaultBlock(),i.appendChild(r)),t.setStart(r,0),t.setEnd(r,0),ut(t)}return this.focus(),this.setSelection(t),this._updatePath(t),this},Kt.insertImage=function(e,t){var n=this.createElement("IMG",k({src:e},t));return this.insertElement(n),n};var sn=/\b((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))|([\w\-.%+]+@(?:[\w\-]+\.)+[A-Z]{2,}\b)/i,dn=function(e){for(var t,r,i,o,a,s,d,l=e.ownerDocument,c=new n(e,U,function(e){return!u(e,"A")},!1);t=c.nextNode();)for(r=t.data,i=t.parentNode;o=sn.exec(r);)a=o.index,s=a+o[0].length,a&&(d=l.createTextNode(r.slice(0,a)),i.insertBefore(d,t)),d=l.createElement("A"),d.textContent=r.slice(a,s),d.href=o[1]?/^(?:ht|f)tps?:/.test(o[1])?o[1]:"http://"+o[1]:"mailto:"+o[2],i.insertBefore(d,t),t.data=r=r.slice(s)};Kt.insertHTML=function(e,t){var n=this.getSelection(),r=this._doc.createDocumentFragment(),i=this.createElement("DIV");i.innerHTML=e,r.appendChild(C(i)),this.saveUndoState(n);try{var o=r,a={fragment:r,preventDefault:function(){this.defaultPrevented=!0},defaultPrevented:!1};for(dn(r),It(r),Ft(r),Ut(r),r.normalize();o=h(o);)S(o);t&&this.fireEvent("willPaste",a),a.defaultPrevented||(ft(n,a.fragment),et||this._docWasChanged(),n.collapse(!1),this._ensureBottomLine()),this.setSelection(n),this._updatePath(n,!0)}catch(s){this.didError(s)}return this},Kt.insertPlainText=function(e,t){var n,r,i,o=e.split("\n");for(n=0,r=o.length;r>n;n+=1)i=o[n],i=i.split("&").join("&").split("<").join("<").split(">").join(">").replace(/ (?= )/g," "),n&&r>n+1&&(i="
"+(i||"
")+"
"),o[n]=i;return this.insertHTML(o.join(""),t)};var ln=function(e,t,n){return function(){return this[e](t,n),this.focus()}};Kt.addStyles=function(e){if(e){var t=this._doc.documentElement.firstChild,n=this.createElement("STYLE",{type:"text/css"});n.appendChild(this._doc.createTextNode(e)),t.appendChild(n)}return this},Kt.bold=ln("changeFormat",{tag:"B"}),Kt.italic=ln("changeFormat",{tag:"I"}),Kt.underline=ln("changeFormat",{tag:"U"}),Kt.strikethrough=ln("changeFormat",{tag:"S"}),Kt.subscript=ln("changeFormat",{tag:"SUB"},{tag:"SUP"}),Kt.superscript=ln("changeFormat",{tag:"SUP"},{tag:"SUB"}),Kt.removeBold=ln("changeFormat",null,{tag:"B"}),Kt.removeItalic=ln("changeFormat",null,{tag:"I"}),Kt.removeUnderline=ln("changeFormat",null,{tag:"U"}),Kt.removeStrikethrough=ln("changeFormat",null,{tag:"S"}),Kt.removeSubscript=ln("changeFormat",null,{tag:"SUB"}),Kt.removeSuperscript=ln("changeFormat",null,{tag:"SUP"}),Kt.makeLink=function(e,t){var n=this.getSelection();if(n.collapsed){var r=e.indexOf(":")+1;if(r)for(;"/"===e[r];)r+=1;dt(n,this._doc.createTextNode(e.slice(r)))}return t||(t={}),t.href=e,this.changeFormat({tag:"A",attributes:t},{tag:"A"},n),this.focus()},Kt.removeLink=function(){return this.changeFormat(null,{tag:"A"},this.getSelection(),!0),this.focus()},Kt.setFontFace=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"font",style:"font-family: "+e+", sans-serif;"}},{tag:"SPAN",attributes:{"class":"font"}}),this.focus()},Kt.setFontSize=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"size",style:"font-size: "+("number"==typeof e?e+"px":e)}},{tag:"SPAN",attributes:{"class":"size"}}),this.focus()},Kt.setTextColour=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"colour",style:"color:"+e}},{tag:"SPAN",attributes:{"class":"colour"}}),this.focus()},Kt.setHighlightColour=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"highlight",style:"background-color:"+e}},{tag:"SPAN",attributes:{"class":"highlight"}}),this.focus()},Kt.setTextAlignment=function(e){return this.forEachBlock(function(t){t.className=(t.className.split(/\s+/).filter(function(e){return!/align/.test(e)}).join(" ")+" align-"+e).trim(),t.style.textAlign=e},!0),this.focus()},Kt.setTextDirection=function(e){return this.forEachBlock(function(t){t.dir=e},!0),this.focus()},Kt.removeAllFormatting=function(e){if(!e&&!(e=this.getSelection())||e.collapsed)return this;for(var t=e.commonAncestorContainer;t&&!d(t);)t=t.parentNode;if(t||(St(e),t=this._body),t.nodeType===D)return this;this.saveUndoState(e),pt(e,t);for(var n,r,i,o=t.ownerDocument,a=e.startContainer,s=e.startOffset,l=e.endContainer,c=e.endOffset,f=o.createDocumentFragment(),h=o.createDocumentFragment(),u=_(l,c,t),p=_(a,s,t);p!==u;)n=p.nextSibling,f.appendChild(p),p=n;return x(this,f,h),h.normalize(),p=h.firstChild,n=h.lastChild,i=t.childNodes,p?(t.insertBefore(h,u),s=nt.call(i,p),c=nt.call(i,n)+1):(s=nt.call(i,u),c=s),r={startContainer:t,startOffset:s,endContainer:t,endOffset:c},T(t,r),e.setStart(r.startContainer,r.startOffset),e.setEnd(r.endContainer,r.endOffset),ut(e),this.setSelection(e),this._updatePath(e,!0),this.focus()},Kt.increaseQuoteLevel=ln("modifyBlocks",$t),Kt.decreaseQuoteLevel=ln("modifyBlocks",Xt),Kt.makeUnorderedList=ln("modifyBlocks",tn),Kt.makeOrderedList=ln("modifyBlocks",nn),Kt.removeList=ln("modifyBlocks",rn),Kt.increaseListLevel=ln("modifyBlocks",on),Kt.decreaseListLevel=ln("modifyBlocks",an),"object"==typeof exports?module.exports=O:"function"==typeof define&&define.amd?define(function(){return O}):(W.Squire=O,top!==W&&"true"===e.documentElement.getAttribute("data-squireinit")&&(W.editor=new O(e),W.onEditorLoad&&(W.onEditorLoad(W.editor),W.onEditorLoad=null)))}(document); \ No newline at end of file +!function(e,t){"use strict";function n(e,t,n){this.root=this.currentNode=e,this.nodeType=t,this.filter=n}function r(e,t){for(var n=e.length;n--;)if(!t(e[n]))return!1;return!0}function i(e,t,n){if(e.nodeName!==t)return!1;for(var r in n)if(e.getAttribute(r)!==n[r])return!1;return!0}function o(e,t){return!a(e)&&e.nodeType===t.nodeType&&e.nodeName===t.nodeName&&e.className===t.className&&(!e.style&&!t.style||e.style.cssText===t.style.cssText)}function a(e){return e.nodeType===A&&!!ot[e.nodeName]}function s(e){return it.test(e.nodeName)}function d(e){var t=e.nodeType;return(t===A||t===R)&&!s(e)&&r(e.childNodes,s)}function l(e){var t=e.nodeType;return!(t!==A&&t!==R||s(e)||d(e))}function c(e){var t=e.ownerDocument,r=new n(t.body,I,d,!1);return r.currentNode=e,r}function f(e){return c(e).previousNode()}function h(e){return c(e).nextNode()}function u(e,t,n){do if(i(e,t,n))return e;while(e=e.parentNode);return null}function p(e){var t,n,r,i,o,a=e.parentNode;return a&&e.nodeType===A?(t=p(a),t+=(t?">":"")+e.nodeName,(n=e.id)&&(t+="#"+n),(r=e.className.trim())&&(i=r.split(/\s\s*/),i.sort(),t+=".",t+=i.join(".")),(o=e.dir)&&(t+="[dir="+o+"]")):t=a?p(a):"",t}function g(e){var t=e.nodeType;return t===A?e.childNodes.length:e.length||0}function m(e){var t=e.parentNode;return t&&t.removeChild(e),e}function v(e,t){var n=e.parentNode;n&&n.replaceChild(t,e)}function C(e){for(var t=e.ownerDocument.createDocumentFragment(),n=e.childNodes,r=n?n.length:0;r--;)t.appendChild(e.firstChild);return t}function N(e,n,r,i){var o,a,s,d,l=e.createElement(n);if(r instanceof Array&&(i=r,r=null),r)for(o in r)a=r[o],a!==t&&l.setAttribute(o,r[o]);if(i)for(s=0,d=i.length;d>s;s+=1)l.appendChild(i[s]);return l}function S(e){var t,n,r=e.ownerDocument,i=e;if("BODY"===e.nodeName&&((n=e.firstChild)&&"BR"!==n.nodeName||(t=B(r).createDefaultBlock(),n?e.replaceChild(t,n):e.appendChild(t),e=t,t=null)),s(e)){for(n=e.firstChild;X&&n&&n.nodeType===D&&!n.data;)e.removeChild(n),n=e.firstChild;n||(X?(t=r.createTextNode(H),B(r)._didAddZWS()):t=r.createTextNode(""))}else if($){for(;e.nodeType!==D&&!a(e);){if(n=e.firstChild,!n){t=r.createTextNode("");break}e=n}e.nodeType===D?/^ +$/.test(e.data)&&(e.data=""):a(e)&&e.parentNode.insertBefore(r.createTextNode(""),e)}else if(!e.querySelector("BR"))for(t=N(r,"BR");(n=e.lastElementChild)&&!s(n);)e=n;return t&&e.appendChild(t),i}function y(e){var t,n,r,i,o=e.childNodes,a=e.ownerDocument,d=null,c=B(a)._config;for(t=0,n=o.length;n>t;t+=1)r=o[t],i="BR"===r.nodeName,!i&&s(r)?(d||(d=N(a,c.blockTag,c.blockAttributes)),d.appendChild(r),t-=1,n-=1):(i||d)&&(d||(d=N(a,c.blockTag,c.blockAttributes)),S(d),i?e.replaceChild(d,r):(e.insertBefore(d,r),t+=1,n+=1),d=null),l(r)&&y(r);return d&&e.appendChild(S(d)),e}function _(e,t,n){var r,i,o,a=e.nodeType;if(a===D&&e!==n)return _(e.parentNode,e.splitText(t),n);if(a===A){if("number"==typeof t&&(t=td?t.startOffset-=1:t.startOffset===d&&(t.startContainer=r,t.startOffset=g(r))),t.endContainer===e&&(t.endOffset>d?t.endOffset-=1:t.endOffset===d&&(t.endContainer=r,t.endOffset=g(r))),m(n),n.nodeType===D?r.appendData(n.data):l.push(C(n));else if(n.nodeType===A){for(i=l.length;i--;)n.appendChild(l.pop());T(n,t)}}function b(e,t,n){for(var r,i,o,a=t;1===a.parentNode.childNodes.length;)a=a.parentNode;m(a),i=e.childNodes.length,r=e.lastChild,r&&"BR"===r.nodeName&&(e.removeChild(r),i-=1),o={startContainer:e,startOffset:i,endContainer:e,endOffset:i},e.appendChild(C(t)),T(e,o),n.setStart(o.startContainer,o.startOffset),n.collapse(!0),G&&(r=e.lastChild)&&"BR"===r.nodeName&&e.removeChild(r)}function E(e){var t,n,r=e.previousSibling,i=e.firstChild,a=e.ownerDocument,s="LI"===e.nodeName;if(!s||i&&/^[OU]L$/.test(i.nodeName))if(r&&o(r,e)){if(!l(r)){if(!s)return;n=N(a,"DIV"),n.appendChild(C(r)),r.appendChild(n)}m(e),t=!l(e),r.appendChild(C(e)),t&&y(r),i&&E(i)}else s&&(r=N(a,"DIV"),e.insertBefore(r,i),S(r))}function B(e){for(var t,n=zt.length;n--;)if(t=zt[n],t._doc===e)return t;return null}function x(e,t){var n,r;e||(e={});for(n in t)r=t[n],e[n]=r&&r.constructor===Object?x(e[n],r):r;return e}function k(e,t){var n,r=e.defaultView,i=e.body;this._win=r,this._doc=e,this._body=i,this._events={},this._lastSelection=null,J&&this.addEventListener("beforedeactivate",this.getSelection),this._hasZWS=!1,this._lastAnchorNode=null,this._lastFocusNode=null,this._path="",this.addEventListener("keyup",this._updatePathOnEvent),this.addEventListener("mouseup",this._updatePathOnEvent),r.addEventListener("focus",this,!1),r.addEventListener("blur",this,!1),this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0,this._isInUndoState=!1,this._ignoreChange=!1,et?(n=new MutationObserver(this._docWasChanged.bind(this)),n.observe(i,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),this._mutation=n):this.addEventListener("keyup",this._keyUpDetectChange),this._awaitingPaste=!1,this.addEventListener(V?"beforecut":"cut",Mt),this.addEventListener("copy",Ht),this.addEventListener(V?"beforepaste":"paste",Wt),this.addEventListener(G?"keypress":"keydown",_t),this._keyHandlers=Object.create(Bt),this.setConfig(t),V&&(r.Text.prototype.splitText=function(e){var t=this.ownerDocument.createTextNode(this.data.slice(e)),n=this.nextSibling,r=this.parentNode,i=this.length-e;return n?r.insertBefore(t,n):r.appendChild(t),i&&this.deleteData(e,i),t}),i.setAttribute("contenteditable","true");try{e.execCommand("enableObjectResizing",!1,"false"),e.execCommand("enableInlineTableEditing",!1,"false")}catch(o){}zt.push(this),this.setHTML("")}function O(e,t,n){var r,i;for(r=t.firstChild;r;r=i){if(i=r.nextSibling,s(r)){if(r.nodeType===D||"BR"===r.nodeName||"IMG"===r.nodeName){n.appendChild(r);continue}}else if(d(r)){n.appendChild(e.createDefaultBlock([O(e,r,e._doc.createDocumentFragment())]));continue}O(e,r,n)}return n}var L=2,A=1,D=3,R=11,I=1,U=4,P=0,w=1,F=2,M=3,H="​",W=e.defaultView,z=navigator.userAgent,K=/iP(?:ad|hone|od)/.test(z),Z=/Mac OS X/.test(z),q=/Gecko\//.test(z),V=/Trident\/[456]\./.test(z),G=!!W.opera,j=/Edge\//.test(z),Q=!j&&/WebKit\//.test(z),Y=Z?"meta-":"ctrl-",$=V||G,X=V||Q,J=V,et="undefined"!=typeof MutationObserver,tt=/[^ \t\r\n]/,nt=Array.prototype.indexOf;Object.create||(Object.create=function(e){var t=function(){};return t.prototype=e,new t});var rt={1:1,2:2,3:4,8:128,9:256,11:1024};n.prototype.nextNode=function(){for(var e,t=this.currentNode,n=this.root,r=this.nodeType,i=this.filter;;){for(e=t.firstChild;!e&&t&&t!==n;)e=t.nextSibling,e||(t=t.parentNode);if(!e)return null;if(rt[e.nodeType]&r&&i(e))return this.currentNode=e,e;t=e}},n.prototype.previousNode=function(){for(var e,t=this.currentNode,n=this.root,r=this.nodeType,i=this.filter;;){if(t===n)return null;if(e=t.previousSibling)for(;t=e.lastChild;)e=t;else e=t.parentNode;if(!e)return null;if(rt[e.nodeType]&r&&i(e))return this.currentNode=e,e;t=e}},n.prototype.previousPONode=function(){for(var e,t=this.currentNode,n=this.root,r=this.nodeType,i=this.filter;;){for(e=t.lastChild;!e&&t&&t!==n;)e=t.previousSibling,e||(t=t.parentNode);if(!e)return null;if(rt[e.nodeType]&r&&i(e))return this.currentNode=e,e;t=e}};var it=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|U|VAR|WBR)$/,ot={BR:1,IMG:1,INPUT:1},at=function(e,t){for(var n=e.childNodes;t&&e.nodeType===A;)e=n[t-1],n=e.childNodes,t=n.length;return e},st=function(e,t){if(e.nodeType===A){var n=e.childNodes;if(t-1,o=e.compareBoundaryPoints(w,r)<1;return!i&&!o}var a=e.compareBoundaryPoints(P,r)<1,s=e.compareBoundaryPoints(F,r)>-1;return a&&s},ut=function(e){for(var t,n=e.startContainer,r=e.startOffset,i=e.endContainer,o=e.endOffset;n.nodeType!==D&&(t=n.childNodes[r],t&&!a(t));)n=t,r=0;if(o)for(;i.nodeType!==D&&(t=i.childNodes[o-1],t&&!a(t));)i=t,o=g(i);else for(;i.nodeType!==D&&(t=i.firstChild,t&&!a(t));)i=t;e.collapsed?(e.setStart(i,o),e.setEnd(n,r)):(e.setStart(n,r),e.setEnd(i,o))},pt=function(e,t){var n,r=e.startContainer,i=e.startOffset,o=e.endContainer,a=e.endOffset;for(t||(t=e.commonAncestorContainer);r!==t&&!i;)n=r.parentNode,i=nt.call(n.childNodes,r),r=n;for(;o!==t&&a===g(o);)n=o.parentNode,a=nt.call(n.childNodes,o)+1,o=n;e.setStart(r,i),e.setEnd(o,a)},gt=function(e){var t,n=e.startContainer;return s(n)?t=f(n):d(n)?t=n:(t=at(n,e.startOffset),t=h(t)),t&&ht(e,t,!0)?t:null},mt=function(e){var t,n,r=e.endContainer;if(s(r))t=f(r);else if(d(r))t=r;else{if(t=st(r,e.endOffset),!t)for(t=r.ownerDocument.body;n=t.lastChild;)t=n;t=f(t)}return t&&ht(e,t,!0)?t:null},vt=new n(null,U|I,function(e){return e.nodeType===D?tt.test(e.data):"IMG"===e.nodeName}),Ct=function(e){var t=e.startContainer,n=e.startOffset;if(vt.root=null,t.nodeType===D){if(n)return!1;vt.currentNode=t}else vt.currentNode=st(t,n);return vt.root=gt(e),!vt.previousNode()},Nt=function(e){var t,n=e.endContainer,r=e.endOffset;if(vt.root=null,n.nodeType===D){if(t=n.data.length,t&&t>r)return!1;vt.currentNode=n}else vt.currentNode=at(n,r);return vt.root=mt(e),!vt.nextNode()},St=function(e){var t,n=gt(e),r=mt(e);n&&r&&(t=n.parentNode,e.setStart(t,nt.call(t.childNodes,n)),t=r.parentNode,e.setEnd(t,nt.call(t.childNodes,r)+1))},yt={8:"backspace",9:"tab",13:"enter",32:"space",33:"pageup",34:"pagedown",37:"left",39:"right",46:"delete",219:"[",221:"]"},_t=function(e){var t=e.keyCode,n=yt[t],r="",i=this.getSelection();e.defaultPrevented||(n||(n=String.fromCharCode(t).toLowerCase(),/^[A-Za-z0-9]$/.test(n)||(n="")),G&&46===e.which&&(n="."),t>111&&124>t&&(n="f"+(t-111)),"backspace"!==n&&"delete"!==n&&(e.altKey&&(r+="alt-"),e.ctrlKey&&(r+="ctrl-"),e.metaKey&&(r+="meta-")),e.shiftKey&&(r+="shift-"),n=r+n,this._keyHandlers[n]?this._keyHandlers[n](this,e,i):1!==n.length||i.collapsed||(this.saveUndoState(i),ct(i),this._ensureBottomLine(),this.setSelection(i),this._updatePath(i,!0)))},Tt=function(e){return function(t,n){n.preventDefault(),t[e]()}},bt=function(e,t){return t=t||null,function(n,r){r.preventDefault();var i=n.getSelection();n.hasFormat(e,null,i)?n.changeFormat(null,{tag:e},i):n.changeFormat({tag:e},t,i)}},Et=function(e,t){try{t||(t=e.getSelection());var n,r=t.startContainer;for(r.nodeType===D&&(r=r.parentNode),n=r;s(n)&&(!n.textContent||n.textContent===H);)r=n,n=r.parentNode;r!==n&&(t.setStart(n,nt.call(n.childNodes,r)),t.collapse(!0),n.removeChild(r),d(n)||(n=f(n)),S(n),ut(t)),"BODY"===r.nodeName&&(r=r.firstChild)&&"BR"===r.nodeName&&m(r),e._ensureBottomLine(),e.setSelection(t),e._updatePath(t,!0)}catch(i){e.didError(i)}},Bt={enter:function(e,t,n){var r,i,o;if(t.preventDefault(),e._recordUndoState(n),dn(n.startContainer),e._removeZWS(),e._getRangeAndRemoveBookmark(n),n.collapsed||ct(n),r=gt(n),!r||/^T[HD]$/.test(r.nodeName))return dt(n,e.createElement("BR")),n.collapse(!1),e.setSelection(n),void e._updatePath(n,!0);if((i=u(r,"LI"))&&(r=i),!r.textContent){if(u(r,"UL")||u(r,"OL"))return e.modifyBlocks(an,n);if(u(r,"BLOCKQUOTE"))return e.modifyBlocks(Jt,n)}for(o=Yt(e,r,n.startContainer,n.startOffset),Vt(r),Ut(r),S(r);o.nodeType===A;){var a,s=o.firstChild;if("A"===o.nodeName&&(!o.textContent||o.textContent===H)){s=e._doc.createTextNode(""),v(o,s),o=s;break}for(;s&&s.nodeType===D&&!s.data&&(a=s.nextSibling,a&&"BR"!==a.nodeName);)m(s),s=a;if(!s||"BR"===s.nodeName||s.nodeType===D&&!G)break;o=s}n=e._createRange(o,0),e.setSelection(n),e._updatePath(n,!0)},backspace:function(e,t,n){if(e._removeZWS(),e.saveUndoState(n),n.collapsed)if(Ct(n)){t.preventDefault();var r,i=gt(n);if(!i)return;if(y(i.parentNode),r=f(i)){if(!r.isContentEditable)return void m(r);for(b(r,i,n),i=r.parentNode;i&&!i.nextSibling;)i=i.parentNode;i&&(i=i.nextSibling)&&E(i),e.setSelection(n)}else if(i){if(u(i,"UL")||u(i,"OL"))return e.modifyBlocks(an,n);if(u(i,"BLOCKQUOTE"))return e.modifyBlocks(Xt,n);e.setSelection(n),e._updatePath(n,!0)}}else e.setSelection(n),setTimeout(function(){Et(e)},0);else t.preventDefault(),ct(n),Et(e,n)},"delete":function(e,t,n){var r,i,o,a,s,d;if(e._removeZWS(),e.saveUndoState(n),n.collapsed)if(Nt(n)){if(t.preventDefault(),r=gt(n),!r)return;if(y(r.parentNode),i=h(r)){if(!i.isContentEditable)return void m(i);for(b(r,i,n),i=r.parentNode;i&&!i.nextSibling;)i=i.parentNode;i&&(i=i.nextSibling)&&E(i),e.setSelection(n),e._updatePath(n,!0)}}else{if(o=n.cloneRange(),pt(n,e._body),a=n.endContainer,s=n.endOffset,a.nodeType===A&&(d=a.childNodes[s],d&&"IMG"===d.nodeName))return t.preventDefault(),m(d),ut(n),void Et(e,n);e.setSelection(o),setTimeout(function(){Et(e)},0)}else t.preventDefault(),ct(n),Et(e,n)},tab:function(e,t,n){var r,i;if(e._removeZWS(),n.collapsed&&Ct(n))for(r=gt(n);i=r.parentNode;){if("UL"===i.nodeName||"OL"===i.nodeName){r.previousSibling&&(t.preventDefault(),e.modifyBlocks(on,n));break}r=i}},"shift-tab":function(e,t,n){if(e._removeZWS(),n.collapsed&&Ct(n)){var r=n.startContainer;(u(r,"UL")||u(r,"OL"))&&(t.preventDefault(),e.modifyBlocks(an,n))}},space:function(e,t,n){var r,i;e._recordUndoState(n),dn(n.startContainer),e._getRangeAndRemoveBookmark(n),r=n.endContainer,i=r.parentNode,n.collapsed&&"A"===i.nodeName&&!r.nextSibling&&n.endOffset===g(r)&&n.setStartAfter(i),e.setSelection(n)},left:function(e){e._removeZWS()},right:function(e){e._removeZWS()}};Z&&q&&(Bt["meta-left"]=function(e,t){t.preventDefault();var n=qt(e);n&&n.modify&&n.modify("move","backward","lineboundary")},Bt["meta-right"]=function(e,t){t.preventDefault();var n=qt(e);n&&n.modify&&n.modify("move","forward","lineboundary")}),Z||(Bt.pageup=function(e){e.moveCursorToStart()},Bt.pagedown=function(e){e.moveCursorToEnd()}),Bt[Y+"b"]=bt("B"),Bt[Y+"i"]=bt("I"),Bt[Y+"u"]=bt("U"),Bt[Y+"shift-7"]=bt("S"),Bt[Y+"shift-5"]=bt("SUB",{tag:"SUP"}),Bt[Y+"shift-6"]=bt("SUP",{tag:"SUB"}),Bt[Y+"shift-8"]=Tt("makeUnorderedList"),Bt[Y+"shift-9"]=Tt("makeOrderedList"),Bt[Y+"["]=Tt("decreaseQuoteLevel"),Bt[Y+"]"]=Tt("increaseQuoteLevel"),Bt[Y+"y"]=Tt("redo"),Bt[Y+"z"]=Tt("undo"),Bt[Y+"shift-z"]=Tt("redo");var xt={1:10,2:13,3:16,4:18,5:24,6:32,7:48},kt={backgroundColor:{regexp:tt,replace:function(e,t){return N(e,"SPAN",{"class":"highlight",style:"background-color:"+t})}},color:{regexp:tt,replace:function(e,t){return N(e,"SPAN",{"class":"colour",style:"color:"+t})}},fontWeight:{regexp:/^bold/i,replace:function(e){return N(e,"B")}},fontStyle:{regexp:/^italic/i,replace:function(e){return N(e,"I")}},fontFamily:{regexp:tt,replace:function(e,t){return N(e,"SPAN",{"class":"font",style:"font-family:"+t})}},fontSize:{regexp:tt,replace:function(e,t){return N(e,"SPAN",{"class":"size",style:"font-size:"+t})}}},Ot=function(e){return function(t,n){var r=N(t.ownerDocument,e);return n.replaceChild(r,t),r.appendChild(C(t)),r}},Lt={SPAN:function(e,t){var n,r,i,o,a,s,d=e.style,l=e.ownerDocument;for(n in kt)r=kt[n],i=d[n],i&&r.regexp.test(i)&&(s=r.replace(l,i),o&&o.appendChild(s),o=s,a||(a=s));return a&&(o.appendChild(C(e)),t.replaceChild(a,e)),o||e},STRONG:Ot("B"),EM:Ot("I"),STRIKE:Ot("S"),FONT:function(e,t){var n,r,i,o,a,s=e.face,d=e.size,l=e.color,c=e.ownerDocument;return s&&(n=N(c,"SPAN",{"class":"font",style:"font-family:"+s}),a=n,o=n),d&&(r=N(c,"SPAN",{"class":"size",style:"font-size:"+xt[d]+"px"}),a||(a=r),o&&o.appendChild(r),o=r),l&&/^#?([\dA-F]{3}){1,2}$/i.test(l)&&("#"!==l.charAt(0)&&(l="#"+l),i=N(c,"SPAN",{"class":"colour",style:"color:"+l}),a||(a=i),o&&o.appendChild(i),o=i),a||(a=o=N(c,"SPAN")),t.replaceChild(a,e),o.appendChild(C(e)),o},TT:function(e,t){var n=N(e.ownerDocument,"SPAN",{"class":"font",style:'font-family:menlo,consolas,"courier new",monospace'});return t.replaceChild(n,e),n.appendChild(C(e)),n}},At=/^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|UL)$/,Dt=/^(?:HEAD|META|STYLE)/,Rt=new n(null,U|I,function(){return!0}),It=function cn(e){var t,n,r,i,o,a,d,l,c,f,h,u,p=e.childNodes;for(t=e;s(t);)t=t.parentNode;for(Rt.root=t,n=0,r=p.length;r>n;n+=1)if(i=p[n],o=i.nodeName,a=i.nodeType,d=Lt[o],a===A){if(l=i.childNodes.length,d)i=d(i,e);else{if(Dt.test(o)){e.removeChild(i),n-=1,r-=1;continue}if(!At.test(o)&&!s(i)){n-=1,r+=l-1,e.replaceChild(C(i),i);continue}}l&&cn(i)}else{if(a===D){if(h=i.data,c=!tt.test(h.charAt(0)),f=!tt.test(h.charAt(h.length-1)),!c&&!f)continue;if(c){for(Rt.currentNode=i;(u=Rt.previousPONode())&&(o=u.nodeName,!("IMG"===o||"#text"===o&&/\S/.test(u.data)));)if(!s(u)){u=null;break}u||(h=h.replace(/^\s+/g,""))}if(f){for(Rt.currentNode=i;(u=Rt.nextNode())&&!("IMG"===o||"#text"===o&&/\S/.test(u.data));)if(!s(u)){u=null;break}u||(h=h.replace(/^\s+/g,""))}if(h){i.data=h;continue}}e.removeChild(i),n-=1,r-=1}return e},Ut=function fn(e){for(var t,n=e.childNodes,r=n.length;r--;)t=n[r],t.nodeType!==A||a(t)?t.nodeType!==D||t.data||e.removeChild(t):(fn(t),s(t)&&!t.firstChild&&e.removeChild(t))},Pt=function(e){return e.nodeType===A?"BR"===e.nodeName:tt.test(e.data)},wt=function(e){for(var t,r=e.parentNode;s(r);)r=r.parentNode;return t=new n(r,I|U,Pt),t.currentNode=e,!!t.nextNode()},Ft=function(e){var t,n,r,i=e.querySelectorAll("BR"),o=[],a=i.length;for(t=0;a>t;t+=1)o[t]=wt(i[t]);for(;a--;)n=i[a],r=n.parentNode,r&&(o[a]?s(r)||y(r):m(n))},Mt=function(e){var t=e.clipboardData,n=this.getSelection(),r=this.createElement("div"),i=this._body,o=this;this.saveUndoState(n),!j&&t?(pt(n,i),r.appendChild(ct(n,i)),t.setData("text/html",r.innerHTML),t.setData("text/plain",r.innerText||r.textContent),e.preventDefault()):setTimeout(function(){try{o._ensureBottomLine()}catch(e){o.didError(e)}},0),this.setSelection(n)},Ht=function(e){var t=e.clipboardData,n=this.getSelection(),r=this.createElement("div");!j&&t&&(r.appendChild(n.cloneContents()),t.setData("text/html",r.innerHTML),t.setData("text/plain",r.innerText||r.textContent),e.preventDefault())},Wt=function(e){var t,n,r,i,o,a=e.clipboardData,s=a&&a.items,d=!1,l=!1,c=null,f=this;if(!j&&s){for(e.preventDefault(),t=s.length;t--;){if(n=s[t],r=n.type,"text/html"===r)return void n.getAsString(function(e){f.insertHTML(e,!0)});"text/plain"===r&&(c=n),/^image\/.*/.test(r)&&(l=!0)}return void(l?(this.fireEvent("dragover",{dataTransfer:a,preventDefault:function(){d=!0}}),d&&this.fireEvent("drop",{dataTransfer:a})):c&&n.getAsString(function(e){f.insertPlainText(e,!0)}))}if(i=a&&a.types,!j&&i&&(nt.call(i,"text/html")>-1||!q&&nt.call(i,"text/plain")>-1&&nt.call(i,"text/rtf")<0))return e.preventDefault(),void((o=a.getData("text/html"))?this.insertHTML(o,!0):(o=a.getData("text/plain"))&&this.insertPlainText(o,!0));this._awaitingPaste=!0;var h=this._body,u=this.getSelection(),p=u.startContainer,g=u.startOffset,v=u.endContainer,C=u.endOffset,N=gt(u),S=this.createElement("DIV",{style:"position: absolute; overflow: hidden; top:"+(h.scrollTop+(N?N.getBoundingClientRect().top:0))+"px; right: 150%; width: 1px; height: 1px;"});h.appendChild(S),u.selectNodeContents(S),this.setSelection(u),setTimeout(function(){try{f._awaitingPaste=!1;for(var e,t,n="",r=S;S=r;)r=S.nextSibling,m(S),e=S.firstChild,e&&e===S.lastChild&&"DIV"===e.nodeName&&(S=e),n+=S.innerHTML;t=f._createRange(p,g,v,C),f.setSelection(t),n&&f.insertHTML(n,!0)}catch(i){f.didError(i)}},0)},zt=[],Kt=k.prototype;Kt.setConfig=function(e){return e=x({blockTag:"DIV",blockAttributes:null,tagAttributes:{blockquote:null,ul:null,ol:null,li:null}},e),e.blockTag=e.blockTag.toUpperCase(),this._config=e,this},Kt.createElement=function(e,t,n){return N(this._doc,e,t,n)},Kt.createDefaultBlock=function(e){var t=this._config;return S(this.createElement(t.blockTag,t.blockAttributes,e))},Kt.didError=function(e){console.log(e)},Kt.getDocument=function(){return this._doc};var Zt={focus:1,blur:1,pathChange:1,select:1,input:1,undoStateChange:1};Kt.fireEvent=function(e,t){var n,r,i=this._events[e];if(i)for(t||(t={}),t.type!==e&&(t.type=e),i=i.slice(),n=i.length;n--;){r=i[n];try{r.handleEvent?r.handleEvent(t):r.call(this,t)}catch(o){o.details="Squire: fireEvent error. Event type: "+e,this.didError(o)}}return this},Kt.destroy=function(){var e,t=this._win,n=this._doc,r=this._events;t.removeEventListener("focus",this,!1),t.removeEventListener("blur",this,!1);for(e in r)Zt[e]||n.removeEventListener(e,this,!0);this._mutation&&this._mutation.disconnect();for(var i=zt.length;i--;)zt[i]===this&&zt.splice(i,1)},Kt.handleEvent=function(e){this.fireEvent(e.type,e)},Kt.addEventListener=function(e,t){var n=this._events[e];return t?(n||(n=this._events[e]=[],Zt[e]||this._doc.addEventListener(e,this,!0)),n.push(t),this):(this.didError({name:"Squire: addEventListener with null or undefined fn",message:"Event type: "+e}),this)},Kt.removeEventListener=function(e,t){var n,r=this._events[e];if(r){for(n=r.length;n--;)r[n]===t&&r.splice(n,1);r.length||(delete this._events[e],Zt[e]||this._doc.removeEventListener(e,this,!1))}return this},Kt._createRange=function(e,t,n,r){if(e instanceof this._win.Range)return e.cloneRange();var i=this._doc.createRange();return i.setStart(e,t),n?i.setEnd(n,r):i.setEnd(e,t),i},Kt.scrollRangeIntoView=function(e){var t,n,r=e.getBoundingClientRect();if(r&&!r.top&&(t=this._doc.createElement("SPAN"),e=e.cloneRange(),dt(e,t),r=t.getBoundingClientRect(),n=t.parentNode,n.removeChild(t),n.normalize()),r){var i=this._win,o=i.innerHeight,a=r.top;a>o&&i.scrollBy(0,a-o+20),this.fireEvent("scrollPointIntoView",{x:r.left,y:a})}},Kt._moveCursorTo=function(e){var t=this._body,n=this._createRange(t,e?0:t.childNodes.length);return ut(n),this.setSelection(n),this},Kt.moveCursorToStart=function(){return this._moveCursorTo(!0)},Kt.moveCursorToEnd=function(){return this._moveCursorTo(!1)};var qt=function(e){return e._win.getSelection()||null};Kt.setSelection=function(e){if(e){K&&this._win.focus();var t=qt(this);t&&(t.removeAllRanges(),t.addRange(e),this.scrollRangeIntoView(e))}return this},Kt.getSelection=function(){var e,t,n,r=qt(this);return r&&r.rangeCount?(e=r.getRangeAt(0).cloneRange(),t=e.startContainer,n=e.endContainer,t&&a(t)&&e.setStartBefore(t),n&&a(n)&&e.setEndBefore(n),this._lastSelection=e):e=this._lastSelection,e||(e=this._createRange(this._body.firstChild,0)),e},Kt.getSelectedText=function(){var e,t=this.getSelection(),r=new n(t.commonAncestorContainer,U|I,function(e){return ht(t,e,!0)}),i=t.startContainer,o=t.endContainer,a=r.currentNode=i,d="",l=!1;for(r.filter(a)||(a=r.nextNode());a;)a.nodeType===D?(e=a.data,e&&/\S/.test(e)&&(a===o&&(e=e.slice(0,t.endOffset)),a===i&&(e=e.slice(t.startOffset)),d+=e,l=!0)):("BR"===a.nodeName||l&&!s(a))&&(d+="\n",l=!1),a=r.nextNode();return d},Kt.getPath=function(){return this._path};var Vt=function(e){for(var t,r,i,o=new n(e,U,function(){return!0},!1);r=o.nextNode();)for(;(i=r.data.indexOf(H))>-1;){if(1===r.length){do t=r.parentNode,t.removeChild(r),r=t,o.currentNode=t;while(s(r)&&!g(r));break}r.deleteData(i,1)}};Kt._didAddZWS=function(){this._hasZWS=!0},Kt._removeZWS=function(){this._hasZWS&&(Vt(this._body),this._hasZWS=!1)},Kt._updatePath=function(e,t){var n,r=e.startContainer,i=e.endContainer;(t||r!==this._lastAnchorNode||i!==this._lastFocusNode)&&(this._lastAnchorNode=r,this._lastFocusNode=i,n=r&&i?r===i?p(i):"(selection)":"",this._path!==n&&(this._path=n,this.fireEvent("pathChange",{path:n}))),e.collapsed||this.fireEvent("select")},Kt._updatePathOnEvent=function(){this._updatePath(this.getSelection())},Kt.focus=function(){return G||this._body.focus(),this._win.focus(),this},Kt.blur=function(){return q&&this._body.blur(),top.focus(),this};var Gt="squire-selection-start",jt="squire-selection-end";Kt._saveRangeToBookmark=function(e){var t,n=this.createElement("INPUT",{id:Gt,type:"hidden"}),r=this.createElement("INPUT",{id:jt,type:"hidden"});dt(e,n),e.collapse(!1),dt(e,r),n.compareDocumentPosition(r)&L&&(n.id=jt,r.id=Gt,t=n,n=r,r=t),e.setStartAfter(n),e.setEndBefore(r)},Kt._getRangeAndRemoveBookmark=function(e){var t=this._doc,n=t.getElementById(Gt),r=t.getElementById(jt);if(n&&r){var i,o=n.parentNode,a=r.parentNode,s={startContainer:o,endContainer:a,startOffset:nt.call(o.childNodes,n),endOffset:nt.call(a.childNodes,r)};o===a&&(s.endOffset-=1),m(n),m(r),T(o,s),o!==a&&T(a,s),e||(e=t.createRange()),e.setStart(s.startContainer,s.startOffset),e.setEnd(s.endContainer,s.endOffset),i=e.collapsed,ut(e),i&&e.collapse(!0)}return e||null},Kt._keyUpDetectChange=function(e){var t=e.keyCode;e.ctrlKey||e.metaKey||e.altKey||!(16>t||t>20)||!(33>t||t>45)||this._docWasChanged()},Kt._docWasChanged=function(){return et&&this._ignoreChange?void(this._ignoreChange=!1):(this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),void this.fireEvent("input"))},Kt._recordUndoState=function(e){if(!this._isInUndoState){var t=this._undoIndex+=1,n=this._undoStack;te+1&&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:t>e+2}),this.fireEvent("input")}return this},Kt.hasFormat=function(e,t,r){if(e=e.toUpperCase(),t||(t={}),!r&&!(r=this.getSelection()))return!1;!r.collapsed&&r.startContainer.nodeType===D&&r.startOffset===r.startContainer.length&&r.startContainer.nextSibling&&r.setStartBefore(r.startContainer.nextSibling),!r.collapsed&&r.endContainer.nodeType===D&&0===r.endOffset&&r.endContainer.previousSibling&&r.setEndAfter(r.endContainer.previousSibling);var i,o,a=r.commonAncestorContainer;if(u(a,e,t))return!0;if(a.nodeType===D)return!1;i=new n(a,U,function(e){return ht(r,e,!0)},!1);for(var s=!1;o=i.nextNode();){if(!u(o,e,t))return!1;s=!0}return s},Kt.getFontInfo=function(e){var n,r,i,o={color:t,backgroundColor:t,family:t,size:t},a=0;if(!e&&!(e=this.getSelection()))return o;if(n=e.commonAncestorContainer,e.collapsed||n.nodeType===D)for(n.nodeType===D&&(n=n.parentNode);4>a&&n&&(r=n.style);)!o.color&&(i=r.color)&&(o.color=i,a+=1),!o.backgroundColor&&(i=r.backgroundColor)&&(o.backgroundColor=i,a+=1),!o.family&&(i=r.fontFamily)&&(o.family=i,a+=1),!o.size&&(i=r.fontSize)&&(o.size=i,a+=1),n=n.parentNode;return o},Kt._addFormat=function(e,t,r){var i,o,a,s,d,l,c,f;if(r.collapsed)i=S(this.createElement(e,t)),dt(r,i),r.setStart(i.firstChild,i.firstChild.length),r.collapse(!0);else{if(o=new n(r.commonAncestorContainer,U|I,function(e){return(e.nodeType===D||"BR"===e.nodeName||"IMG"===e.nodeName)&&ht(r,e,!0)},!1),a=r.startContainer,d=r.startOffset,s=r.endContainer,l=r.endOffset,o.currentNode=a,o.filter(a)||(a=o.nextNode(),d=0),!a)return r;do c=o.currentNode,f=!u(c,e,t),f&&(c===s&&c.length>l&&c.splitText(l),c===a&&d&&(c=c.splitText(d),s===a&&(s=c,l-=d),a=c,d=0),i=this.createElement(e,t),v(c,i),i.appendChild(c));while(o.nextNode());s.nodeType!==D&&(c.nodeType===D?(s=c,l=c.length):(s=c.parentNode,l=1)),r=this._createRange(a,d,s,l)}return r},Kt._removeFormat=function(e,t,n,r){this._saveRangeToBookmark(n);var o,a=this._doc;n.collapsed&&(X?(o=a.createTextNode(H),this._didAddZWS()):o=a.createTextNode(""),dt(n,o));for(var d=n.commonAncestorContainer;s(d);)d=d.parentNode;var l=n.startContainer,c=n.startOffset,f=n.endContainer,h=n.endOffset,u=[],p=function(e,t){if(!ht(n,e,!1)){var r,i,o=e.nodeType===D;if(!ht(n,e,!0))return void("INPUT"===e.nodeName||o&&!e.data||u.push([t,e]));if(o)e===f&&h!==e.length&&u.push([t,e.splitText(h)]),e===l&&c&&(e.splitText(c),u.push([t,e]));else for(r=e.firstChild;r;r=i)i=r.nextSibling,p(r,t)}},g=Array.prototype.filter.call(d.getElementsByTagName(e),function(r){return ht(n,r,!0)&&i(r,e,t)});r||g.forEach(function(e){p(e,e)}),u.forEach(function(e){var t=e[0].cloneNode(!1),n=e[1];v(n,t),t.appendChild(n)}),g.forEach(function(e){v(e,C(e))}),this._getRangeAndRemoveBookmark(n),o&&n.collapse(!1);var m={startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset};return T(d,m),n.setStart(m.startContainer,m.startOffset),n.setEnd(m.endContainer,m.endOffset),n},Kt.changeFormat=function(e,t,n,r){return n||(n=this.getSelection())?(this.saveUndoState(n),t&&(n=this._removeFormat(t.tag.toUpperCase(),t.attributes||{},n,r)),e&&(n=this._addFormat(e.tag.toUpperCase(),e.attributes||{},n)),this.setSelection(n),this._updatePath(n,!0),et||this._docWasChanged(),this):void 0};var Qt={DT:"DD",DD:"DT",LI:"LI"},Yt=function(e,t,n,r){var o=Qt[t.nodeName],a=null,s=_(n,r,t.parentNode),d=e._config; +return o||(o=d.blockTag,a=d.blockAttributes),i(s,o,a)||(t=N(s.ownerDocument,o,a),s.dir&&(t.dir=s.dir),v(s,t),t.appendChild(C(s)),s=t),s};Kt.forEachBlock=function(e,t,n){if(!n&&!(n=this.getSelection()))return this;t&&this.saveUndoState(n);var r=gt(n),i=mt(n);if(r&&i)do if(e(r)||r===i)break;while(r=h(r));return t&&(this.setSelection(n),this._updatePath(n,!0),et||this._docWasChanged()),this},Kt.modifyBlocks=function(e,t){if(!t&&!(t=this.getSelection()))return this;this._isInUndoState?this._saveRangeToBookmark(t):this._recordUndoState(t),St(t);var n,r=this._body;return pt(t,r),n=lt(t,r),dt(t,e.call(this,n)),t.endOffsett;t+=1){for(i=d[t],o=C(i),a=o.childNodes,r=a.length;r--;)s=a[r],v(s,C(s));y(o),v(i,o)}return e},on=function(e){var t,n,r,i,o,a,s=e.querySelectorAll("LI"),d=this._config.tagAttributes,c=d.li;for(t=0,n=s.length;n>t;t+=1)r=s[t],l(r.firstChild)||(i=r.parentNode.nodeName,o=r.previousSibling,o&&(o=o.lastChild)&&o.nodeName===i||(a=d[i.toLowerCase()],v(r,this.createElement("LI",c,[o=this.createElement(i,a)]))),o.appendChild(r));return e},an=function(e){var t=e.querySelectorAll("LI");return Array.prototype.filter.call(t,function(e){return!l(e.firstChild)}).forEach(function(t){var n,r=t.parentNode,i=r.parentNode,o=t.firstChild,a=o;for(t.previousSibling&&(r=_(r,t,i));a&&(n=a.nextSibling,!l(a));)i.insertBefore(a,r),a=n;for("LI"===i.nodeName&&o.previousSibling&&_(i,o,i.parentNode);t!==e&&!t.childNodes.length;)r=t.parentNode,r.removeChild(t),t=r},this),y(e),e};Kt._ensureBottomLine=function(){var e=this._body,t=e.lastElementChild;t&&t.nodeName===this._config.blockTag&&d(t)||e.appendChild(this.createDefaultBlock())},Kt.setKeyHandler=function(e,t){return this._keyHandlers[e]=t,this},Kt._getHTML=function(){return this._body.innerHTML},Kt._setHTML=function(e){var t=this._body;t.innerHTML=e;do S(t);while(t=h(t));this._ignoreChange=!0},Kt.getHTML=function(e){var t,n,r,i,o,a=[];if(e&&(o=this.getSelection())&&this._saveRangeToBookmark(o),$)for(t=this._body;t=h(t);)t.textContent||t.querySelector("BR")||(n=this.createElement("BR"),t.appendChild(n),a.push(n));if(r=this._getHTML().replace(/\u200B/g,""),$)for(i=a.length;i--;)m(a[i]);return o&&this._getRangeAndRemoveBookmark(o),r},Kt.setHTML=function(e){var t,n=this._doc.createDocumentFragment(),r=this.createElement("DIV");r.innerHTML=e,n.appendChild(C(r)),It(n),Ft(n),y(n);for(var i=n;i=h(i);)S(i);this._ignoreChange=!0;for(var o=this._body;t=o.lastChild;)o.removeChild(t);o.appendChild(n),S(o),this._undoIndex=-1,this._undoStack.length=0,this._undoStackLength=0,this._isInUndoState=!1;var a=this._getRangeAndRemoveBookmark()||this._createRange(o.firstChild,0);return this.saveUndoState(a),J?this._lastSelection=a:this.setSelection(a),this._updatePath(a,!0),this},Kt.insertElement=function(e,t){if(t||(t=this.getSelection()),t.collapse(!0),s(e))dt(t,e),t.setStartAfter(e);else{for(var n,r,i=this._body,o=gt(t)||i;o!==i&&!o.nextSibling;)o=o.parentNode;o!==i&&(n=o.parentNode,r=_(n,o.nextSibling,i)),r?i.insertBefore(e,r):(i.appendChild(e),r=this.createDefaultBlock(),i.appendChild(r)),t.setStart(r,0),t.setEnd(r,0),ut(t)}return this.focus(),this.setSelection(t),this._updatePath(t),this},Kt.insertImage=function(e,t){var n=this.createElement("IMG",x({src:e},t));return this.insertElement(n),n};var sn=/\b((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))|([\w\-.%+]+@(?:[\w\-]+\.)+[A-Z]{2,}\b)/i,dn=function(e){for(var t,r,i,o,a,s,d,l=e.ownerDocument,c=new n(e,U,function(e){return!u(e,"A")},!1);t=c.nextNode();)for(r=t.data,i=t.parentNode;o=sn.exec(r);)a=o.index,s=a+o[0].length,a&&(d=l.createTextNode(r.slice(0,a)),i.insertBefore(d,t)),d=l.createElement("A"),d.textContent=r.slice(a,s),d.href=o[1]?/^(?:ht|f)tps?:/.test(o[1])?o[1]:"http://"+o[1]:"mailto:"+o[2],i.insertBefore(d,t),t.data=r=r.slice(s)};Kt.insertHTML=function(e,t){var n=this.getSelection(),r=this._doc.createDocumentFragment(),i=this.createElement("DIV");i.innerHTML=e,r.appendChild(C(i)),this.saveUndoState(n);try{var o=r,a={fragment:r,preventDefault:function(){this.defaultPrevented=!0},defaultPrevented:!1};for(dn(r),It(r),Ft(r),Ut(r),r.normalize();o=h(o);)S(o);t&&this.fireEvent("willPaste",a),a.defaultPrevented||(ft(n,a.fragment),et||this._docWasChanged(),n.collapse(!1),this._ensureBottomLine()),this.setSelection(n),this._updatePath(n,!0)}catch(s){this.didError(s)}return this},Kt.insertPlainText=function(e,t){var n,r,i,o=e.split("\n");for(n=0,r=o.length;r>n;n+=1)i=o[n],i=i.split("&").join("&").split("<").join("<").split(">").join(">").replace(/ (?= )/g," "),n&&r>n+1&&(i="
"+(i||"
")+"
"),o[n]=i;return this.insertHTML(o.join(""),t)};var ln=function(e,t,n){return function(){return this[e](t,n),this.focus()}};Kt.addStyles=function(e){if(e){var t=this._doc.documentElement.firstChild,n=this.createElement("STYLE",{type:"text/css"});n.appendChild(this._doc.createTextNode(e)),t.appendChild(n)}return this},Kt.bold=ln("changeFormat",{tag:"B"}),Kt.italic=ln("changeFormat",{tag:"I"}),Kt.underline=ln("changeFormat",{tag:"U"}),Kt.strikethrough=ln("changeFormat",{tag:"S"}),Kt.subscript=ln("changeFormat",{tag:"SUB"},{tag:"SUP"}),Kt.superscript=ln("changeFormat",{tag:"SUP"},{tag:"SUB"}),Kt.removeBold=ln("changeFormat",null,{tag:"B"}),Kt.removeItalic=ln("changeFormat",null,{tag:"I"}),Kt.removeUnderline=ln("changeFormat",null,{tag:"U"}),Kt.removeStrikethrough=ln("changeFormat",null,{tag:"S"}),Kt.removeSubscript=ln("changeFormat",null,{tag:"SUB"}),Kt.removeSuperscript=ln("changeFormat",null,{tag:"SUP"}),Kt.makeLink=function(e,t){var n=this.getSelection();if(n.collapsed){var r=e.indexOf(":")+1;if(r)for(;"/"===e[r];)r+=1;dt(n,this._doc.createTextNode(e.slice(r)))}return t||(t={}),t.href=e,this.changeFormat({tag:"A",attributes:t},{tag:"A"},n),this.focus()},Kt.removeLink=function(){return this.changeFormat(null,{tag:"A"},this.getSelection(),!0),this.focus()},Kt.setFontFace=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"font",style:"font-family: "+e+", sans-serif;"}},{tag:"SPAN",attributes:{"class":"font"}}),this.focus()},Kt.setFontSize=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"size",style:"font-size: "+("number"==typeof e?e+"px":e)}},{tag:"SPAN",attributes:{"class":"size"}}),this.focus()},Kt.setTextColour=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"colour",style:"color:"+e}},{tag:"SPAN",attributes:{"class":"colour"}}),this.focus()},Kt.setHighlightColour=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"highlight",style:"background-color:"+e}},{tag:"SPAN",attributes:{"class":"highlight"}}),this.focus()},Kt.setTextAlignment=function(e){return this.forEachBlock(function(t){t.className=(t.className.split(/\s+/).filter(function(e){return!/align/.test(e)}).join(" ")+" align-"+e).trim(),t.style.textAlign=e},!0),this.focus()},Kt.setTextDirection=function(e){return this.forEachBlock(function(t){t.dir=e},!0),this.focus()},Kt.removeAllFormatting=function(e){if(!e&&!(e=this.getSelection())||e.collapsed)return this;for(var t=e.commonAncestorContainer;t&&!d(t);)t=t.parentNode;if(t||(St(e),t=this._body),t.nodeType===D)return this;this.saveUndoState(e),pt(e,t);for(var n,r,i,o=t.ownerDocument,a=e.startContainer,s=e.startOffset,l=e.endContainer,c=e.endOffset,f=o.createDocumentFragment(),h=o.createDocumentFragment(),u=_(l,c,t),p=_(a,s,t);p!==u;)n=p.nextSibling,f.appendChild(p),p=n;return O(this,f,h),h.normalize(),p=h.firstChild,n=h.lastChild,i=t.childNodes,p?(t.insertBefore(h,u),s=nt.call(i,p),c=nt.call(i,n)+1):(s=nt.call(i,u),c=s),r={startContainer:t,startOffset:s,endContainer:t,endOffset:c},T(t,r),e.setStart(r.startContainer,r.startOffset),e.setEnd(r.endContainer,r.endOffset),ut(e),this.setSelection(e),this._updatePath(e,!0),this.focus()},Kt.increaseQuoteLevel=ln("modifyBlocks",$t),Kt.decreaseQuoteLevel=ln("modifyBlocks",Xt),Kt.makeUnorderedList=ln("modifyBlocks",tn),Kt.makeOrderedList=ln("modifyBlocks",nn),Kt.removeList=ln("modifyBlocks",rn),Kt.increaseListLevel=ln("modifyBlocks",on),Kt.decreaseListLevel=ln("modifyBlocks",an),"object"==typeof exports?module.exports=k:"function"==typeof define&&define.amd?define(function(){return k}):(W.Squire=k,top!==W&&"true"===e.documentElement.getAttribute("data-squireinit")&&(W.editor=new k(e),W.onEditorLoad&&(W.onEditorLoad(W.editor),W.onEditorLoad=null)))}(document); \ No newline at end of file diff --git a/package.json b/package.json index b3a89a5..93a1877 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "squire-rte", - "version": "1.5.0", + "version": "1.5.1", "description": "Squire is an HTML5 rich text editor, which provides powerful cross-browser normalisation, whilst being supremely lightweight and flexible.", "main": "build/squire.js", "scripts": {