0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 23:40:35 -05:00
Squire/build/squire.js

1 line
51 KiB
JavaScript
Raw Normal View History

2021-10-31 14:52:33 -05:00
!function(e,t){"use strict";var n=1,i=3,o=9,r=11,a=1,s="",d=e.defaultView,l=navigator.userAgent,c=(/Android/.test(l),/Mac OS X/.test(l)),h=/Windows NT/.test(l),f=/iP(?:ad|hone|od)/.test(l)||c&&!!navigator.maxTouchPoints,u=/Gecko\//.test(l),p=/Edge\//.test(l),g=!p&&/WebKit\//.test(l),m=/Trident\/[4567]\./.test(l),v=c?"meta-":"ctrl-",C=g,_="undefined"!=typeof MutationObserver,N="undefined"!=typeof WeakMap,S=/[^ \t\r\n]/,y=Array.prototype.indexOf,T={1:1,2:2,3:4,8:128,9:256,11:1024},E=function(){return!0};function L(e,t,n){this.root=this.currentNode=e,this.nodeType=t,this.filter=n||E}L.prototype.nextNode=function(){for(var e,t=this.currentNode,n=this.root,i=this.nodeType,o=this.filter;;){for(e=t.firstChild;!e&&t&&t!==n;)(e=t.nextSibling)||(t=t.parentNode);if(!e)return null;if(T[e.nodeType]&i&&o(e))return this.currentNode=e,e;t=e}},L.prototype.previousNode=function(){for(var e,t=this.currentNode,n=this.root,i=this.nodeType,o=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(T[e.nodeType]&i&&o(e))return this.currentNode=e,e;t=e}},L.prototype.previousPONode=function(){for(var e,t=this.currentNode,n=this.root,i=this.nodeType,o=this.filter;;){for(e=t.lastChild;!e&&t&&t!==n;)(e=t.previousSibling)||(t=t.parentNode);if(!e)return null;if(T[e.nodeType]&i&&o(e))return this.currentNode=e,e;t=e}};var b=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,k={BR:1,HR:1,IFRAME:1,IMG:1,INPUT:1};var x=0,O=1,A=2,B=3,D=N?new WeakMap:null;function R(e){return e.nodeType===n&&!!k[e.nodeName]}function P(e){switch(e.nodeType){case i:return O;case n:case r:if(N&&D.has(e))return D.get(e);break;default:return x}var t;return t=function(e,t){for(var n=e.length;n--;)if(!t(e[n]))return!1;return!0}(e.childNodes,U)?b.test(e.nodeName)?O:A:B,N&&D.set(e,t),t}function U(e){return P(e)===O}function I(e){return P(e)===A}function F(e){return P(e)===B}function w(e,t){var n=new L(t,a,I);return n.currentNode=e,n}function M(e,t){return(e=w(e,t).previousNode())!==t?e:null}function H(e,t){return(e=w(e,t).nextNode())!==t?e:null}function z(e){return!e.textContent&&!e.querySelector("IMG")}function W(e,t){return!R(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 q(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 K(e,t,n,i){for(;e&&e!==t;){if(q(e,n,i))return e;e=e.parentNode}return null}function G(e,t){for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function Z(e){var t=e.nodeType;return t===n||t===r?e.childNodes.length:e.length||0}function Q(e){var t=e.parentNode;return t&&t.removeChild(e),e}function $(e,t){var n=e.parentNode;n&&n.replaceChild(t,e)}function j(e){for(var t=e.ownerDocument.createDocumentFragment(),n=e.childNodes,i=n?n.length:0;i--;)t.appendChild(e.firstChild);return t}function V(e,n,i,o){var r,a,s,d,l=e.createElement(n);if(i instanceof Array&&(o=i,i=null),i)for(r in i)(a=i[r])!==t&&l.setAttribute(r,a);if(o)for(s=0,d=o.length;s<d;s+=1)l.appendChild(o[s]);return l}function Y(e,t){var n,o,r=t.__squire__,a=e.ownerDocument,d=e;if(e===t&&((o=e.firstChild)&&"BR"!==o.nodeName||(n=r.createDefaultBlock(),o?e.replaceChild(n,o):e.appendChild(n),e=n,n=null)),e.nodeType===i)return d;if(U(e)){for(o=e.firstChild;C&&o&&o.nodeType===i&&!o.data;)e.removeChild(o),o=e.firstChild;o||(C?(n=a.createTextNode(s),r._didAddZWS()):n=a.createTextNode(""))}else if(!e.querySelector("BR"))for(n=V(a,"BR");(o=e.lastElementChild)&&!U(o);)e=o;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 X(e,t){var n,i,o,r,a=e.childNodes,s=e.ownerDocument,d=null;for(n=0,i=a.length;n<i;n+=1)!(r="BR"===(o=a[n]).nodeName)&&U(o)?(d||(d=V(s,"div")),d.appendChild(o),n-=1,i-=1):(r||d)&&(d||(d=V(s,"div")),Y(d,t),r?e.replaceC